diff --git a/pom.xml b/pom.xml index 87930b628..2a7dbb29b 100755 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,12 @@ spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-mail + + mysql @@ -92,6 +98,12 @@ rome 1.0 + + + org.apache.commons + commons-lang3 + 3.7 + @@ -101,7 +113,6 @@ halo - src/main/java false diff --git a/src/main/java/cc/ryanc/halo/config/StartupConfiguration.java b/src/main/java/cc/ryanc/halo/config/StartupConfiguration.java index d4ea7e636..ceb0c5643 100755 --- a/src/main/java/cc/ryanc/halo/config/StartupConfiguration.java +++ b/src/main/java/cc/ryanc/halo/config/StartupConfiguration.java @@ -3,6 +3,7 @@ package cc.ryanc.halo.config; import cc.ryanc.halo.model.domain.Attachment; import cc.ryanc.halo.model.domain.User; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.model.dto.Theme; import cc.ryanc.halo.service.AttachmentService; import cc.ryanc.halo.service.OptionsService; import cc.ryanc.halo.service.UserService; @@ -87,8 +88,19 @@ public class StartupConfiguration implements ApplicationListener themes = HaloUtil.getThemes(); + if(null!=themes){ + HaloConst.THEMES = themes; + } + }catch (Exception e){ + log.error("加载主题失败:"+e.getMessage()); + } } private void loadUser(){ diff --git a/src/main/java/cc/ryanc/halo/model/domain/Attachment.java b/src/main/java/cc/ryanc/halo/model/domain/Attachment.java index e72e2b80d..339da33b5 100644 --- a/src/main/java/cc/ryanc/halo/model/domain/Attachment.java +++ b/src/main/java/cc/ryanc/halo/model/domain/Attachment.java @@ -21,7 +21,7 @@ import java.util.Date; public class Attachment implements Serializable{ @Id @GeneratedValue - private Integer attachId; + private Long attachId; private String attachName; private String attachPath; private String attachSmallPath; diff --git a/src/main/java/cc/ryanc/halo/model/domain/Category.java b/src/main/java/cc/ryanc/halo/model/domain/Category.java index a1dd75d9c..b20d3af83 100755 --- a/src/main/java/cc/ryanc/halo/model/domain/Category.java +++ b/src/main/java/cc/ryanc/halo/model/domain/Category.java @@ -20,7 +20,7 @@ import java.util.List; public class Category implements Serializable{ @Id @GeneratedValue - private Integer cateId; + private Long cateId; private String cateName; private String cateUrl; private String cateDesc; diff --git a/src/main/java/cc/ryanc/halo/model/domain/Comment.java b/src/main/java/cc/ryanc/halo/model/domain/Comment.java new file mode 100644 index 000000000..529e88c23 --- /dev/null +++ b/src/main/java/cc/ryanc/halo/model/domain/Comment.java @@ -0,0 +1,81 @@ +package cc.ryanc.halo.model.domain; + +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +/** + * @author : RYAN0UP + * @version : 1.0 + * @date : 2018/1/22 + * description : 评论实体类 + */ +@Data +@Entity +@Table(name = "halo_comment") +public class Comment implements Serializable { + + /** + * 评论id 自增 + */ + @Id + @GeneratedValue + private Long commentId; + + /** + * 评论文章 + */ + @ManyToOne(targetEntity = Post.class,fetch = FetchType.EAGER) + @JoinColumn(name = "post_id") + private Post post; + + /** + * 评论人 + */ + private String commentAuthor; + + /** + * 评论人的邮箱 + */ + private String commentAuthorEmail; + + /** + * 评论人的主页 + */ + private String commentAuthorUrl; + + /** + * 评论人的ip + */ + private String commentAuthorIp; + + /** + * 评论时间 + */ + private Date commentDate; + + /** + * 评论内容 + */ + @Lob + private String commentContent; + + /** + * 评论者ua信息 + */ + private String commentAgent; + + /** + * 上一级 + */ + @OneToOne + @JoinColumn(name = "comment_id") + private Comment commentParent; + + /** + * 评论状态,0:正常,1:待审核,2:回收站 + */ + private Integer commentStatus=1; +} diff --git a/src/main/java/cc/ryanc/halo/model/domain/Link.java b/src/main/java/cc/ryanc/halo/model/domain/Link.java index 411146b9b..8976381f5 100755 --- a/src/main/java/cc/ryanc/halo/model/domain/Link.java +++ b/src/main/java/cc/ryanc/halo/model/domain/Link.java @@ -20,7 +20,7 @@ import java.io.Serializable; public class Link implements Serializable{ @Id @GeneratedValue - private Integer linkId; + private Long linkId; private String linkName; private String linkUrl; private String linkPic; diff --git a/src/main/java/cc/ryanc/halo/model/domain/Logs.java b/src/main/java/cc/ryanc/halo/model/domain/Logs.java index 21911e34d..dd4776a30 100644 --- a/src/main/java/cc/ryanc/halo/model/domain/Logs.java +++ b/src/main/java/cc/ryanc/halo/model/domain/Logs.java @@ -25,7 +25,7 @@ public class Logs implements Serializable { */ @Id @GeneratedValue - private Integer logId; + private Long logId; /** * 标题 diff --git a/src/main/java/cc/ryanc/halo/model/domain/Post.java b/src/main/java/cc/ryanc/halo/model/domain/Post.java index d5f1a004f..59e83a7a0 100755 --- a/src/main/java/cc/ryanc/halo/model/domain/Post.java +++ b/src/main/java/cc/ryanc/halo/model/domain/Post.java @@ -1,5 +1,6 @@ package cc.ryanc.halo.model.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import javax.persistence.*; @@ -21,7 +22,7 @@ public class Post implements Serializable{ */ @Id @GeneratedValue - private Integer postId; + private Long postId; /** * 发表用户 多对一 @@ -35,6 +36,13 @@ public class Post implements Serializable{ */ private String postTitle; + /** + * 文章类型 + * post 文章 + * page 页面 + */ + private String postType = "post"; + /** * 文章内容 Markdown格式 */ @@ -76,6 +84,11 @@ public class Post implements Serializable{ inverseJoinColumns = {@JoinColumn(name = "tag_id",nullable = false)}) private List tags = new ArrayList<>(); + + @OneToMany(mappedBy = "post",cascade = {CascadeType.REMOVE},fetch = FetchType.EAGER) + @JsonIgnore + private List comments = new ArrayList<>(); + /** * 发表日期 */ diff --git a/src/main/java/cc/ryanc/halo/model/domain/PostMeta.java b/src/main/java/cc/ryanc/halo/model/domain/PostMeta.java index f3307dbb4..9a7794548 100755 --- a/src/main/java/cc/ryanc/halo/model/domain/PostMeta.java +++ b/src/main/java/cc/ryanc/halo/model/domain/PostMeta.java @@ -20,6 +20,6 @@ import java.io.Serializable; public class PostMeta implements Serializable{ @Id @GeneratedValue - private Integer metaId; + private Long metaId; } diff --git a/src/main/java/cc/ryanc/halo/model/domain/Tag.java b/src/main/java/cc/ryanc/halo/model/domain/Tag.java index 922082f2c..f8b0ee69f 100644 --- a/src/main/java/cc/ryanc/halo/model/domain/Tag.java +++ b/src/main/java/cc/ryanc/halo/model/domain/Tag.java @@ -20,7 +20,7 @@ import java.util.List; public class Tag implements Serializable{ @Id @GeneratedValue - private Integer tagId; + private Long tagId; private String tagName; private String tagUrl; diff --git a/src/main/java/cc/ryanc/halo/model/domain/User.java b/src/main/java/cc/ryanc/halo/model/domain/User.java index 5da46bb63..ae5007816 100755 --- a/src/main/java/cc/ryanc/halo/model/domain/User.java +++ b/src/main/java/cc/ryanc/halo/model/domain/User.java @@ -21,7 +21,7 @@ public class User implements Serializable{ /** * 编号 */ - private Integer userId; + private Long userId; /** * 用户名 */ diff --git a/src/main/java/cc/ryanc/halo/model/domain/UserMeta.java b/src/main/java/cc/ryanc/halo/model/domain/UserMeta.java index aba3ca700..0749af94b 100755 --- a/src/main/java/cc/ryanc/halo/model/domain/UserMeta.java +++ b/src/main/java/cc/ryanc/halo/model/domain/UserMeta.java @@ -17,8 +17,8 @@ import java.io.Serializable; public class UserMeta implements Serializable{ @Id @GeneratedValue - private Integer userMetaId; - private Integer userId; + private Long userMetaId; + private Long userId; private String userMetaKey; @Lob private String userMetaValue; diff --git a/src/main/java/cc/ryanc/halo/model/dto/HaloConst.java b/src/main/java/cc/ryanc/halo/model/dto/HaloConst.java index fed6e116d..1b7dd719c 100644 --- a/src/main/java/cc/ryanc/halo/model/dto/HaloConst.java +++ b/src/main/java/cc/ryanc/halo/model/dto/HaloConst.java @@ -1,7 +1,6 @@ package cc.ryanc.halo.model.dto; import cc.ryanc.halo.model.domain.Attachment; -import cc.ryanc.halo.model.domain.Theme; import cc.ryanc.halo.model.domain.User; import java.util.ArrayList; diff --git a/src/main/java/cc/ryanc/halo/model/domain/Theme.java b/src/main/java/cc/ryanc/halo/model/dto/Theme.java similarity index 60% rename from src/main/java/cc/ryanc/halo/model/domain/Theme.java rename to src/main/java/cc/ryanc/halo/model/dto/Theme.java index 941e0ac0a..d388c3fc6 100644 --- a/src/main/java/cc/ryanc/halo/model/domain/Theme.java +++ b/src/main/java/cc/ryanc/halo/model/dto/Theme.java @@ -1,4 +1,4 @@ -package cc.ryanc.halo.model.domain; +package cc.ryanc.halo.model.dto; import lombok.Data; @@ -12,7 +12,14 @@ import java.io.Serializable; */ @Data public class Theme implements Serializable { - private Integer themeId; + + /** + * 主题名称 + */ private String themeName; - private String themeScreenShot; + + /** + * 是否支持设置 + */ + private boolean hasOptions; } diff --git a/src/main/java/cc/ryanc/halo/repository/AttachmentRepository.java b/src/main/java/cc/ryanc/halo/repository/AttachmentRepository.java index eed3000fe..a50942417 100644 --- a/src/main/java/cc/ryanc/halo/repository/AttachmentRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/AttachmentRepository.java @@ -11,7 +11,13 @@ import org.springframework.data.jpa.repository.JpaRepository; * description : * @date : 2018/1/10 */ -public interface AttachmentRepository extends JpaRepository{ +public interface AttachmentRepository extends JpaRepository{ + + /** + * 查询所有附件,分页 + * @param pageable pageable + * @return page + */ @Override Page findAll(Pageable pageable); } diff --git a/src/main/java/cc/ryanc/halo/repository/CategoryRepository.java b/src/main/java/cc/ryanc/halo/repository/CategoryRepository.java index 042d5d384..1c8cc2435 100755 --- a/src/main/java/cc/ryanc/halo/repository/CategoryRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/CategoryRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; * @version : 1.0 * description: 分类目录持久层 */ -public interface CategoryRepository extends JpaRepository{ +public interface CategoryRepository extends JpaRepository{ /** * 根据分类目录路径查询,用于验证是否已经存在该路径 diff --git a/src/main/java/cc/ryanc/halo/repository/CommentRepository.java b/src/main/java/cc/ryanc/halo/repository/CommentRepository.java new file mode 100644 index 000000000..0f9cbf264 --- /dev/null +++ b/src/main/java/cc/ryanc/halo/repository/CommentRepository.java @@ -0,0 +1,52 @@ +package cc.ryanc.halo.repository; + +import cc.ryanc.halo.model.domain.Comment; +import cc.ryanc.halo.model.domain.Post; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +/** + * @author : RYAN0UP + * @version : 1.0 + * description : + * @date : 2018/1/22 + */ +public interface CommentRepository extends JpaRepository { + + /** + * 根据评论状态查询所有评论 + * @param status Status + * @param pageable pageable + * @return page + */ + Page findCommentsByCommentStatus(Integer status, Pageable pageable); + + /** + * 根据文章查询评论 + * @param post post + * @param pageable pageable + * @return page + */ + Page findCommentsByPost(Post post,Pageable pageable); + + /** + * 根据文章和评论状态查询评论 + * @param post post + * @param pageable pageable + * @param status status + * @return page + */ + Page findCommentsByPostAndCommentStatus(Post post,Pageable pageable,Integer status); + + /** + * 查询最新的前五条评论 + * @return list + */ + @Query(value = "SELECT * FROM halo_comment ORDER BY comment_date DESC LIMIT 5",nativeQuery = true) + List findTopFive(); + +} diff --git a/src/main/java/cc/ryanc/halo/repository/LinkRepository.java b/src/main/java/cc/ryanc/halo/repository/LinkRepository.java index f1e4af542..282ef72fe 100755 --- a/src/main/java/cc/ryanc/halo/repository/LinkRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/LinkRepository.java @@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository; * @date : 2017/11/14 * description: 友情链接持久层 */ -public interface LinkRepository extends JpaRepository{ +public interface LinkRepository extends JpaRepository{ } diff --git a/src/main/java/cc/ryanc/halo/repository/LogsRepository.java b/src/main/java/cc/ryanc/halo/repository/LogsRepository.java index 282246610..9c0a32e37 100644 --- a/src/main/java/cc/ryanc/halo/repository/LogsRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/LogsRepository.java @@ -12,12 +12,12 @@ import java.util.List; * description : * @date : 2018/1/19 */ -public interface LogsRepository extends JpaRepository { +public interface LogsRepository extends JpaRepository { /** * 查询最新的五条数据 * @return list */ - @Query(value = "SELECT * FROM halo_logs ORDER BY log_id DESC LIMIT 5",nativeQuery = true) + @Query(value = "SELECT * FROM halo_logs ORDER BY log_created DESC LIMIT 5",nativeQuery = true) List findTopFive(); } diff --git a/src/main/java/cc/ryanc/halo/repository/OptionsRepository.java b/src/main/java/cc/ryanc/halo/repository/OptionsRepository.java index bfe354d45..b20ee25ff 100755 --- a/src/main/java/cc/ryanc/halo/repository/OptionsRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/OptionsRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; * @version : 1.0 * description: 设置选项持久层 */ -public interface OptionsRepository extends JpaRepository{ +public interface OptionsRepository extends JpaRepository{ /** * 根据key查询单个option diff --git a/src/main/java/cc/ryanc/halo/repository/PostMetaRepository.java b/src/main/java/cc/ryanc/halo/repository/PostMetaRepository.java index bd3119dd2..911d1a04a 100755 --- a/src/main/java/cc/ryanc/halo/repository/PostMetaRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/PostMetaRepository.java @@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository; * @version : 1.0 * description: */ -public interface PostMetaRepository extends JpaRepository{ +public interface PostMetaRepository extends JpaRepository{ } diff --git a/src/main/java/cc/ryanc/halo/repository/PostRepository.java b/src/main/java/cc/ryanc/halo/repository/PostRepository.java index 5ae4b87df..2b6da847d 100755 --- a/src/main/java/cc/ryanc/halo/repository/PostRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/PostRepository.java @@ -18,13 +18,13 @@ import java.util.List; * @date : 2017/11/14 * description : 文章持久层 */ -public interface PostRepository extends JpaRepository{ +public interface PostRepository extends JpaRepository{ /** * 查询前五条文章 * @return list */ - @Query(value = "SELECT * FROM halo_post ORDER BY post_id DESC LIMIT 5",nativeQuery = true) + @Query(value = "SELECT * FROM halo_post ORDER BY post_date DESC LIMIT 5",nativeQuery = true) List findTopFive(); /** diff --git a/src/main/java/cc/ryanc/halo/repository/TagRepository.java b/src/main/java/cc/ryanc/halo/repository/TagRepository.java index 3f22bb892..8ee9aeeff 100644 --- a/src/main/java/cc/ryanc/halo/repository/TagRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/TagRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; * description : * @date : 2018/1/12 */ -public interface TagRepository extends JpaRepository{ +public interface TagRepository extends JpaRepository{ /** * 根据标签路径查询,用于验证是否已经存在该路径 diff --git a/src/main/java/cc/ryanc/halo/repository/UserMetaRepository.java b/src/main/java/cc/ryanc/halo/repository/UserMetaRepository.java index 480e3693e..89e340c77 100755 --- a/src/main/java/cc/ryanc/halo/repository/UserMetaRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/UserMetaRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; * @date : 2017/11/14 * description: */ -public interface UserMetaRepository extends JpaRepository{ +public interface UserMetaRepository extends JpaRepository{ UserMeta findByUserMetaKey(String key); } diff --git a/src/main/java/cc/ryanc/halo/repository/UserRepository.java b/src/main/java/cc/ryanc/halo/repository/UserRepository.java index 3e1f08491..b2a072022 100755 --- a/src/main/java/cc/ryanc/halo/repository/UserRepository.java +++ b/src/main/java/cc/ryanc/halo/repository/UserRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; * @version : 1.0 * description: */ -public interface UserRepository extends JpaRepository{ +public interface UserRepository extends JpaRepository{ /** * 根据用户名和密码查询 * @param userName userName @@ -24,5 +24,5 @@ public interface UserRepository extends JpaRepository{ * @param userPass userpass * @return User */ - User findByUserIdAndUserPass(Integer userId,String userPass); + User findByUserIdAndUserPass(Long userId,String userPass); } diff --git a/src/main/java/cc/ryanc/halo/service/AttachmentService.java b/src/main/java/cc/ryanc/halo/service/AttachmentService.java index cdf458de0..cd8c27dd4 100644 --- a/src/main/java/cc/ryanc/halo/service/AttachmentService.java +++ b/src/main/java/cc/ryanc/halo/service/AttachmentService.java @@ -26,6 +26,11 @@ public interface AttachmentService { */ List findAllAttachments(); + /** + * 查询所有附件,分类 + * @param pageable pageable + * @return page + */ Page findAllAttachments(Pageable pageable); /** @@ -33,12 +38,12 @@ public interface AttachmentService { * @param attachId attachId * @return Attachment */ - Attachment findByAttachId(Integer attachId); + Attachment findByAttachId(Long attachId); /** * 根据编号移除 * @param attachId attachId * @return Attachment */ - Attachment removeByAttachId(Integer attachId); + Attachment removeByAttachId(Long attachId); } diff --git a/src/main/java/cc/ryanc/halo/service/CategoryService.java b/src/main/java/cc/ryanc/halo/service/CategoryService.java index 25653910b..deedf89ff 100755 --- a/src/main/java/cc/ryanc/halo/service/CategoryService.java +++ b/src/main/java/cc/ryanc/halo/service/CategoryService.java @@ -23,7 +23,7 @@ public interface CategoryService { * @param cateId 分类目录编号 * @return category */ - Category removeByCateId(Integer cateId); + Category removeByCateId(Long cateId); /** * 修改分类目录信息 @@ -43,7 +43,7 @@ public interface CategoryService { * @param cateId 分类编号 * @return 返回category实体 */ - Category findByCateId(Integer cateId); + Category findByCateId(Long cateId); /** * 根据分类目录路径查询,用于验证是否已经存在该路径 diff --git a/src/main/java/cc/ryanc/halo/service/CommentService.java b/src/main/java/cc/ryanc/halo/service/CommentService.java new file mode 100644 index 000000000..2c0d91715 --- /dev/null +++ b/src/main/java/cc/ryanc/halo/service/CommentService.java @@ -0,0 +1,76 @@ +package cc.ryanc.halo.service; + +import cc.ryanc.halo.model.domain.Comment; +import cc.ryanc.halo.model.domain.Post; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * @author : RYAN0UP + * @version : 1.0 + * @date : 2018/1/22 + * description : + */ +public interface CommentService { + + /** + * 新增评论 + * @param comment comment + */ + void saveByComment(Comment comment); + + /** + * 查询所有的评论,用于后台管理 + * @param status status + * @param pageable pageable + * @return page + */ + Page findAllComments(Integer status, Pageable pageable); + + + /** + * 查询所有评论,不分页 + * @return + */ + List findAllComments(); + + /** + * 更改评论的状态 + * @param commentId commentId + * @param status status + * @return comment + */ + Comment updateCommentStatus(Long commentId,Integer status); + + /** + * 根据评论编号查询评论 + * @param commentId commentId + * @return comment + */ + Comment findCommentById(Long commentId); + + /** + * 根据文章查询评论 + * @param post post + * @param pageable pageable + * @return page + */ + Page findCommentsByPost(Post post,Pageable pageable); + + /** + * 根据文章和评论状态查询评论 + * @param post post + * @param pageable pageable + * @param status status + * @return page + */ + Page findCommentsByPostAndCommentStatus(Post post,Pageable pageable,Integer status); + + /** + * 查询最新的前五条评论 + * @return list + */ + List findCommentsLatest(); +} diff --git a/src/main/java/cc/ryanc/halo/service/LinkService.java b/src/main/java/cc/ryanc/halo/service/LinkService.java index c546f09b7..9689edca1 100755 --- a/src/main/java/cc/ryanc/halo/service/LinkService.java +++ b/src/main/java/cc/ryanc/halo/service/LinkService.java @@ -23,7 +23,7 @@ public interface LinkService { * @param linkId linkId * @return Link */ - Link removeByLinkId(Integer linkId); + Link removeByLinkId(Long linkId); /** * 修改 @@ -43,5 +43,5 @@ public interface LinkService { * @param linkId linkId * @return Link */ - Link findByLinkId(Integer linkId); + Link findByLinkId(Long linkId); } diff --git a/src/main/java/cc/ryanc/halo/service/LogsService.java b/src/main/java/cc/ryanc/halo/service/LogsService.java index 283529565..5c44af617 100644 --- a/src/main/java/cc/ryanc/halo/service/LogsService.java +++ b/src/main/java/cc/ryanc/halo/service/LogsService.java @@ -25,9 +25,8 @@ public interface LogsService { /** * 根据编号移除 * @param logsId logsId - * @return Logs */ - void removeByLogsId(Integer logsId); + void removeByLogsId(Long logsId); /** * 移除所有日志 @@ -52,5 +51,5 @@ public interface LogsService { * @param logsId logsId * @return logs */ - Logs findLogsByLogsId(Integer logsId); + Logs findLogsByLogsId(Long logsId); } diff --git a/src/main/java/cc/ryanc/halo/service/MailService.java b/src/main/java/cc/ryanc/halo/service/MailService.java new file mode 100644 index 000000000..dd70f4060 --- /dev/null +++ b/src/main/java/cc/ryanc/halo/service/MailService.java @@ -0,0 +1,11 @@ +package cc.ryanc.halo.service; + +/** + * @author : RYAN0UP + * @version : 1.0 + * description : + * @date : 2018/1/23 + */ +public interface MailService { + void sendMail(String to,String subject,String content); +} diff --git a/src/main/java/cc/ryanc/halo/service/PostService.java b/src/main/java/cc/ryanc/halo/service/PostService.java index b720ccc1f..89628e84a 100755 --- a/src/main/java/cc/ryanc/halo/service/PostService.java +++ b/src/main/java/cc/ryanc/halo/service/PostService.java @@ -28,7 +28,7 @@ public interface PostService { * @param postId postId * @return Post */ - Post removeByPostId(Integer postId); + Post removeByPostId(Long postId); /** * 修改文章 @@ -43,7 +43,7 @@ public interface PostService { * @param status status * @return Post */ - Post updatePostStatus(Integer postId,Integer status); + Post updatePostStatus(Long postId,Integer status); /** * 批量修改摘要 @@ -90,7 +90,7 @@ public interface PostService { * @param postId postId * @return Post */ - Post findByPostId(Integer postId); + Post findByPostId(Long postId); /** * 根据文章路径查询 @@ -133,6 +133,12 @@ public interface PostService { */ List findPostByYearAndMonth(String year,String month); + /** + * 根据年份和月份查询文章 分页 + * @param year year + * @param month month + * @param pageable pageable + * @return page + */ Page findPostByYearAndMonth(@Param("year") String year, @Param("month") String month, Pageable pageable); - } diff --git a/src/main/java/cc/ryanc/halo/service/TagService.java b/src/main/java/cc/ryanc/halo/service/TagService.java index d01b08f51..68050f9e5 100644 --- a/src/main/java/cc/ryanc/halo/service/TagService.java +++ b/src/main/java/cc/ryanc/halo/service/TagService.java @@ -24,7 +24,7 @@ public interface TagService { * @param tagId tagId * @return Tag */ - Tag removeByTagId(Integer tagId); + Tag removeByTagId(Long tagId); /** * 更新标签 @@ -44,7 +44,7 @@ public interface TagService { * @param tagId tagId * @return Link */ - Tag findByTagId(Integer tagId); + Tag findByTagId(Long tagId); /** * 根据标签路径查询 diff --git a/src/main/java/cc/ryanc/halo/service/UserService.java b/src/main/java/cc/ryanc/halo/service/UserService.java index 09671ac4a..5545bc9c2 100755 --- a/src/main/java/cc/ryanc/halo/service/UserService.java +++ b/src/main/java/cc/ryanc/halo/service/UserService.java @@ -36,5 +36,5 @@ public interface UserService { * @param userPass userpass * @return user */ - User findByUserIdAndUserPass(Integer userId,String userPass); + User findByUserIdAndUserPass(Long userId,String userPass); } diff --git a/src/main/java/cc/ryanc/halo/service/impl/AttachmentServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/AttachmentServiceImpl.java index ff38e3f9d..39e630395 100644 --- a/src/main/java/cc/ryanc/halo/service/impl/AttachmentServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/AttachmentServiceImpl.java @@ -43,12 +43,12 @@ public class AttachmentServiceImpl implements AttachmentService{ } @Override - public Attachment findByAttachId(Integer attachId) { + public Attachment findByAttachId(Long attachId) { return attachmentRepository.findOne(attachId); } @Override - public Attachment removeByAttachId(Integer attachId) { + public Attachment removeByAttachId(Long attachId) { Attachment attachment = this.findByAttachId(attachId); attachmentRepository.delete(attachment); return attachment; diff --git a/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java index 02310c7cf..04a564681 100755 --- a/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java @@ -48,7 +48,7 @@ public class CategoryServiceImpl implements CategoryService{ */ @CacheEvict(value = CATEGORY_CACHE_NAME,key = CATEGORY_KEY) @Override - public Category removeByCateId(Integer cateId) { + public Category removeByCateId(Long cateId) { Category category = this.findByCateId(cateId); categoryRepository.delete(category); return category; @@ -83,7 +83,7 @@ public class CategoryServiceImpl implements CategoryService{ */ @Cacheable(value = CATEGORY_CACHE_NAME,key = "#cateId+'cate'") @Override - public Category findByCateId(Integer cateId) { + public Category findByCateId(Long cateId) { return categoryRepository.findOne(cateId); } @@ -106,7 +106,7 @@ public class CategoryServiceImpl implements CategoryService{ List categories = new ArrayList<>(); Category category = null; for(String str:strings){ - category = findByCateId(Integer.parseInt(str)); + category = findByCateId(Long.parseLong(str)); categories.add(category); } return categories; diff --git a/src/main/java/cc/ryanc/halo/service/impl/CommentServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/CommentServiceImpl.java new file mode 100644 index 000000000..5b077885a --- /dev/null +++ b/src/main/java/cc/ryanc/halo/service/impl/CommentServiceImpl.java @@ -0,0 +1,116 @@ +package cc.ryanc.halo.service.impl; + +import cc.ryanc.halo.model.domain.Comment; +import cc.ryanc.halo.model.domain.Post; +import cc.ryanc.halo.repository.CommentRepository; +import cc.ryanc.halo.service.CommentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author : RYAN0UP + * @version : 1.0 + * description : + * @date : 2018/1/22 + */ +@Service +public class CommentServiceImpl implements CommentService { + + @Autowired + private CommentRepository commentRepository; + + /** + * 新增评论 + * + * @param comment comment + */ + @Override + public void saveByComment(Comment comment) { + commentRepository.save(comment); + } + + /** + * 查询所有的评论,用于后台管理 + * + * @param pageable pageable + * @return page + */ + @Override + public Page findAllComments(Integer status, Pageable pageable) { + return commentRepository.findCommentsByCommentStatus(status,pageable); + } + + /** + * 查询所有评论,不分页 + * + * @return + */ + @Override + public List findAllComments() { + return commentRepository.findAll(); + } + + /** + * 更改评论的状态 + * + * @param commentId commentId + * @param status status + * @return comment + */ + @Override + public Comment updateCommentStatus(Long commentId, Integer status) { + Comment comment = findCommentById(commentId); + comment.setCommentStatus(status); + return commentRepository.save(comment); + } + + /** + * 根据评论编号查询评论 + * + * @param commentId commentId + * @return comment + */ + @Override + public Comment findCommentById(Long commentId) { + return commentRepository.findOne(commentId); + } + + /** + * 根据文章查询评论 + * + * @param post post + * @param pageable pageable + * @return page + */ + @Override + public Page findCommentsByPost(Post post,Pageable pageable) { + return commentRepository.findCommentsByPost(post,pageable); + } + + /** + * 根据文章和评论状态查询评论 + * + * @param post post + * @param pageable pageable + * @param status status + * @return page + */ + @Override + public Page findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status) { + return commentRepository.findCommentsByPostAndCommentStatus(post,pageable,status); + } + + /** + * 查询最新的前五条评论 + * + * @return list + */ + @Override + public List findCommentsLatest() { + return commentRepository.findTopFive(); + } +} diff --git a/src/main/java/cc/ryanc/halo/service/impl/LinkServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/LinkServiceImpl.java index 47c5d350a..31ff6c93c 100755 --- a/src/main/java/cc/ryanc/halo/service/impl/LinkServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/LinkServiceImpl.java @@ -45,7 +45,7 @@ public class LinkServiceImpl implements LinkService { */ @CacheEvict(value = LINK_CACHE_NAME,key = LINK_KEY) @Override - public Link removeByLinkId(Integer linkId) { + public Link removeByLinkId(Long linkId) { Link link = this.findByLinkId(linkId); linkRepository.delete(link); return link; @@ -80,7 +80,7 @@ public class LinkServiceImpl implements LinkService { */ @Cacheable(value = LINK_CACHE_NAME,key = "#linkId+'link'") @Override - public Link findByLinkId(Integer linkId) { + public Link findByLinkId(Long linkId) { return linkRepository.findOne(linkId); } } diff --git a/src/main/java/cc/ryanc/halo/service/impl/LogsServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/LogsServiceImpl.java index 70ea1a8eb..0524c9735 100644 --- a/src/main/java/cc/ryanc/halo/service/impl/LogsServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/LogsServiceImpl.java @@ -40,7 +40,7 @@ public class LogsServiceImpl implements LogsService { * @return Logs */ @Override - public void removeByLogsId(Integer logsId) { + public void removeByLogsId(Long logsId) { Logs logs = this.findLogsByLogsId(logsId); logsRepository.delete(logs); } @@ -81,7 +81,7 @@ public class LogsServiceImpl implements LogsService { * @return logs */ @Override - public Logs findLogsByLogsId(Integer logsId) { + public Logs findLogsByLogsId(Long logsId) { return logsRepository.findOne(logsId); } } diff --git a/src/main/java/cc/ryanc/halo/service/impl/MailServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/MailServiceImpl.java new file mode 100644 index 000000000..e4352219c --- /dev/null +++ b/src/main/java/cc/ryanc/halo/service/impl/MailServiceImpl.java @@ -0,0 +1,81 @@ +package cc.ryanc.halo.service.impl; + +import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.service.MailService; +import freemarker.template.Template; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.stereotype.Service; +import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; +import javax.mail.internet.MimeMessage; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * @author : RYAN0UP + * @version : 1.0 + * description : + * @date : 2018/1/23 + */ +@Service +public class MailServiceImpl implements MailService{ + + private static final String HOST = HaloConst.OPTIONS.get("mail_smtp_host"); + private static final String USERNAME = HaloConst.OPTIONS.get("mail_smtp_username"); + private static final String PASSWORD = HaloConst.OPTIONS.get("mail_smtp_password"); + private static final String FROM_EMAIL = HaloConst.OPTIONS.get("mail_smtp_username"); + private static final String FROM_NAME = HaloConst.OPTIONS.get("mail_from_name"); + private static final JavaMailSenderImpl mailSender = createMailSender(); + + @Autowired + private FreeMarkerConfigurer freeMarker; + + /** + * 配置邮件发送器 + * @return JavaMailSenderImpl + */ + private static JavaMailSenderImpl createMailSender() { + JavaMailSenderImpl sender = new JavaMailSenderImpl(); + sender.setHost(HOST); + sender.setUsername(USERNAME); + sender.setPassword(PASSWORD); + sender.setDefaultEncoding("utf-8"); + Properties p = new Properties(); + p.setProperty("mail.smtp.auth", "true"); + p.setProperty("mail.smtp.timeout", "25000"); + p.setProperty("mail.smtp.starttls.enable","true"); + p.setProperty("mail.smtp.starttls.required","true"); + sender.setJavaMailProperties(p); + return sender; + } + + /** + * 发送邮件 + * @param to to + * @param subject subject + * @param content content + */ + @Override + public void sendMail(String to, String subject, String content) { + MimeMessage mimeMessage = mailSender.createMimeMessage(); + try { + MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true,"UTF-8"); + helper.setFrom(FROM_EMAIL,FROM_NAME); + helper.setTo(to); + helper.setSubject(subject); + + Template template = freeMarker.getConfiguration().getTemplate("common/mail.ftl"); + Map map = new HashMap(); + map.put("hahah","哈哈哈"); + map.put("hehehe","呵呵呵"); + content = FreeMarkerTemplateUtils.processTemplateIntoString(template,map); + helper.setText(content,true); + mailSender.send(mimeMessage); + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java index f7dca532b..41c581076 100755 --- a/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java @@ -51,7 +51,7 @@ public class PostServiceImpl implements PostService { */ @CacheEvict(value = POST_CACHE_NAME,key = POST_KEY) @Override - public Post removeByPostId(Integer postId) { + public Post removeByPostId(Long postId) { Post post = this.findByPostId(postId); postRepository.delete(post); return post; @@ -76,7 +76,7 @@ public class PostServiceImpl implements PostService { */ @CacheEvict(value = POST_CACHE_NAME,key = POST_KEY) @Override - public Post updatePostStatus(Integer postId, Integer status) { + public Post updatePostStatus(Long postId, Integer status) { Post post = this.findByPostId(postId); post.setPostStatus(status); return postRepository.save(post); @@ -158,7 +158,7 @@ public class PostServiceImpl implements PostService { */ @Cacheable(value = POST_CACHE_NAME,key = "#postId+'post'") @Override - public Post findByPostId(Integer postId) { + public Post findByPostId(Long postId) { return postRepository.findOne(postId); } diff --git a/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java index a2a846bd1..a35b82cbe 100644 --- a/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java @@ -38,7 +38,7 @@ public class TagServiceImpl implements TagService { * @return Tag */ @Override - public Tag removeByTagId(Integer tagId) { + public Tag removeByTagId(Long tagId) { Tag tag = findByTagId(tagId); tagRepository.delete(tag); return tag; @@ -72,7 +72,7 @@ public class TagServiceImpl implements TagService { * @return Link */ @Override - public Tag findByTagId(Integer tagId) { + public Tag findByTagId(Long tagId) { return tagRepository.findOne(tagId); } diff --git a/src/main/java/cc/ryanc/halo/service/impl/UserServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/UserServiceImpl.java index dbf4a4a80..efc24885d 100755 --- a/src/main/java/cc/ryanc/halo/service/impl/UserServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/UserServiceImpl.java @@ -56,7 +56,7 @@ public class UserServiceImpl implements UserService { * @return User */ @Override - public User findByUserIdAndUserPass(Integer userId, String userPass) { + public User findByUserIdAndUserPass(Long userId, String userPass) { return userRepository.findByUserIdAndUserPass(userId,userPass); } } diff --git a/src/main/java/cc/ryanc/halo/util/HaloUtil.java b/src/main/java/cc/ryanc/halo/util/HaloUtil.java index fdcdd90d3..4f8c239f7 100755 --- a/src/main/java/cc/ryanc/halo/util/HaloUtil.java +++ b/src/main/java/cc/ryanc/halo/util/HaloUtil.java @@ -2,12 +2,14 @@ package cc.ryanc.halo.util; import cc.ryanc.halo.model.domain.Post; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.model.dto.Theme; import com.sun.syndication.feed.rss.Channel; import com.sun.syndication.feed.rss.Content; import com.sun.syndication.feed.rss.Item; import com.sun.syndication.io.FeedException; import com.sun.syndication.io.WireFeedOutput; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.util.ResourceUtils; import javax.imageio.ImageIO; @@ -176,7 +178,7 @@ public class HaloUtil { } /** - * 获取所有文件 + * 获取所有附件 * @param filePath filePath * @return Map */ @@ -203,22 +205,55 @@ public class HaloUtil { } /** - * 获取当前时间 - * @return 字符串 + * 获取所有主题 + * @return list */ - public static String getStringDate() { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateString = formatter.format(new Date()); - return dateString; + public static List getThemes(){ + List themes = new ArrayList<>(); + try { + //获取项目根路径 + File basePath = new File(ResourceUtils.getURL("classpath:").getPath()); + //获取主题路径 + File themesPath = new File(basePath.getAbsolutePath(),"templates/themes"); + File[] files = themesPath.listFiles(); + if(null!=files) { + Theme theme = null; + for (File file : files) { + if (file.isDirectory()) { + theme = new Theme(); + theme.setThemeName(file.getName()); + File optionsPath = new File(themesPath.getAbsolutePath(), file.getName() + "/module/options.ftl"); + if (optionsPath.exists()) { + theme.setHasOptions(true); + } else { + theme.setHasOptions(false); + } + themes.add(theme); + } + } + } + }catch (Exception e){ + log.error("主题获取失败:"+e.getMessage()); + } + return themes; + } + + public static boolean removeFile(String fileName){ + File file = new File(fileName); + if(!file.exists()){ + return false; + }else{ + return file.delete(); + } } /** * 获取当前时间 - * @return 字符串使用下划线,用于备份文件名 + * @return 字符串 */ - public static String getStringDateWithLine(){ - SimpleDateFormat format = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss"); - String dateString = format.format(new Date()); + public static String getStringDate(String format) { + SimpleDateFormat formatter = new SimpleDateFormat(format); + String dateString = formatter.format(new Date()); return dateString; } @@ -446,4 +481,27 @@ public class HaloUtil { } return head+urlBody+""; } + +// public static String importMarkdowns(String filePath) throws Exception{ +// File file = new File(filePath); +// FileReader reader = new FileReader(file); +// BufferedReader bufferedReader = new BufferedReader(reader); +// StringBuffer stringBuffer = new StringBuffer(); +// String s = ""; +// while ((s = bufferedReader.readLine())!=null){ +// stringBuffer.append(s+"\n"); +// } +// bufferedReader.close(); +// String str = stringBuffer.toString(); +// return str; +// } +// +// public static void main(String[] args) throws Exception{ +// String content = importMarkdowns("/Users/ryan0up/Desktop/hello-hexo.md"); +// String matter = StringUtils.substringBetween(content,"---","---"); +// String[] strs = matter.split("\n"); +// for(String str:strs){ +// System.out.println(StringUtils.substringBetween("title","\n","\n")); +// } +// } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/BaseController.java b/src/main/java/cc/ryanc/halo/web/controller/BaseController.java index 0539d8a3d..04b11320e 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/BaseController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/BaseController.java @@ -1,7 +1,14 @@ package cc.ryanc.halo.web.controller; +import cc.ryanc.halo.model.domain.Comment; +import cc.ryanc.halo.service.CommentService; import cc.ryanc.halo.service.PostService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; + import javax.servlet.http.HttpSession; /** @@ -18,7 +25,7 @@ public abstract class BaseController { public static String THEME = "halo"; @Autowired - private PostService postService; + private CommentService commentService; /** * 渲染页面 @@ -29,7 +36,15 @@ public abstract class BaseController { return "themes/"+THEME+"/"+pageName; } + /** + * 获取新评论 + * @param session session + */ protected void getNewComments(HttpSession session){ - session.setAttribute("postTopFive",postService.findPostLatest()); + Sort sort = new Sort(Sort.Direction.DESC,"commentDate"); + Pageable pageable = new PageRequest(0,999,sort); + Page comments = commentService.findAllComments(1,pageable); + session.removeAttribute("newComments"); + session.setAttribute("newComments",comments.getContent()); } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/CommonController.java b/src/main/java/cc/ryanc/halo/web/controller/CommonController.java index ef036310e..23674651d 100644 --- a/src/main/java/cc/ryanc/halo/web/controller/CommonController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/CommonController.java @@ -1,40 +1,40 @@ -package cc.ryanc.halo.web.controller; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.autoconfigure.web.ErrorController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import javax.servlet.http.HttpServletRequest; -/** - * @author : RYAN0UP - * @date : 2017/12/26 - * @version: 1.0 - * description: - */ -@Slf4j -@Controller -public class CommonController implements ErrorController{ - - private static final String ERROR_PATH = "/error"; - - @GetMapping(value = ERROR_PATH) - public String handleError(HttpServletRequest request){ - Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); - if(statusCode==404) { - return "common/404"; - }else{ - return "common/500"; - } - } - - /** - * Returns the path of the error page. - * - * @return the error path - */ - @Override - public String getErrorPath() { - return ERROR_PATH; - } -} +package cc.ryanc.halo.web.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.web.ErrorController; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import javax.servlet.http.HttpServletRequest; +/** + * @author : RYAN0UP + * @date : 2017/12/26 + * @version : 1.0 + * description: + */ +@Slf4j +@Controller +public class CommonController implements ErrorController{ + + private static final String ERROR_PATH = "/error"; + + @GetMapping(value = ERROR_PATH) + public String handleError(HttpServletRequest request){ + Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); + if(statusCode==404) { + return "common/404"; + }else{ + return "common/500"; + } + } + + /** + * Returns the path of the error page. + * + * @return the error path + */ + @Override + public String getErrorPath() { + return ERROR_PATH; + } +} diff --git a/src/main/java/cc/ryanc/halo/web/controller/IndexController.java b/src/main/java/cc/ryanc/halo/web/controller/IndexController.java index 297c65c33..943cf1aee 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/IndexController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/IndexController.java @@ -1,18 +1,12 @@ package cc.ryanc.halo.web.controller; -import cc.ryanc.halo.model.domain.Category; -import cc.ryanc.halo.model.domain.Link; -import cc.ryanc.halo.model.domain.Post; -import cc.ryanc.halo.model.domain.Tag; +import cc.ryanc.halo.model.domain.*; import cc.ryanc.halo.model.dto.Archive; import cc.ryanc.halo.model.dto.HaloConst; -import cc.ryanc.halo.service.CategoryService; -import cc.ryanc.halo.service.LinkService; -import cc.ryanc.halo.service.PostService; -import cc.ryanc.halo.service.TagService; +import cc.ryanc.halo.service.*; import cc.ryanc.halo.util.HaloUtil; import lombok.extern.slf4j.Slf4j; -import org.apache.coyote.Response; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -20,11 +14,9 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.websocket.server.PathParam; import java.util.Date; import java.util.List; @@ -53,6 +45,11 @@ public class IndexController extends BaseController{ @Autowired private TagService tagService; + @Autowired + private CommentService commentService; + + @Autowired + private MailService mailService; /** * 请求首页 @@ -79,10 +76,9 @@ public class IndexController extends BaseController{ //默认显示10条 Integer size = 10; //尝试加载设置选项,用于设置显示条数 - if(HaloUtil.isNotNull(HaloConst.OPTIONS.get("index_posts"))){ + if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){ size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts")); } - //所有文章数据,分页 Pageable pageable = new PageRequest(page-1,size,sort); Page posts = postService.findPostByStatus(0,pageable); @@ -98,7 +94,7 @@ public class IndexController extends BaseController{ List categories = categoryService.findAllCategories(); model.addAttribute("categories",categories); - //归档数据,包含[year,month,List] + //归档数据,包含[year,month,count,List] List archives = postService.findPostGroupByPostDate(); model.addAttribute("archives",archives); return this.render("index"); @@ -116,7 +112,7 @@ public class IndexController extends BaseController{ //默认显示10条 Integer size = 10; //尝试加载设置选项,用于设置显示条数 - if(HaloUtil.isNotNull(HaloConst.OPTIONS.get("index_posts"))){ + if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){ size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts")); } @@ -164,6 +160,17 @@ public class IndexController extends BaseController{ //所有分类目录 List categories = categoryService.findAllCategories(); model.addAttribute("categories",categories); + + //归档数据,包含[year,month,count,List] + List archives = postService.findPostGroupByPostDate(); + + //该文章的评论 + Sort sort = new Sort(Sort.Direction.DESC,"commentDate"); + Pageable pageable = new PageRequest(0,10,sort); + Page comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,0); + model.addAttribute("comments",comments); + + model.addAttribute("archives",archives); return this.render("post"); } @@ -206,9 +213,15 @@ public class IndexController extends BaseController{ //系统设置 model.addAttribute("options",HaloConst.OPTIONS); + model.addAttribute("user",HaloConst.USER); + //所有分类目录 List categories = categoryService.findAllCategories(); model.addAttribute("categories",categories); + + //归档数据,包含[year,month,count,List] + List archives = postService.findPostGroupByPostDate(); + model.addAttribute("archives",archives); return this.render("links"); } @@ -227,6 +240,12 @@ public class IndexController extends BaseController{ List categories = categoryService.findAllCategories(); model.addAttribute("categories",categories); + model.addAttribute("user",HaloConst.USER); + + //归档数据,包含[year,month,count,List] + List archives = postService.findPostGroupByPostDate(); + model.addAttribute("archives",archives); + //系统设置 model.addAttribute("options",HaloConst.OPTIONS); return this.render("tags"); @@ -318,6 +337,10 @@ public class IndexController extends BaseController{ List categories = categoryService.findAllCategories(); model.addAttribute("categories",categories); + //归档数据,包含[year,month,count,List] + List archives = postService.findPostGroupByPostDate(); + model.addAttribute("archives",archives); + //是否是归档页,用于判断输出链接 model.addAttribute("isArchives","true"); return this.render("archives"); @@ -331,7 +354,7 @@ public class IndexController extends BaseController{ @ResponseBody public String feed(){ String rssPosts = HaloConst.OPTIONS.get("rss_posts"); - if(null==rssPosts || "".equals(rssPosts)){ + if(StringUtils.isBlank(rssPosts)){ rssPosts = "20"; } //获取文章列表并根据时间排序 @@ -362,4 +385,22 @@ public class IndexController extends BaseController{ List posts = postsPage.getContent(); return HaloUtil.getSiteMap(posts); } + + + /** + * 提交新评论 + * @param comment comment + * @return string + */ + @PostMapping(value = "/newComment") + @ResponseBody + public String newComment(@ModelAttribute("comment") Comment comment, + @ModelAttribute("post") Post post, + HttpServletRequest request){ + comment.setPost(post); + comment.setCommentDate(new Date()); + comment.setCommentAuthorIp(HaloUtil.getIpAddr(request)); + commentService.saveByComment(comment); + return "success"; + } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/AdminController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/AdminController.java index 57bd029ea..7615c1ade 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/AdminController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/AdminController.java @@ -1,11 +1,13 @@ package cc.ryanc.halo.web.controller.admin; +import cc.ryanc.halo.model.domain.Comment; import cc.ryanc.halo.model.domain.Logs; 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.dto.LogsRecord; import cc.ryanc.halo.model.dto.RespStatus; +import cc.ryanc.halo.service.CommentService; import cc.ryanc.halo.service.LogsService; import cc.ryanc.halo.service.PostService; import cc.ryanc.halo.service.UserService; @@ -49,6 +51,9 @@ public class AdminController extends BaseController{ @Autowired private HttpServletRequest request; + @Autowired + private CommentService commentService; + /** * 请求后台页面 * @return freemarker @@ -58,13 +63,21 @@ public class AdminController extends BaseController{ //查询文章条数 Integer postCount = postService.findAllPosts().size(); model.addAttribute("postCount",postCount); + //查询评论的条数 + Integer commentCount = commentService.findAllComments().size(); + model.addAttribute("commentCount",commentCount); //查询最新的文章 List postsLatest = postService.findPostLatest(); model.addAttribute("postTopFive",postsLatest); - model.addAttribute("options", HaloConst.OPTIONS); - model.addAttribute("mediaCount",HaloConst.ATTACHMENTS.size()); + //查询最新的日志 List logsLatest = logsService.findLogsLatest(); model.addAttribute("logs",logsLatest); + //查询最新的评论 + List comments = commentService.findCommentsLatest(); + model.addAttribute("comments",comments); + + model.addAttribute("options", HaloConst.OPTIONS); + model.addAttribute("mediaCount",HaloConst.ATTACHMENTS.size()); this.getNewComments(session); return "admin/index"; } @@ -147,6 +160,10 @@ public class AdminController extends BaseController{ return "admin/widget/_logs-all"; } + /** + * 清除所有日志 + * @return return + */ @GetMapping(value = "/logs/clear") public String logsClear(){ try { @@ -156,4 +173,15 @@ public class AdminController extends BaseController{ } return "redirect:/admin"; } + + /** + * 不可描述的页面 + * @param model model + * @return string + */ + @GetMapping(value = "/halo") + public String halo(Model model){ + model.addAttribute("options",HaloConst.OPTIONS); + return "admin/halo"; + } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java index 6bc9b9439..e0bb756db 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java @@ -24,7 +24,7 @@ import java.io.File; * @author : RYAN0UP * @date : 2017/12/19 * @version : 1.0 - * description: + * description: 附件 */ @Slf4j @Controller @@ -87,9 +87,9 @@ public class AttachmentController { * 上传文件 * @param file file */ - @RequestMapping(value = "/upload",method = RequestMethod.POST) + @PostMapping(value = "/upload",produces = { "application/json;charset=UTF-8" }) @ResponseBody - public String uploadAttachment(@RequestParam("file") MultipartFile file){ + public boolean uploadAttachment(@RequestParam("file") MultipartFile file){ if(!file.isEmpty()){ try{ File basePath = new File(ResourceUtils.getURL("classpath:").getPath()); @@ -117,15 +117,14 @@ public class AttachmentController { updateConst(); log.info("上传文件["+file.getOriginalFilename()+"]到["+mediaPath.getAbsolutePath()+"]成功"); - return RespStatus.SUCCESS; + return true; }catch (Exception e){ log.error("未知错误:"+e.getMessage()); - return RespStatus.ERROR; } }else { log.error("文件不能为空"); - return RespStatus.ERROR; } + return false; } /** @@ -134,7 +133,7 @@ public class AttachmentController { * @return string */ @GetMapping(value = "/attachment") - public String attachmentDetail(Model model,@PathParam("attachId") Integer attachId){ + public String attachmentDetail(Model model,@PathParam("attachId") Long attachId){ Attachment attachment = attachmentService.findByAttachId(attachId); model.addAttribute("attachment",attachment); return "admin/widget/_attachment-detail"; @@ -147,7 +146,7 @@ public class AttachmentController { */ @GetMapping(value = "/remove") @ResponseBody - public String removeAttachment(@PathParam("attachId") Integer attachId){ + public String removeAttachment(@PathParam("attachId") Long attachId){ Attachment attachment = attachmentService.findByAttachId(attachId); String delFileName = attachment.getAttachName(); String delSmallFileName = delFileName.substring(0,delFileName.lastIndexOf('.'))+"_small"+attachment.getAttachSuffix(); diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/BackupController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/BackupController.java index 3e7abd836..41799e3d7 100644 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/BackupController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/BackupController.java @@ -17,9 +17,9 @@ import java.util.List; /** * @author : RYAN0UP - * @version : 1.0 - * description : * @date : 2018/1/21 + * @version : 1.0 + * description : 备份 */ @Slf4j @Controller @@ -47,7 +47,7 @@ public class BackupController { */ @GetMapping(value = "/backupDb") public String backupDatabase(){ - String fileName = "db_backup_"+HaloUtil.getStringDateWithLine()+".sql"; + String fileName = "db_backup_"+HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss")+".sql"; try { File path = new File(ResourceUtils.getURL("classpath:").getPath()); String savePath = path.getAbsolutePath()+"/backup/database"; @@ -76,7 +76,7 @@ public class BackupController { List posts = postService.findAllPosts(); try { File path = new File(ResourceUtils.getURL("classpath:").getPath()); - String savePath = path.getAbsolutePath()+"/backup/posts/posts_backup_"+HaloUtil.getStringDateWithLine(); + String savePath = path.getAbsolutePath()+"/backup/posts/posts_backup_"+HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss"); for(Post post : posts){ HaloUtil.dbToFile(post.getPostContentMd(),savePath,post.getPostTitle()+".md"); } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/CategoryController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/CategoryController.java index 5d41cc1d3..f70c78c1b 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/CategoryController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/CategoryController.java @@ -78,7 +78,7 @@ public class CategoryController { * @return freemarker */ @GetMapping(value = "/remove") - public String removeCategory(@PathParam("cateId") Integer cateId){ + public String removeCategory(@PathParam("cateId") Long cateId){ try{ Category category = categoryService.removeByCateId(cateId); log.info("删除的分类目录:"+category); @@ -112,7 +112,7 @@ public class CategoryController { * @return String */ @GetMapping(value = "/edit") - public String toEditCategory(Model model,@PathParam("cateId") Integer cateId){ + public String toEditCategory(Model model,@PathParam("cateId") Long cateId){ try{ Category category = categoryService.findByCateId(cateId); model.addAttribute("category",category); diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/CommentController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/CommentController.java index 20c2f3e39..e9e075002 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/CommentController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/CommentController.java @@ -1,11 +1,26 @@ package cc.ryanc.halo.web.controller.admin; +import cc.ryanc.halo.model.domain.Comment; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.service.CommentService; +import cc.ryanc.halo.service.MailService; +import cc.ryanc.halo.service.PostService; +import cc.ryanc.halo.util.HaloUtil; import cc.ryanc.halo.web.controller.BaseController; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpSession; /** * @author : RYAN0UP @@ -13,12 +28,78 @@ import org.springframework.web.bind.annotation.RequestMapping; * @version : 1.0 * description : 评论系统管理 */ +@Slf4j @Controller -@RequestMapping(value = "/admin/comment") +@RequestMapping(value = "/admin/comments") public class CommentController extends BaseController{ + + @Autowired + private CommentService commentService; + + @Autowired + private MailService mailService; + + /** + * 渲染评论管理页面 + * @param model model + * @param status status + * @param page page + * @param size size + * @return string + */ @GetMapping - public String comments(Model model){ + public String comments(Model model, + @RequestParam(value = "status",defaultValue = "0") Integer status, + @RequestParam(value = "page",defaultValue = "0") Integer page, + @RequestParam(value = "size",defaultValue = "10") Integer size){ + Sort sort = new Sort(Sort.Direction.DESC,"commentDate"); + Pageable pageable = new PageRequest(page,size,sort); + Page comments = commentService.findAllComments(status,pageable); + model.addAttribute("comments",comments); + model.addAttribute("publicCount",commentService.findAllComments(0,pageable).getTotalElements()); + model.addAttribute("checkCount",commentService.findAllComments(1,pageable).getTotalElements()); + model.addAttribute("trashCount",commentService.findAllComments(2,pageable).getTotalElements()); + model.addAttribute("status",status); model.addAttribute("options", HaloConst.OPTIONS); return "admin/comment"; } + + /** + * 将评论移到回收站 + * @param commentId commentId + * @return string + */ + @GetMapping(value = "/throw") + public String moveToTrash(@RequestParam("commentId") Long commentId, + HttpSession session){ + try { + commentService.updateCommentStatus(commentId,2); + this.getNewComments(session); + }catch (Exception e){ + log.error("未知错误:"+e.getMessage()); + } + return "redirect:/admin/comments"; + } + + /** + * 将评论改变为发布状态 + * @param commentId commentId + * @param status status + * @return + */ + @GetMapping("/revert") + public String moveToPublish(@RequestParam("commentId") Long commentId, + @RequestParam("status") Integer status, + HttpSession session){ + try{ + Comment comment = commentService.updateCommentStatus(commentId,0); + if(status==1){ + mailService.sendMail(comment.getCommentAuthorEmail(),"你在"+ HaloConst.OPTIONS.get("site_title")+"的评论已通过审核","你在"+comment.getPost().getPostTitle()+"的评论已经通过审核!"); + } + this.getNewComments(session); + }catch (Exception e){ + log.error("未知错误:"+e.getMessage()); + } + return "redirect:/admin/comments?status="+status; + } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java index 14ef4be23..2ca7d44a7 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java @@ -31,7 +31,6 @@ public class OptionController { @GetMapping public String options(Model model){ model.addAttribute("options", HaloConst.OPTIONS); - log.info("所有的设置选项:"+HaloConst.OPTIONS); return "admin/option"; } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java index 0e53337b2..9d2115f7f 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java @@ -19,7 +19,7 @@ import java.util.List; * @author : RYAN0UP * @date : 2017/12/10 * @version : 1.0 - * description : + * description : 预设页面,自定义页面 */ @Slf4j @Controller @@ -58,7 +58,7 @@ public class PageController { * @return String */ @GetMapping(value = "/links/remove") - public String removeLink(@PathParam("linkId") Integer linkId){ + public String removeLink(@PathParam("linkId") Long linkId){ try{ Link link = linkService.removeByLinkId(linkId); log.info("删除的友情链接:"+link); @@ -105,7 +105,7 @@ public class PageController { * @return String */ @GetMapping("/links/edit") - public String toEditLink(Model model,@PathParam("linkId") Integer linkId){ + public String toEditLink(Model model,@PathParam("linkId") Long linkId){ Link link = linkService.findByLinkId(linkId); model.addAttribute("link",link); model.addAttribute("options", HaloConst.OPTIONS); diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java index b5086c008..68fb03fcd 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java @@ -69,12 +69,9 @@ public class PostController extends BaseController{ Pageable pageable = new PageRequest(page,size,sort); Page posts = postService.findPostByStatus(status,pageable); model.addAttribute("posts",posts); - List postsPublish = postService.findPostByStatus(0); - model.addAttribute("publishCount",postsPublish.size()); - List postsDraft = postService.findPostByStatus(1); - model.addAttribute("draftCount",postsDraft.size()); - List postsTrash = postService.findPostByStatus(2); - model.addAttribute("trashCount",postsTrash.size()); + model.addAttribute("publishCount",postService.findPostByStatus(0,pageable).getTotalElements()); + model.addAttribute("draftCount",postService.findPostByStatus(1,pageable).getTotalElements()); + model.addAttribute("trashCount",postService.findPostByStatus(2,pageable).getTotalElements()); model.addAttribute("options", HaloConst.OPTIONS); model.addAttribute("status",status); }catch (Exception e){ @@ -115,7 +112,7 @@ public class PostController extends BaseController{ * @return freemarker */ @GetMapping(value = "/view") - public String viewPost(@PathParam("postId") Integer postId,Model model){ + public String viewPost(@PathParam("postId") Long postId,Model model){ Post post = postService.findByPostId(postId); model.addAttribute("post",post); model.addAttribute("options", HaloConst.OPTIONS); @@ -179,7 +176,7 @@ public class PostController extends BaseController{ * @return String */ @GetMapping("/throw") - public String moveToTrash(@RequestParam("postId") Integer postId){ + public String moveToTrash(@RequestParam("postId") Long postId){ try{ postService.updatePostStatus(postId,2); log.info("编号为"+postId+"的文章已被移到回收站"); @@ -195,7 +192,7 @@ public class PostController extends BaseController{ * @return String */ @GetMapping("/revert") - public String moveToPublish(@RequestParam("postId") Integer postId, + public String moveToPublish(@RequestParam("postId") Long postId, @RequestParam("status") Integer status){ try{ postService.updatePostStatus(postId,0); @@ -212,7 +209,7 @@ public class PostController extends BaseController{ * @return 转发 */ @GetMapping(value = "/remove") - public String removePost(@PathParam("postId") Integer postId){ + public String removePost(@PathParam("postId") Long postId){ try{ Post post = postService.findByPostId(postId); postService.removeByPostId(postId); @@ -231,7 +228,7 @@ public class PostController extends BaseController{ * @return String */ @GetMapping(value = "/edit") - public String editPost(@PathParam("postId") Integer postId, Model model){ + public String editPost(@PathParam("postId") Long postId, Model model){ try { Post post = postService.findByPostId(postId); model.addAttribute("post",post); diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/TagController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/TagController.java index e11bec1b2..26fc0b6ba 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/TagController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/TagController.java @@ -17,7 +17,7 @@ import java.util.List; * @author : RYAN0UP * @date : 2017/12/10 * @version : 1.0 - * description: + * description: 标签控制器 */ @Slf4j @Controller @@ -78,7 +78,7 @@ public class TagController { * @return string */ @GetMapping(value = "/remove") - public String removeTag(@PathParam("tagId") Integer tagId){ + public String removeTag(@PathParam("tagId") Long tagId){ try{ Tag tag = tagService.removeByTagId(tagId); log.info("删除的标签:"+tag); @@ -95,7 +95,7 @@ public class TagController { * @return string */ @GetMapping(value = "/edit") - public String toEditTag(Model model,@PathParam("tagId") Integer tagId){ + public String toEditTag(Model model,@PathParam("tagId") Long tagId){ try{ Tag tag = tagService.findByTagId(tagId); model.addAttribute("tag",tag); diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java index 7bb4db31b..fc14f813e 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java @@ -19,7 +19,7 @@ import java.io.File; * @author : RYAN0UP * @date : 2017/12/16 * @version : 1.0 - * description: + * description: 主题控制器 */ @Slf4j @Controller @@ -28,19 +28,18 @@ public class ThemeController extends BaseController{ @Autowired private OptionsService optionsService; + /** * 渲染主题设置页面 * @return String */ @GetMapping public String themes(Model model){ - try { - model.addAttribute("theme",BaseController.THEME); - model.addAttribute("options", HaloConst.OPTIONS); - log.info("当前的主题为:"+BaseController.THEME); - }catch (Exception e){ - log.error("未知错误:"+e.getMessage()); + model.addAttribute("activeTheme",BaseController.THEME); + if(null!=HaloConst.THEMES){ + model.addAttribute("themes",HaloConst.THEMES); } + model.addAttribute("options", HaloConst.OPTIONS); return "admin/theme"; } @@ -72,7 +71,7 @@ public class ThemeController extends BaseController{ */ @RequestMapping(value = "/upload", method = RequestMethod.POST) @ResponseBody - public void uploadTheme(@RequestParam("file") MultipartFile file){ + public boolean uploadTheme(@RequestParam("file") MultipartFile file){ try { if(!file.isEmpty()) { //获取项目根路径 @@ -81,12 +80,18 @@ public class ThemeController extends BaseController{ file.transferTo(themePath); log.info("上传主题成功,路径:" + themePath.getAbsolutePath()); HaloUtil.unZip(themePath.getAbsolutePath(),new File(basePath.getAbsolutePath(),"templates/themes/").getAbsolutePath()); + HaloUtil.removeFile(themePath.getAbsolutePath()); + System.out.println(themePath); + HaloConst.THEMES.clear(); + HaloConst.THEMES = HaloUtil.getThemes(); + return true; }else{ log.error("上传失败,没有选择文件"); } }catch (Exception e){ log.error("上传失败:"+e.getMessage()); } + return false; } /** @@ -96,6 +101,7 @@ public class ThemeController extends BaseController{ @GetMapping(value = "/options") public String setting(Model model,@RequestParam("theme") String theme){ model.addAttribute("options",HaloConst.OPTIONS); + model.addAttribute("themeDir",theme); return "themes/"+theme+"/module/options"; } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java index f3b901a86..2e6c08aa9 100644 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java @@ -17,7 +17,7 @@ import javax.servlet.http.HttpSession; * @author : RYAN0UP * @date : 2017/12/24 * @version : 1.0 - * description: + * description: 用户控制 */ @Slf4j @Controller @@ -72,7 +72,7 @@ public class UserController { @ResponseBody public String changePass(@ModelAttribute("beforePass") String beforePass, @ModelAttribute("newPass") String newPass, - @ModelAttribute("userId") Integer userId, + @ModelAttribute("userId") Long userId, HttpSession session){ try { User user = userService.findByUserIdAndUserPass(userId,HaloUtil.getMD5(beforePass)); diff --git a/src/main/java/cc/ryanc/halo/web/interceptor/LoginInterceptor.java b/src/main/java/cc/ryanc/halo/web/interceptor/LoginInterceptor.java index 69a92148f..c36a2bf21 100755 --- a/src/main/java/cc/ryanc/halo/web/interceptor/LoginInterceptor.java +++ b/src/main/java/cc/ryanc/halo/web/interceptor/LoginInterceptor.java @@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse; * @author : RYAN0UP * @date : 2017/12/13 * @version : 1.0 - * description: + * description: 登录拦截器 */ @Component public class LoginInterceptor implements HandlerInterceptor{ diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index e2346f8f8..5f611ed04 100755 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -33,7 +33,18 @@ spring: http: multipart: max-file-size: 10Mb - max-request-size: 20Mb + max-request-size: + mail: + host: smtp.exmail.qq.com + username: i@ryanc.cc + password: Wangdashen666 + properties: + mail: + smtp: + auth: true + starttls: + enable: true + required: true # TODO config this ehcache cache: ehcache: @@ -43,3 +54,4 @@ logging: file: ./logs/log.log + diff --git a/src/main/resources/static/images/future.png b/src/main/resources/static/images/future.png deleted file mode 100644 index 6c6daa379..000000000 Binary files a/src/main/resources/static/images/future.png and /dev/null differ diff --git a/src/main/resources/static/images/next.jpg b/src/main/resources/static/images/next.jpg deleted file mode 100755 index 55a811b7e..000000000 Binary files a/src/main/resources/static/images/next.jpg and /dev/null differ diff --git a/src/main/resources/static/images/ryan0up.png b/src/main/resources/static/images/ryan0up.png deleted file mode 100755 index 4c1d8c752..000000000 Binary files a/src/main/resources/static/images/ryan0up.png and /dev/null differ diff --git a/src/main/resources/templates/admin/_cate-update.ftl b/src/main/resources/templates/admin/_cate-update.ftl index 5d3fbccba..b72b6616c 100755 --- a/src/main/resources/templates/admin/_cate-update.ftl +++ b/src/main/resources/templates/admin/_cate-update.ftl @@ -73,7 +73,6 @@ <#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/_link-update.ftl b/src/main/resources/templates/admin/_link-update.ftl index fa92ee639..5c95c6f2b 100755 --- a/src/main/resources/templates/admin/_link-update.ftl +++ b/src/main/resources/templates/admin/_link-update.ftl @@ -81,7 +81,6 @@ <#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/_md-editor.ftl b/src/main/resources/templates/admin/_md-editor.ftl index 9672270f7..b2f9f41fd 100644 --- a/src/main/resources/templates/admin/_md-editor.ftl +++ b/src/main/resources/templates/admin/_md-editor.ftl @@ -41,8 +41,8 @@ 永久链接: https://ryanc.cc/archives// - - + +
@@ -69,8 +69,8 @@
@@ -121,7 +121,7 @@
- +
@@ -257,6 +257,5 @@ <#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/_rt-editor.ftl b/src/main/resources/templates/admin/_rt-editor.ftl index 98128b4ba..0395f9677 100644 --- a/src/main/resources/templates/admin/_rt-editor.ftl +++ b/src/main/resources/templates/admin/_rt-editor.ftl @@ -130,7 +130,6 @@ <#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/_tag-update.ftl b/src/main/resources/templates/admin/_tag-update.ftl index 57a6c9ba5..d9f15bb2e 100755 --- a/src/main/resources/templates/admin/_tag-update.ftl +++ b/src/main/resources/templates/admin/_tag-update.ftl @@ -68,7 +68,6 @@ <#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/attachment.ftl b/src/main/resources/templates/admin/attachment.ftl index 929e16309..19a19be3c 100755 --- a/src/main/resources/templates/admin/attachment.ftl +++ b/src/main/resources/templates/admin/attachment.ftl @@ -9,6 +9,7 @@ <#include "module/_sidebar.ftl">
+

评论

- + +
+
+
+
+ + + + + + + + + + + + <#list comments.content as comment> + + + + + + + + + +
评论者评论内容评论页面日期操作
${comment.commentAuthor}${comment.commentContent} + ${comment.post.postTitle} + ${comment.commentDate} + <#switch comment.commentStatus> + <#case 0> + + + <#break > + <#case 1> + 通过 + + <#break > + <#case 2> + 还原 + + <#break > + +
+
+ +
+
+
+ + +
<#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/halo.ftl b/src/main/resources/templates/admin/halo.ftl new file mode 100644 index 000000000..a167d944f --- /dev/null +++ b/src/main/resources/templates/admin/halo.ftl @@ -0,0 +1,26 @@ +<#include "module/_macro.ftl"> +<@head title="Halo后台管理-关于Halo"> +
+ + <#include "module/_header.ftl"> + + <#include "module/_sidebar.ftl"> +
+
+

关于Halo

+ +
+
+

+ 非常感谢你使用Halo进行创作。 +

+
+
+ <#include "module/_footer.ftl"> +
+<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/index.ftl b/src/main/resources/templates/admin/index.ftl index 85054737b..6f02d31bf 100755 --- a/src/main/resources/templates/admin/index.ftl +++ b/src/main/resources/templates/admin/index.ftl @@ -41,10 +41,10 @@
@@ -52,10 +52,10 @@
@@ -63,10 +63,10 @@
@@ -74,10 +74,10 @@
@@ -87,10 +87,10 @@
@@ -98,10 +98,10 @@
@@ -109,10 +109,10 @@
@@ -138,9 +138,9 @@
-

53

评论

+

${commentCount?default(0)}

评论

- 查看所有 + 查看所有
@@ -182,13 +182,20 @@
- +
+ + + + + + + <#if postTopFive??> <#list postTopFive as post> - + @@ -95,8 +95,8 @@ @@ -138,7 +138,6 @@ <#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/theme.ftl b/src/main/resources/templates/admin/theme.ftl index f911ab474..495871a4f 100755 --- a/src/main/resources/templates/admin/theme.ftl +++ b/src/main/resources/templates/admin/theme.ftl @@ -80,48 +80,35 @@
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
+
@@ -133,11 +120,32 @@ $('#uploadTheme').fileinput({ language: 'zh', uploadUrl: '/admin/themes/upload', - allowedFileExtensions: ['zip'], + allowedFileExtensions: ['zip','jpg'], maxFileCount: 1, enctype: 'multipart/form-data', dropZoneTitle: '拖拽文件到这里 …
此模式不支持多文件同时上传', showClose: false + }).on("fileuploaded",function (event,data,previewId,index) { + var data = data.jqXHR.responseJSON; + if(data==true){ + $("#uploadForm").hide(400); + $.toast({ + text: "上传成功!", + heading: '提示', + icon: 'success', + showHideTransition: 'fade', + allowToastClose: true, + hideAfter: 1000, + stack: 1, + position: 'top-center', + textAlign: 'left', + loader: true, + loaderBg: '#ffffff', + afterHidden: function () { + window.location.reload(); + } + }); + } }); }); }); @@ -197,6 +205,5 @@
<#include "module/_footer.ftl"> -
<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/widget/_attachment-select.ftl b/src/main/resources/templates/admin/widget/_attachment-select.ftl index 4e2b6af73..f4606dad8 100644 --- a/src/main/resources/templates/admin/widget/_attachment-select.ftl +++ b/src/main/resources/templates/admin/widget/_attachment-select.ftl @@ -64,6 +64,7 @@ + + \ No newline at end of file diff --git a/src/main/resources/templates/common/mail.ftl b/src/main/resources/templates/common/mail.ftl new file mode 100644 index 000000000..a52dccfaf --- /dev/null +++ b/src/main/resources/templates/common/mail.ftl @@ -0,0 +1,14 @@ + + +
标题状态日期
${post.postTitle}${post.postTitle} <#if post.postStatus==0> 已发布 @@ -223,9 +230,46 @@
- +
+ + + + + + + - + <#if comments??> + + <#list comments as comment> + + + + + + + + + + <#else> + +
评论者评论页面内容状态时间
暂无数据
${comment.commentAuthor} + ${comment.post.postTitle} + + ${comment.commentContent} + + <#switch comment.commentStatus> + <#case 0> + 已发布 + <#break > + <#case 1> + 待审核 + <#break > + <#case 2> + 回收站 + <#break > + + ${comment.commentDate}
暂无数据
@@ -245,11 +289,14 @@
  • 查看所有
  • 清空日志
  • +
    - +
    @@ -325,6 +372,5 @@ <#include "module/_footer.ftl"> -
    <@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/link.ftl b/src/main/resources/templates/admin/link.ftl index cdc7ff090..0f9f2fcd4 100755 --- a/src/main/resources/templates/admin/link.ftl +++ b/src/main/resources/templates/admin/link.ftl @@ -115,7 +115,6 @@ <#include "module/_footer.ftl"> -
    <@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/login.ftl b/src/main/resources/templates/admin/login.ftl index 7a8846b1c..8e5fbea9e 100755 --- a/src/main/resources/templates/admin/login.ftl +++ b/src/main/resources/templates/admin/login.ftl @@ -71,7 +71,7 @@ showHideTransition: 'fade', allowToastClose: true, hideAfter: 1000, - stack: 5, + stack: 1, position: 'top-center', textAlign: 'left', loader: true, @@ -88,7 +88,7 @@ showHideTransition: 'fade', allowToastClose: true, hideAfter: 2000, - stack: 5, + stack: 1, position: 'top-center', textAlign: 'left', loader: true, diff --git a/src/main/resources/templates/admin/module/_footer.ftl b/src/main/resources/templates/admin/module/_footer.ftl index 6833634af..899ff3ff8 100755 --- a/src/main/resources/templates/admin/module/_footer.ftl +++ b/src/main/resources/templates/admin/module/_footer.ftl @@ -1,4 +1,4 @@ \ No newline at end of file diff --git a/src/main/resources/templates/admin/module/_header.ftl b/src/main/resources/templates/admin/module/_header.ftl index 7e7ce6223..b48efbbb3 100755 --- a/src/main/resources/templates/admin/module/_header.ftl +++ b/src/main/resources/templates/admin/module/_header.ftl @@ -13,37 +13,39 @@ - - diff --git a/src/main/resources/templates/admin/module/_sidebar.ftl b/src/main/resources/templates/admin/module/_sidebar.ftl index 6346e5b70..4df9215c9 100755 --- a/src/main/resources/templates/admin/module/_sidebar.ftl +++ b/src/main/resources/templates/admin/module/_sidebar.ftl @@ -2,7 +2,7 @@ - + + + + + + @@ -70,43 +77,38 @@
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - - +
    +
    事件 结果
    友情链接/link/links - 预览 - 配置 + 预览 + 配置 +
    图库页面/about + 预览 + 配置
    关于页面 /about - 预览 - 配置 + 预览 + 配置
    + + + + + + + + + + + + + + + + + + + + + + +
    标题路径日期操作
    友情链接/link日期 + 预览 + 配置 +
    关于页面/about日期 + 预览 + 配置 +
    +
    @@ -115,7 +117,6 @@ <#include "module/_footer.ftl"> -
    <@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/post.ftl b/src/main/resources/templates/admin/post.ftl index 947b5be14..3d0ed2c14 100755 --- a/src/main/resources/templates/admin/post.ftl +++ b/src/main/resources/templates/admin/post.ftl @@ -41,20 +41,6 @@
    -
    @@ -69,37 +55,43 @@ <#list posts.content as post> - - - - - - - - + + + + + + + +
    ${post.postTitle} - <#if post.categories??> - <#list post.categories as cate> - ${cate.cateName} - - - 无标签0${post.postDate?if_exists?string("yyyy-MM-dd HH:mm")} - <#switch post.postStatus> - <#case 0> - 预览 - 修改 - - <#break > - <#case 1> - 预览 - 修改 - - <#break > - <#case 2> - 还原 - - <#break > - -
    ${post.postTitle} + <#if post.categories?size gt 0> + <#list post.categories as cate> + ${cate.cateName} + + <#else > + 无分类 + + 无标签 + <#if post.getComments()??> + ${post.getComments()?size} + + ${post.postDate?if_exists?string("yyyy-MM-dd HH:mm")} + <#switch post.postStatus> + <#case 0> + 预览 + 修改 + + <#break > + <#case 1> + 预览 + 修改 + + <#break > + <#case 2> + 还原 + + <#break > + +
    @@ -151,7 +143,6 @@
    <#include "module/_footer.ftl"> -
    <@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/profile.ftl b/src/main/resources/templates/admin/profile.ftl index 084fd3bc5..e02aeca9d 100644 --- a/src/main/resources/templates/admin/profile.ftl +++ b/src/main/resources/templates/admin/profile.ftl @@ -77,7 +77,7 @@
    - +
    @@ -94,7 +94,7 @@
    @@ -122,7 +122,7 @@ @@ -224,7 +224,6 @@ <#include "module/_footer.ftl"> -
    <@footer> \ No newline at end of file diff --git a/src/main/resources/templates/admin/tag.ftl b/src/main/resources/templates/admin/tag.ftl index 9b8e4a814..212435eb7 100755 --- a/src/main/resources/templates/admin/tag.ftl +++ b/src/main/resources/templates/admin/tag.ftl @@ -43,7 +43,7 @@ @@ -70,8 +70,8 @@
    ${tag.tagUrl} 2 - 修改 - + 修改 +
    + + + + + + + + +
    发件人事件
    ${hahah}${hehehe}
    + + \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/archives.ftl b/src/main/resources/templates/themes/Anatole/archives.ftl index ab5576904..a1fb28a0a 100644 --- a/src/main/resources/templates/themes/Anatole/archives.ftl +++ b/src/main/resources/templates/themes/Anatole/archives.ftl @@ -1,154 +1,30 @@ - - - - - - - - - 归档 · ${options.site_title} - - - - - - - - - - - - - - - - +<#include "module/marco.ftl"> +<@head title="归档 · ${options.site_title?default('Anatole')}" keywords="文章归档,${options.seo_keywords?default('Anatole')}" description="${options.seo_desc?default('Anatole')}"> +<#include "module/sidebar.ftl">
    -
    - -
    -
    -
  • - -
  • -
    -
    - -
    -
    -
    + <#include "module/page-top.ftl">
      -
      - <#list archives as archive> -
      ${archive.year}.${archive.month}
      -
        - <#list archive.posts as post> -
        -
        - ${post.postTitle} -
        - ${post.postDate?string("MM-dd")} -
        -
        + <#list archives as archive> +
        ${archive.year}.${archive.month}
        +
          + <#list archive.posts as post> +
          +
          + ${post.postTitle} +
          + ${post.postDate?string("yyyy-MM-dd")}
          - -
        - - +
        +
      + +
    +
    - - - - - - - - - \ No newline at end of file +<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/index.ftl b/src/main/resources/templates/themes/Anatole/index.ftl index ca63f3c15..441e7e8f3 100644 --- a/src/main/resources/templates/themes/Anatole/index.ftl +++ b/src/main/resources/templates/themes/Anatole/index.ftl @@ -1,164 +1,34 @@ - - - - - - - - - ${options.site_title} - - - - - - - - - - - - - - - - +<#include "module/marco.ftl"> +<@head title="${options.site_title?default('Anatole')}" keywords="${options.seo_keywords?default('Anatole')}" description="${options.seo_desc?default('Anatole')}"> +<#include "module/sidebar.ftl">
    -
    - -
    -
    -
  • - -
  • -
    -
    - -
    -
    -
    + <#include "module/page-top.ftl">
    - <#list posts.content as post> -
    -
    -

    - ${post.postTitle} -

    -
    -
    -

    ${post.postSummary?if_exists}...

    -
    - -
    - + <#include "module/post_entry.ftl"> + <#if posts.totalPages gt 1> +
    - - - - - - - - \ No newline at end of file +<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/links.ftl b/src/main/resources/templates/themes/Anatole/links.ftl index 71e4831eb..3205f06b5 100644 --- a/src/main/resources/templates/themes/Anatole/links.ftl +++ b/src/main/resources/templates/themes/Anatole/links.ftl @@ -1,294 +1,23 @@ - - - - - - - - - links · 可乐没气的猫 - - - - - - - - - - - - - - - - - +<#include "module/marco.ftl"> +<@head title="友情链接 · ${options.site_title?default('Anatole')}" keywords="${options.seo_keywords?default('Anatole')}" description="${options.seo_desc?default('Anatole')}"> +<#include "module/sidebar.ftl">
    -
    - -
    -
    -
  • - -
  • -
    -
    - -
    -
    -
    + <#include "module/page-top.ftl">
    -

    - links -

    +

    links

    -

    - FOCKSHOP – 独立原创品牌视觉工作室

    -

    - 创造狮 – 为创意工作者而设计

    -

    - 爱追梦 – 一条挣扎在咸鱼标签上的咸鱼

    -

    - Zohar’s Blog – 一个关注IT、分享技术的个人博客

    -

    - xcatliu – A cat who writes code

    -

    - BEET’S BLOG – just talk something!

    -

    - 梦魇小栈 – 心,若没有栖息的地方,到哪里都是流浪……

    -

    - neoFelhz’s Blog – 孤独之人 不应执着 为何仍追逐幻梦

    -

    - Sibyl的博客 – 没有白吃的午餐,只有白痴的无惨

    -
    -
    - -
    -
    -
    - - - - -
    -
    - 0 条评论 - Disqus 讨论区 -
    -
    -
    - -
    -
    -
    - -
    -
    -
      -
      -
      -
      -
      -
      -
      - - - - -
      -
      - - -
      -
      -
      - -
      -
      -
        - 加载更多 -
        - -
        - - -
        - - - - - - - - - \ No newline at end of file +<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/themes/halo/module/comment.ftl b/src/main/resources/templates/themes/Anatole/module/comment.ftl similarity index 79% rename from src/main/resources/templates/themes/halo/module/comment.ftl rename to src/main/resources/templates/themes/Anatole/module/comment.ftl index cf004c2cb..63173322d 100644 --- a/src/main/resources/templates/themes/halo/module/comment.ftl +++ b/src/main/resources/templates/themes/Anatole/module/comment.ftl @@ -6,4 +6,6 @@ <#include "../../../common/comment/_livere_comment.ftl"> <#elseif (options.comment_system!)=='changyan'> <#include "../../../common/comment/_changyan_comment.ftl"> +<#elseif (options.comment_system!)=='native'> + <#include "../../../common/comment/_native_comment.ftl"> \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/module/marco.ftl b/src/main/resources/templates/themes/Anatole/module/marco.ftl new file mode 100644 index 000000000..2eccce2af --- /dev/null +++ b/src/main/resources/templates/themes/Anatole/module/marco.ftl @@ -0,0 +1,29 @@ +<#macro head title="" keywords="" description=""> + + + + + + ${title?default("Anatole")} + + + + + + + + + + + + + + + +<#macro footer> + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/module/options.ftl b/src/main/resources/templates/themes/Anatole/module/options.ftl new file mode 100644 index 000000000..90b4d0448 --- /dev/null +++ b/src/main/resources/templates/themes/Anatole/module/options.ftl @@ -0,0 +1,131 @@ + + + + + + + + + + + + +
        +
        +
        + +
        +
        + +
        +
        +
        + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/module/page-top.ftl b/src/main/resources/templates/themes/Anatole/module/page-top.ftl new file mode 100644 index 000000000..5414b5d75 --- /dev/null +++ b/src/main/resources/templates/themes/Anatole/module/page-top.ftl @@ -0,0 +1,26 @@ +
        + +
        +
        +
      • + +
      • +
        +
        + +
        +
        +
        \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/module/post_entry.ftl b/src/main/resources/templates/themes/Anatole/module/post_entry.ftl new file mode 100644 index 000000000..9b3882cc2 --- /dev/null +++ b/src/main/resources/templates/themes/Anatole/module/post_entry.ftl @@ -0,0 +1,31 @@ +<#list posts.content as post> +
        +
        +

        + ${post.postTitle} +

        +
        +
        +
        +

        ${post.postSummary?if_exists}...

        +
        +
        +

        +
        +
        + +
        + \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/module/sidebar.ftl b/src/main/resources/templates/themes/Anatole/module/sidebar.ftl new file mode 100644 index 000000000..94c2f9042 --- /dev/null +++ b/src/main/resources/templates/themes/Anatole/module/sidebar.ftl @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/module/social-list.ftl b/src/main/resources/templates/themes/Anatole/module/social-list.ftl new file mode 100644 index 000000000..76f333230 --- /dev/null +++ b/src/main/resources/templates/themes/Anatole/module/social-list.ftl @@ -0,0 +1,57 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/post.ftl b/src/main/resources/templates/themes/Anatole/post.ftl index 8bdbebaad..14db3e2b8 100644 --- a/src/main/resources/templates/themes/Anatole/post.ftl +++ b/src/main/resources/templates/themes/Anatole/post.ftl @@ -1,103 +1,8 @@ - - - - - - - - ${post.postTitle} · ${options.site_title} - - - - - - - - - - - - - - - - - +<#include "module/marco.ftl"> +<@head title="${post.postTitle} · ${options.site_title?default('Anatole')}" keywords="${post.postTitle},${options.seo_keywords?default('Anatole')}" description="${options.seo_desc?default('Anatole')}"> +<#include "module/sidebar.ftl">
        -
        - -
        -
        -
      • - -
      • -
        -
        - -
        -
        -
        + <#include "module/page-top.ftl">
        @@ -114,70 +19,50 @@
        - 2018-01-08 + ${post.postDate?string("yyyy-MM-dd")} - 评论 + Comments - 技术6 - 动态范围 - 宽容度 - RAW - Log +  App +  Evernote +  Mac
        - -
        +
        + <#include "module/comment.ftl"> +
        - - - - - - - - \ No newline at end of file +<@footer> \ No newline at end of file diff --git a/src/main/resources/templates/themes/Anatole/screenshot.png b/src/main/resources/templates/themes/Anatole/screenshot.png new file mode 100644 index 000000000..5f74efc22 Binary files /dev/null and b/src/main/resources/templates/themes/Anatole/screenshot.png differ diff --git a/src/main/resources/templates/themes/halo/archives.ftl b/src/main/resources/templates/themes/Halo/archives.ftl similarity index 100% rename from src/main/resources/templates/themes/halo/archives.ftl rename to src/main/resources/templates/themes/Halo/archives.ftl diff --git a/src/main/resources/templates/themes/halo/index.ftl b/src/main/resources/templates/themes/Halo/index.ftl similarity index 100% rename from src/main/resources/templates/themes/halo/index.ftl rename to src/main/resources/templates/themes/Halo/index.ftl diff --git a/src/main/resources/templates/themes/halo/links.ftl b/src/main/resources/templates/themes/Halo/links.ftl similarity index 100% rename from src/main/resources/templates/themes/halo/links.ftl rename to src/main/resources/templates/themes/Halo/links.ftl diff --git a/src/main/resources/templates/themes/Halo/module/comment.ftl b/src/main/resources/templates/themes/Halo/module/comment.ftl new file mode 100644 index 000000000..63173322d --- /dev/null +++ b/src/main/resources/templates/themes/Halo/module/comment.ftl @@ -0,0 +1,11 @@ +<#if (options.comment_system!)=='valine'> + <#include "../../../common/comment/_valine_comment.ftl"> +<#elseif (options.comment_system!)=='disqus'> + <#include "../../../common/comment/_disqus_comment.ftl"> +<#elseif (options.comment_system!)=='livere'> + <#include "../../../common/comment/_livere_comment.ftl"> +<#elseif (options.comment_system!)=='changyan'> + <#include "../../../common/comment/_changyan_comment.ftl"> +<#elseif (options.comment_system!)=='native'> + <#include "../../../common/comment/_native_comment.ftl"> + \ No newline at end of file diff --git a/src/main/resources/templates/themes/halo/module/header.ftl b/src/main/resources/templates/themes/Halo/module/header.ftl similarity index 100% rename from src/main/resources/templates/themes/halo/module/header.ftl rename to src/main/resources/templates/themes/Halo/module/header.ftl diff --git a/src/main/resources/templates/themes/halo/module/macro.ftl b/src/main/resources/templates/themes/Halo/module/macro.ftl similarity index 96% rename from src/main/resources/templates/themes/halo/module/macro.ftl rename to src/main/resources/templates/themes/Halo/module/macro.ftl index b4930aef1..99c0162fc 100644 --- a/src/main/resources/templates/themes/halo/module/macro.ftl +++ b/src/main/resources/templates/themes/Halo/module/macro.ftl @@ -62,7 +62,7 @@ ${options.statistics_code?if_exists} -<#if options.theme_halo_pjax == "true"> +<#if options.theme_halo_pjax?default("true") == "true"> @@ -75,7 +75,7 @@ NProgress.done(); }, 1000); }); - <#if options.theme_halo_pjax == "true"> + <#if options.theme_halo_pjax?default("true") == "true"> $(document).pjax('a[target!=_blank]', '.wrapper', {fragment: '.wrapper',timeout: 8000}); $(document).on('pjax:start', NProgress.start).on('pjax:end', NProgress.done); diff --git a/src/main/resources/templates/themes/halo/module/options.ftl b/src/main/resources/templates/themes/Halo/module/options.ftl similarity index 98% rename from src/main/resources/templates/themes/halo/module/options.ftl rename to src/main/resources/templates/themes/Halo/module/options.ftl index 4ff1bca52..9278797fc 100644 --- a/src/main/resources/templates/themes/halo/module/options.ftl +++ b/src/main/resources/templates/themes/Halo/module/options.ftl @@ -22,7 +22,7 @@
        - +