Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
608548d5
Unverified
Commit
608548d5
authored
Jan 25, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
Markdown 支持改进 #54
parent
fd2d2c6c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
200 additions
and
83 deletions
+200
-83
src/main/java/org/b3log/solo/model/Option.java
src/main/java/org/b3log/solo/model/Option.java
+29
-8
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+31
-1
src/main/java/org/b3log/solo/util/Markdowns.java
src/main/java/org/b3log/solo/util/Markdowns.java
+12
-2
src/main/resources/admin/admin-preference.ftl
src/main/resources/admin/admin-preference.ftl
+54
-1
src/main/resources/js/admin/admin.min.js
src/main/resources/js/admin/admin.min.js
+1
-1
src/main/resources/js/admin/preference.js
src/main/resources/js/admin/preference.js
+57
-66
src/main/resources/lang_en_US.properties
src/main/resources/lang_en_US.properties
+8
-2
src/main/resources/lang_zh_CN.properties
src/main/resources/lang_zh_CN.properties
+8
-2
No files found.
src/main/java/org/b3log/solo/model/Option.java
View file @
608548d5
...
...
@@ -26,7 +26,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.6.0.
4, Jan 24
, 2020
* @version 1.6.0.
5, Jan 25
, 2020
* @since 0.6.0
*/
public
final
class
Option
{
...
...
@@ -52,11 +52,37 @@ public final class Option {
public
static
final
String
OPTION_CATEGORY
=
"optionCategory"
;
// oId constants
/**
* Key of inline math allow digit after open marker flag. 内联数学公式是否允许起始 $ 后紧跟数字 https://github.com/88250/solo/issues/54
*/
public
static
final
String
ID_C_IMADAOM
=
"inlineMathAllowDigitAfterOpenMarker"
;
/**
* Key of chinese punct flag. 中文后跟英文逗号句号等标点替换为中文对应标点 https://github.com/88250/solo/issues/54
*/
public
static
final
String
ID_C_CHINESE_PUNCT
=
"chinesePunct"
;
/**
* Key of fix term typo flag. 术语修正 https://github.com/88250/solo/issues/54
*/
public
static
final
String
ID_C_FIX_TERM_TYPO
=
"fixTermTypo"
;
/**
* Key of show ToC flag. 支持 ToC 显示 https://github.com/88250/solo/issues/52
* Key of auto space flag. 中西文间自动插入空格 https://github.com/88250/solo/issues/54
*/
public
static
final
String
ID_C_AUTO_SPACE
=
"autoSpace"
;
/**
* Key of show ToC flag. 支持 [ToC] https://github.com/88250/solo/issues/54
*/
public
static
final
String
ID_C_SHOW_TOC
=
"showToC"
;
/**
* Key of footnotes flag. 支持脚注 https://github.com/88250/solo/issues/54
*/
public
static
final
String
ID_C_FOOTNOTES
=
"footnotes"
;
/**
* Key of show code block line num flag. 支持代码块行号显示 https://github.com/88250/solo/issues/4
*/
...
...
@@ -310,16 +336,11 @@ public final class Option {
* Default preference.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.0.
5, Jan 24
, 2020
* @version 2.3.0.
6, Jan 25
, 2020
* @since 0.3.1
*/
public
static
final
class
DefaultPreference
{
/**
* Default show ToC.
*/
public
static
final
String
DEFAULT_SHOW_TOC
=
"false"
;
/**
* Default show code block line num.
*/
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
608548d5
...
...
@@ -472,12 +472,42 @@ public class InitService {
private
void
initOptions
(
final
JSONObject
requestJSONObject
)
throws
Exception
{
LOGGER
.
debug
(
"Initializing preference...."
);
final
JSONObject
IMADAOMOpt
=
new
JSONObject
();
IMADAOMOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_IMADAOM
);
IMADAOMOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
IMADAOMOpt
.
put
(
Option
.
OPTION_VALUE
,
"false"
);
optionRepository
.
add
(
IMADAOMOpt
);
final
JSONObject
chinesePunctOpt
=
new
JSONObject
();
chinesePunctOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_CHINESE_PUNCT
);
chinesePunctOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
chinesePunctOpt
.
put
(
Option
.
OPTION_VALUE
,
"true"
);
optionRepository
.
add
(
chinesePunctOpt
);
final
JSONObject
fixTermTypoOpt
=
new
JSONObject
();
fixTermTypoOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FIX_TERM_TYPO
);
fixTermTypoOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
fixTermTypoOpt
.
put
(
Option
.
OPTION_VALUE
,
"true"
);
optionRepository
.
add
(
fixTermTypoOpt
);
final
JSONObject
autoSpaceOpt
=
new
JSONObject
();
autoSpaceOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_AUTO_SPACE
);
autoSpaceOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
autoSpaceOpt
.
put
(
Option
.
OPTION_VALUE
,
"true"
);
optionRepository
.
add
(
autoSpaceOpt
);
final
JSONObject
showToCOpt
=
new
JSONObject
();
showToCOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SHOW_TOC
);
showToCOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
showToCOpt
.
put
(
Option
.
OPTION_VALUE
,
DefaultPreference
.
DEFAULT_SHOW_TOC
);
showToCOpt
.
put
(
Option
.
OPTION_VALUE
,
"false"
);
optionRepository
.
add
(
showToCOpt
);
final
JSONObject
footnotesOpt
=
new
JSONObject
();
footnotesOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FOOTNOTES
);
footnotesOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
footnotesOpt
.
put
(
Option
.
OPTION_VALUE
,
"true"
);
optionRepository
.
add
(
footnotesOpt
);
final
JSONObject
showCodeBlockLnOpt
=
new
JSONObject
();
showCodeBlockLnOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SHOW_CODE_BLOCK_LN
);
showCodeBlockLnOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
...
...
src/main/java/org/b3log/solo/util/Markdowns.java
View file @
608548d5
...
...
@@ -60,7 +60,7 @@ import java.util.concurrent.*;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.1.1
4, Jan 24
, 2020
* @version 2.3.1.1
5, Jan 25
, 2020
* @since 0.4.5
*/
public
final
class
Markdowns
{
...
...
@@ -113,7 +113,12 @@ public final class Markdowns {
public
static
boolean
LUTE_AVAILABLE
;
public
static
boolean
SHOW_CODE_BLOCK_LN
=
false
;
public
static
boolean
FOOTNOTES
=
false
;
public
static
boolean
SHOW_TOC
=
false
;
public
static
boolean
AUTO_SPACE
=
false
;
public
static
boolean
FIX_TERM_TYPO
=
false
;
public
static
boolean
CHINESE_PUNCT
=
false
;
public
static
boolean
IMADAOM
=
false
;
/**
* Clears cache.
...
...
@@ -269,9 +274,14 @@ public final class Markdowns {
final
URL
url
=
new
URL
(
LUTE_ENGINE_URL
);
final
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setRequestProperty
(
"X-CodeSyntaxHighlightLineNum"
,
String
.
valueOf
(
Markdowns
.
SHOW_CODE_BLOCK_LN
));
conn
.
setRequestProperty
(
"X-Footnotes"
,
String
.
valueOf
(
Markdowns
.
FOOTNOTES
));
conn
.
setRequestProperty
(
"X-ToC"
,
String
.
valueOf
(
Markdowns
.
SHOW_TOC
));
conn
.
setRequestProperty
(
"X-AutoSpace"
,
String
.
valueOf
(
Markdowns
.
AUTO_SPACE
));
conn
.
setRequestProperty
(
"X-FixTermTypo"
,
String
.
valueOf
(
Markdowns
.
FIX_TERM_TYPO
));
conn
.
setRequestProperty
(
"X-ChinesePunct"
,
String
.
valueOf
(
Markdowns
.
CHINESE_PUNCT
));
conn
.
setRequestProperty
(
"X-IMADAOM"
,
String
.
valueOf
(
Markdowns
.
IMADAOM
));
conn
.
setConnectTimeout
(
100
);
conn
.
setReadTimeout
(
1
000
);
conn
.
setReadTimeout
(
3
000
);
conn
.
setDoOutput
(
true
);
try
(
final
OutputStream
outputStream
=
conn
.
getOutputStream
())
{
...
...
src/main/resources/admin/admin-preference.ftl
View file @
608548d5
...
...
@@ -34,6 +34,11 @@
<a href="#tools/preference/setting">${paramSettingsLabel}</a>
</div>
</li>
<li>
<div id="tabPreference_markdown">
<a href="#tools/preference/markdown">Markdown</a>
</div>
</li>
</ul>
</div>
<div id="tabPreferencePanel" class="sub-tabs-main">
...
...
@@ -185,7 +190,7 @@
</label>
<label>
<div class="fn__flex-inline">
${s
how
ToCLabel}
${s
upport
ToCLabel}
<input id="showToC" type="checkbox" class="normalInput"/>
</div>
</label>
...
...
@@ -249,5 +254,53 @@
<button onclick="admin.preference.update()" class="fn__right">${updateLabel}</button>
<div class="fn__clear"></div>
</div>
<div id="tabPreferencePanel_markdown" class="fn__none form">
<div class="fn__clear">
${luteHTTPLabel}
</div>
<button class="fn__right" onclick="admin.preference.update()">${updateLabel}</button>
<div class="fn__flex">
<div class="fn__flex-1">
<label>
<div class="fn__flex-inline">
<input id="footnotes" type="checkbox" class="normalInput"/>
${supportFootnotesLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="showToC" type="checkbox" class="normalInput"/>
${supportToCLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="autoSpace" type="checkbox" class="normalInput"/>
${autoSpaceLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="fixTermTypo" type="checkbox" class="normalInput"/>
${fixTermTypoLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="chinesePunct" type="checkbox" class="normalInput"/>
${chinesePunctLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="inlineMathAllowDigitAfterOpenMarker" type="checkbox" class="normalInput"/>
${inlineMathAllowDigitAfterOpenMarkerLabel}
</div>
</label>
</div>
</div>
<button class="fn__right" onclick="admin.preference.update()">${updateLabel}</button>
<div class="fn__clear"></div>
</div>
</div>
${plugins}
src/main/resources/js/admin/admin.min.js
View file @
608548d5
This diff is collapsed.
Click to expand it.
src/main/resources/js/admin/preference.js
View file @
608548d5
This diff is collapsed.
Click to expand it.
src/main/resources/lang_en_US.properties
View file @
608548d5
...
...
@@ -18,13 +18,19 @@
#
# Description: Solo language configurations(en_US).
# Version: 2.3
8.0.0, Jan 24
, 2020
# Version: 2.3
9.0.0, Jan 25
, 2020
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
#
showToCLabel
=
Support Markdown [TOC] (need <a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>):
inlineMathAllowDigitAfterOpenMarkerLabel
=
Whether inline math formulas allow a starting $ followed by a number
chinesePunctLabel
=
Chinese punctuation followed by English comma and period are replaced with Chinese corresponding punctuation
fixTermTypoLabel
=
Fix term typo
autoSpaceLabel
=
Automatically insert spaces between Chinese and Western languages
supportFootnotesLabel
=
Support footnotes
supportToCLabel
=
Support [TOC]
luteHTTPLabel
=
The following features are based on <a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>.
showCodeBlockLnLabel
=
Show code block line num:
siteURLLabel
=
Site URL:
siteGenedLabel
=
Site generated, target dir is [{dir}]
...
...
src/main/resources/lang_zh_CN.properties
View file @
608548d5
...
...
@@ -18,13 +18,19 @@
#
# Description: Solo default language configurations(zh_CN).
# Version: 2.3
8.0.0, Jan 24
, 2020
# Version: 2.3
9.0.0, Jan 25
, 2020
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
#
showToCLabel
=
\u
652F
\u6301
Markdown [TOC]
\u
FF08
\u9700\u
542F
\u7528
<a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>
\u
FF09
\u
FF1A
inlineMathAllowDigitAfterOpenMarkerLabel
=
\u5185\u8054\u6570\u
5B66
\u
516C
\u
5F0F
\u
662F
\u5426\u5141\u
8BB8
\u
8D77
\u
59CB $
\u
540E
\u
7D27
\u
8DDF
\u6570\u
5B57
chinesePunctLabel
=
\u
4E2D
\u6587\u
540E
\u
8DDF
\u
82F1
\u6587\u9017\u
53F7
\u
53E5
\u
53F7
\u
7B49
\u6807\u
70B9
\u
66FF
\u6362\u
4E3A
\u
4E2D
\u6587\u
5BF9
\u
5E94
\u6807\u
70B9
fixTermTypoLabel
=
\u
672F
\u
8BED
\u
4FEE
\u
6B63
autoSpaceLabel
=
\u
4E2D
\u
897F
\u6587\u
95F4
\u
81EA
\u
52A8
\u
63D2
\u5165\u
7A7A
\u
683C
supportFootnotesLabel
=
\u
652F
\u6301\u
811A
\u
6CE8
supportToCLabel
=
\u
652F
\u6301
[TOC]
luteHTTPLabel
=
\u
4EE5
\u
4E0B
\u
914D
\u
7F6E
\u9879\u9700\u
542F
\u7528
<a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>
\u
5F15
\u
64CE
\u
624D
\u
80FD
\u
5F97
\u5230\u
652F
\u6301\u3002
showCodeBlockLnLabel
=
\u
4EE3
\u7801\u5757\u
663E
\u
793A
\u
884C
\u
53F7
\u
FF1A
siteURLLabel
=
\u
7AD9
\u
70B9
\u5730\u5740\u
FF1A
siteGenedLabel
=
\u
7AD9
\u
70B9
\u
751F
\u6210\u
5B8C
\u
6BD5
\u
FF0C
\u
8BF7
\u
67E5
\u
770B
\u
76EE
\u
5F55 [{dir}]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment