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.Template;
|
||||||
import freemarker.template.TemplateException;
|
import freemarker.template.TemplateException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
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 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 static String XML_MEDIA_TYPE = MediaType.APPLICATION_XML_VALUE + UTF_8_SUFFIX;
|
||||||
|
|
||||||
private final PostService postService;
|
private final PostService postService;
|
||||||
|
@ -206,6 +209,10 @@ public class ContentFeedController {
|
||||||
|
|
||||||
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
|
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
|
||||||
Page<PostDetailVO> posts = postService.convertToDetailVo(postPage);
|
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();
|
return posts.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,6 +229,10 @@ public class ContentFeedController {
|
||||||
|
|
||||||
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable);
|
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable);
|
||||||
Page<PostDetailVO> posts = postService.convertToDetailVo(postPage);
|
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();
|
return posts.getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,4 +64,4 @@ halo:
|
||||||
auth-enabled: true
|
auth-enabled: true
|
||||||
mode: development
|
mode: development
|
||||||
workDir: ${user.home}/halo-dev/
|
workDir: ${user.home}/halo-dev/
|
||||||
cache: level
|
cache: memory
|
|
@ -41,14 +41,12 @@
|
||||||
<name>${user.nickname!}</name>
|
<name>${user.nickname!}</name>
|
||||||
<uri>${blog_url!}</uri>
|
<uri>${blog_url!}</uri>
|
||||||
</author>
|
</author>
|
||||||
<content type="html" xml:base="${blog_url!}" xml:lang="en">
|
<content type="html">
|
||||||
<![CDATA[
|
<#if (options.rss_content_type!'full') == 'full'>
|
||||||
<#if (options.rss_content_type!'full') == 'full'>
|
<![CDATA[${post.formatContent!}]]>
|
||||||
${post.formatContent!}
|
<#else>
|
||||||
<#else>
|
<![CDATA[${post.summary!}]]>
|
||||||
${post.summary!}
|
</#if>
|
||||||
</#if>
|
|
||||||
]]>
|
|
||||||
</content>
|
</content>
|
||||||
</entry>
|
</entry>
|
||||||
</#list>
|
</#list>
|
||||||
|
|
|
@ -26,19 +26,15 @@
|
||||||
<#list posts as post>
|
<#list posts as post>
|
||||||
<item>
|
<item>
|
||||||
<title>
|
<title>
|
||||||
<![CDATA[
|
<![CDATA[${post.title!}]]>
|
||||||
${post.title!}
|
|
||||||
]]>
|
|
||||||
</title>
|
</title>
|
||||||
<link>${post.fullPath!}</link>
|
<link>${post.fullPath!}</link>
|
||||||
<description>
|
<description>
|
||||||
<![CDATA[
|
<#if (options.rss_content_type!'full') == 'full'>
|
||||||
<#if (options.rss_content_type!'full') == 'full'>
|
<![CDATA[${post.formatContent!}]]>
|
||||||
${post.formatContent!}
|
<#else>
|
||||||
<#else>
|
<![CDATA[${post.summary!}]]>
|
||||||
${post.summary!}
|
</#if>
|
||||||
</#if>
|
|
||||||
]]>
|
|
||||||
</description>
|
</description>
|
||||||
<pubDate>${post.createTime?iso_local}</pubDate>
|
<pubDate>${post.createTime?iso_local}</pubDate>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue