mirror of https://github.com/halo-dev/halo
parent
1d020ff550
commit
7ae722e6fd
|
@ -3,6 +3,7 @@ package run.halo.app.controller.content;
|
|||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -43,6 +44,8 @@ public class ContentFeedController {
|
|||
|
||||
private final static String UTF_8_SUFFIX = ";charset=UTF-8";
|
||||
|
||||
private final static String XML_INVAID_CHAR = "[\\x00-\\x1F\\x7F]";
|
||||
|
||||
private final static String XML_MEDIA_TYPE = MediaType.APPLICATION_XML_VALUE + UTF_8_SUFFIX;
|
||||
|
||||
private final PostService postService;
|
||||
|
@ -206,6 +209,10 @@ public class ContentFeedController {
|
|||
|
||||
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
|
||||
Page<PostDetailVO> posts = postService.convertToDetailVo(postPage);
|
||||
posts.getContent().forEach(postDetailVO -> {
|
||||
postDetailVO.setFormatContent(RegExUtils.replaceAll(postDetailVO.getFormatContent(), XML_INVAID_CHAR, ""));
|
||||
postDetailVO.setSummary(RegExUtils.replaceAll(postDetailVO.getSummary(), XML_INVAID_CHAR, ""));
|
||||
});
|
||||
return posts.getContent();
|
||||
}
|
||||
|
||||
|
@ -222,6 +229,10 @@ public class ContentFeedController {
|
|||
|
||||
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable);
|
||||
Page<PostDetailVO> posts = postService.convertToDetailVo(postPage);
|
||||
posts.getContent().forEach(postDetailVO -> {
|
||||
postDetailVO.setFormatContent(RegExUtils.replaceAll(postDetailVO.getFormatContent(), XML_INVAID_CHAR, ""));
|
||||
postDetailVO.setSummary(RegExUtils.replaceAll(postDetailVO.getSummary(), XML_INVAID_CHAR, ""));
|
||||
});
|
||||
return posts.getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,4 +64,4 @@ halo:
|
|||
auth-enabled: true
|
||||
mode: development
|
||||
workDir: ${user.home}/halo-dev/
|
||||
cache: level
|
||||
cache: memory
|
|
@ -41,14 +41,12 @@
|
|||
<name>${user.nickname!}</name>
|
||||
<uri>${blog_url!}</uri>
|
||||
</author>
|
||||
<content type="html" xml:base="${blog_url!}" xml:lang="en">
|
||||
<![CDATA[
|
||||
<#if (options.rss_content_type!'full') == 'full'>
|
||||
${post.formatContent!}
|
||||
<#else>
|
||||
${post.summary!}
|
||||
</#if>
|
||||
]]>
|
||||
<content type="html">
|
||||
<#if (options.rss_content_type!'full') == 'full'>
|
||||
<![CDATA[${post.formatContent!}]]>
|
||||
<#else>
|
||||
<![CDATA[${post.summary!}]]>
|
||||
</#if>
|
||||
</content>
|
||||
</entry>
|
||||
</#list>
|
||||
|
|
|
@ -26,19 +26,15 @@
|
|||
<#list posts as post>
|
||||
<item>
|
||||
<title>
|
||||
<![CDATA[
|
||||
${post.title!}
|
||||
]]>
|
||||
<![CDATA[${post.title!}]]>
|
||||
</title>
|
||||
<link>${post.fullPath!}</link>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<#if (options.rss_content_type!'full') == 'full'>
|
||||
${post.formatContent!}
|
||||
<#else>
|
||||
${post.summary!}
|
||||
</#if>
|
||||
]]>
|
||||
<#if (options.rss_content_type!'full') == 'full'>
|
||||
<![CDATA[${post.formatContent!}]]>
|
||||
<#else>
|
||||
<![CDATA[${post.summary!}]]>
|
||||
</#if>
|
||||
</description>
|
||||
<pubDate>${post.createTime?iso_local}</pubDate>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue