Commit b0d56607 authored by Liang Ding's avatar Liang Ding

Fix #12039

parent b394027d
...@@ -19,7 +19,7 @@ package org.b3log.solo.model; ...@@ -19,7 +19,7 @@ package org.b3log.solo.model;
* This class defines option model relevant keys. * This class defines option model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, Sep 12, 2015 * @version 1.1.0.1, Nov 7, 2015
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -69,6 +69,11 @@ public final class Option { ...@@ -69,6 +69,11 @@ public final class Option {
* Key of Qiniu bucket. * Key of Qiniu bucket.
*/ */
public static final String ID_C_QINIU_BUCKET = "qiniuBucket"; public static final String ID_C_QINIU_BUCKET = "qiniuBucket";
/**
* Key of footer content.
*/
public static final String ID_C_FOOTER_CONTENT = "footerContent";
// Category constants // Category constants
/** /**
...@@ -80,6 +85,11 @@ public final class Option { ...@@ -80,6 +85,11 @@ public final class Option {
* Qiniu. * Qiniu.
*/ */
public static final String CATEGORY_C_QINIU = "qiniu"; public static final String CATEGORY_C_QINIU = "qiniu";
/**
* Preference.
*/
public static final String CATEGORY_C_PREFERENCE = "preference";
/** /**
* Private constructor. * Private constructor.
......
...@@ -46,7 +46,7 @@ import org.json.JSONObject; ...@@ -46,7 +46,7 @@ import org.json.JSONObject;
* Preference console request processing. * Preference console request processing.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.6, Sep 12, 2015 * @version 1.1.0.7, Nov 7, 2015
* @since 0.4.0 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -295,6 +295,7 @@ public class PreferenceConsole { ...@@ -295,6 +295,7 @@ public class PreferenceConsole {
* "skinDirName": "" * "skinDirName": ""
* }, ....]", * }, ....]",
* "noticeBoard": "", * "noticeBoard": "",
* "footerContent": "",
* "htmlHead": "", * "htmlHead": "",
* "adminEmail": "", * "adminEmail": "",
* "metaKeywords": "", * "metaKeywords": "",
...@@ -341,6 +342,13 @@ public class PreferenceConsole { ...@@ -341,6 +342,13 @@ public class PreferenceConsole {
return; return;
} }
String footerContent = "";
final JSONObject opt = optionQueryService.getOptionById(Option.ID_C_FOOTER_CONTENT);
if (null != opt) {
footerContent = opt.optString(Option.OPTION_VALUE);
}
preference.put(Option.ID_C_FOOTER_CONTENT, footerContent);
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret); renderer.setJSONObject(ret);
...@@ -377,6 +385,7 @@ public class PreferenceConsole { ...@@ -377,6 +385,7 @@ public class PreferenceConsole {
* "localeString": "", * "localeString": "",
* "timeZoneId": "", * "timeZoneId": "",
* "noticeBoard": "", * "noticeBoard": "",
* "footerContent": "",
* "htmlHead": "", * "htmlHead": "",
* "metaKeywords": "", * "metaKeywords": "",
* "metaDescription": "", * "metaDescription": "",
...@@ -422,7 +431,7 @@ public class PreferenceConsole { ...@@ -422,7 +431,7 @@ public class PreferenceConsole {
if (isInvalid(preference, ret)) { if (isInvalid(preference, ret)) {
return; return;
} }
preferenceMgmtService.updatePreference(preference); preferenceMgmtService.updatePreference(preference);
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
......
...@@ -57,6 +57,7 @@ import org.b3log.solo.repository.PageRepository; ...@@ -57,6 +57,7 @@ import org.b3log.solo.repository.PageRepository;
import org.b3log.solo.repository.TagRepository; import org.b3log.solo.repository.TagRepository;
import org.b3log.solo.repository.UserRepository; import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.service.ArticleQueryService; import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.OptionQueryService;
import org.b3log.solo.service.StatisticQueryService; import org.b3log.solo.service.StatisticQueryService;
import org.b3log.solo.service.TagQueryService; import org.b3log.solo.service.TagQueryService;
import org.b3log.solo.service.UserQueryService; import org.b3log.solo.service.UserQueryService;
...@@ -70,7 +71,7 @@ import org.json.JSONObject; ...@@ -70,7 +71,7 @@ import org.json.JSONObject;
* Filler utilities. * Filler utilities.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.11.11, Nov 1, 2015 * @version 1.5.11.11, Nov 7, 2015
* @since 0.3.1 * @since 0.3.1
*/ */
@Service @Service
...@@ -135,6 +136,12 @@ public class Filler { ...@@ -135,6 +136,12 @@ public class Filler {
@Inject @Inject
private UserRepository userRepository; private UserRepository userRepository;
/**
* Option query service..
*/
@Inject
private OptionQueryService optionQueryService;
/** /**
* Article query service. * Article query service.
*/ */
...@@ -567,6 +574,13 @@ public class Filler { ...@@ -567,6 +574,13 @@ public class Filler {
dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion()); dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion());
dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR))); dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
String footerContent = "";
final JSONObject opt = optionQueryService.getOptionById(Option.ID_C_FOOTER_CONTENT);
if (null != opt) {
footerContent = opt.optString(Option.OPTION_VALUE);
}
dataModel.put(Option.ID_C_FOOTER_CONTENT, footerContent);
dataModel.put(Keys.Server.STATIC_SERVER, Latkes.getStaticServer()); dataModel.put(Keys.Server.STATIC_SERVER, Latkes.getStaticServer());
dataModel.put(Keys.Server.SERVER, Latkes.getServer()); dataModel.put(Keys.Server.SERVER, Latkes.getServer());
...@@ -663,7 +677,7 @@ public class Filler { ...@@ -663,7 +677,7 @@ public class Filler {
final JSONArray users = result.getJSONArray(Keys.RESULTS); final JSONArray users = result.getJSONArray(Keys.RESULTS);
final List<JSONObject> userList = CollectionUtils.jsonArrayToList(users); final List<JSONObject> userList = CollectionUtils.jsonArrayToList(users);
dataModel.put(User.USERS, userList); dataModel.put(User.USERS, userList);
final JSONObject admin = userRepository.getAdmin(); final JSONObject admin = userRepository.getAdmin();
dataModel.put(Common.ADMIN_USER, admin); dataModel.put(Common.ADMIN_USER, admin);
......
...@@ -23,6 +23,7 @@ import java.util.Locale; ...@@ -23,6 +23,7 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
...@@ -34,6 +35,7 @@ import org.b3log.latke.util.Stopwatchs; ...@@ -34,6 +35,7 @@ import org.b3log.latke.util.Stopwatchs;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.latke.util.freemarker.Templates; import org.b3log.latke.util.freemarker.Templates;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference; import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.b3log.solo.repository.PreferenceRepository; import org.b3log.solo.repository.PreferenceRepository;
...@@ -43,6 +45,7 @@ import static org.b3log.solo.model.Preference.*; ...@@ -43,6 +45,7 @@ import static org.b3log.solo.model.Preference.*;
import static org.b3log.solo.model.Skin.SKINS; import static org.b3log.solo.model.Skin.SKINS;
import static org.b3log.solo.model.Skin.SKIN_DIR_NAME; import static org.b3log.solo.model.Skin.SKIN_DIR_NAME;
import static org.b3log.solo.model.Skin.SKIN_NAME; import static org.b3log.solo.model.Skin.SKIN_NAME;
import org.b3log.solo.repository.OptionRepository;
import static org.b3log.solo.util.Skins.getSkinDirNames; import static org.b3log.solo.util.Skins.getSkinDirNames;
import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading; import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading;
...@@ -50,7 +53,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading; ...@@ -50,7 +53,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading;
* 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.0.1.9, Oct 31, 2015 * @version 1.1.1.9, Nov 7, 2015
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -66,6 +69,12 @@ public class PreferenceMgmtService { ...@@ -66,6 +69,12 @@ public class PreferenceMgmtService {
*/ */
@Inject @Inject
private PreferenceRepository preferenceRepository; private PreferenceRepository preferenceRepository;
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/** /**
* Language service. * Language service.
...@@ -238,6 +247,22 @@ public class PreferenceMgmtService { ...@@ -238,6 +247,22 @@ public class PreferenceMgmtService {
LOGGER.log(Level.DEBUG, "Current locale[string={0}]", localeString); LOGGER.log(Level.DEBUG, "Current locale[string={0}]", localeString);
Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString))); Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString)));
final String footerContent = preference.optString(Option.ID_C_FOOTER_CONTENT);
JSONObject opt = optionRepository.get(Option.ID_C_FOOTER_CONTENT);
if (null == opt) {
opt = new JSONObject();
opt.put(Keys.OBJECT_ID, Option.ID_C_FOOTER_CONTENT);
opt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
opt.put(Option.OPTION_VALUE, footerContent);
optionRepository.add(opt);
} else {
opt.put(Option.OPTION_VALUE, footerContent);
optionRepository.update(Option.ID_C_FOOTER_CONTENT, opt);
}
preference.remove(Option.ID_C_FOOTER_CONTENT);
preferenceRepository.update(Preference.PREFERENCE, preference); preferenceRepository.update(Preference.PREFERENCE, preference);
transaction.commit(); transaction.commit();
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# #
# Description: Solo language configurations(en_US). # Description: Solo language configurations(en_US).
# Version: 2.5.2.5, Oct 17, 2015 # Version: 2.5.2.6, Nov 7, 2015
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
footerContent1Label=Footer:
userAvatar1Label=Avatar: userAvatar1Label=Avatar:
uploadFileLabel=Upload <a href="http://hacpai.com/article/1442418791213" target="_blank">(?)</a> uploadFileLabel=Upload <a href="http://hacpai.com/article/1442418791213" target="_blank">(?)</a>
accessKey1Label=Access Key: accessKey1Label=Access Key:
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# #
# Description: Solo default language configurations(zh_CN). # Description: Solo default language configurations(zh_CN).
# Version: 2.5.4.13, Oct 17, 2015 # Version: 2.5.4.14, Nov 7, 2015
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
footerContent1Label=\u9875\u811a\uff1a
userAvatar1Label=\u5934\u50cf\uff1a userAvatar1Label=\u5934\u50cf\uff1a
uploadFileLabel=\u6587\u4ef6\u4e0a\u4f20 <a href="http://hacpai.com/article/1442418791213" target="_blank">(?)</a> uploadFileLabel=\u6587\u4ef6\u4e0a\u4f20 <a href="http://hacpai.com/article/1442418791213" target="_blank">(?)</a>
accessKey1Label=Access Key\uff1a accessKey1Label=Access Key\uff1a
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<label for="htmlHead">${htmlhead1Label}</label> <label for="htmlHead">${htmlhead1Label}</label>
</th> </th>
<td> <td>
<textarea rows="9" id="htmlHead"></textarea> <textarea rows="6" id="htmlHead"></textarea>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -94,7 +94,15 @@ ...@@ -94,7 +94,15 @@
<label for="noticeBoard">${noticeBoard1Label}</label> <label for="noticeBoard">${noticeBoard1Label}</label>
</th> </th>
<td> <td>
<textarea rows="9" id="noticeBoard"></textarea> <textarea rows="6" id="noticeBoard"></textarea>
</td>
</tr>
<tr>
<th valign="top">
<label for="footerContent">${footerContent1Label}</label>
</th>
<td>
<textarea rows="2" id="footerContent"></textarea>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.8, Sep 12, 2015 * @version 1.1.1.9, Nov 7, 2015
*/ */
/* preference 相关操作 */ /* preference 相关操作 */
...@@ -57,6 +57,7 @@ admin.preference = { ...@@ -57,6 +57,7 @@ admin.preference = {
$("#localeString").val(preference.localeString); $("#localeString").val(preference.localeString);
$("#timeZoneId").val(preference.timeZoneId); $("#timeZoneId").val(preference.timeZoneId);
$("#noticeBoard").val(preference.noticeBoard); $("#noticeBoard").val(preference.noticeBoard);
$("#footerContent").val(preference.footerContent);
$("#htmlHead").val(preference.htmlHead); $("#htmlHead").val(preference.htmlHead);
$("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount); $("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount);
$("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount); $("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount);
...@@ -77,7 +78,7 @@ admin.preference = { ...@@ -77,7 +78,7 @@ admin.preference = {
if (skins[i].skinName === preference.skinName if (skins[i].skinName === preference.skinName
&& skins[i].skinDirName === preference.skinDirName) { && skins[i].skinDirName === preference.skinDirName) {
selectedClass += " selected"; selectedClass += " selected";
} }
skinsHTML += "<div title='" + skins[i].skinDirName skinsHTML += "<div title='" + skins[i].skinDirName
+ "' class='left skinItem" + selectedClass + "'><img class='skinPreview' src='" + "' class='left skinItem" + selectedClass + "'><img class='skinPreview' src='"
+ latkeConfig.staticServePath + "/skins/" + skins[i].skinDirName + latkeConfig.staticServePath + "/skins/" + skins[i].skinDirName
...@@ -89,8 +90,8 @@ admin.preference = { ...@@ -89,8 +90,8 @@ admin.preference = {
$(".skinItem").removeClass("selected"); $(".skinItem").removeClass("selected");
$(this).addClass("selected"); $(this).addClass("selected");
$("#skinMain").data("skinDirName", this.title); $("#skinMain").data("skinDirName", this.title);
}); });
// sign // sign
var signs = eval('(' + preference.signs + ')'); var signs = eval('(' + preference.signs + ')');
for (var j = 1; j < signs.length; j++) { for (var j = 1; j < signs.length; j++) {
...@@ -114,8 +115,8 @@ admin.preference = { ...@@ -114,8 +115,8 @@ admin.preference = {
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/qiniu", url: latkeConfig.servePath + "/console/preference/qiniu",
type: "GET", type: "GET",
cache: false, cache: false,
...@@ -216,6 +217,7 @@ admin.preference = { ...@@ -216,6 +217,7 @@ admin.preference = {
"localeString": $("#localeString").val(), "localeString": $("#localeString").val(),
"timeZoneId": $("#timeZoneId").val(), "timeZoneId": $("#timeZoneId").val(),
"noticeBoard": $("#noticeBoard").val(), "noticeBoard": $("#noticeBoard").val(),
"footerContent": $("#footerContent").val(),
"htmlHead": $("#htmlHead").val(), "htmlHead": $("#htmlHead").val(),
"externalRelevantArticlesDisplayCount": $("#externalRelevantArticlesDisplayCount").val(), "externalRelevantArticlesDisplayCount": $("#externalRelevantArticlesDisplayCount").val(),
"relevantArticlesDisplayCount": $("#relevantArticlesDisplayCount").val(), "relevantArticlesDisplayCount": $("#relevantArticlesDisplayCount").val(),
......
<footer class="site-footer fn-clear"> <footer class="site-footer fn-clear">
<a href="${servePath}">${blogTitle}</a> <a href="${servePath}">${blogTitle}</a>
&copy; ${year} &copy; ${year}
${footerContent}
<span class="fn-right"> <span class="fn-right">
Powered by <a href="http://b3log.org" target="_blank">B3log 开源</a> • <a href="http://b3log.org/services/#solo" target="_blank">Solo</a> ${version}&nbsp;&nbsp; Powered by <a href="http://b3log.org" target="_blank">B3log 开源</a> • <a href="http://b3log.org/services/#solo" target="_blank">Solo</a> ${version}&nbsp;&nbsp;
Theme by <a rel="friend" href="http://vanessa.b3log.org" target="_blank">Vanessa</a>. Theme by <a rel="friend" href="http://vanessa.b3log.org" target="_blank">Vanessa</a>.
......
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