Skip to content

Commit

Permalink
🐛 暂时下线自动保存文章功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Aug 31, 2018
1 parent c5af7bf commit e6fa100
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cc.ryanc.halo.utils.CommentUtil;
import cc.ryanc.halo.web.controller.core.BaseController;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.PageUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -153,10 +154,12 @@ public String getPost(@PathVariable String postUrl,
}
//评论分页
ListPage<Comment> commentsPage = new ListPage<Comment>(CommentUtil.getComments(comments),cp, size);
int[] rainbow = PageUtil.rainbow(cp, commentsPage.getTotalPage(), 3);
model.addAttribute("is_post",true);
model.addAttribute("post", post);
model.addAttribute("comments", commentsPage);
model.addAttribute("commentsCount", comments.size());
model.addAttribute("rainbow", rainbow);
model.addAttribute("tagWords", CollUtil.join(tagWords, ","));
postService.updatePostView(post);
return this.render("post");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cc.ryanc.halo.service.CategoryService;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.web.controller.core.BaseController;
import cn.hutool.core.util.PageUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -88,8 +89,10 @@ public String categories(Model model,
}
Pageable pageable = PageRequest.of(page - 1, size, sort);
Page<Post> posts = postService.findPostByCategories(category, pageable);
int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
model.addAttribute("is_categories",true);
model.addAttribute("posts", posts);
model.addAttribute("rainbow", rainbow);
model.addAttribute("category", category);
return this.render("category");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.web.controller.core.BaseController;
import cn.hutool.core.util.PageUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -75,8 +76,10 @@ public String index(Model model,
if (null == posts) {
return this.renderNotFound();
}
int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
model.addAttribute("is_index",true);
model.addAttribute("posts", posts);
model.addAttribute("rainbow", rainbow);
return this.render("index");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.utils.CommentUtil;
import cc.ryanc.halo.web.controller.core.BaseController;
import cn.hutool.core.util.PageUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -95,10 +96,12 @@ public String getPage(@PathVariable(value = "postUrl") String postUrl,
}
//评论分页
ListPage<Comment> commentsPage = new ListPage<Comment>(CommentUtil.getComments(comments),cp, size);
int[] rainbow = PageUtil.rainbow(cp, commentsPage.getTotalPage(), 3);
model.addAttribute("is_page",true);
model.addAttribute("post", post);
model.addAttribute("comments", commentsPage);
model.addAttribute("commentsCount", comments.size());
model.addAttribute("rainbow", rainbow);
postService.updatePostView(post);
return this.render("page");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.service.TagService;
import cc.ryanc.halo.web.controller.core.BaseController;
import cn.hutool.core.util.PageUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -83,8 +84,10 @@ public String tags(Model model,
}
Pageable pageable = PageRequest.of(page - 1, size, sort);
Page<Post> posts = postService.findPostsByTags(tag, pageable);
int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
model.addAttribute("is_tags",true);
model.addAttribute("posts", posts);
model.addAttribute("rainbow", rainbow);
model.addAttribute("tag", tag);
return this.render("tag");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
});
}
setInterval("autoPush()","60000");
// setInterval("autoPush()","60000");
/**
* 自动保存文章
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
}
});
}
setInterval("autoPush()","60000");
// setInterval("autoPush()","60000");
/**
* 自动保存文章
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,13 @@
</li>
</#if>
<li>
<span title="当前页">${comments.nowPage}</span>
<#list rainbow as r>
<#if r == comments.nowPage>
<a href="?cp=${comments.nowPage}#comments-list" style="color: red;">${r}</a>
<#else>
<a href="?cp=${r}#comments-list">${r}</a>
</#if>
</#list>
</li>
<#if comments.hasNext>
<li>
Expand Down

0 comments on commit e6fa100

Please sign in to comment.