Commit 9909b1c1 authored by Liang Ding's avatar Liang Ding

Merge remote-tracking branch 'refs/remotes/origin/2.1.0-dev'

parents 8772454d aeb7d1cf
......@@ -27,7 +27,7 @@
Solo 沉淀至今的**每一个功能你应该都会用到**。我们不会将只有“20%”用户使用的功能添加进来,只有这样才能保持博客系统本该有的纯净,足够轻量才能带来简约的使用体验。
* Markdown / TinyMCE / KindEditor / Emoji
* Markdown / Emoji
* [聚合分类](https://github.com/b3log/solo/issues/12256) / 标签
* 自定义导航(页面、链接)
* 草稿夹
......@@ -111,8 +111,6 @@ Solo 的诞生离不开以下开源项目:
* [jQuery](https://github.com/jquery/jquery):使用最广泛的 JavaScript 工具库
* [CodeMirror](https://github.com/codemirror/CodeMirror):Markdown 编辑器内核
* [KindEditor](https://github.com/kindsoft/kindeditor):一个富文本编辑器
* [TinyMCE](https://github.com/tinymce/tinymce):又一个富文本编辑器
* [SyntaxHighlighter](https://github.com/syntaxhighlighter/syntaxhighlighter):一个代码高亮库
* [Highlight.js](https://github.com/isagalaev/highlight.js):又一个代码高亮库
* [emojify.js](https://github.com/Ranks/emojify.js):前端 Emoji 处理库
......
......@@ -48,7 +48,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading;
* Preference management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.2.11, Feb 18, 2017
* @version 1.3.2.12, May 2, 2017
* @since 0.4.0
*/
@Service
......@@ -57,7 +57,7 @@ public class PreferenceMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(PreferenceMgmtService.class.getName());
private static final Logger LOGGER = Logger.getLogger(PreferenceMgmtService.class);
/**
* Preference query service.
......@@ -79,7 +79,6 @@ public class PreferenceMgmtService {
/**
* Loads skins for the specified preference and initializes templates loading.
*
* <p>
* If the skins directory has been changed, persists the change into preference.
* </p>
......@@ -120,14 +119,13 @@ public class PreferenceMgmtService {
if (!skinDirNames.contains(currentSkinDirName)) {
LOGGER.log(Level.WARN, "Configred skin[dirName={0}] can not find, try to use " + "default skin[dirName="
+ Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME + "] instead.",
currentSkinDirName);
+ Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME + "] instead.", currentSkinDirName);
if (!skinDirNames.contains(Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME)) {
LOGGER.log(Level.ERROR, "Can not find skin[dirName=" + Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME + "]");
throw new IllegalStateException(
"Can not find default skin[dirName=" + Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME
+ "], please redeploy your Solo and make sure contains this default skin!");
+ "], please redeploy your Solo and make sure contains this default skin!");
}
preference.put(SKIN_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
......@@ -137,7 +135,6 @@ public class PreferenceMgmtService {
}
final String skinsString = skinArray.toString();
if (!skinsString.equals(preference.getString(SKINS))) {
LOGGER.debug("The skins directory has been changed, persists the change into preference");
preference.put(SKINS, skinsString);
......@@ -147,7 +144,6 @@ public class PreferenceMgmtService {
setDirectoryForTemplateLoading(preference.getString(SKIN_DIR_NAME));
final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
if ("zh_CN".equals(localeString)) {
TimeZones.setTimeZone("Asia/Shanghai");
}
......@@ -193,9 +189,7 @@ public class PreferenceMgmtService {
* @throws ServiceException service exception
*/
public void updatePreference(final JSONObject preference) throws ServiceException {
@SuppressWarnings("unchecked")
final Iterator<String> keys = preference.keys();
while (keys.hasNext()) {
final String key = keys.next();
......@@ -216,11 +210,9 @@ public class PreferenceMgmtService {
for (final String dirName : skinDirNames) {
final JSONObject skin = new JSONObject();
skinArray.put(skin);
final String name = Latkes.getSkinName(dirName);
skin.put(Skin.SKIN_NAME, name);
skin.put(Skin.SKIN_DIR_NAME, dirName);
}
......@@ -280,7 +272,9 @@ public class PreferenceMgmtService {
optionRepository.update(Option.ID_C_COMMENTABLE, commentableOpt);
final JSONObject editorTypeOpt = optionRepository.get(Option.ID_C_EDITOR_TYPE);
editorTypeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_EDITOR_TYPE));
// https://github.com/b3log/solo/issues/12285
// editorTypeOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_EDITOR_TYPE));
editorTypeOpt.put(Option.OPTION_VALUE, Option.DefaultPreference.DEFAULT_EDITOR_TYPE);
optionRepository.update(Option.ID_C_EDITOR_TYPE, editorTypeOpt);
final JSONObject enableArticleUpdateHintOpt = optionRepository.get(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT);
......
......@@ -51,7 +51,7 @@ import java.sql.Statement;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.2.0.11, Apr 10, 2017
* @version 1.2.0.12, May 2, 2017
* @since 1.2.0
*/
@Service
......@@ -61,51 +61,62 @@ public class UpgradeService {
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(UpgradeService.class);
/**
* Step for article updating.
*/
private static final int STEP = 50;
/**
* Mail Service.
*/
private static final MailService MAIL_SVC = MailServiceFactory.getMailService();
/**
* Old version.
*/
private static final String FROM_VER = "1.9.0";
/**
* New version.
*/
private static final String TO_VER = SoloServletListener.VERSION;
/**
* Whether the email has been sent.
*/
private static boolean sent = false;
/**
* Article repository.
*/
@Inject
private ArticleRepository articleRepository;
/**
* Comment repository.
*/
@Inject
private CommentRepository commentRepository;
/**
* User repository.
*/
@Inject
private UserRepository userRepository;
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/**
* Preference Query Service.
*/
@Inject
private PreferenceQueryService preferenceQueryService;
/**
* Language service.
*/
......@@ -137,7 +148,6 @@ public class UpgradeService {
if (!sent) {
notifyUserByEmail();
sent = true;
}
} catch (final Exception e) {
......@@ -158,7 +168,6 @@ public class UpgradeService {
LOGGER.log(Level.INFO, "Upgrading from version [{0}] to version [{1}]....", FROM_VER, TO_VER);
Transaction transaction = null;
try {
final Connection connection = Connections.getConnection();
final Statement statement = connection.createStatement();
......@@ -189,6 +198,11 @@ public class UpgradeService {
versionOpt.put(Option.OPTION_VALUE, TO_VER);
optionRepository.update(Option.ID_C_VERSION, versionOpt);
// https://github.com/b3log/solo/issues/12285
// final JSONObject editorTypeOpt = optionRepository.get(Option.ID_C_EDITOR_TYPE);
// editorTypeOpt.put(Option.OPTION_VALUE, Option.DefaultPreference.DEFAULT_EDITOR_TYPE);
// optionRepository.update(Option.ID_C_EDITOR_TYPE, editorTypeOpt);
transaction.commit();
LOGGER.log(Level.INFO, "Updated preference");
......@@ -218,11 +232,9 @@ public class UpgradeService {
for (int i = 0; i < users.length(); i++) {
final JSONObject user = users.getJSONObject(i);
final String email = user.optString(User.USER_EMAIL);
user.put(UserExt.USER_AVATAR, Thumbnails.getGravatarURL(email, "128"));
userRepository.update(user.optString(Keys.OBJECT_ID), user);
LOGGER.log(Level.INFO, "Updated user[email={0}]", email);
}
}
......@@ -236,14 +248,12 @@ public class UpgradeService {
LOGGER.log(Level.INFO, "Adds a property [articleEditorType] to each of articles");
final JSONArray articles = articleRepository.get(new Query()).getJSONArray(Keys.RESULTS);
if (articles.length() <= 0) {
LOGGER.log(Level.TRACE, "No articles");
return;
}
Transaction transaction = null;
try {
for (int i = 0; i < articles.length(); i++) {
if (0 == i % STEP || !transaction.isActive()) {
......@@ -251,9 +261,7 @@ public class UpgradeService {
}
final JSONObject article = articles.getJSONObject(i);
final String articleId = article.optString(Keys.OBJECT_ID);
LOGGER.log(Level.INFO, "Found an article[id={0}]", articleId);
article.put(Article.ARTICLE_EDITOR_TYPE, "tinyMCE");
......@@ -296,7 +304,6 @@ public class UpgradeService {
message.setHtmlBody(langPropsService.get("skipVersionMailBody"));
MAIL_SVC.send(message);
LOGGER.info("Send an email to the user who upgrades Solo with a discontinuous version.");
}
}
......@@ -161,6 +161,7 @@
</select>
</td>
</tr>
<#-- https://github.com/b3log/solo/issues/12285
<tr>
<th>
<label for="editorType">${editType1Label}</label>
......@@ -173,6 +174,7 @@
</select>
</td>
</tr>
-->
<tr>
<th>
<label for="articleListDisplay">${articleListDisplay1Label}</label>
......
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