Commit b1b78109 authored by Liang Ding's avatar Liang Ding

🔥 #12637

parent 70e83321
......@@ -25,7 +25,7 @@ import org.jsoup.safety.Whitelist;
* This class defines all article model relevant keys.
*
* @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
*/
public final class Article {
......@@ -155,11 +155,6 @@ public final class Article {
*/
public static final String ARTICLE_VIEW_PWD = "articleViewPwd";
/**
* Key of article editor type.
*/
public static final String ARTICLE_EDITOR_TYPE = "articleEditorType";
//// constants
/**
......
......@@ -30,7 +30,7 @@ import java.util.Set;
*
* @author <a href="http://88250.b3log.org">Liang Ding</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
*/
public final class Option {
......@@ -266,19 +266,6 @@ public final class Option {
*/
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.
*/
......@@ -555,16 +542,6 @@ public final class Option {
*/
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 {
final JSONArray signs = new JSONArray();
final int signLength = 4;
......
......@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all page model relevant keys.
*
* @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
*/
public final class Page {
......@@ -106,11 +106,6 @@ public final class Page {
*/
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.
*/
......
......@@ -48,7 +48,7 @@ import java.util.Map;
* Page processor.
*
* @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
*/
@RequestProcessor
......@@ -128,16 +128,12 @@ public class PageProcessor {
dataModel.put(Page.PAGE_COMMENTS_REF, comments);
// 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);
content = Markdowns.toHTML(content);
page.put(Page.PAGE_CONTENT, content);
Stopwatchs.end();
}
dataModelService.fillCommon(context, dataModel, preference);
statisticMgmtService.incBlogViewCount(context, response);
......
......@@ -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.
*
* @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
*/
@RequestProcessor
......@@ -87,8 +87,7 @@ public class B3ArticleReceiver {
* "articleTitle": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "articleEditorType": ""
* "userB3Key": ""
* }
* }
* </pre>
......@@ -165,8 +164,7 @@ public class B3ArticleReceiver {
* "articleTitle": "",
* "articleContent": "",
* "articleTags": "tag1,tag2,tag3",
* "userB3Key": "",
* "articleEditorType": ""
* "userB3Key": ""
* }
* }
* </pre>
......
......@@ -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);
// Update
......@@ -381,7 +376,7 @@ public class ArticleMgmtService {
* "articleSignId": "" // optional, default is "0",
* "articleCommentable": boolean,
* "articleViewPwd": "",
* "articleEditorType": "", // optional, preference specified if not exists this key
* "articleEditorType": "", // optional
* "oId": "" // optional, generate it if not exists this key
* }
* }
......@@ -460,10 +455,6 @@ public class ArticleMgmtService {
final boolean postToCommunity = article.optBoolean(Common.POST_TO_COMMUNITY, true);
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);
article.put(Common.POST_TO_COMMUNITY, postToCommunity); // Restores the property
......
......@@ -53,7 +53,7 @@ import static org.b3log.solo.model.Article.*;
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @author <a href="http://zephyr.b3log.org">Zephyr</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
*/
@Service
......@@ -976,9 +976,8 @@ public class ArticleQueryService {
if (null != context && Solos.needViewPwd(context.getRequest(), context.getResponse(), article)) {
final String content = langPropsService.get("articleContentPwd");
article.put(ARTICLE_CONTENT, content);
} else if ("CodeMirror-Markdown".equals(article.optString(ARTICLE_EDITOR_TYPE))) {
} else {
// Markdown to HTML for content and abstract
Stopwatchs.start("Get Article Content [Markdown]");
String content = article.optString(ARTICLE_CONTENT);
......@@ -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.
*
* @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) {
markdown(article);
}
......@@ -1012,21 +1010,16 @@ public class ArticleQueryService {
* Converts the content and abstract for the specified article to HTML if it is saved by Markdown editor.
*
* @param article the specified article
* @throws Exception exception
*/
public void markdown(final JSONObject article) throws Exception {
if ("CodeMirror-Markdown".equals(article.optString(ARTICLE_EDITOR_TYPE))) {
Stopwatchs.start("Markdown Article[id=" + article.optString(Keys.OBJECT_ID) + "]");
public void markdown(final JSONObject article) {
Stopwatchs.start("Markdown Article [id=" + article.optString(Keys.OBJECT_ID) + "]");
Stopwatchs.start("Content");
String content = article.optString(ARTICLE_CONTENT);
content = Emotions.convert(content);
content = Markdowns.toHTML(content);
article.put(ARTICLE_CONTENT, content);
Stopwatchs.end();
String abstractContent = article.optString(ARTICLE_ABSTRACT);
if (StringUtils.isNotBlank(abstractContent)) {
Stopwatchs.start("Abstract");
abstractContent = Emotions.convert(abstractContent);
......@@ -1037,7 +1030,6 @@ public class ArticleQueryService {
Stopwatchs.end();
}
}
/**
* Removes unused properties of each article in the specified articles.
......
{
"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": [
"Liang Ding"
],
......@@ -280,13 +280,6 @@
"type": "String",
"length": 255
},
{
"name": "pageEditorType",
"description": "页面编辑器类型,目前仅支持 CodeMirror-Markdown",
"type": "String",
"length": 20,
"nullable": true
},
{
"name": "pageIcon",
"description": "页面展示用小图标",
......@@ -530,13 +523,6 @@
"description": "文章浏览密码,留空为不设置访问密码",
"type": "String",
"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