Commit 0987c5f9 authored by Liang Ding's avatar Liang Ding

#4

parent 93ac213c
......@@ -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.2, Aug 18, 2019
* @version 1.6.0.3, Jan 18, 2020
* @since 0.6.0
*/
public final class Option {
......@@ -52,6 +52,11 @@ public final class Option {
public static final String OPTION_CATEGORY = "optionCategory";
// oId constants
/**
* Key of code block line num show flag. 支持代码块行号显示 https://github.com/88250/solo/issues/4
*/
public static final String ID_C_SHOW_CODE_BLOCK_LN = "showCodeBlockLn";
/**
* Key of hljs theme. 在设置中可选择语法高亮主题 https://github.com/b3log/solo/issues/12722
*/
......@@ -300,11 +305,16 @@ public final class Option {
* Default preference.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.0.3, Sep 18, 2019
* @version 2.3.0.4, Jan 18, 2020
* @since 0.3.1
*/
public static final class DefaultPreference {
/**
* Default show code block line num.
*/
public static final String DEFAULT_SHOW_CODE_BLOCK_LN = "false";
/**
* Default hljs theme.
*/
......
......@@ -520,6 +520,12 @@ public class DataModelService {
}
dataModel.put(Option.ID_C_HLJS_THEME, hljsTheme);
String showCodeBlockLn = preference.optString(Option.ID_C_SHOW_CODE_BLOCK_LN);
if (StringUtils.isBlank(showCodeBlockLn)) {
showCodeBlockLn = Option.DefaultPreference.DEFAULT_SHOW_CODE_BLOCK_LN;
}
dataModel.put(Option.ID_C_SHOW_CODE_BLOCK_LN, showCodeBlockLn);
dataModel.put(Common.COMMENTABLE, preference.optBoolean(Option.ID_C_COMMENTABLE));
dataModel.put("staticSite", Solos.GEN_STATIC_SITE);
......
......@@ -53,7 +53,7 @@ import java.util.List;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.36, Dec 28, 2019
* @version 1.5.2.37, Jan 18, 2020
* @since 0.4.0
*/
@Service
......@@ -472,6 +472,12 @@ public class InitService {
private void initOptions(final JSONObject requestJSONObject) throws Exception {
LOGGER.debug("Initializing preference....");
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);
showCodeBlockLnOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_SHOW_CODE_BLOCK_LN);
optionRepository.add(showCodeBlockLnOpt);
final JSONObject hljsThemeOpt = new JSONObject();
hljsThemeOpt.put(Keys.OBJECT_ID, Option.ID_C_HLJS_THEME);
hljsThemeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
......
......@@ -20,6 +20,7 @@ package org.b3log.solo.service;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.repository.Transaction;
......@@ -38,7 +39,7 @@ import java.util.Locale;
* Preference management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.0.2, Aug 18, 2019
* @version 1.4.0.3, Jan 18, 2020
* @since 0.4.0
*/
@Service
......@@ -219,6 +220,15 @@ public class PreferenceMgmtService {
hljsThemeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_HLJS_THEME));
optionRepository.update(Option.ID_C_HLJS_THEME, hljsThemeOpt);
JSONObject showCodeBlockLnOpt = optionRepository.get(Option.ID_C_SHOW_CODE_BLOCK_LN);
if (null == showCodeBlockLnOpt) {
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, preference.optString(Option.ID_C_SHOW_CODE_BLOCK_LN));
optionRepository.update(Option.ID_C_SHOW_CODE_BLOCK_LN, showCodeBlockLnOpt);
final JSONObject customVarsOpt = optionRepository.get(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);
......
......@@ -177,6 +177,12 @@
<input id="pullGitHub" type="checkbox" class="normalInput"/>
</div>
</label>
<label>
<div class="fn__flex-inline">
${showCodeBlockLnLabel}
<input id="showCodeBlockLn" type="checkbox" class="normalInput"/>
</div>
</label>
</div>
<div class="fn__margin12"></div>
<div class="fn__flex-1">
......
This diff is collapsed.
......@@ -77,6 +77,7 @@ admin.preference = {
'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')
admin.preference.locale = preference.localeString
......@@ -226,6 +227,7 @@ admin.preference = {
'faviconURL': $('#faviconURL').val(),
'syncGitHub': $('#syncGitHub').prop('checked'),
'pullGitHub': $('#pullGitHub').prop('checked'),
'showCodeBlockLn': $('#showCodeBlockLn').prop('checked'),
'commentable': $('#commentable').prop('checked'),
'customVars': $('#customVars').val(),
},
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import $ from 'jquery'
const pjaxUtil = {
support: {
......
......@@ -24,6 +24,7 @@
# Author: Dongxu Wang
#
showCodeBlockLnLabel=Show code block line num:
siteURLLabel=Site URL:
siteGenedLabel=Site generated, target dir is [{dir}]
generateLabel=Gen
......
......@@ -24,6 +24,7 @@
# Author: Dongxu Wang
#
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}]
generateLabel=\u751F\u6210
......
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