Commit 816d5bb7 authored by Liang Ding's avatar Liang Ding

🎨 #12826

parent 3d0dcdbf
...@@ -29,7 +29,7 @@ import java.util.Set; ...@@ -29,7 +29,7 @@ import java.util.Set;
* Item. * Item.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.3.0, Jul 5, 2018 * @version 1.1.3.1, Jul 29, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Item { public final class Item {
...@@ -259,7 +259,7 @@ public final class Item { ...@@ -259,7 +259,7 @@ public final class Item {
stringBuilder.append(END_LINK_ELEMENT); stringBuilder.append(END_LINK_ELEMENT);
stringBuilder.append(START_DESCRIPTION_ELEMENT); stringBuilder.append(START_DESCRIPTION_ELEMENT);
stringBuilder.append(StringEscapeUtils.escapeXml(description)); stringBuilder.append("<![CDATA[" + description + "]]>");
stringBuilder.append(END_DESCRIPTION_ELEMENT); stringBuilder.append(END_DESCRIPTION_ELEMENT);
stringBuilder.append(START_AUTHOR_ELEMENT); stringBuilder.append(START_AUTHOR_ELEMENT);
......
...@@ -44,6 +44,7 @@ import org.b3log.solo.model.rss.Item; ...@@ -44,6 +44,7 @@ import org.b3log.solo.model.rss.Item;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.service.ArticleQueryService; import org.b3log.solo.service.ArticleQueryService;
import org.b3log.solo.service.OptionQueryService; import org.b3log.solo.service.OptionQueryService;
import org.b3log.solo.util.Markdowns;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -59,7 +60,7 @@ import java.util.List; ...@@ -59,7 +60,7 @@ import java.util.List;
* @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/feroozkhanchintu">feroozkhanchintu</a> * @author <a href="https://github.com/feroozkhanchintu">feroozkhanchintu</a>
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a> * @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
* @version 2.0.0.2, May 15, 2019 * @version 2.0.0.3, Jul 29, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -189,27 +190,22 @@ public class FeedProcessor { ...@@ -189,27 +190,22 @@ public class FeedProcessor {
channel.setLastBuildDate(new Date()); channel.setLastBuildDate(new Date());
channel.setLink(Latkes.getServePath()); channel.setLink(Latkes.getServePath());
channel.setAtomLink(Latkes.getServePath() + "/rss.xml"); channel.setAtomLink(Latkes.getServePath() + "/rss.xml");
channel.setGenerator("Solo, ver " + SoloServletListener.VERSION); channel.setGenerator("Solo, v" + SoloServletListener.VERSION + ", https://solo.b3log.org");
final String localeString = preference.getString(Option.ID_C_LOCALE_STRING); final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
final String country = Locales.getCountry(localeString).toLowerCase(); final String country = Locales.getCountry(localeString).toLowerCase();
final String language = Locales.getLanguage(localeString).toLowerCase(); final String language = Locales.getLanguage(localeString).toLowerCase();
channel.setLanguage(language + '-' + country); channel.setLanguage(language + '-' + country);
channel.setDescription(blogSubtitle); channel.setDescription(blogSubtitle);
final List<Filter> filters = new ArrayList<>(); final List<Filter> filters = new ArrayList<>();
filters.add(new PropertyFilter(Article.ARTICLE_STATUS, FilterOperator.EQUAL, Article.ARTICLE_STATUS_C_PUBLISHED)); filters.add(new PropertyFilter(Article.ARTICLE_STATUS, FilterOperator.EQUAL, Article.ARTICLE_STATUS_C_PUBLISHED));
filters.add(new PropertyFilter(Article.ARTICLE_VIEW_PWD, FilterOperator.EQUAL, "")); filters.add(new PropertyFilter(Article.ARTICLE_VIEW_PWD, FilterOperator.EQUAL, ""));
final Query query = new Query().setPageCount(1).setPage(1, outputCnt). final Query query = new Query().setPageCount(1).setPage(1, outputCnt).
setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)). setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING); addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING);
final JSONObject articleResult = articleRepository.get(query); final JSONObject articleResult = articleRepository.get(query);
final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS); final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS);
final boolean isFullContent = "fullContent".equals(preference.getString(Option.ID_C_FEED_OUTPUT_MODE)); final boolean isFullContent = "fullContent".equals(preference.getString(Option.ID_C_FEED_OUTPUT_MODE));
for (int i = 0; i < articles.length(); i++) { for (int i = 0; i < articles.length(); i++) {
final Item item = getItem(articles, isFullContent, i); final Item item = getItem(articles, isFullContent, i);
channel.addItem(item); channel.addItem(item);
...@@ -223,8 +219,7 @@ public class FeedProcessor { ...@@ -223,8 +219,7 @@ public class FeedProcessor {
} }
} }
private Item getItem(final JSONArray articles, final boolean isFullContent, int i) private Item getItem(final JSONArray articles, final boolean isFullContent, int i) throws JSONException, ServiceException {
throws JSONException, ServiceException {
final JSONObject article = articles.getJSONObject(i); final JSONObject article = articles.getJSONObject(i);
final Item ret = new Item(); final Item ret = new Item();
String title = article.getString(Article.ARTICLE_TITLE); String title = article.getString(Article.ARTICLE_TITLE);
...@@ -234,6 +229,7 @@ public class FeedProcessor { ...@@ -234,6 +229,7 @@ public class FeedProcessor {
? article.getString(Article.ARTICLE_CONTENT) ? article.getString(Article.ARTICLE_CONTENT)
: article.optString(Article.ARTICLE_ABSTRACT); : article.optString(Article.ARTICLE_ABSTRACT);
description = EmojiParser.parseToAliases(description); description = EmojiParser.parseToAliases(description);
description = Markdowns.toHTML(description);
ret.setDescription(description); ret.setDescription(description);
final long pubDate = article.getLong(Article.ARTICLE_UPDATED); final long pubDate = article.getLong(Article.ARTICLE_UPDATED);
ret.setPubDate(new Date(pubDate)); ret.setPubDate(new Date(pubDate));
......
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