Commit 315df631 authored by Liang Ding's avatar Liang Ding

#12159

parent 8cc8dd46
......@@ -15,7 +15,6 @@
*/
package org.b3log.solo.processor;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -41,16 +40,16 @@ import org.b3log.solo.processor.util.Filler;
import org.b3log.solo.service.CommentQueryService;
import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.service.StatisticMgmtService;
import org.b3log.solo.util.Emotions;
import org.b3log.solo.util.Markdowns;
import org.b3log.solo.util.Skins;
import org.json.JSONObject;
/**
* Page processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.5, Nov 20, 2015
* @version 1.1.0.6, Nov 8, 2016
* @since 0.3.1
*/
@RequestProcessor
......@@ -139,9 +138,10 @@ public class PageProcessor {
if ("CodeMirror-Markdown".equals(page.optString(Page.PAGE_EDITOR_TYPE))) {
Stopwatchs.start("Markdown Page[id=" + page.optString(Keys.OBJECT_ID) + "]");
final String content = page.optString(Page.PAGE_CONTENT);
page.put(Page.PAGE_CONTENT, Markdowns.toHTML(content));
String content = page.optString(Page.PAGE_CONTENT);
content = Emotions.convert(content);
content = Markdowns.toHTML(content);
page.put(Page.PAGE_CONTENT, content);
Stopwatchs.end();
}
......
......@@ -15,7 +15,6 @@
*/
package org.b3log.solo.processor.console;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -38,12 +37,12 @@ import org.b3log.solo.model.Article;
import org.b3log.solo.service.ArticleMgmtService;
import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.UserQueryService;
import org.b3log.solo.util.Emotions;
import org.b3log.solo.util.Markdowns;
import org.b3log.solo.util.QueryResults;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* Article console request processing.
*
......@@ -95,19 +94,19 @@ public class ArticleConsole {
* </pre>
* </p>
*
* @param request the specified http servlet request, for example,
* <pre>
* @param request the specified http servlet request, for example, <pre>
* {
* "markdownText": ""
* }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing(value = "/console/markdown/2html", method = HTTPRequestMethod.POST)
public void markdown2HTML(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception {
throws Exception {
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
......@@ -132,7 +131,8 @@ public class ArticleConsole {
}
try {
final String html = Markdowns.toHTML(markdownText);
String html = Emotions.convert(markdownText);
html = Markdowns.toHTML(html);
result.put("html", html);
} catch (final Exception e) {
......@@ -179,7 +179,7 @@ public class ArticleConsole {
*/
@RequestProcessing(value = "/console/article/*", method = HTTPRequestMethod.GET)
public void getArticle(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -207,13 +207,12 @@ public class ArticleConsole {
}
/**
* Gets articles(by crate date descending) by the specified request json
* object.
* Gets articles(by crate date descending) by the specified request json object.
*
* <p>
* The request URI contains the pagination arguments. For example, the
* request URI is /console/articles/status/published/1/10/20, means the
* current page is 1, the page size is 10, and the window size is 20.
* The request URI contains the pagination arguments. For example, the request URI is
* /console/articles/status/published/1/10/20, means the current page is 1, the page size is 10, and the window size
* is 20.
* </p>
*
* <p>
......@@ -245,9 +244,9 @@ public class ArticleConsole {
* @throws Exception exception
*/
@RequestProcessing(value = "/console/articles/status/*/*/*/*"/* Requests.PAGINATION_PATH_PATTERN */,
method = HTTPRequestMethod.GET)
method = HTTPRequestMethod.GET)
public void getArticles(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -315,7 +314,7 @@ public class ArticleConsole {
*/
@RequestProcessing(value = "/console/article/{articleId}", method = HTTPRequestMethod.DELETE)
public void removeArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response,
final String articleId) throws Exception {
final String articleId) throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -372,7 +371,7 @@ public class ArticleConsole {
*/
@RequestProcessing(value = "/console/article/unpublish/*", method = HTTPRequestMethod.PUT)
public void cancelPublishArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -431,7 +430,7 @@ public class ArticleConsole {
*/
@RequestProcessing(value = "/console/article/canceltop/*", method = HTTPRequestMethod.PUT)
public void cancelTopArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -490,7 +489,7 @@ public class ArticleConsole {
*/
@RequestProcessing(value = "/console/article/puttop/*", method = HTTPRequestMethod.PUT)
public void putTopArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -543,8 +542,7 @@ public class ArticleConsole {
* </p>
*
* @param context the specified http request context
* @param request the specified http servlet request, for example,
* <pre>
* @param request the specified http servlet request, for example, <pre>
* {
* "article": {
* "oId": "",
......@@ -561,12 +559,13 @@ public class ArticleConsole {
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @throws Exception exception
*/
@RequestProcessing(value = "/console/article/", method = HTTPRequestMethod.PUT)
public void updateArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......@@ -621,8 +620,7 @@ public class ArticleConsole {
* </pre>
* </p>
*
* @param request the specified http servlet request, for example,
* <pre>
* @param request the specified http servlet request, for example, <pre>
* {
* "article": {
* "articleTitle": "",
......@@ -638,13 +636,14 @@ public class ArticleConsole {
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing(value = "/console/article/", method = HTTPRequestMethod.POST)
public void addArticle(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
......
......@@ -51,6 +51,7 @@ import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.TagArticleRepository;
import org.b3log.solo.repository.TagRepository;
import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.util.Emotions;
import org.b3log.solo.util.Markdowns;
import org.b3log.solo.util.comparator.Comparators;
import org.json.JSONArray;
......@@ -964,9 +965,10 @@ public class ArticleQueryService {
} else if ("CodeMirror-Markdown".equals(article.optString(ARTICLE_EDITOR_TYPE))) {
// Markdown to HTML for content and abstract
Stopwatchs.start("Get Article Content [Markdown]");
final String content = article.optString(ARTICLE_CONTENT);
article.put(ARTICLE_CONTENT, Markdowns.toHTML(content));
String content = article.optString(ARTICLE_CONTENT);
content = Emotions.convert(content);
content = Markdowns.toHTML(content);
article.put(ARTICLE_CONTENT, content);
Stopwatchs.end();
}
......@@ -1001,16 +1003,19 @@ public class ArticleQueryService {
Stopwatchs.start("Markdown Article[id=" + article.optString(Keys.OBJECT_ID) + "]");
Stopwatchs.start("Content");
final String content = article.optString(ARTICLE_CONTENT);
article.put(ARTICLE_CONTENT, Markdowns.toHTML(content));
String content = article.optString(ARTICLE_CONTENT);
content = Emotions.convert(content);
content = Markdowns.toHTML(content);
article.put(ARTICLE_CONTENT, content);
Stopwatchs.end();
final String abstractContent = article.optString(ARTICLE_ABSTRACT);
String abstractContent = article.optString(ARTICLE_ABSTRACT);
if (!Strings.isEmptyOrNull(abstractContent)) {
Stopwatchs.start("Abstract");
article.put(ARTICLE_ABSTRACT, Markdowns.toHTML(abstractContent));
abstractContent = Emotions.convert(abstractContent);
abstractContent = Markdowns.toHTML(abstractContent);
article.put(ARTICLE_ABSTRACT, abstractContent);
Stopwatchs.end();
}
......
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