提交 2929d08b 编写于 作者: RYAN0UP's avatar RYAN0UP

Fixed render atom.xml error.

上级 1c3a40cb
......@@ -2,6 +2,7 @@ package run.halo.app.controller.content;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
......@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import run.halo.app.model.entity.Post;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.service.OptionService;
import run.halo.app.service.PostService;
......@@ -140,11 +142,14 @@ public class ContentFeedController {
* @param pageable pageable
* @return List<Post>
*/
private List<Post> buildPosts(Pageable pageable) {
private List<PostListVO> buildPosts(Pageable pageable) {
if (pageable == null) {
return postService.listAllBy(PostStatus.PUBLISHED);
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, null);
return postService.convertToListVo(postPage).getContent();
}
return postService.pageBy(PostStatus.PUBLISHED, pageable).map(postService::filterIfEncrypt).getContent();
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
Page<PostListVO> posts = postService.convertToListVo(postPage);
return posts.getContent();
}
}
......@@ -13,10 +13,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.Tag;
import run.halo.app.service.OptionService;
import run.halo.app.service.PostTagService;
import run.halo.app.service.TagService;
import run.halo.app.service.ThemeService;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.service.*;
import static org.springframework.data.domain.Sort.Direction.DESC;
......@@ -32,14 +30,21 @@ public class ContentTagController {
private final TagService tagService;
private final PostService postService;
private final PostTagService postTagService;
private final OptionService optionService;
private final ThemeService themeService;
public ContentTagController(TagService tagService, PostTagService postTagService, OptionService optionService, ThemeService themeService) {
public ContentTagController(TagService tagService,
PostService postService,
PostTagService postTagService,
OptionService optionService,
ThemeService themeService) {
this.tagService = tagService;
this.postService = postService;
this.postTagService = postTagService;
this.optionService = optionService;
this.themeService = themeService;
......@@ -84,7 +89,8 @@ public class ContentTagController {
Tag tag = tagService.getBySlugNameOfNonNull(slugName);
final Pageable pageable = PageRequest.of(page - 1, optionService.getPostPageSize(), sort);
Page<Post> posts = postTagService.pagePostsBy(tag.getId(), pageable);
Page<Post> postPage = postTagService.pagePostsBy(tag.getId(), pageable);
Page<PostListVO> posts = postService.convertToListVo(postPage);
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
model.addAttribute("is_tags", true);
......
......@@ -22,7 +22,7 @@
<title>${post.title!}</title>
<link>${options.blog_url!}/archives/${post.url!}</link>
<comments>${options.blog_url!}/archives/${post.url!}#comments</comments>
<pubDate>${post.createTime}</pubDate>
<pubDate>${post.createTime!}</pubDate>
<dc:creator><![CDATA[${user.nickName!}]]></dc:creator>
<#if post.categories?? && post.categories?size gt 0>
......@@ -40,7 +40,7 @@
${post.formatContent!}
]]>
</content:encoded>
<slash:comments>${post.comments?size}</slash:comments>
<slash:comments>${post.commentCount!0}</slash:comments>
</item>
</#list>
</#if>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册