Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Mar 17, 2019
1 parent aaa841f commit de87596
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/main/java/org/b3log/solo/model/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
*
* @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.
*/
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/b3log/solo/model/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @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 {
Expand All @@ -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.
*/
Expand Down Expand Up @@ -269,11 +274,16 @@ private 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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*
* @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
Expand Down Expand Up @@ -167,6 +167,7 @@ public void getSigns(final RequestContext context) {
* "commentable": boolean,
* "feedOutputMode: "" // Optional values: "abstract"/"full"
* "feedOutputCnt": int,
* "faviconURL": "",
* "customVars" "", // 支持配置自定义参数 https://github.com/b3log/solo/issues/12535
* }
* }
Expand Down Expand Up @@ -244,6 +245,7 @@ public void getPreference(final RequestContext context) {
* "commentable": boolean,
* "feedOutputMode: "",
* "feedOutputCnt": int,
* "faviconURL": "",
* "customVars" "", // 支持配置自定义参数 https://github.com/b3log/solo/issues/12535
* }
* }
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/b3log/solo/service/DataModelService.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*
* @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
Expand Down Expand Up @@ -569,6 +569,9 @@ public void fillCommon(final RequestContext context, final Map<String, Object> d

// 使用 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));
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/b3log/solo/service/InitService.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ private void initStatistic() throws RepositoryException, JSONException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ public void updatePreference(final JSONObject preference) throws ServiceExceptio
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);
Expand Down

0 comments on commit de87596

Please sign in to comment.