Commit 608548d5 authored by Liang Ding's avatar Liang Ding

Markdown 支持改进 #54

parent fd2d2c6c
......@@ -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.
*/
......
......@@ -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);
......
......@@ -60,7 +60,7 @@ import java.util.concurrent.*;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.1.14, Jan 24, 2020
* @version 2.3.1.15, 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(1000);
conn.setReadTimeout(3000);
conn.setDoOutput(true);
try (final OutputStream outputStream = conn.getOutputStream()) {
......
......@@ -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">
${showToCLabel}
${supportToCLabel}
<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"/>
&nbsp;${supportFootnotesLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="showToC" type="checkbox" class="normalInput"/>
&nbsp;${supportToCLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="autoSpace" type="checkbox" class="normalInput"/>
&nbsp;${autoSpaceLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="fixTermTypo" type="checkbox" class="normalInput"/>
&nbsp;${fixTermTypoLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="chinesePunct" type="checkbox" class="normalInput"/>
&nbsp;${chinesePunctLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="inlineMathAllowDigitAfterOpenMarker" type="checkbox" class="normalInput"/>
&nbsp;${inlineMathAllowDigitAfterOpenMarkerLabel}
</div>
</label>
</div>
</div>
<button class="fn__right" onclick="admin.preference.update()">${updateLabel}</button>
<div class="fn__clear"></div>
</div>
</div>
${plugins}
......@@ -310,7 +310,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _tab
/*! no static exports found */
/***/ (function(module, exports) {
eval("/*\r\n * Solo - A small and beautiful blogging system written in Java.\r\n * Copyright (c) 2010-present, b3log.org\r\n *\r\n * This program is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU Affero General Public License as published by\r\n * the Free Software Foundation, either version 3 of the License, or\r\n * (at your option) any later version.\r\n *\r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU Affero General Public License for more details.\r\n *\r\n * You should have received a copy of the GNU Affero General Public License\r\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\r\n */\n\n/**\r\n * preference for admin.\r\n *\r\n * @author <a href=\"http://vanessa.b3log.org\">Liyuan Li</a>\r\n * @author <a href=\"http://88250.b3log.org\">Liang Ding</a>\r\n * @version 1.3.0.4, Jan 24, 2020\r\n */\n\n/* preference 相关操作 */\nadmin.preference = {\n locale: '',\n\n /*\r\n * 初始化\r\n */\n init: function init() {\n $('#tabPreference').tabs();\n $.ajax({\n url: Label.servePath + '/console/preference/',\n type: 'GET',\n cache: false,\n success: function success(result, textStatus) {\n $('#tipMsg').text(result.msg);\n\n if (!result.sc) {\n $('#loadMsg').text('');\n return;\n }\n\n var preference = result.preference;\n $('#metaKeywords').val(preference.metaKeywords);\n $('#metaDescription').val(preference.metaDescription);\n $('#blogTitle').val(preference.blogTitle);\n $('#blogSubtitle').val(preference.blogSubtitle);\n $('#mostCommentArticleDisplayCount').val(preference.mostCommentArticleDisplayCount);\n $('#mostViewArticleDisplayCount').val(preference.mostViewArticleDisplayCount);\n $('#recentCommentDisplayCount').val(preference.recentCommentDisplayCount);\n $('#mostUsedTagDisplayCount').val(preference.mostUsedTagDisplayCount);\n $('#articleListDisplayCount').val(preference.articleListDisplayCount);\n $('#articleListPaginationWindowSize').val(preference.articleListPaginationWindowSize);\n $('#localeString').val(preference.localeString);\n $('#timeZoneId').val(preference.timeZoneId);\n $('#noticeBoard').val(preference.noticeBoard);\n $('#footerContent').val(preference.footerContent);\n $('#htmlHead').val(preference.htmlHead);\n $('#externalRelevantArticlesDisplayCount').val(preference.externalRelevantArticlesDisplayCount);\n $('#relevantArticlesDisplayCount').val(preference.relevantArticlesDisplayCount);\n $('#randomArticlesDisplayCount').val(preference.randomArticlesDisplayCount);\n $('#customVars').val(preference.customVars);\n 'true' === preference.enableArticleUpdateHint ? $('#enableArticleUpdateHint').attr('checked', 'checked') : $('#enableArticleUpdateHint').removeAttr('checked');\n 'true' === preference.allowVisitDraftViaPermalink ? $('#allowVisitDraftViaPermalink').attr('checked', 'checked') : $('allowVisitDraftViaPermalink').removeAttr('checked');\n 'true' === preference.commentable ? $('#commentable').attr('checked', 'checked') : $('commentable').removeAttr('checked');\n 'true' === preference.syncGitHub ? $('#syncGitHub').attr('checked', 'checked') : $('syncGitHub').removeAttr('checked');\n 'true' === preference.pullGitHub ? $('#pullGitHub').attr('checked', 'checked') : $('pullGitHub').removeAttr('checked');\n 'true' === preference.showCodeBlockLn ? $('#showCodeBlockLn').attr('checked', 'checked') : $('showCodeBlockLn').removeAttr('checked');\n 'true' === preference.showToC ? $('#showToC').attr('checked', 'checked') : $('showToC').removeAttr('checked');\n admin.preference.locale = preference.localeString; // sign\n\n var signs = eval('(' + preference.signs + ')');\n\n for (var j = 1; j < signs.length; j++) {\n $('#preferenceSign' + j).val(signs[j].signHTML);\n }\n\n $('#articleListDisplay').val(preference.articleListStyle);\n $('#hljsTheme').val(preference.hljsTheme);\n $('#feedOutputMode').val(preference.feedOutputMode);\n $('#feedOutputCnt').val(preference.feedOutputCnt);\n $('#faviconURL').val(preference.faviconURL);\n $('#loadMsg').text('');\n }\n });\n },\n\n /*\r\n * @description 参数校验\r\n */\n validate: function validate() {\n if (!/^\\d+$/.test($('#mostUsedTagDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexTagDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#mostUsedTagDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#recentCommentDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexRecentCommentDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#recentCommentDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#mostCommentArticleDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexMostCommentArticleDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#mostCommentArticleDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#mostViewArticleDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexMostViewArticleDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#mostViewArticleDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#articleListDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.pageSizeLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#articleListDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#articleListPaginationWindowSize').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.windowSizeLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#articleListPaginationWindowSize').focus();\n return false;\n } else if (!/^\\d+$/.test($('#randomArticlesDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.randomArticlesDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#randomArticlesDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#relevantArticlesDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.relevantArticlesDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#relevantArticlesDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#externalRelevantArticlesDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.externalRelevantArticlesDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#externalRelevantArticlesDisplayCount').focus();\n return false;\n }\n\n return true;\n },\n\n /*\r\n * @description 更新\r\n */\n update: function update() {\n if (!admin.preference.validate()) {\n return;\n }\n\n $('#tipMsg').text('');\n $('#loadMsg').text(Label.loadingLabel);\n var signs = [{\n 'oId': 0,\n 'signHTML': ''\n }, {\n 'oId': 1,\n 'signHTML': $('#preferenceSign1').val()\n }, {\n 'oId': 2,\n 'signHTML': $('#preferenceSign2').val()\n }, {\n 'oId': 3,\n 'signHTML': $('#preferenceSign3').val()\n }];\n var requestJSONObject = {\n 'preference': {\n 'metaKeywords': $('#metaKeywords').val(),\n 'metaDescription': $('#metaDescription').val(),\n 'blogTitle': $('#blogTitle').val(),\n 'blogSubtitle': $('#blogSubtitle').val(),\n 'mostCommentArticleDisplayCount': $('#mostCommentArticleDisplayCount').val(),\n 'mostViewArticleDisplayCount': $('#mostViewArticleDisplayCount').val(),\n 'recentCommentDisplayCount': $('#recentCommentDisplayCount').val(),\n 'mostUsedTagDisplayCount': $('#mostUsedTagDisplayCount').val(),\n 'articleListDisplayCount': $('#articleListDisplayCount').val(),\n 'articleListPaginationWindowSize': $('#articleListPaginationWindowSize').val(),\n 'localeString': $('#localeString').val(),\n 'timeZoneId': $('#timeZoneId').val(),\n 'noticeBoard': $('#noticeBoard').val(),\n 'footerContent': $('#footerContent').val(),\n 'htmlHead': $('#htmlHead').val(),\n 'externalRelevantArticlesDisplayCount': $('#externalRelevantArticlesDisplayCount').val(),\n 'relevantArticlesDisplayCount': $('#relevantArticlesDisplayCount').val(),\n 'randomArticlesDisplayCount': $('#randomArticlesDisplayCount').val(),\n 'enableArticleUpdateHint': $('#enableArticleUpdateHint').prop('checked'),\n 'signs': signs,\n 'allowVisitDraftViaPermalink': $('#allowVisitDraftViaPermalink').prop('checked'),\n 'articleListStyle': $('#articleListDisplay').val(),\n 'hljsTheme': $('#hljsTheme').val(),\n 'feedOutputMode': $('#feedOutputMode').val(),\n 'feedOutputCnt': $('#feedOutputCnt').val(),\n 'faviconURL': $('#faviconURL').val(),\n 'syncGitHub': $('#syncGitHub').prop('checked'),\n 'pullGitHub': $('#pullGitHub').prop('checked'),\n 'showCodeBlockLn': $('#showCodeBlockLn').prop('checked'),\n 'showToC': $('#showToC').prop('checked'),\n 'commentable': $('#commentable').prop('checked'),\n 'customVars': $('#customVars').val()\n }\n };\n $.ajax({\n url: Label.servePath + '/console/preference/',\n type: 'PUT',\n cache: false,\n data: JSON.stringify(requestJSONObject),\n success: function success(result, textStatus) {\n $('#tipMsg').text(result.msg);\n\n if (!result.sc) {\n $('#loadMsg').text('');\n return;\n }\n\n if ($('#localeString').val() !== admin.preference.locale) {\n window.location.reload();\n }\n\n $('#loadMsg').text('');\n }\n });\n }\n};\n/*\r\n * 注册到 admin 进行管理\r\n */\n\nadmin.register['preference'] = {\n 'obj': admin.preference,\n 'init': admin.preference.init,\n 'refresh': function refresh() {\n admin.clearTip();\n }\n};\n\n//# sourceURL=webpack:///./src/main/resources/js/admin/preference.js?");
eval("/*\r\n * Solo - A small and beautiful blogging system written in Java.\r\n * Copyright (c) 2010-present, b3log.org\r\n *\r\n * This program is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU Affero General Public License as published by\r\n * the Free Software Foundation, either version 3 of the License, or\r\n * (at your option) any later version.\r\n *\r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU Affero General Public License for more details.\r\n *\r\n * You should have received a copy of the GNU Affero General Public License\r\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\r\n */\n\n/**\r\n * preference for admin.\r\n *\r\n * @author <a href=\"http://vanessa.b3log.org\">Liyuan Li</a>\r\n * @author <a href=\"http://88250.b3log.org\">Liang Ding</a>\r\n * @version 1.3.0.4, Jan 24, 2020\r\n */\n\n/* preference 相关操作 */\nadmin.preference = {\n locale: '',\n\n /*\r\n * 初始化\r\n */\n init: function init() {\n $('#tabPreference').tabs();\n $.ajax({\n url: Label.servePath + '/console/preference/',\n type: 'GET',\n cache: false,\n success: function success(result, textStatus) {\n $('#tipMsg').text(result.msg);\n\n if (!result.sc) {\n $('#loadMsg').text('');\n return;\n }\n\n var preference = result.preference;\n $('#metaKeywords').val(preference.metaKeywords);\n $('#metaDescription').val(preference.metaDescription);\n $('#blogTitle').val(preference.blogTitle);\n $('#blogSubtitle').val(preference.blogSubtitle);\n $('#mostCommentArticleDisplayCount').val(preference.mostCommentArticleDisplayCount);\n $('#mostViewArticleDisplayCount').val(preference.mostViewArticleDisplayCount);\n $('#recentCommentDisplayCount').val(preference.recentCommentDisplayCount);\n $('#mostUsedTagDisplayCount').val(preference.mostUsedTagDisplayCount);\n $('#articleListDisplayCount').val(preference.articleListDisplayCount);\n $('#articleListPaginationWindowSize').val(preference.articleListPaginationWindowSize);\n $('#localeString').val(preference.localeString);\n $('#timeZoneId').val(preference.timeZoneId);\n $('#noticeBoard').val(preference.noticeBoard);\n $('#footerContent').val(preference.footerContent);\n $('#htmlHead').val(preference.htmlHead);\n $('#externalRelevantArticlesDisplayCount').val(preference.externalRelevantArticlesDisplayCount);\n $('#relevantArticlesDisplayCount').val(preference.relevantArticlesDisplayCount);\n $('#randomArticlesDisplayCount').val(preference.randomArticlesDisplayCount);\n $('#customVars').val(preference.customVars);\n 'true' === preference.enableArticleUpdateHint ? $('#enableArticleUpdateHint').attr('checked', 'checked') : $('#enableArticleUpdateHint').removeAttr('checked');\n 'true' === preference.allowVisitDraftViaPermalink ? $('#allowVisitDraftViaPermalink').attr('checked', 'checked') : $('#allowVisitDraftViaPermalink').removeAttr('checked');\n 'true' === preference.commentable ? $('#commentable').attr('checked', 'checked') : $('#commentable').removeAttr('checked');\n 'true' === preference.syncGitHub ? $('#syncGitHub').attr('checked', 'checked') : $('#syncGitHub').removeAttr('checked');\n 'true' === preference.pullGitHub ? $('#pullGitHub').attr('checked', 'checked') : $('#pullGitHub').removeAttr('checked');\n 'true' === preference.showCodeBlockLn ? $('#showCodeBlockLn').attr('checked', 'checked') : $('#showCodeBlockLn').removeAttr('checked');\n 'true' === preference.footnotes ? $('#footnotes').attr('checked', 'checked') : $('#footnotes').removeAttr('checked');\n 'true' === preference.showToC ? $('#showToC').attr('checked', 'checked') : $('#showToC').removeAttr('checked');\n 'true' === preference.autoSpace ? $('#autoSpace').attr('checked', 'checked') : $('#autoSpace').removeAttr('checked');\n 'true' === preference.fixTermTypo ? $('#fixTermTypo').attr('checked', 'checked') : $('#fixTermTypo').removeAttr('checked');\n 'true' === preference.chinesePunct ? $('#chinesePunct').attr('checked', 'checked') : $('#chinesePunct').removeAttr('checked');\n 'true' === preference.inlineMathAllowDigitAfterOpenMarker ? $('#inlineMathAllowDigitAfterOpenMarker').attr('checked', 'checked') : $('#inlineMathAllowDigitAfterOpenMarker').removeAttr('checked');\n admin.preference.locale = preference.localeString; // sign\n\n var signs = eval('(' + preference.signs + ')');\n\n for (var j = 1; j < signs.length; j++) {\n $('#preferenceSign' + j).val(signs[j].signHTML);\n }\n\n $('#articleListDisplay').val(preference.articleListStyle);\n $('#hljsTheme').val(preference.hljsTheme);\n $('#feedOutputMode').val(preference.feedOutputMode);\n $('#feedOutputCnt').val(preference.feedOutputCnt);\n $('#faviconURL').val(preference.faviconURL);\n $('#loadMsg').text('');\n }\n });\n },\n\n /*\r\n * @description 参数校验\r\n */\n validate: function validate() {\n if (!/^\\d+$/.test($('#mostUsedTagDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexTagDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#mostUsedTagDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#recentCommentDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexRecentCommentDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#recentCommentDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#mostCommentArticleDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexMostCommentArticleDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#mostCommentArticleDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#mostViewArticleDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.indexMostViewArticleDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#mostViewArticleDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#articleListDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.pageSizeLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#articleListDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#articleListPaginationWindowSize').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.windowSizeLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#articleListPaginationWindowSize').focus();\n return false;\n } else if (!/^\\d+$/.test($('#randomArticlesDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.randomArticlesDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#randomArticlesDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#relevantArticlesDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.relevantArticlesDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#relevantArticlesDisplayCount').focus();\n return false;\n } else if (!/^\\d+$/.test($('#externalRelevantArticlesDisplayCount').val())) {\n $('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.externalRelevantArticlesDisplayCntLabel + '] ' + Label.nonNegativeIntegerOnlyLabel);\n $('#externalRelevantArticlesDisplayCount').focus();\n return false;\n }\n\n return true;\n },\n\n /*\r\n * @description 更新\r\n */\n update: function update() {\n if (!admin.preference.validate()) {\n return;\n }\n\n $('#tipMsg').text('');\n $('#loadMsg').text(Label.loadingLabel);\n var signs = [{\n 'oId': 0,\n 'signHTML': ''\n }, {\n 'oId': 1,\n 'signHTML': $('#preferenceSign1').val()\n }, {\n 'oId': 2,\n 'signHTML': $('#preferenceSign2').val()\n }, {\n 'oId': 3,\n 'signHTML': $('#preferenceSign3').val()\n }];\n var requestJSONObject = {\n 'preference': {\n 'metaKeywords': $('#metaKeywords').val(),\n 'metaDescription': $('#metaDescription').val(),\n 'blogTitle': $('#blogTitle').val(),\n 'blogSubtitle': $('#blogSubtitle').val(),\n 'mostCommentArticleDisplayCount': $('#mostCommentArticleDisplayCount').val(),\n 'mostViewArticleDisplayCount': $('#mostViewArticleDisplayCount').val(),\n 'recentCommentDisplayCount': $('#recentCommentDisplayCount').val(),\n 'mostUsedTagDisplayCount': $('#mostUsedTagDisplayCount').val(),\n 'articleListDisplayCount': $('#articleListDisplayCount').val(),\n 'articleListPaginationWindowSize': $('#articleListPaginationWindowSize').val(),\n 'localeString': $('#localeString').val(),\n 'timeZoneId': $('#timeZoneId').val(),\n 'noticeBoard': $('#noticeBoard').val(),\n 'footerContent': $('#footerContent').val(),\n 'htmlHead': $('#htmlHead').val(),\n 'externalRelevantArticlesDisplayCount': $('#externalRelevantArticlesDisplayCount').val(),\n 'relevantArticlesDisplayCount': $('#relevantArticlesDisplayCount').val(),\n 'randomArticlesDisplayCount': $('#randomArticlesDisplayCount').val(),\n 'enableArticleUpdateHint': $('#enableArticleUpdateHint').prop('checked'),\n 'signs': signs,\n 'allowVisitDraftViaPermalink': $('#allowVisitDraftViaPermalink').prop('checked'),\n 'articleListStyle': $('#articleListDisplay').val(),\n 'hljsTheme': $('#hljsTheme').val(),\n 'feedOutputMode': $('#feedOutputMode').val(),\n 'feedOutputCnt': $('#feedOutputCnt').val(),\n 'faviconURL': $('#faviconURL').val(),\n 'syncGitHub': $('#syncGitHub').prop('checked'),\n 'pullGitHub': $('#pullGitHub').prop('checked'),\n 'showCodeBlockLn': $('#showCodeBlockLn').prop('checked'),\n 'commentable': $('#commentable').prop('checked'),\n 'customVars': $('#customVars').val(),\n 'footnotes': $('#footnotes').prop('checked'),\n 'showToC': $('#showToC').prop('checked'),\n 'autoSpace': $('#autoSpace').prop('checked'),\n 'fixTermTypo': $('#fixTermTypo').prop('checked'),\n 'chinesePunct': $('#chinesePunct').prop('checked'),\n 'inlineMathAllowDigitAfterOpenMarker': $('#inlineMathAllowDigitAfterOpenMarker').prop('checked')\n }\n };\n $.ajax({\n url: Label.servePath + '/console/preference/',\n type: 'PUT',\n cache: false,\n data: JSON.stringify(requestJSONObject),\n success: function success(result, textStatus) {\n $('#tipMsg').text(result.msg);\n\n if (!result.sc) {\n $('#loadMsg').text('');\n return;\n }\n\n if ($('#localeString').val() !== admin.preference.locale) {\n window.location.reload();\n }\n\n $('#loadMsg').text('');\n }\n });\n }\n};\n/*\r\n * 注册到 admin 进行管理\r\n */\n\nadmin.register['preference'] = {\n 'obj': admin.preference,\n 'init': admin.preference.init,\n 'refresh': function refresh() {\n admin.clearTip();\n }\n};\n\n//# sourceURL=webpack:///./src/main/resources/js/admin/preference.js?");
/***/ }),
......
......@@ -49,36 +49,35 @@ admin.preference = {
$('#metaDescription').val(preference.metaDescription)
$('#blogTitle').val(preference.blogTitle)
$('#blogSubtitle').val(preference.blogSubtitle)
$('#mostCommentArticleDisplayCount').
val(preference.mostCommentArticleDisplayCount)
$('#mostViewArticleDisplayCount').
val(preference.mostViewArticleDisplayCount)
$('#recentCommentDisplayCount').
val(preference.recentCommentDisplayCount)
$('#mostCommentArticleDisplayCount').val(preference.mostCommentArticleDisplayCount)
$('#mostViewArticleDisplayCount').val(preference.mostViewArticleDisplayCount)
$('#recentCommentDisplayCount').val(preference.recentCommentDisplayCount)
$('#mostUsedTagDisplayCount').val(preference.mostUsedTagDisplayCount)
$('#articleListDisplayCount').val(preference.articleListDisplayCount)
$('#articleListPaginationWindowSize').
val(preference.articleListPaginationWindowSize)
$('#articleListPaginationWindowSize').val(preference.articleListPaginationWindowSize)
$('#localeString').val(preference.localeString)
$('#timeZoneId').val(preference.timeZoneId)
$('#noticeBoard').val(preference.noticeBoard)
$('#footerContent').val(preference.footerContent)
$('#htmlHead').val(preference.htmlHead)
$('#externalRelevantArticlesDisplayCount').
val(preference.externalRelevantArticlesDisplayCount)
$('#relevantArticlesDisplayCount').
val(preference.relevantArticlesDisplayCount)
$('#randomArticlesDisplayCount').
val(preference.randomArticlesDisplayCount)
$('#externalRelevantArticlesDisplayCount').val(preference.externalRelevantArticlesDisplayCount)
$('#relevantArticlesDisplayCount').val(preference.relevantArticlesDisplayCount)
$('#randomArticlesDisplayCount').val(preference.randomArticlesDisplayCount)
$('#customVars').val(preference.customVars)
'true' === preference.enableArticleUpdateHint ? $('#enableArticleUpdateHint').attr('checked', 'checked') : $('#enableArticleUpdateHint').removeAttr('checked')
'true' === preference.allowVisitDraftViaPermalink ? $('#allowVisitDraftViaPermalink').attr('checked', 'checked') : $('allowVisitDraftViaPermalink').removeAttr('checked')
'true' === preference.commentable ? $('#commentable').attr('checked', 'checked') : $('commentable').removeAttr('checked')
'true' === preference.syncGitHub ? $('#syncGitHub').attr('checked', 'checked') : $('syncGitHub').removeAttr('checked')
'true' === preference.pullGitHub ? $('#pullGitHub').attr('checked', 'checked') : $('pullGitHub').removeAttr('checked')
'true' === preference.showCodeBlockLn ? $('#showCodeBlockLn').attr('checked', 'checked') : $('showCodeBlockLn').removeAttr('checked')
'true' === preference.showToC ? $('#showToC').attr('checked', 'checked') : $('showToC').removeAttr('checked')
'true' === preference.allowVisitDraftViaPermalink ? $('#allowVisitDraftViaPermalink').attr('checked', 'checked') : $('#allowVisitDraftViaPermalink').removeAttr('checked')
'true' === preference.commentable ? $('#commentable').attr('checked', 'checked') : $('#commentable').removeAttr('checked')
'true' === preference.syncGitHub ? $('#syncGitHub').attr('checked', 'checked') : $('#syncGitHub').removeAttr('checked')
'true' === preference.pullGitHub ? $('#pullGitHub').attr('checked', 'checked') : $('#pullGitHub').removeAttr('checked')
'true' === preference.showCodeBlockLn ? $('#showCodeBlockLn').attr('checked', 'checked') : $('#showCodeBlockLn').removeAttr('checked')
'true' === preference.footnotes ? $('#footnotes').attr('checked', 'checked') : $('#footnotes').removeAttr('checked')
'true' === preference.showToC ? $('#showToC').attr('checked', 'checked') : $('#showToC').removeAttr('checked')
'true' === preference.autoSpace ? $('#autoSpace').attr('checked', 'checked') : $('#autoSpace').removeAttr('checked')
'true' === preference.fixTermTypo ? $('#fixTermTypo').attr('checked', 'checked') : $('#fixTermTypo').removeAttr('checked')
'true' === preference.chinesePunct ? $('#chinesePunct').attr('checked', 'checked') : $('#chinesePunct').removeAttr('checked')
'true' === preference.inlineMathAllowDigitAfterOpenMarker ? $('#inlineMathAllowDigitAfterOpenMarker').attr('checked', 'checked') : $('#inlineMathAllowDigitAfterOpenMarker').removeAttr('checked')
admin.preference.locale = preference.localeString
......@@ -103,63 +102,54 @@ admin.preference = {
*/
validate: function () {
if (!/^\d+$/.test($('#mostUsedTagDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.indexTagDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#mostUsedTagDisplayCount').focus()
return false
} else if (!/^\d+$/.test($('#recentCommentDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.indexRecentCommentDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#recentCommentDisplayCount').focus()
return false
} else if (!/^\d+$/.test($('#mostCommentArticleDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.indexMostCommentArticleDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#mostCommentArticleDisplayCount').focus()
return false
} else if (!/^\d+$/.test($('#mostViewArticleDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.indexMostViewArticleDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#mostViewArticleDisplayCount').focus()
return false
} else if (!/^\d+$/.test($('#articleListDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' + Label.pageSizeLabel +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.pageSizeLabel +
'] ' + Label.nonNegativeIntegerOnlyLabel)
$('#articleListDisplayCount').focus()
return false
} else if (!/^\d+$/.test($('#articleListPaginationWindowSize').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' + Label.windowSizeLabel +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' + Label.windowSizeLabel +
'] ' + Label.nonNegativeIntegerOnlyLabel)
$('#articleListPaginationWindowSize').focus()
return false
} else if (!/^\d+$/.test($('#randomArticlesDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.randomArticlesDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#randomArticlesDisplayCount').focus()
return false
} else if (!/^\d+$/.test($('#relevantArticlesDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.relevantArticlesDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#relevantArticlesDisplayCount').focus()
return false
} else if (!/^\d+$/.test(
$('#externalRelevantArticlesDisplayCount').val())) {
$('#tipMsg').
text('[' + Label.paramSettingsLabel + ' - ' +
$('#tipMsg').text('[' + Label.paramSettingsLabel + ' - ' +
Label.externalRelevantArticlesDisplayCntLabel + '] ' +
Label.nonNegativeIntegerOnlyLabel)
$('#externalRelevantArticlesDisplayCount').focus()
......@@ -190,7 +180,8 @@ admin.preference = {
}, {
'oId': 3,
'signHTML': $('#preferenceSign3').val(),
}]
}
]
var requestJSONObject = {
'preference': {
......@@ -198,14 +189,12 @@ admin.preference = {
'metaDescription': $('#metaDescription').val(),
'blogTitle': $('#blogTitle').val(),
'blogSubtitle': $('#blogSubtitle').val(),
'mostCommentArticleDisplayCount': $('#mostCommentArticleDisplayCount').
val(),
'mostCommentArticleDisplayCount': $('#mostCommentArticleDisplayCount').val(),
'mostViewArticleDisplayCount': $('#mostViewArticleDisplayCount').val(),
'recentCommentDisplayCount': $('#recentCommentDisplayCount').val(),
'mostUsedTagDisplayCount': $('#mostUsedTagDisplayCount').val(),
'articleListDisplayCount': $('#articleListDisplayCount').val(),
'articleListPaginationWindowSize': $(
'#articleListPaginationWindowSize').val(),
'articleListPaginationWindowSize': $('#articleListPaginationWindowSize').val(),
'localeString': $('#localeString').val(),
'timeZoneId': $('#timeZoneId').val(),
'noticeBoard': $('#noticeBoard').val(),
......@@ -213,14 +202,11 @@ admin.preference = {
'htmlHead': $('#htmlHead').val(),
'externalRelevantArticlesDisplayCount': $(
'#externalRelevantArticlesDisplayCount').val(),
'relevantArticlesDisplayCount': $('#relevantArticlesDisplayCount').
val(),
'relevantArticlesDisplayCount': $('#relevantArticlesDisplayCount').val(),
'randomArticlesDisplayCount': $('#randomArticlesDisplayCount').val(),
'enableArticleUpdateHint': $('#enableArticleUpdateHint').
prop('checked'),
'enableArticleUpdateHint': $('#enableArticleUpdateHint').prop('checked'),
'signs': signs,
'allowVisitDraftViaPermalink': $('#allowVisitDraftViaPermalink').
prop('checked'),
'allowVisitDraftViaPermalink': $('#allowVisitDraftViaPermalink').prop('checked'),
'articleListStyle': $('#articleListDisplay').val(),
'hljsTheme': $('#hljsTheme').val(),
'feedOutputMode': $('#feedOutputMode').val(),
......@@ -229,9 +215,14 @@ admin.preference = {
'syncGitHub': $('#syncGitHub').prop('checked'),
'pullGitHub': $('#pullGitHub').prop('checked'),
'showCodeBlockLn': $('#showCodeBlockLn').prop('checked'),
'showToC': $('#showToC').prop('checked'),
'commentable': $('#commentable').prop('checked'),
'customVars': $('#customVars').val(),
'footnotes': $('#footnotes').prop('checked'),
'showToC': $('#showToC').prop('checked'),
'autoSpace': $('#autoSpace').prop('checked'),
'fixTermTypo': $('#fixTermTypo').prop('checked'),
'chinesePunct': $('#chinesePunct').prop('checked'),
'inlineMathAllowDigitAfterOpenMarker': $('#inlineMathAllowDigitAfterOpenMarker').prop('checked'),
},
}
......
......@@ -18,13 +18,19 @@
#
# Description: Solo language configurations(en_US).
# Version: 2.38.0.0, Jan 24, 2020
# Version: 2.39.0.0, Jan 25, 2020
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
#
showToCLabel=Support Markdown [TOC] (need&nbsp;<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}]
......
......@@ -18,13 +18,19 @@
#
# Description: Solo default language configurations(zh_CN).
# Version: 2.38.0.0, Jan 24, 2020
# Version: 2.39.0.0, Jan 25, 2020
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
#
showToCLabel=\u652F\u6301 Markdown [TOC]\uFF08\u9700\u542F\u7528&nbsp;<a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>\uFF09\uFF1A
inlineMathAllowDigitAfterOpenMarkerLabel=\u5185\u8054\u6570\u5B66\u516C\u5F0F\u662F\u5426\u5141\u8BB8\u8D77\u59CB $ \u540E\u7D27\u8DDF\u6570\u5B57
chinesePunctLabel=\u4E2D\u6587\u540E\u8DDF\u82F1\u6587\u9017\u53F7\u53E5\u53F7\u7B49\u6807\u70B9\u66FF\u6362\u4E3A\u4E2D\u6587\u5BF9\u5E94\u6807\u70B9
fixTermTypoLabel=\u672F\u8BED\u4FEE\u6B63
autoSpaceLabel=\u4E2D\u897F\u6587\u95F4\u81EA\u52A8\u63D2\u5165\u7A7A\u683C
supportFootnotesLabel=\u652F\u6301\u811A\u6CE8
supportToCLabel=\u652F\u6301 [TOC]
luteHTTPLabel=\u4EE5\u4E0B\u914D\u7F6E\u9879\u9700\u542F\u7528 <a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a> \u5F15\u64CE\u624D\u80FD\u5F97\u5230\u652F\u6301\u3002
showCodeBlockLnLabel=\u4EE3\u7801\u5757\u663E\u793A\u884C\u53F7\uFF1A
siteURLLabel=\u7AD9\u70B9\u5730\u5740\uFF1A
siteGenedLabel=\u7AD9\u70B9\u751F\u6210\u5B8C\u6BD5\uFF0C\u8BF7\u67E5\u770B\u76EE\u5F55 [{dir}]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment