mirror of https://github.com/halo-dev/halo
👽 代码优化
parent
1b1ec582ed
commit
2dd9b2918b
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.model.dto;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -14,7 +15,9 @@ import java.util.List;
|
|||
* @date : 2018/1/20
|
||||
*/
|
||||
@Data
|
||||
public class Archive {
|
||||
public class Archive implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 年份
|
||||
|
|
|
@ -36,14 +36,4 @@ public class HaloConst {
|
|||
* user_session
|
||||
*/
|
||||
public static String USER_SESSION_KEY = "user_session";
|
||||
|
||||
/**
|
||||
* Post类型:文章
|
||||
*/
|
||||
public static String POST_TYPE_POST = "post";
|
||||
|
||||
/**
|
||||
* Post类型:页面
|
||||
*/
|
||||
public static String POST_TYPE_PAGE = "page";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/1
|
||||
*/
|
||||
public enum PostStatus {
|
||||
|
||||
/**
|
||||
* 已发布
|
||||
*/
|
||||
PUBLISHED(0,"已发布"),
|
||||
|
||||
/**
|
||||
* 草稿
|
||||
*/
|
||||
DRAFT(1,"草稿"),
|
||||
|
||||
/**
|
||||
* 回收站
|
||||
*/
|
||||
RECYCLE(2,"回收站");
|
||||
|
||||
private Integer code;
|
||||
private String desc;
|
||||
|
||||
PostStatus(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/1
|
||||
*/
|
||||
public enum PostType {
|
||||
|
||||
/**
|
||||
* 文章
|
||||
*/
|
||||
POST_TYPE_POST("post"),
|
||||
|
||||
/**
|
||||
* 页面
|
||||
*/
|
||||
POST_TYPE_PAGE("page");
|
||||
|
||||
private String desc;
|
||||
|
||||
PostType(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/1
|
||||
*/
|
||||
public enum ResponseStatus {
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
*/
|
||||
SUCCESS(200,"OK"),
|
||||
|
||||
/**
|
||||
* 资源为空
|
||||
*/
|
||||
EMPTY(204,"No Content"),
|
||||
|
||||
/**
|
||||
* 服务器内部错误
|
||||
*/
|
||||
ERROR(500,"Internal Server Error"),
|
||||
|
||||
/**
|
||||
* 未找到资源
|
||||
*/
|
||||
NOTFOUND(404,"Not Found");
|
||||
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
ResponseStatus(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package cc.ryanc.halo.model.tag;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.*;
|
||||
|
@ -33,7 +33,7 @@ public class ArticleTagDirective implements TemplateDirectiveModel {
|
|||
String method = map.get(METHOD_KEY).toString();
|
||||
switch (method) {
|
||||
case "postsCount":
|
||||
environment.setVariable("postsCount", builder.build().wrap(postService.findAllPosts(HaloConst.POST_TYPE_POST).size()));
|
||||
environment.setVariable("postsCount", builder.build().wrap(postService.findAllPosts(PostType.POST_TYPE_POST.getDesc()).size()));
|
||||
break;
|
||||
case "archives":
|
||||
environment.setVariable("archives", builder.build().wrap(postService.findPostGroupByYearAndMonth()));
|
||||
|
@ -50,4 +50,4 @@ public class ArticleTagDirective implements TemplateDirectiveModel {
|
|||
}
|
||||
templateDirectiveBody.render(environment.getOut());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,13 @@ public interface PostService {
|
|||
*/
|
||||
Post updatePostStatus(Long postId, Integer status);
|
||||
|
||||
/**
|
||||
* 修改文章阅读量
|
||||
*
|
||||
* @param post post
|
||||
*/
|
||||
void updatePostView(Post post);
|
||||
|
||||
/**
|
||||
* 批量修改摘要
|
||||
*
|
||||
|
|
|
@ -4,7 +4,8 @@ import cc.ryanc.halo.model.domain.Category;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.Tag;
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.repository.PostRepository;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -75,6 +76,17 @@ public class PostServiceImpl implements PostService {
|
|||
return postRepository.save(post.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章阅读量
|
||||
*
|
||||
* @param post post
|
||||
*/
|
||||
@Override
|
||||
public void updatePostView(Post post) {
|
||||
post.setPostViews(post.getPostViews()+1);
|
||||
postRepository.save(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新文章摘要
|
||||
*
|
||||
|
@ -83,7 +95,7 @@ public class PostServiceImpl implements PostService {
|
|||
@Override
|
||||
@CacheEvict(value = POSTS_CACHE_NAME, allEntries = true, beforeInvocation = true)
|
||||
public void updateAllSummary(Integer postSummary) {
|
||||
List<Post> posts = this.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||
List<Post> posts = this.findAllPosts(PostType.POST_TYPE_POST.getDesc());
|
||||
for (Post post : posts) {
|
||||
String text = HtmlUtil.cleanHtmlTag(post.getPostContent());
|
||||
if (text.length() > postSummary) {
|
||||
|
@ -153,7 +165,7 @@ public class PostServiceImpl implements PostService {
|
|||
@Override
|
||||
@Cacheable(value = POSTS_CACHE_NAME, key = "'posts_page_'+#pageable.pageNumber")
|
||||
public Page<Post> findPostByStatus(Pageable pageable) {
|
||||
return postRepository.findPostsByPostStatusAndPostType(0,HaloConst.POST_TYPE_POST,pageable);
|
||||
return postRepository.findPostsByPostStatusAndPostType(PostStatus.PUBLISHED.getCode(),PostType.POST_TYPE_POST.getDesc(),pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,6 +199,7 @@ public class PostServiceImpl implements PostService {
|
|||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = POSTS_CACHE_NAME,key = "'posts_posturl_'+#postUrl+'_'+#postType")
|
||||
public Post findByPostUrl(String postUrl, String postType) {
|
||||
return postRepository.findPostByPostUrlAndPostType(postUrl, postType);
|
||||
}
|
||||
|
@ -210,7 +223,7 @@ public class PostServiceImpl implements PostService {
|
|||
*/
|
||||
@Override
|
||||
public List<Post> findByPostDateAfter(Date postDate) {
|
||||
return postRepository.findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(postDate, 0, HaloConst.POST_TYPE_POST);
|
||||
return postRepository.findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(postDate, PostStatus.PUBLISHED.getCode(), PostType.POST_TYPE_POST.getDesc());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,7 +234,7 @@ public class PostServiceImpl implements PostService {
|
|||
*/
|
||||
@Override
|
||||
public List<Post> findByPostDateBefore(Date postDate) {
|
||||
return postRepository.findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(postDate, 0, HaloConst.POST_TYPE_POST);
|
||||
return postRepository.findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(postDate, PostStatus.PUBLISHED.getCode(), PostType.POST_TYPE_POST.getDesc());
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,7 +364,7 @@ public class PostServiceImpl implements PostService {
|
|||
@Override
|
||||
@Cacheable(value = POSTS_CACHE_NAME, key = "'posts_hot'")
|
||||
public List<Post> hotPosts() {
|
||||
return postRepository.findPostsByPostTypeOrderByPostViewsDesc(HaloConst.POST_TYPE_POST);
|
||||
return postRepository.findPostsByPostTypeOrderByPostViewsDesc(PostType.POST_TYPE_POST.getDesc());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,7 @@ import cc.ryanc.halo.model.domain.User;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -69,7 +70,7 @@ public class AdminController extends BaseController {
|
|||
@GetMapping(value = {"", "/index"})
|
||||
public String index(Model model, HttpSession session) {
|
||||
//查询文章条数
|
||||
Integer postCount = postService.findAllPosts(HaloConst.POST_TYPE_POST).size();
|
||||
Integer postCount = postService.findAllPosts(PostType.POST_TYPE_POST.getDesc()).size();
|
||||
model.addAttribute("postCount", postCount);
|
||||
|
||||
//查询评论的条数
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.ryanc.halo.model.domain.User;
|
|||
import cc.ryanc.halo.model.dto.BackupDto;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.MailService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -139,8 +140,8 @@ public class BackupController {
|
|||
* @return JsonResult
|
||||
*/
|
||||
public JsonResult backupPosts() {
|
||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||
posts.addAll(postService.findAllPosts(HaloConst.POST_TYPE_PAGE));
|
||||
List<Post> posts = postService.findAllPosts(PostType.POST_TYPE_POST.getDesc());
|
||||
posts.addAll(postService.findAllPosts(PostType.POST_TYPE_PAGE.getDesc()));
|
||||
try {
|
||||
if(HaloUtils.getBackUps("posts").size()>10){
|
||||
FileUtil.del(System.getProperties().getProperty("user.home") + "/halo/backup/posts/");
|
||||
|
|
|
@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.Comment;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.User;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.MailService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -118,7 +119,7 @@ public class CommentController extends BaseController {
|
|||
try {
|
||||
if (status == 1 && Validator.isEmail(comment.getCommentAuthorEmail())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (StringUtils.equals(post.getPostType(), HaloConst.POST_TYPE_POST)) {
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
|
@ -210,7 +211,7 @@ public class CommentController extends BaseController {
|
|||
map.put("blogTitle", HaloConst.OPTIONS.get("blog_title"));
|
||||
map.put("commentAuthor", lastComment.getCommentAuthor());
|
||||
map.put("pageName", lastComment.getPost().getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), HaloConst.POST_TYPE_POST)) {
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
|
|
|
@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.*;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
|
@ -59,7 +60,7 @@ public class PageController {
|
|||
*/
|
||||
@GetMapping
|
||||
public String pages(Model model) {
|
||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_PAGE);
|
||||
List<Post> posts = postService.findAllPosts(PostType.POST_TYPE_PAGE.getDesc());
|
||||
model.addAttribute("pages", posts);
|
||||
return "admin/admin_page";
|
||||
}
|
||||
|
@ -100,7 +101,7 @@ public class PageController {
|
|||
Link backLink = linkService.saveByLink(link);
|
||||
log.info("保存成功,数据为:" + backLink);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("未知错误:", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/page/links";
|
||||
}
|
||||
|
@ -117,7 +118,7 @@ public class PageController {
|
|||
Link link = linkService.removeByLinkId(linkId);
|
||||
log.info("删除的友情链接:" + link);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("未知错误:", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/page/links";
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ public class PageController {
|
|||
//发表用户
|
||||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||
post.setUser(user);
|
||||
post.setPostType(HaloConst.POST_TYPE_PAGE);
|
||||
post.setPostType(PostType.POST_TYPE_PAGE.getDesc());
|
||||
if(null!=post.getPostId()){
|
||||
post.setPostViews(postService.findByPostId(post.getPostId()).get().getPostViews());
|
||||
post.setPostDate(postService.findByPostId(post.getPostId()).get().getPostDate());
|
||||
|
@ -260,7 +261,7 @@ public class PageController {
|
|||
@GetMapping(value = "/checkUrl")
|
||||
@ResponseBody
|
||||
public boolean checkUrlExists(@PathParam("postUrl") String postUrl) {
|
||||
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_PAGE);
|
||||
Post post = postService.findByPostUrl(postUrl, PostType.POST_TYPE_PAGE.getDesc());
|
||||
// TODO 还没写完
|
||||
if (null != post || StringUtils.equals("archives", postUrl) || StringUtils.equals("galleries", postUrl)) {
|
||||
return true;
|
||||
|
|
|
@ -4,6 +4,8 @@ import cc.ryanc.halo.model.domain.*;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CategoryService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -86,11 +88,11 @@ public class PostController extends BaseController {
|
|||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
Page<Post> posts = postService.findPostByStatus(status, HaloConst.POST_TYPE_POST, pageable);
|
||||
Page<Post> posts = postService.findPostByStatus(status, PostType.POST_TYPE_POST.getDesc(), pageable);
|
||||
model.addAttribute("posts", posts);
|
||||
model.addAttribute("publishCount", postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable).getTotalElements());
|
||||
model.addAttribute("draftCount", postService.findPostByStatus(1, HaloConst.POST_TYPE_POST, pageable).getTotalElements());
|
||||
model.addAttribute("trashCount", postService.findPostByStatus(2, HaloConst.POST_TYPE_POST, pageable).getTotalElements());
|
||||
model.addAttribute("publishCount", postService.findPostByStatus(PostStatus.PUBLISHED.getCode(), PostType.POST_TYPE_POST.getDesc(), pageable).getTotalElements());
|
||||
model.addAttribute("draftCount", postService.findPostByStatus(PostStatus.DRAFT.getCode(), PostType.POST_TYPE_POST.getDesc(), pageable).getTotalElements());
|
||||
model.addAttribute("trashCount", postService.findPostByStatus(PostStatus.RECYCLE.getCode(), PostType.POST_TYPE_POST.getDesc(), pageable).getTotalElements());
|
||||
model.addAttribute("status", status);
|
||||
return "admin/admin_post";
|
||||
}
|
||||
|
@ -115,7 +117,7 @@ public class PostController extends BaseController {
|
|||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
model.addAttribute("posts", postService.searchPosts(keyword, pageable));
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("未知错误:", e.getMessage());
|
||||
}
|
||||
return "admin/admin_post";
|
||||
}
|
||||
|
@ -259,10 +261,10 @@ public class PostController extends BaseController {
|
|||
@GetMapping("/throw")
|
||||
public String moveToTrash(@RequestParam("postId") Long postId, @RequestParam("status") Integer status) {
|
||||
try {
|
||||
postService.updatePostStatus(postId, 2);
|
||||
postService.updatePostStatus(postId, PostStatus.RECYCLE.getCode());
|
||||
log.info("编号为" + postId + "的文章已被移到回收站");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("未知错误:", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts?status=" + status;
|
||||
}
|
||||
|
@ -277,10 +279,10 @@ public class PostController extends BaseController {
|
|||
public String moveToPublish(@RequestParam("postId") Long postId,
|
||||
@RequestParam("status") Integer status) {
|
||||
try {
|
||||
postService.updatePostStatus(postId, 0);
|
||||
postService.updatePostStatus(postId, PostStatus.PUBLISHED.getCode());
|
||||
log.info("编号为" + postId + "的文章已改变为发布状态");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("未知错误:", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts?status=" + status;
|
||||
}
|
||||
|
@ -298,9 +300,9 @@ public class PostController extends BaseController {
|
|||
postService.removeByPostId(postId);
|
||||
logsService.saveByLogs(new Logs(LogsRecord.REMOVE_POST, post.get().getPostTitle(), ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("未知错误:", e.getMessage());
|
||||
}
|
||||
if (StringUtils.equals(HaloConst.POST_TYPE_POST, postType)) {
|
||||
if (StringUtils.equals(PostType.POST_TYPE_POST.getDesc(), postType)) {
|
||||
return "redirect:/admin/posts?status=2";
|
||||
}
|
||||
return "redirect:/admin/page";
|
||||
|
@ -348,7 +350,7 @@ public class PostController extends BaseController {
|
|||
@ResponseBody
|
||||
public boolean checkUrlExists(@PathParam("postUrl") String postUrl) {
|
||||
postUrl = urlFilter(postUrl);
|
||||
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_POST);
|
||||
Post post = postService.findByPostUrl(postUrl, PostType.POST_TYPE_POST.getDesc());
|
||||
return null != post;
|
||||
}
|
||||
|
||||
|
@ -365,7 +367,7 @@ public class PostController extends BaseController {
|
|||
return false;
|
||||
}
|
||||
String blogUrl = HaloConst.OPTIONS.get("blog_url");
|
||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||
List<Post> posts = postService.findAllPosts(PostType.POST_TYPE_POST.getDesc());
|
||||
StringBuilder urls = new StringBuilder();
|
||||
for (Post post : posts) {
|
||||
urls.append(blogUrl);
|
||||
|
|
|
@ -14,7 +14,6 @@ import cn.hutool.core.util.ZipUtil;
|
|||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.ehcache.CacheManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -30,9 +31,9 @@ public class ApiArchivesController {
|
|||
public JsonResult archivesYear(){
|
||||
List<Archive> archives = postService.findPostGroupByYear();
|
||||
if(null!=archives || archives.size()>0){
|
||||
return new JsonResult(200,"success",archives);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),archives);
|
||||
}else {
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,9 +46,9 @@ public class ApiArchivesController {
|
|||
public JsonResult archivesYearAndMonth(){
|
||||
List<Archive> archives = postService.findPostGroupByYearAndMonth();
|
||||
if(null!=archives || archives.size()>0){
|
||||
return new JsonResult(200,"success",archives);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),archives);
|
||||
}else {
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Category;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.CategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -31,9 +32,9 @@ public class ApiCategoryController {
|
|||
public JsonResult categories(){
|
||||
List<Category> categories = categoryService.findAllCategories();
|
||||
if(null!=categories && categories.size()>0){
|
||||
return new JsonResult(200,"success",categories);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),categories);
|
||||
}else{
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,9 +48,9 @@ public class ApiCategoryController {
|
|||
public JsonResult categories(@PathVariable("cateUrl") String cateUrl){
|
||||
Category category = categoryService.findByCateUrl(cateUrl);
|
||||
if(null!=category){
|
||||
return new JsonResult(200,"success",category);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),category);
|
||||
}else{
|
||||
return new JsonResult(404,"not found");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Gallery;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -32,9 +33,9 @@ public class ApiGalleryController {
|
|||
public JsonResult galleries(){
|
||||
List<Gallery> galleries = galleryService.findAllGalleries();
|
||||
if(null!=galleries && galleries.size()>0){
|
||||
return new JsonResult(200,"success",galleries);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),galleries);
|
||||
}else {
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,9 +49,9 @@ public class ApiGalleryController {
|
|||
public JsonResult galleries(@PathVariable("id") Long id){
|
||||
Optional<Gallery> gallery = galleryService.findByGalleryId(id);
|
||||
if(gallery.isPresent()){
|
||||
return new JsonResult(200,"success",gallery.get());
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),gallery.get());
|
||||
}else{
|
||||
return new JsonResult(404,"not found");
|
||||
return new JsonResult(ResponseStatus.NOTFOUND.getCode(),ResponseStatus.NOTFOUND.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Link;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -30,9 +31,9 @@ public class ApiLinkController {
|
|||
public JsonResult links(){
|
||||
List<Link> links = linkService.findAllLinks();
|
||||
if(null!=links && links.size()>0){
|
||||
return new JsonResult(200,"success",links);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),links);
|
||||
}else{
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Menu;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.MenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -30,9 +31,9 @@ public class ApiMenuController {
|
|||
public JsonResult menus(){
|
||||
List<Menu> menus = menuService.findAllMenus();
|
||||
if(null!=menus && menus.size()>0){
|
||||
return new JsonResult(200,"success",menus);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),menus);
|
||||
}else{
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package cc.ryanc.halo.web.controller.api;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -28,11 +29,11 @@ public class ApiPageController {
|
|||
*/
|
||||
@GetMapping(value = "/{postUrl}")
|
||||
public JsonResult pages(@PathVariable(value = "postUrl") String postUrl){
|
||||
Post post = postService.findByPostUrl(postUrl,HaloConst.POST_TYPE_PAGE);
|
||||
Post post = postService.findByPostUrl(postUrl,PostType.POST_TYPE_PAGE.getDesc());
|
||||
if(null!=post){
|
||||
return new JsonResult(200,"success",post);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),post);
|
||||
}else{
|
||||
return new JsonResult(404,"not found");
|
||||
return new JsonResult(ResponseStatus.NOTFOUND.getCode(),ResponseStatus.NOTFOUND.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ package cc.ryanc.halo.web.controller.api;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -42,20 +45,20 @@ public class ApiPostController {
|
|||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||
}
|
||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||
Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||
Page<Post> posts = postService.findPostByStatus(PostStatus.PUBLISHED.getCode(), PostType.POST_TYPE_POST.getDesc(), pageable);
|
||||
if (null == posts) {
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
return new JsonResult(200,"success",posts);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),posts);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/hot")
|
||||
public JsonResult hotPosts() {
|
||||
List<Post> posts = postService.hotPosts();
|
||||
if (null != posts && posts.size() > 0) {
|
||||
return new JsonResult(200, "success", posts);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(), posts);
|
||||
} else {
|
||||
return new JsonResult(200, "empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,11 +70,11 @@ public class ApiPostController {
|
|||
*/
|
||||
@GetMapping(value = "/{postUrl}")
|
||||
public JsonResult posts(@PathVariable(value = "postUrl") String postUrl){
|
||||
Post post = postService.findByPostUrl(postUrl,HaloConst.POST_TYPE_POST);
|
||||
Post post = postService.findByPostUrl(postUrl,PostType.POST_TYPE_POST.getDesc());
|
||||
if(null!=post){
|
||||
return new JsonResult(200,"success",post);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),post);
|
||||
}else {
|
||||
return new JsonResult(404,"not found");
|
||||
return new JsonResult(ResponseStatus.NOTFOUND.getCode(),ResponseStatus.NOTFOUND.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Tag;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.TagService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -31,9 +32,9 @@ public class ApiTagController {
|
|||
public JsonResult tags(){
|
||||
List<Tag> tags = tagService.findAllTags();
|
||||
if(null!=tags && tags.size()>0){
|
||||
return new JsonResult(200,"success",tags);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),tags);
|
||||
}else{
|
||||
return new JsonResult(200,"empty");
|
||||
return new JsonResult(ResponseStatus.EMPTY.getCode(),ResponseStatus.EMPTY.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,9 +48,9 @@ public class ApiTagController {
|
|||
public JsonResult tags(@PathVariable("tagUrl") String tagUrl){
|
||||
Tag tag = tagService.findByTagUrl(tagUrl);
|
||||
if(null!=tag){
|
||||
return new JsonResult(200,"success",tag);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),tag);
|
||||
}else{
|
||||
return new JsonResult(404,"not found");
|
||||
return new JsonResult(ResponseStatus.NOTFOUND.getCode(),ResponseStatus.NOTFOUND.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.domain.User;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
import cc.ryanc.halo.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -27,6 +28,6 @@ public class ApiUserController {
|
|||
@GetMapping
|
||||
public JsonResult user(){
|
||||
User user = userService.findUser();
|
||||
return new JsonResult(200,"success",user);
|
||||
return new JsonResult(ResponseStatus.SUCCESS.getCode(),ResponseStatus.SUCCESS.getMsg(),user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Comment;
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||
|
@ -61,7 +61,7 @@ public class FrontArchiveController extends BaseController {
|
|||
//所有文章数据,分页,material主题适用
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Pageable pageable = PageRequest.of(page - 1, 5, sort);
|
||||
Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||
Page<Post> posts = postService.findPostByStatus(0, PostType.POST_TYPE_POST.getDesc(), pageable);
|
||||
if(null==posts){
|
||||
return this.renderNotFound();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class FrontArchiveController extends BaseController {
|
|||
*/
|
||||
@GetMapping(value = "{postUrl}")
|
||||
public String getPost(@PathVariable String postUrl, Model model) {
|
||||
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_POST);
|
||||
Post post = postService.findByPostUrl(postUrl, PostType.POST_TYPE_POST.getDesc());
|
||||
if(null==post || post.getPostStatus()!=0){
|
||||
return this.renderNotFound();
|
||||
}
|
||||
|
@ -120,8 +120,7 @@ public class FrontArchiveController extends BaseController {
|
|||
Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,0);
|
||||
model.addAttribute("post", post);
|
||||
model.addAttribute("comments",comments);
|
||||
post.setPostViews(post.getPostViews()+1);
|
||||
postService.saveByPost(post);
|
||||
postService.updatePostView(post);
|
||||
return this.render("post");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.Comment;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.MailService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -149,7 +150,7 @@ public class FrontCommentController {
|
|||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("author", userService.findUser().getUserDisplayName());
|
||||
map.put("pageName", post.getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), HaloConst.POST_TYPE_POST)) {
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
|
@ -189,7 +190,7 @@ public class FrontCommentController {
|
|||
map.put("blogTitle",HaloConst.OPTIONS.get("blog_title"));
|
||||
map.put("commentAuthor",lastComment.getCommentAuthor());
|
||||
map.put("pageName",lastComment.getPost().getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), HaloConst.POST_TYPE_POST)) {
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -40,7 +41,7 @@ public class FrontOthersController {
|
|||
//获取文章列表并根据时间排序
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Pageable pageable = PageRequest.of(0, Integer.parseInt(rssPosts), sort);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0, PostType.POST_TYPE_POST.getDesc(), pageable);
|
||||
List<Post> posts = postsPage.getContent();
|
||||
return postService.buildRss(posts);
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ public class FrontOthersController {
|
|||
//获取文章列表并根据时间排序
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Pageable pageable = PageRequest.of(0, 999, sort);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0, PostType.POST_TYPE_POST.getDesc(), pageable);
|
||||
List<Post> posts = postsPage.getContent();
|
||||
return postService.buildSiteMap(posts);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
import cc.ryanc.halo.model.domain.Comment;
|
||||
import cc.ryanc.halo.model.domain.Gallery;
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -67,7 +67,7 @@ public class FrontPageController extends BaseController {
|
|||
*/
|
||||
@GetMapping(value = "/p/{postUrl}")
|
||||
public String getPage(@PathVariable(value = "postUrl") String postUrl, Model model) {
|
||||
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_PAGE);
|
||||
Post post = postService.findByPostUrl(postUrl, PostType.POST_TYPE_PAGE.getDesc());
|
||||
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
|
||||
Pageable pageable = PageRequest.of(0,999,sort);
|
||||
|
@ -77,8 +77,7 @@ public class FrontPageController extends BaseController {
|
|||
}
|
||||
model.addAttribute("comments",comments);
|
||||
model.addAttribute("post", post);
|
||||
post.setPostViews(post.getPostViews()+1);
|
||||
postService.saveByPost(post);
|
||||
postService.updatePostView(post);
|
||||
return this.render("page");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,24 @@
|
|||
<!-- Import CSS -->
|
||||
<style id="material_css"></style><script>if(typeof window.lsLoadCSSMaxNums === "undefined")window.lsLoadCSSMaxNums = 0;window.lsLoadCSSMaxNums++;lsloader.load("material_css","/material/source/css/material.min.css?Z7a72R1E4SxzBKR/WGctOA==",function(){if(typeof window.lsLoadCSSNums === "undefined")window.lsLoadCSSNums = 0;window.lsLoadCSSNums++;if(window.lsLoadCSSNums == window.lsLoadCSSMaxNums)document.documentElement.style.display="";}, false)</script>
|
||||
<style id="style_css"></style><script>if(typeof window.lsLoadCSSMaxNums === "undefined")window.lsLoadCSSMaxNums = 0;window.lsLoadCSSMaxNums++;lsloader.load("style_css","/material/source/css/style.min.css?MKetZV3cUTfDxvMffaOezg==",function(){if(typeof window.lsLoadCSSNums === "undefined")window.lsLoadCSSNums = 0;window.lsLoadCSSNums++;if(window.lsLoadCSSNums == window.lsLoadCSSMaxNums)document.documentElement.style.display="";}, false)</script>
|
||||
|
||||
<style id="prettify_css"></style>
|
||||
<script>
|
||||
void 0 === window.lsLoadCSSMaxNums && (window.lsLoadCSSMaxNums = 0), window.lsLoadCSSMaxNums++, lsloader.load(
|
||||
"prettify_css", "/material/source/css/prettify.min.css?zp8STOU9v89XWFEnN+6YmQ==",
|
||||
function () {
|
||||
void 0 === window.lsLoadCSSNums && (window.lsLoadCSSNums = 0), ++window.lsLoadCSSNums == window.lsLoadCSSMaxNums &&
|
||||
(document.documentElement.style.display = "")
|
||||
}, !1)
|
||||
</script>
|
||||
<style id="prettify_theme"></style>
|
||||
<script>
|
||||
void 0 === window.lsLoadCSSMaxNums && (window.lsLoadCSSMaxNums = 0), window.lsLoadCSSMaxNums++, lsloader.load(
|
||||
"prettify_theme", "/material/source/css/prettify/github-v2.min.css?AfzKxt++K+/lhZBlSjnxwg==",
|
||||
function () {
|
||||
void 0 === window.lsLoadCSSNums && (window.lsLoadCSSNums = 0), ++window.lsLoadCSSNums == window.lsLoadCSSMaxNums &&
|
||||
(document.documentElement.style.display = "")
|
||||
}, !1)
|
||||
</script>
|
||||
<#if options.theme_material_scheme?default('Paradox') == "Isolation">
|
||||
<link rel="stylesheet" href="/material/source/css/fontawesome.min.css">
|
||||
</#if>
|
||||
|
@ -129,4 +146,4 @@
|
|||
<% } %>
|
||||
-->
|
||||
</head>
|
||||
</#macro>
|
||||
</#macro>
|
||||
|
|
|
@ -17,18 +17,11 @@
|
|||
</script>
|
||||
|
||||
<!-- Import prettify js -->
|
||||
|
||||
<script>
|
||||
lsloader.load("prettify_js", "/material/source/js/prettify.min.js?WN07fivHQSMKWy7BmHBB6w==", !0)
|
||||
</script>
|
||||
<!--
|
||||
<% if (theme.prettify.enable){ %>
|
||||
<% if ( (is_post()) ) { %>
|
||||
<% if(theme.vendors.prettify) { %>
|
||||
<%- jsLsload({path:(theme.vendors.prettify),key:'prettify_js'}) %>
|
||||
<% } else if(theme.vendors.materialcdn) { %>
|
||||
<%- jsLsload({path:(theme.vendors.materialcdn + '/js/prettify.min.js'),key:'prettify_js'}) %>
|
||||
<% } else { %>
|
||||
<%- jsLsload({path:('js/prettify.min.js'),key:'prettify_js'}) %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (theme.hanabi.enable) { %>
|
||||
<% if(theme.vendors.materialcdn) { %>
|
||||
<%- jsLsload({path:(theme.vendors.materialcdn + '/js/hanabi-browser-bundle.js'),key:'hanabi'}) %>
|
||||
|
@ -96,4 +89,4 @@
|
|||
}
|
||||
})()
|
||||
console.log('\n %c © Material Theme | Version: 1.5.2 | https://github.com/viosey/hexo-theme-material %c \n', 'color:#455a64;background:#e0e0e0;padding:5px 0;border-top-left-radius:5px;border-bottom-left-radius:5px;', 'color:#455a64;background:#e0e0e0;padding:5px 0;border-top-right-radius:5px;border-bottom-right-radius:5px;');
|
||||
</script>
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue