Commit b1b78109 authored by Liang Ding's avatar Liang Ding

🔥 #12637

parent 70e83321
...@@ -25,7 +25,7 @@ import org.jsoup.safety.Whitelist; ...@@ -25,7 +25,7 @@ import org.jsoup.safety.Whitelist;
* This class defines all article model relevant keys. * This class defines all article 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.2.0.0, Sep 16, 2018 * @version 1.2.0.1, Feb 6, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Article { public final class Article {
...@@ -155,11 +155,6 @@ public final class Article { ...@@ -155,11 +155,6 @@ public final class Article {
*/ */
public static final String ARTICLE_VIEW_PWD = "articleViewPwd"; public static final String ARTICLE_VIEW_PWD = "articleViewPwd";
/**
* Key of article editor type.
*/
public static final String ARTICLE_EDITOR_TYPE = "articleEditorType";
//// constants //// constants
/** /**
......
...@@ -30,7 +30,7 @@ import java.util.Set; ...@@ -30,7 +30,7 @@ import java.util.Set;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a> * @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.5.0.1, Jan 28, 2019 * @version 1.5.0.2, Feb 6, 2019
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -266,19 +266,6 @@ public final class Option { ...@@ -266,19 +266,6 @@ public final class Option {
*/ */
public static final String ID_C_FEED_OUTPUT_CNT = "feedOutputCnt"; public static final String ID_C_FEED_OUTPUT_CNT = "feedOutputCnt";
/**
* Key of editor type.
* <p>
* Optional values:
* <ul>
* <li>"tinyMCE"</li>
* <li>"CodeMirror-Markdown"</li>
* <li>"KindEditor"</li>
* </ul>
* </p>
*/
public static final String ID_C_EDITOR_TYPE = "editorType";
/** /**
* Key of skins. * Key of skins.
*/ */
...@@ -555,16 +542,6 @@ public final class Option { ...@@ -555,16 +542,6 @@ public final class Option {
*/ */
public static final int DEFAULT_FEED_OUTPUT_CNT = 10; public static final int DEFAULT_FEED_OUTPUT_CNT = 10;
/**
* Default editor type.
*/
public static final String DEFAULT_EDITOR_TYPE = "CodeMirror-Markdown";
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(DefaultPreference.class);
static { static {
final JSONArray signs = new JSONArray(); final JSONArray signs = new JSONArray();
final int signLength = 4; final int signLength = 4;
......
...@@ -21,7 +21,7 @@ package org.b3log.solo.model; ...@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all page model relevant keys. * This class defines all page 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 21, 2017 * @version 1.1.0.1, Feb 6, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Page { public final class Page {
...@@ -106,11 +106,6 @@ public final class Page { ...@@ -106,11 +106,6 @@ public final class Page {
*/ */
public static final String PAGE_OPEN_TARGET = "pageOpenTarget"; public static final String PAGE_OPEN_TARGET = "pageOpenTarget";
/**
* Key of page editor type.
*/
public static final String PAGE_EDITOR_TYPE = "pageEditorType";
/** /**
* Key of icon URL. * Key of icon URL.
*/ */
......
...@@ -48,7 +48,7 @@ import java.util.Map; ...@@ -48,7 +48,7 @@ import java.util.Map;
* Page processor. * Page processor.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.9, Jan 5, 2019 * @version 1.1.0.10, Feb 6, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -128,16 +128,12 @@ public class PageProcessor { ...@@ -128,16 +128,12 @@ public class PageProcessor {
dataModel.put(Page.PAGE_COMMENTS_REF, comments); dataModel.put(Page.PAGE_COMMENTS_REF, comments);
// Markdown // Markdown
if ("CodeMirror-Markdown".equals(page.optString(Page.PAGE_EDITOR_TYPE))) { Stopwatchs.start("Markdown Page [id=" + page.optString(Keys.OBJECT_ID) + "]");
Stopwatchs.start("Markdown Page[id=" + page.optString(Keys.OBJECT_ID) + "]"); String content = page.optString(Page.PAGE_CONTENT);
content = Emotions.convert(content);
String content = page.optString(Page.PAGE_CONTENT); content = Markdowns.toHTML(content);
content = Emotions.convert(content); page.put(Page.PAGE_CONTENT, content);
content = Markdowns.toHTML(content); Stopwatchs.end();
page.put(Page.PAGE_CONTENT, content);
Stopwatchs.end();
}
dataModelService.fillCommon(context, dataModel, preference); dataModelService.fillCommon(context, dataModel, preference);
statisticMgmtService.incBlogViewCount(context, response); statisticMgmtService.incBlogViewCount(context, response);
......
...@@ -41,7 +41,7 @@ import org.json.JSONObject; ...@@ -41,7 +41,7 @@ import org.json.JSONObject;
* Receiving articles from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details. * Receiving articles from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.4.3, Sep 25, 2018 * @version 1.0.4.4, Feb 6, 2019
* @since 0.5.5 * @since 0.5.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -87,8 +87,7 @@ public class B3ArticleReceiver { ...@@ -87,8 +87,7 @@ public class B3ArticleReceiver {
* "articleTitle": "", * "articleTitle": "",
* "articleContent": "", * "articleContent": "",
* "articleTags": "tag1,tag2,tag3", * "articleTags": "tag1,tag2,tag3",
* "userB3Key": "", * "userB3Key": ""
* "articleEditorType": ""
* } * }
* } * }
* </pre> * </pre>
...@@ -165,8 +164,7 @@ public class B3ArticleReceiver { ...@@ -165,8 +164,7 @@ public class B3ArticleReceiver {
* "articleTitle": "", * "articleTitle": "",
* "articleContent": "", * "articleContent": "",
* "articleTags": "tag1,tag2,tag3", * "articleTags": "tag1,tag2,tag3",
* "userB3Key": "", * "userB3Key": ""
* "articleEditorType": ""
* } * }
* } * }
* </pre> * </pre>
......
...@@ -317,11 +317,6 @@ public class ArticleMgmtService { ...@@ -317,11 +317,6 @@ public class ArticleMgmtService {
} }
} }
// Set editor type
if (!article.has(Article.ARTICLE_EDITOR_TYPE)) {
article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Option.ID_C_EDITOR_TYPE));
}
final boolean publishNewArticle = !oldArticle.getBoolean(ARTICLE_IS_PUBLISHED) && article.getBoolean(ARTICLE_IS_PUBLISHED); final boolean publishNewArticle = !oldArticle.getBoolean(ARTICLE_IS_PUBLISHED) && article.getBoolean(ARTICLE_IS_PUBLISHED);
// Update // Update
...@@ -381,7 +376,7 @@ public class ArticleMgmtService { ...@@ -381,7 +376,7 @@ public class ArticleMgmtService {
* "articleSignId": "" // optional, default is "0", * "articleSignId": "" // optional, default is "0",
* "articleCommentable": boolean, * "articleCommentable": boolean,
* "articleViewPwd": "", * "articleViewPwd": "",
* "articleEditorType": "", // optional, preference specified if not exists this key * "articleEditorType": "", // optional
* "oId": "" // optional, generate it if not exists this key * "oId": "" // optional, generate it if not exists this key
* } * }
* } * }
...@@ -460,10 +455,6 @@ public class ArticleMgmtService { ...@@ -460,10 +455,6 @@ public class ArticleMgmtService {
final boolean postToCommunity = article.optBoolean(Common.POST_TO_COMMUNITY, true); final boolean postToCommunity = article.optBoolean(Common.POST_TO_COMMUNITY, true);
article.remove(Common.POST_TO_COMMUNITY); // Do not persist this property article.remove(Common.POST_TO_COMMUNITY); // Do not persist this property
if (!article.has(Article.ARTICLE_EDITOR_TYPE)) {
article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Option.ID_C_EDITOR_TYPE));
}
articleRepository.add(article); articleRepository.add(article);
article.put(Common.POST_TO_COMMUNITY, postToCommunity); // Restores the property article.put(Common.POST_TO_COMMUNITY, postToCommunity); // Restores the property
......
...@@ -53,7 +53,7 @@ import static org.b3log.solo.model.Article.*; ...@@ -53,7 +53,7 @@ import static org.b3log.solo.model.Article.*;
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a> * @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @author <a href="http://zephyr.b3log.org">Zephyr</a> * @author <a href="http://zephyr.b3log.org">Zephyr</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.3.2.8, Jan 15, 2019 * @version 1.3.2.9, Feb 6, 2019
* @since 0.3.5 * @since 0.3.5
*/ */
@Service @Service
...@@ -976,9 +976,8 @@ public class ArticleQueryService { ...@@ -976,9 +976,8 @@ public class ArticleQueryService {
if (null != context && Solos.needViewPwd(context.getRequest(), context.getResponse(), article)) { if (null != context && Solos.needViewPwd(context.getRequest(), context.getResponse(), article)) {
final String content = langPropsService.get("articleContentPwd"); final String content = langPropsService.get("articleContentPwd");
article.put(ARTICLE_CONTENT, content); article.put(ARTICLE_CONTENT, content);
} else if ("CodeMirror-Markdown".equals(article.optString(ARTICLE_EDITOR_TYPE))) { } else {
// Markdown to HTML for content and abstract // Markdown to HTML for content and abstract
Stopwatchs.start("Get Article Content [Markdown]"); Stopwatchs.start("Get Article Content [Markdown]");
String content = article.optString(ARTICLE_CONTENT); String content = article.optString(ARTICLE_CONTENT);
...@@ -1000,9 +999,8 @@ public class ArticleQueryService { ...@@ -1000,9 +999,8 @@ public class ArticleQueryService {
* Converts the content and abstract for each of the specified articles to HTML if that is saved by Markdown editor. * Converts the content and abstract for each of the specified articles to HTML if that is saved by Markdown editor.
* *
* @param articles the specified articles * @param articles the specified articles
* @throws Exception exception
*/ */
public void markdowns(final List<JSONObject> articles) throws Exception { public void markdowns(final List<JSONObject> articles) {
for (final JSONObject article : articles) { for (final JSONObject article : articles) {
markdown(article); markdown(article);
} }
...@@ -1012,31 +1010,25 @@ public class ArticleQueryService { ...@@ -1012,31 +1010,25 @@ public class ArticleQueryService {
* Converts the content and abstract for the specified article to HTML if it is saved by Markdown editor. * Converts the content and abstract for the specified article to HTML if it is saved by Markdown editor.
* *
* @param article the specified article * @param article the specified article
* @throws Exception exception
*/ */
public void markdown(final JSONObject article) throws Exception { public void markdown(final JSONObject article) {
if ("CodeMirror-Markdown".equals(article.optString(ARTICLE_EDITOR_TYPE))) { Stopwatchs.start("Markdown Article [id=" + article.optString(Keys.OBJECT_ID) + "]");
Stopwatchs.start("Markdown Article[id=" + article.optString(Keys.OBJECT_ID) + "]");
String content = article.optString(ARTICLE_CONTENT);
Stopwatchs.start("Content"); content = Emotions.convert(content);
String content = article.optString(ARTICLE_CONTENT); content = Markdowns.toHTML(content);
content = Emotions.convert(content); article.put(ARTICLE_CONTENT, content);
content = Markdowns.toHTML(content);
article.put(ARTICLE_CONTENT, content); String abstractContent = article.optString(ARTICLE_ABSTRACT);
Stopwatchs.end(); if (StringUtils.isNotBlank(abstractContent)) {
Stopwatchs.start("Abstract");
String abstractContent = article.optString(ARTICLE_ABSTRACT); abstractContent = Emotions.convert(abstractContent);
abstractContent = Markdowns.toHTML(abstractContent);
if (StringUtils.isNotBlank(abstractContent)) { article.put(ARTICLE_ABSTRACT, abstractContent);
Stopwatchs.start("Abstract");
abstractContent = Emotions.convert(abstractContent);
abstractContent = Markdowns.toHTML(abstractContent);
article.put(ARTICLE_ABSTRACT, abstractContent);
Stopwatchs.end();
}
Stopwatchs.end(); Stopwatchs.end();
} }
Stopwatchs.end();
} }
/** /**
......
{ {
"description": "Description of repository structures, for generation of the relational database table and persistence validation.", "description": "Description of repository structures, for generation of the relational database table and persistence validation.",
"version": "3.2.1.2, Jan 28, 2019", "version": "3.2.1.3, Feb 6, 2019",
"authors": [ "authors": [
"Liang Ding" "Liang Ding"
], ],
...@@ -280,13 +280,6 @@ ...@@ -280,13 +280,6 @@
"type": "String", "type": "String",
"length": 255 "length": 255
}, },
{
"name": "pageEditorType",
"description": "页面编辑器类型,目前仅支持 CodeMirror-Markdown",
"type": "String",
"length": 20,
"nullable": true
},
{ {
"name": "pageIcon", "name": "pageIcon",
"description": "页面展示用小图标", "description": "页面展示用小图标",
...@@ -530,13 +523,6 @@ ...@@ -530,13 +523,6 @@
"description": "文章浏览密码,留空为不设置访问密码", "description": "文章浏览密码,留空为不设置访问密码",
"type": "String", "type": "String",
"legnth": 255 "legnth": 255
},
{
"name": "articleEditorType",
"description": "文章编辑器类型,目前仅支持 CodeMirror-Markdown",
"type": "String",
"length": 20,
"nullable": true
} }
] ]
}, },
......
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