Commit 833e48c8 authored by Liang Ding's avatar Liang Ding

🐛 Fix #12207

parent f0e02a93
......@@ -15,9 +15,6 @@
*/
package org.b3log.solo.api.symphony;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.b3log.latke.Keys;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
......@@ -42,11 +39,15 @@ import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Article receiver (from B3log Symphony).
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.2.7, Nov 8, 2016
* @version 1.0.3.7, Jan 15, 2017
* @since 0.5.5
*/
@RequestProcessor
......@@ -56,39 +57,33 @@ public class ArticleReceiver {
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(ArticleReceiver.class.getName());
/**
* Article abstract length.
*/
private static final int ARTICLE_ABSTRACT_LENGTH = 500;
/**
* Preference query service.
*/
@Inject
private PreferenceQueryService preferenceQueryService;
/**
* Article management service.
*/
@Inject
private ArticleMgmtService articleMgmtService;
/**
* Article query service.
*/
@Inject
private ArticleQueryService articleQueryService;
/**
* User query service.
*/
@Inject
private UserQueryService userQueryService;
/**
* Article abstract length.
*/
private static final int ARTICLE_ABSTRACT_LENGTH = 500;
/**
* Adds an article with the specified request.
*
* <p>
* Renders the response with a json object, for example,
* <pre>
......@@ -100,8 +95,7 @@ public class ArticleReceiver {
* </pre>
* </p>
*
* @param request the specified http servlet request, for example, <pre>
* {
* @param request the specified http servlet request, for example,
* "article": {
* "oId": "",
* "articleTitle": "",
......@@ -110,9 +104,6 @@ public class ArticleReceiver {
* "userB3Key": "",
* "articleEditorType": ""
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
......@@ -179,7 +170,6 @@ public class ArticleReceiver {
/**
* Updates an article with the specified request.
*
* <p>
* Renders the response with a json object, for example,
* <pre>
......@@ -190,8 +180,7 @@ public class ArticleReceiver {
* </pre>
* </p>
*
* @param request the specified http servlet request, for example, <pre>
* {
* @param request the specified http servlet request, for example,
* "article": {
* "oId": "", // Symphony Article#clientArticleId
* "articleTitle": "",
......@@ -200,9 +189,6 @@ public class ArticleReceiver {
* "userB3Key": "",
* "articleEditorType": ""
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
......@@ -240,8 +226,8 @@ public class ArticleReceiver {
return;
}
final String plainTextContent = Jsoup.parse(article.optString(Article.ARTICLE_CONTENT)).text();
final String articleContent = article.optString(Article.ARTICLE_CONTENT);
final String plainTextContent = Jsoup.clean(Markdowns.toHTML(articleContent), Whitelist.none());
if (plainTextContent.length() > ARTICLE_ABSTRACT_LENGTH) {
article.put(Article.ARTICLE_ABSTRACT, plainTextContent.substring(0, ARTICLE_ABSTRACT_LENGTH) + "....");
} else {
......
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