Commit 96da7dbb authored by Liang Ding's avatar Liang Ding

🎨 #12706

parent 862f4dc4
...@@ -224,6 +224,7 @@ public class ArticleProcessor { ...@@ -224,6 +224,7 @@ public class ArticleProcessor {
Keys.fillRuntime(dataModel); Keys.fillRuntime(dataModel);
dataModelService.fillMinified(dataModel); dataModelService.fillMinified(dataModel);
dataModelService.fillFaviconURL(dataModel, preference);
} }
/** /**
...@@ -623,6 +624,7 @@ public class ArticleProcessor { ...@@ -623,6 +624,7 @@ public class ArticleProcessor {
prepareShowAuthorArticles(pageNums, dataModel, pageCount, currentPageNum, articles, author); prepareShowAuthorArticles(pageNums, dataModel, pageCount, currentPageNum, articles, author);
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel); Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
...@@ -678,6 +680,7 @@ public class ArticleProcessor { ...@@ -678,6 +680,7 @@ public class ArticleProcessor {
prepareShowArchiveArticles(preference, dataModel, articles, currentPageNum, pageCount, archiveDateString, archiveDate); prepareShowArchiveArticles(preference, dataModel, articles, currentPageNum, pageCount, archiveDateString, archiveDate);
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
} catch (final Exception e) { } catch (final Exception e) {
...@@ -751,6 +754,7 @@ public class ArticleProcessor { ...@@ -751,6 +754,7 @@ public class ArticleProcessor {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel); Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
if (!StatisticMgmtService.hasBeenServed(context, response)) { if (!StatisticMgmtService.hasBeenServed(context, response)) {
......
...@@ -151,6 +151,7 @@ public class CategoryProcessor { ...@@ -151,6 +151,7 @@ public class CategoryProcessor {
dataModel.put(Common.PATH, "/category/" + URLs.encode(categoryURI)); dataModel.put(Common.PATH, "/category/" + URLs.encode(categoryURI));
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
} catch (final ServiceException | JSONException e) { } catch (final ServiceException | JSONException e) {
......
...@@ -101,6 +101,7 @@ public class ErrorProcessor { ...@@ -101,6 +101,7 @@ public class ErrorProcessor {
dataModel.putAll(langs); dataModel.putAll(langs);
final JSONObject preference = optionQueryService.getPreference(); final JSONObject preference = optionQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
final String msg = (String) context.attr(Keys.MSG); final String msg = (String) context.attr(Keys.MSG);
dataModel.put(Keys.MSG, msg); dataModel.put(Keys.MSG, msg);
dataModel.put(Common.LOGIN_URL, userQueryService.getLoginURL(Common.ADMIN_INDEX_URI)); dataModel.put(Common.LOGIN_URL, userQueryService.getLoginURL(Common.ADMIN_INDEX_URI));
......
...@@ -129,6 +129,7 @@ public class IndexProcessor { ...@@ -129,6 +129,7 @@ public class IndexProcessor {
dataModelService.fillIndexArticles(context, dataModel, currentPageNum, preference); dataModelService.fillIndexArticles(context, dataModel, currentPageNum, preference);
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
dataModel.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, currentPageNum); dataModel.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, currentPageNum);
final int previousPageNum = currentPageNum > 1 ? currentPageNum - 1 : 0; final int previousPageNum = currentPageNum > 1 ? currentPageNum - 1 : 0;
...@@ -176,15 +177,8 @@ public class IndexProcessor { ...@@ -176,15 +177,8 @@ public class IndexProcessor {
dataModel.put(Common.REFERER, referer); dataModel.put(Common.REFERER, referer);
Keys.fillRuntime(dataModel); Keys.fillRuntime(dataModel);
dataModelService.fillMinified(dataModel); dataModelService.fillMinified(dataModel);
dataModelService.fillFaviconURL(dataModel, optionQueryService.getPreference());
Solos.addGoogleNoIndex(context); Solos.addGoogleNoIndex(context);
try {
final JSONObject preference = optionQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} }
/** /**
...@@ -217,6 +211,7 @@ public class IndexProcessor { ...@@ -217,6 +211,7 @@ public class IndexProcessor {
dataModel.putAll(langs); dataModel.putAll(langs);
final JSONObject preference = optionQueryService.getPreference(); final JSONObject preference = optionQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
Keys.fillServer(dataModel); Keys.fillServer(dataModel);
Keys.fillRuntime(dataModel); Keys.fillRuntime(dataModel);
dataModelService.fillMinified(dataModel); dataModelService.fillMinified(dataModel);
......
...@@ -136,6 +136,7 @@ public class PageProcessor { ...@@ -136,6 +136,7 @@ public class PageProcessor {
Stopwatchs.end(); Stopwatchs.end();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
......
...@@ -148,6 +148,7 @@ public class SearchProcessor { ...@@ -148,6 +148,7 @@ public class SearchProcessor {
final JSONObject preference = optionQueryService.getPreference(); final JSONObject preference = optionQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
dataModelService.setArticlesExProperties(context, articles, preference); dataModelService.setArticlesExProperties(context, articles, preference);
dataModel.put(Article.ARTICLES, articles); dataModel.put(Article.ARTICLES, articles);
......
...@@ -148,6 +148,7 @@ public class TagProcessor { ...@@ -148,6 +148,7 @@ public class TagProcessor {
dataModel.put(Keys.OBJECT_ID, tagId); dataModel.put(Keys.OBJECT_ID, tagId);
dataModel.put(Tag.TAG, tag); dataModel.put(Tag.TAG, tag);
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
......
...@@ -111,6 +111,7 @@ public class UserTemplateProcessor { ...@@ -111,6 +111,7 @@ public class UserTemplateProcessor {
dataModel.putAll(langs); dataModel.putAll(langs);
final JSONObject preference = optionQueryService.getPreference(); final JSONObject preference = optionQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
dataModelService.fillUserTemplate(context, template, dataModel, preference); dataModelService.fillUserTemplate(context, template, dataModel, preference);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel); Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
......
...@@ -160,7 +160,7 @@ public class AdminConsole { ...@@ -160,7 +160,7 @@ public class AdminConsole {
dataModel.put(Common.UPLOAD_URL, upload.optString(Common.UPLOAD_URL)); dataModel.put(Common.UPLOAD_URL, upload.optString(Common.UPLOAD_URL));
dataModel.put(Common.UPLOAD_MSG, upload.optString(Common.UPLOAD_MSG)); dataModel.put(Common.UPLOAD_MSG, upload.optString(Common.UPLOAD_MSG));
} }
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillFaviconURL(dataModel, preference);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Admin index render failed", e); LOGGER.log(Level.ERROR, "Admin index render failed", e);
} }
......
...@@ -537,6 +537,20 @@ public class DataModelService { ...@@ -537,6 +537,20 @@ public class DataModelService {
} }
} }
/**
* Fills favicon URL. 可配置 favicon 图标路径 https://github.com/b3log/solo/issues/12706
*
* @param dataModel the specified data model
* @param preference the specified preference
*/
public void fillFaviconURL(final Map<String, Object> dataModel, final JSONObject preference) {
if (null == preference) {
dataModel.put(Common.FAVICON_URL, Option.DefaultPreference.DEFAULT_FAVICON_URL);
} else {
dataModel.put(Common.FAVICON_URL, preference.optString(Option.ID_C_FAVICON_URL));
}
}
/** /**
* Fills common parts (header, side and footer). * Fills common parts (header, side and footer).
* *
...@@ -568,9 +582,6 @@ public class DataModelService { ...@@ -568,9 +582,6 @@ public class DataModelService {
// 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614 // 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614
dataModel.put(Common.MARKED_AVAILABLE, Markdowns.MARKDOWN_HTTP_AVAILABLE); 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));
} }
/** /**
......
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