Commit 11451562 authored by Van's avatar Van

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/resources/js/admin/admin.min.js
#	src/main/resources/skins/Bubble/js/common.min.js
#	src/main/resources/skins/Casper/js/common.min.js
#	src/main/resources/skins/Finding/js/common.min.js
#	src/main/resources/skins/Jane/js/common.min.js
#	src/main/resources/skins/Medium/js/common.min.js
#	src/main/resources/skins/NeoEase/js/common.min.js
#	src/main/resources/skins/Pinghsu/js/common.min.js
#	src/main/resources/skins/metro-hot/js/common.min.js
#	src/main/resources/skins/next/js/common.min.js
#	src/main/resources/skins/nijigen/js/common.min.js
parents 12d54174 cfba07fe
*.min.js linguist-vendored
*.scss linguist-vendored
<p align = "center">
<img alt="Solo" src="https://user-images.githubusercontent.com/873584/52320401-2593e600-2a0a-11e9-9ba1-db79ee71d1af.png">
<br><br>
小而美的博客系统,专为程序员设计
<br><br>
<a title="Build Status" target="_blank" href="https://travis-ci.org/88250/solo"><img src="https://img.shields.io/travis/88250/solo.svg?style=flat-square"></a>
<a title="Docker Image CI" target="_blank" href="https://github.com/88250/solo/actions"><img src="https://img.shields.io/github/workflow/status/88250/solo/Docker%20Image%20CI?color=blue&label=Actions&logo=github&style=flat-square"></a>
<a title="Coverage Status" target="_blank" href="https://coveralls.io/github/88250/solo"><img src="https://img.shields.io/coveralls/github/88250/solo.svg?style=flat-square&color=CC9933"></a>
<a title="Code Size" target="_blank" href="https://github.com/88250/solo"><img src="https://img.shields.io/github/languages/code-size/88250/solo.svg?style=flat-square&color=6699FF"></a>
<a title="AGPLv3" target="_blank" href="https://www.gnu.org/licenses/agpl-3.0.txt"><img src="http://img.shields.io/badge/license-AGPLv3-orange.svg?style=flat-square"></a>
<br>
<a title="Releases" target="_blank" href="https://github.com/88250/solo/releases"><img src="https://img.shields.io/github/release/88250/solo.svg?style=flat-square&color=CC6666"></a>
<a title="Release Date" target="_blank" href="https://github.com/88250/solo/releases"><img src="https://img.shields.io/github/release-date/88250/solo.svg?style=flat-square&color=99CCFF"></a>
<a title="Downloads" target="_blank" href="https://github.com/88250/solo/releases"><img src="https://img.shields.io/github/downloads/88250/solo/total.svg?style=flat-square&color=99CC99"></a>
<a title="Docker Pulls" target="_blank" href="https://hub.docker.com/r/88250/solo"><img src="https://img.shields.io/docker/pulls/88250/solo.svg?style=flat-square&color=blueviolet"></a>
<br>
<a title="GitHub Commits" target="_blank" href="https://github.com/88250/solo/commits/master"><img src="https://img.shields.io/github/commit-activity/m/88250/solo.svg?style=flat-square"></a>
<a title="Last Commit" target="_blank" href="https://github.com/88250/solo/commits/master"><img src="https://img.shields.io/github/last-commit/88250/solo.svg?style=flat-square&color=FF9900"></a>
<a title="GitHub Pull Requests" target="_blank" href="https://github.com/88250/solo/pulls"><img src="https://img.shields.io/github/issues-pr-closed/88250/solo.svg?style=flat-square&color=FF9966"></a>
<a title="Hits" target="_blank" href="https://github.com/88250/hits"><img src="https://hits.b3log.org/88250/solo.svg"></a>
<br><br>
<a title="GitHub Watchers" target="_blank" href="https://github.com/88250/solo/watchers"><img src="https://img.shields.io/github/watchers/88250/solo.svg?label=Watchers&style=social"></a>
<a title="GitHub Stars" target="_blank" href="https://github.com/88250/solo/stargazers"><img src="https://img.shields.io/github/stars/88250/solo.svg?label=Stars&style=social"></a>
<a title="GitHub Forks" target="_blank" href="https://github.com/88250/solo/network/members"><img src="https://img.shields.io/github/forks/88250/solo.svg?label=Forks&style=social"></a>
<a title="Author GitHub Followers" target="_blank" href="https://github.com/88250"><img src="https://img.shields.io/github/followers/88250.svg?label=Followers&style=social"></a>
</p>
* [B3log 构思 - 分布式社区网络](https://hacpai.com/article/1546941897596) * [B3log 构思 - 分布式社区网络](https://hacpai.com/article/1546941897596)
* [Solo 用户指南](https://hacpai.com/article/1492881378588) * [Solo 用户指南](https://hacpai.com/article/1492881378588)
* [Solo 从设计到实现](https://hacpai.com/article/1537690756242) * [Solo 从设计到实现](https://hacpai.com/article/1537690756242)
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: Solo POM. Description: Solo POM.
Version: 3.18.3.81, Jan 16, 2020 Version: 3.18.3.82, Jan 24, 2020
Author: <a href="http://88250.b3log.org">Liang Ding</a> Author: <a href="http://88250.b3log.org">Liang Ding</a>
Author: <a href="http://www.annpeter.cn">Ann Peter</a> Author: <a href="http://www.annpeter.cn">Ann Peter</a>
Author: <a href="http://vanessa.b3log.org">Vanessa</a> Author: <a href="http://vanessa.b3log.org">Vanessa</a>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</scm> </scm>
<properties> <properties>
<org.b3log.latke.version>3.2.1</org.b3log.latke.version> <org.b3log.latke.version>3.2.2</org.b3log.latke.version>
<jsoup.version>1.12.1</jsoup.version> <jsoup.version>1.12.1</jsoup.version>
<flexmark.version>0.50.40</flexmark.version> <flexmark.version>0.50.40</flexmark.version>
......
...@@ -47,7 +47,7 @@ import org.json.JSONObject; ...@@ -47,7 +47,7 @@ import org.json.JSONObject;
* Server. * Server.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.8, Jan 13, 2020 * @version 2.0.0.9, Jan 24, 2020
* @since 1.2.0 * @since 1.2.0
*/ */
public final class Server extends BaseServer { public final class Server extends BaseServer {
...@@ -308,6 +308,8 @@ public final class Server extends BaseServer { ...@@ -308,6 +308,8 @@ public final class Server extends BaseServer {
final String showClodeBlockLn = preference.optString(org.b3log.solo.model.Option.ID_C_SHOW_CODE_BLOCK_LN); final String showClodeBlockLn = preference.optString(org.b3log.solo.model.Option.ID_C_SHOW_CODE_BLOCK_LN);
Markdowns.SHOW_CODE_BLOCK_LN = StringUtils.equalsIgnoreCase(showClodeBlockLn, "true"); Markdowns.SHOW_CODE_BLOCK_LN = StringUtils.equalsIgnoreCase(showClodeBlockLn, "true");
final String showToC = preference.optString(org.b3log.solo.model.Option.ID_C_SHOW_TOC);
Markdowns.SHOW_TOC = StringUtils.equalsIgnoreCase(showToC, "true");
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
......
...@@ -26,7 +26,7 @@ import org.json.JSONObject; ...@@ -26,7 +26,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a> * @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.6.0.3, Jan 18, 2020 * @version 1.6.0.5, Jan 25, 2020
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -52,8 +52,39 @@ public final class Option { ...@@ -52,8 +52,39 @@ public final class Option {
public static final String OPTION_CATEGORY = "optionCategory"; public static final String OPTION_CATEGORY = "optionCategory";
// oId constants // 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 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 code block line num show flag. 支持代码块行号显示 https://github.com/88250/solo/issues/4 * Key of show code block line num flag. 支持代码块行号显示 https://github.com/88250/solo/issues/4
*/ */
public static final String ID_C_SHOW_CODE_BLOCK_LN = "showCodeBlockLn"; public static final String ID_C_SHOW_CODE_BLOCK_LN = "showCodeBlockLn";
...@@ -305,7 +336,7 @@ public final class Option { ...@@ -305,7 +336,7 @@ public final class Option {
* Default preference. * Default preference.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.0.4, Jan 18, 2020 * @version 2.3.0.6, Jan 25, 2020
* @since 0.3.1 * @since 0.3.1
*/ */
public static final class DefaultPreference { public static final class DefaultPreference {
......
...@@ -20,8 +20,11 @@ package org.b3log.solo.plugin; ...@@ -20,8 +20,11 @@ package org.b3log.solo.plugin;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.b3log.latke.event.AbstractEventListener; import org.b3log.latke.event.AbstractEventListener;
import org.b3log.latke.event.Event; import org.b3log.latke.event.Event;
import org.b3log.latke.event.EventManager;
import org.b3log.latke.http.RequestContext; import org.b3log.latke.http.RequestContext;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.plugin.NotInteractivePlugin; import org.b3log.latke.plugin.NotInteractivePlugin;
import org.b3log.latke.plugin.PluginStatus;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -39,16 +42,24 @@ import java.util.Map; ...@@ -39,16 +42,24 @@ import java.util.Map;
* ToC event handler. * ToC event handler.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.0, Jul 29, 2019 * @version 2.0.1.0, Jan 24, 2020
* @since 0.6.7 * @since 0.6.7
*/ */
public class ToCPlugin extends NotInteractivePlugin { public class ToCPlugin extends NotInteractivePlugin {
/** private ToCEventHandler handler = new ToCEventHandler();
* Public constructor.
*/ @Override
public ToCPlugin() { public void changeStatus() {
addEventListener(new ToCEventHandler()); super.changeStatus();
final EventManager eventManager = BeanManager.getInstance().getReference(EventManager.class);
final PluginStatus status = getStatus();
if (PluginStatus.DISABLED == status) {
eventManager.unregisterListener(handler);
} else {
eventManager.registerListener(handler);
}
} }
@Override @Override
...@@ -66,7 +77,7 @@ public class ToCPlugin extends NotInteractivePlugin { ...@@ -66,7 +77,7 @@ public class ToCPlugin extends NotInteractivePlugin {
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://www.annpeter.cn">Ann Peter</a> * @author <a href="http://www.annpeter.cn">Ann Peter</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a> * @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 2.0.0.0, Jul 29, 2019 * @version 2.0.0.1, Jan 24, 2020
* @since 0.6.7 * @since 0.6.7
*/ */
class ToCEventHandler extends AbstractEventListener<JSONObject> { class ToCEventHandler extends AbstractEventListener<JSONObject> {
...@@ -90,7 +101,7 @@ class ToCEventHandler extends AbstractEventListener<JSONObject> { ...@@ -90,7 +101,7 @@ class ToCEventHandler extends AbstractEventListener<JSONObject> {
final Element element = hs.get(i); final Element element = hs.get(i);
final String tagName = element.tagName().toLowerCase(); final String tagName = element.tagName().toLowerCase();
final String text = element.text(); final String text = element.text();
final String id = "b3_solo_" + tagName + "_" + i; final String id = "toc_" + tagName + "_" + i;
element.attr("id", id); element.attr("id", id);
final JSONObject li = new JSONObject(). final JSONObject li = new JSONObject().
put("className", "toc__" + tagName). put("className", "toc__" + tagName).
......
...@@ -61,7 +61,7 @@ import java.util.*; ...@@ -61,7 +61,7 @@ import java.util.*;
* Admin console render processing. * Admin console render processing.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.7.0.17, Dec 15, 2019 * @version 1.7.0.18, Jan 25, 2020
* @since 0.4.1 * @since 0.4.1
*/ */
@Singleton @Singleton
...@@ -216,6 +216,7 @@ public class AdminConsole { ...@@ -216,6 +216,7 @@ public class AdminConsole {
timeZoneIdOptions.append(option); timeZoneIdOptions.append(option);
} }
dataModel.put(Common.LUTE_AVAILABLE, Markdowns.LUTE_AVAILABLE);
dataModel.put("timeZoneIdOptions", timeZoneIdOptions.toString()); dataModel.put("timeZoneIdOptions", timeZoneIdOptions.toString());
fireFreeMarkerActionEvent(templateName, dataModel); fireFreeMarkerActionEvent(templateName, dataModel);
} }
......
...@@ -41,7 +41,7 @@ import org.json.JSONObject; ...@@ -41,7 +41,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a> * @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.2.0.25, Jun 13, 2019 * @version 1.2.0.26, Jan 25, 2020
* @since 0.4.0 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -243,7 +243,14 @@ public class PreferenceConsole { ...@@ -243,7 +243,14 @@ public class PreferenceConsole {
* "faviconURL": "", * "faviconURL": "",
* "syncGitHub": boolean, * "syncGitHub": boolean,
* "pullGitHub": boolean, * "pullGitHub": boolean,
* "customVars" "", // 支持配置自定义参数 https://github.com/b3log/solo/issues/12535 * "customVars": "", // 支持配置自定义参数 https://github.com/b3log/solo/issues/12535
* "showCodeBlockLn": boolean, // 支持代码块行号显示 https://github.com/88250/solo/issues/4
* "footnotes": boolean, // Markdown 支持改进 https://github.com/88250/solo/issues/54
* "showToC": boolean, // Markdown 支持改进 https://github.com/88250/solo/issues/54
* "autoSpace": boolean, // Markdown 支持改进 https://github.com/88250/solo/issues/54
* "fixTermTypo": boolean, // Markdown 支持改进 https://github.com/88250/solo/issues/54
* "chinesePunct": boolean, // Markdown 支持改进 https://github.com/88250/solo/issues/54
* "inlineMathAllowDigitAfterOpenMarker": boolean, // Markdown 支持改进 https://github.com/88250/solo/issues/54
* } * }
* } * }
* </pre> * </pre>
......
...@@ -53,7 +53,7 @@ import java.util.List; ...@@ -53,7 +53,7 @@ import java.util.List;
* Solo initialization service. * Solo initialization service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.37, Jan 18, 2020 * @version 1.5.2.38, Jan 24, 2020
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -472,6 +472,42 @@ public class InitService { ...@@ -472,6 +472,42 @@ public class InitService {
private void initOptions(final JSONObject requestJSONObject) throws Exception { private void initOptions(final JSONObject requestJSONObject) throws Exception {
LOGGER.debug("Initializing preference...."); 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, "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(); final JSONObject showCodeBlockLnOpt = new JSONObject();
showCodeBlockLnOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_CODE_BLOCK_LN); showCodeBlockLnOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_CODE_BLOCK_LN);
showCodeBlockLnOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); showCodeBlockLnOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
......
...@@ -40,7 +40,7 @@ import java.util.Locale; ...@@ -40,7 +40,7 @@ import java.util.Locale;
* Preference management service. * Preference management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.0.3, Jan 18, 2020 * @version 1.4.0.5, Jan 25, 2020
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -221,24 +221,38 @@ public class PreferenceMgmtService { ...@@ -221,24 +221,38 @@ public class PreferenceMgmtService {
hljsThemeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_HLJS_THEME)); hljsThemeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_HLJS_THEME));
optionRepository.update(Option.ID_C_HLJS_THEME, hljsThemeOpt); optionRepository.update(Option.ID_C_HLJS_THEME, hljsThemeOpt);
JSONObject showCodeBlockLnOpt = optionRepository.get(Option.ID_C_SHOW_CODE_BLOCK_LN);
final String showCodeBlockLnVal = preference.optString(Option.ID_C_SHOW_CODE_BLOCK_LN); final String showCodeBlockLnVal = preference.optString(Option.ID_C_SHOW_CODE_BLOCK_LN);
if (null == showCodeBlockLnOpt) { emptyPreferenceOptSave(Option.ID_C_SHOW_CODE_BLOCK_LN, showCodeBlockLnVal);
showCodeBlockLnOpt = new JSONObject();
showCodeBlockLnOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_CODE_BLOCK_LN);
showCodeBlockLnOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
showCodeBlockLnOpt.put(Option.OPTION_VALUE, showCodeBlockLnVal);
optionRepository.add(showCodeBlockLnOpt);
} else {
showCodeBlockLnOpt.put(Option.OPTION_VALUE, showCodeBlockLnVal);
optionRepository.update(Option.ID_C_SHOW_CODE_BLOCK_LN, showCodeBlockLnOpt);
}
Markdowns.SHOW_CODE_BLOCK_LN = "true".equalsIgnoreCase(showCodeBlockLnVal); Markdowns.SHOW_CODE_BLOCK_LN = "true".equalsIgnoreCase(showCodeBlockLnVal);
final JSONObject customVarsOpt = optionRepository.get(Option.ID_C_CUSTOM_VARS); final JSONObject customVarsOpt = optionRepository.get(Option.ID_C_CUSTOM_VARS);
customVarsOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_CUSTOM_VARS)); customVarsOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_CUSTOM_VARS));
optionRepository.update(Option.ID_C_CUSTOM_VARS, customVarsOpt); optionRepository.update(Option.ID_C_CUSTOM_VARS, customVarsOpt);
final String footnotesVal = preference.optString(Option.ID_C_FOOTNOTES);
emptyPreferenceOptSave(Option.ID_C_FOOTNOTES, footnotesVal);
Markdowns.FOOTNOTES = "true".equalsIgnoreCase(footnotesVal);
final String showToCVal = preference.optString(Option.ID_C_SHOW_TOC);
emptyPreferenceOptSave(Option.ID_C_SHOW_TOC, showToCVal);
Markdowns.SHOW_TOC = "true".equalsIgnoreCase(showToCVal);
final String autoSpaceVal = preference.optString(Option.ID_C_AUTO_SPACE);
emptyPreferenceOptSave(Option.ID_C_AUTO_SPACE, autoSpaceVal);
Markdowns.AUTO_SPACE = "true".equalsIgnoreCase(autoSpaceVal);
final String fixTermTypoVal = preference.optString(Option.ID_C_FIX_TERM_TYPO);
emptyPreferenceOptSave(Option.ID_C_FIX_TERM_TYPO, fixTermTypoVal);
Markdowns.FIX_TERM_TYPO = "true".equalsIgnoreCase(fixTermTypoVal);
final String chinesePunctVal = preference.optString(Option.ID_C_CHINESE_PUNCT);
emptyPreferenceOptSave(Option.ID_C_CHINESE_PUNCT, chinesePunctVal);
Markdowns.CHINESE_PUNCT = "true".equalsIgnoreCase(chinesePunctVal);
final String IMADAOMVal = preference.optString(Option.ID_C_IMADAOM);
emptyPreferenceOptSave(Option.ID_C_IMADAOM, IMADAOMVal);
Markdowns.IMADAOM = "true".equalsIgnoreCase(IMADAOMVal);
transaction.commit(); transaction.commit();
Markdowns.clearCache(); Markdowns.clearCache();
...@@ -253,4 +267,18 @@ public class PreferenceMgmtService { ...@@ -253,4 +267,18 @@ public class PreferenceMgmtService {
LOGGER.log(Level.DEBUG, "Updates preference successfully"); LOGGER.log(Level.DEBUG, "Updates preference successfully");
} }
private void emptyPreferenceOptSave(final String optID, final String val) throws Exception {
JSONObject opt = optionRepository.get(optID);
if (null == opt) {
opt = new JSONObject();
opt.put(Keys.OBJECT_ID, optID);
opt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
opt.put(Option.OPTION_VALUE, val);
optionRepository.add(opt);
} else {
opt.put(Option.OPTION_VALUE, val);
optionRepository.update(optID, opt);
}
}
} }
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
package org.b3log.solo.util; package org.b3log.solo.util;
import com.vladsch.flexmark.ext.autolink.AutolinkExtension; import com.vladsch.flexmark.ext.autolink.AutolinkExtension;
import com.vladsch.flexmark.ext.footnotes.FootnoteExtension;
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension; import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension;
import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension; import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension;
import com.vladsch.flexmark.ext.tables.TablesExtension; import com.vladsch.flexmark.ext.tables.TablesExtension;
...@@ -61,7 +60,7 @@ import java.util.concurrent.*; ...@@ -61,7 +60,7 @@ import java.util.concurrent.*;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.1.13, Jan 20, 2020 * @version 2.3.1.15, Jan 25, 2020
* @since 0.4.5 * @since 0.4.5
*/ */
public final class Markdowns { public final class Markdowns {
...@@ -89,8 +88,7 @@ public final class Markdowns { ...@@ -89,8 +88,7 @@ public final class Markdowns {
TablesExtension.create(), TablesExtension.create(),
TaskListExtension.create(), TaskListExtension.create(),
StrikethroughExtension.create(), StrikethroughExtension.create(),
AutolinkExtension.create(), AutolinkExtension.create())).
FootnoteExtension.create())).
set(HtmlRenderer.SOFT_BREAK, "<br />\n"); set(HtmlRenderer.SOFT_BREAK, "<br />\n");
/** /**
...@@ -115,6 +113,12 @@ public final class Markdowns { ...@@ -115,6 +113,12 @@ public final class Markdowns {
public static boolean LUTE_AVAILABLE; public static boolean LUTE_AVAILABLE;
public static boolean SHOW_CODE_BLOCK_LN = false; 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. * Clears cache.
...@@ -270,8 +274,14 @@ public final class Markdowns { ...@@ -270,8 +274,14 @@ public final class Markdowns {
final URL url = new URL(LUTE_ENGINE_URL); final URL url = new URL(LUTE_ENGINE_URL);
final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-CodeSyntaxHighlightLineNum", String.valueOf(Markdowns.SHOW_CODE_BLOCK_LN)); 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.setConnectTimeout(100);
conn.setReadTimeout(1000); conn.setReadTimeout(3000);
conn.setDoOutput(true); conn.setDoOutput(true);
try (final OutputStream outputStream = conn.getOutputStream()) { try (final OutputStream outputStream = conn.getOutputStream()) {
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
<a href="#tools/preference/setting">${paramSettingsLabel}</a> <a href="#tools/preference/setting">${paramSettingsLabel}</a>
</div> </div>
</li> </li>
<li>
<div id="tabPreference_markdown">
<a href="#tools/preference/markdown">Markdown</a>
</div>
</li>
</ul> </ul>
</div> </div>
<div id="tabPreferencePanel" class="sub-tabs-main"> <div id="tabPreferencePanel" class="sub-tabs-main">
...@@ -243,5 +248,55 @@ ...@@ -243,5 +248,55 @@
<button onclick="admin.preference.update()" class="fn__right">${updateLabel}</button> <button onclick="admin.preference.update()" class="fn__right">${updateLabel}</button>
<div class="fn__clear"></div> <div class="fn__clear"></div>
</div> </div>
<div id="tabPreferencePanel_markdown" class="fn__none form">
<#if !luteAvailable>
<div class="fn__clear">
${luteHTTPLabel}
</div>
</#if>
<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> </div>
${plugins} ${plugins}
This diff is collapsed.
...@@ -18,12 +18,19 @@ ...@@ -18,12 +18,19 @@
# #
# Description: Solo language configurations(en_US). # Description: Solo language configurations(en_US).
# Version: 2.37.0.0, Jan 13, 2020 # Version: 2.39.0.0, Jan 25, 2020
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
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: showCodeBlockLnLabel=Show code block line num:
siteURLLabel=Site URL: siteURLLabel=Site URL:
siteGenedLabel=Site generated, target dir is [{dir}] siteGenedLabel=Site generated, target dir is [{dir}]
......
...@@ -18,12 +18,19 @@ ...@@ -18,12 +18,19 @@
# #
# Description: Solo default language configurations(zh_CN). # Description: Solo default language configurations(zh_CN).
# Version: 2.37.0.0, Jan 13, 2020 # Version: 2.39.0.0, Jan 25, 2020
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
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 showCodeBlockLnLabel=\u4EE3\u7801\u5757\u663E\u793A\u884C\u53F7\uFF1A
siteURLLabel=\u7AD9\u70B9\u5730\u5740\uFF1A siteURLLabel=\u7AD9\u70B9\u5730\u5740\uFF1A
siteGenedLabel=\u7AD9\u70B9\u751F\u6210\u5B8C\u6BD5\uFF0C\u8BF7\u67E5\u770B\u76EE\u5F55 [{dir}] siteGenedLabel=\u7AD9\u70B9\u751F\u6210\u5B8C\u6BD5\uFF0C\u8BF7\u67E5\u770B\u76EE\u5F55 [{dir}]
......
...@@ -125,7 +125,7 @@ window.Skin = { ...@@ -125,7 +125,7 @@ window.Skin = {
}) })
} }
var $articleTocs = $('.vditor-reset [id^=b3_solo_h]') var $articleTocs = $('.vditor-reset [id^=toc_h]')
var $articleToc = $('.article__toc') var $articleToc = $('.article__toc')
$articleToc.find('a').click(function (event) { $articleToc.find('a').click(function (event) {
......
...@@ -59,7 +59,7 @@ window.Skin = { ...@@ -59,7 +59,7 @@ window.Skin = {
initArticle: function () { initArticle: function () {
page.share() page.share()
var $articleTocs = $('.vditor-reset [id^=b3_solo_h]') var $articleTocs = $('.vditor-reset [id^=toc_h]')
var $articleToc = $('.article__toc') var $articleToc = $('.article__toc')
var $articleProgress = $('.article__progress') var $articleProgress = $('.article__progress')
......
...@@ -83,7 +83,7 @@ window.Skin = { ...@@ -83,7 +83,7 @@ window.Skin = {
$('.post__toc'). $('.post__toc').
css('left', $('.post').offset().left + $('.post').outerWidth()) css('left', $('.post').offset().left + $('.post').outerWidth())
var $articleTocs = $('.vditor-reset [id^=b3_solo_h]'), var $articleTocs = $('.vditor-reset [id^=toc_h]'),
$articleToc = $('.article__toc') $articleToc = $('.article__toc')
$(window).unbind('scroll').scroll(function (event) { $(window).unbind('scroll').scroll(function (event) {
......
...@@ -100,7 +100,7 @@ window.NexT = { ...@@ -100,7 +100,7 @@ window.NexT = {
} }
}, },
initToc: function () { initToc: function () {
var $articleTocs = $('.vditor-reset [id^=b3_solo_h]'), var $articleTocs = $('.vditor-reset [id^=toc_h]'),
$articleToc = $('.article__toc'); $articleToc = $('.article__toc');
$(window).scroll(function (event) { $(window).scroll(function (event) {
......
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