Commit de875966 authored by Liang Ding's avatar Liang Ding

🎨 #12706

parent aaa841f3
......@@ -22,11 +22,16 @@ package org.b3log.solo.model;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a>
* @version 1.7.0.3, Feb 27, 2019
* @version 1.7.0.4, Mar 17, 2019
* @since 0.3.1
*/
public final class Common {
/**
* Key of favicon URL.
*/
public static final String FAVICON_URL = "faviconURL";
/**
* Key of URL.
*/
......
......@@ -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.5.0.4, Mar 3, 2019
* @version 1.5.0.5, Mar 17, 2019
* @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 favicon URL.
*/
public static final String ID_C_FAVICON_URL = "faviconURL";
/**
* Key of custom vars.
*/
......@@ -269,11 +274,16 @@ public final class Option {
* Default preference.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.2.0.1, Feb 17, 2019
* @version 2.2.0.2, Mar 17, 2019
* @since 0.3.1
*/
public static final class DefaultPreference {
/**
* Default favicon URL.
*/
public static final String DEFAULT_FAVICON_URL = "https://static.b3log.org/images/brand/solo-32.png";
/**
* Default custom vars.
*/
......
......@@ -44,7 +44,7 @@ import javax.servlet.http.HttpServletResponse;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.2.0.21, Feb 8, 2019
* @version 1.2.0.22, Mar 17, 2019
* @since 0.4.0
*/
@RequestProcessor
......@@ -167,6 +167,7 @@ public class PreferenceConsole {
* "commentable": boolean,
* "feedOutputMode: "" // Optional values: "abstract"/"full"
* "feedOutputCnt": int,
* "faviconURL": "",
* "customVars" "", // 支持配置自定义参数 https://github.com/b3log/solo/issues/12535
* }
* }
......@@ -244,6 +245,7 @@ public class PreferenceConsole {
* "commentable": boolean,
* "feedOutputMode: "",
* "feedOutputCnt": int,
* "faviconURL": "",
* "customVars" "", // 支持配置自定义参数 https://github.com/b3log/solo/issues/12535
* }
* }
......
......@@ -59,7 +59,7 @@ import static org.b3log.solo.model.Article.ARTICLE_CONTENT;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.7.0.5, Feb 27, 2019
* @version 1.7.0.6, Mar 17, 2019
* @since 0.3.1
*/
@Service
......@@ -569,6 +569,9 @@ public class DataModelService {
// 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614
dataModel.put(Common.MARKED_AVAILABLE, Markdowns.MARKDOWN_HTTP_AVAILABLE);
// 可配置 favicon 图标路径 https://github.com/b3log/solo/issues/12706
dataModel.put(Common.FAVICON_URL, preference.optString(Option.ID_C_FAVICON_URL));
}
/**
......
......@@ -475,6 +475,12 @@ public class InitService {
private void initPreference(final JSONObject requestJSONObject) throws Exception {
LOGGER.debug("Initializing preference....");
final JSONObject faviconURLOpt = new JSONObject();
faviconURLOpt.put(Keys.OBJECT_ID, Option.ID_C_FAVICON_URL);
faviconURLOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
faviconURLOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_FAVICON_URL);
optionRepository.add(faviconURLOpt);
final JSONObject customVarsOpt = new JSONObject();
customVarsOpt.put(Keys.OBJECT_ID, Option.ID_C_CUSTOM_VARS);
customVarsOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
......
......@@ -307,6 +307,10 @@ public class PreferenceMgmtService {
versionOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_VERSION));
optionRepository.update(Option.ID_C_VERSION, versionOpt);
final JSONObject faviconURLOpt = optionRepository.get(Option.ID_C_FAVICON_URL);
faviconURLOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_FAVICON_URL));
optionRepository.update(Option.ID_C_FAVICON_URL, faviconURLOpt);
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);
......
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