mirror of https://github.com/halo-dev/halo
👽 细节修复
parent
767fa132b6
commit
75caa32785
61
PREVIEW.md
61
PREVIEW.md
|
@ -1,61 +0,0 @@
|
||||||
# Halo界面预览
|
|
||||||
|
|
||||||
## 安装页
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 后台登录
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 后台首页
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 文章列表
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 文章编辑
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 标签列表
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 预设页面
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 附件页面
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 评论管理
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 菜单管理
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 系统设置
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 主题管理
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Material主题(感谢[Viosey](https://viosey.com))
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Anatole主题(感谢[Caicai](https://www.caicai.me/))
|
|
||||||
|
|
||||||

|
|
|
@ -42,13 +42,13 @@ Let's start: http://localhost:8090
|
||||||
|
|
||||||
## Demo 演示
|
## Demo 演示
|
||||||
|
|
||||||
[界面预览](PREVIEW.md)
|
[界面预览](https://halo-doc.ryanc.cc/preview)
|
||||||
|
|
||||||
[Ryan0up'S Blog](https://ryanc.cc)
|
[Ryan0up'S Blog](https://ryanc.cc)
|
||||||
|
|
||||||
[SNAIL BLOG](https://slogc.cc)
|
[SNAIL BLOG](https://slogc.cc)
|
||||||
|
|
||||||
[宋浩志博客](http://songhaozhi.com/)
|
[宋浩志博客](http://songhaozhi.com)
|
||||||
|
|
||||||
## Download 下载
|
## Download 下载
|
||||||
|
|
||||||
|
|
5
pom.xml
5
pom.xml
|
@ -65,15 +65,14 @@
|
||||||
<version>${oh-my-email.version}</version>
|
<version>${oh-my-email.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- mysql -->
|
<!-- mysql-->
|
||||||
<!--
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
|
|
||||||
|
<!-- H2Database -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class FreeMarkerConfig {
|
||||||
private ArticleTagDirective articleTagDirective;
|
private ArticleTagDirective articleTagDirective;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void setSharedVariable(){
|
public void setSharedVariable() {
|
||||||
configuration.setSharedVariable("commonTag",commonTagDirective);
|
configuration.setSharedVariable("commonTag", commonTagDirective);
|
||||||
configuration.setSharedVariable("articleTag",articleTagDirective);
|
configuration.setSharedVariable("articleTag", articleTagDirective);
|
||||||
try{
|
try {
|
||||||
configuration.setSharedVariable("options",optionsService.findAllOptions());
|
configuration.setSharedVariable("options", optionsService.findAllOptions());
|
||||||
configuration.setSharedVariable("user",userService.findUser());
|
configuration.setSharedVariable("user", userService.findUser());
|
||||||
}catch (TemplateModelException e){
|
} catch (TemplateModelException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/2
|
* @date : 2018/1/2
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Map;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/12/22
|
* @date : 2017/12/22
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description: Springboot启动后
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package cc.ryanc.halo.config;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.security.XssFilter;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2018/5/4
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class XssConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean xssFilterRegistrationBean() {
|
||||||
|
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
||||||
|
filterRegistrationBean.setFilter(new XssFilter());
|
||||||
|
filterRegistrationBean.setOrder(1);
|
||||||
|
filterRegistrationBean.setEnabled(true);
|
||||||
|
filterRegistrationBean.addUrlPatterns("/*");
|
||||||
|
Map<String, String> initParameters = Maps.newHashMap();
|
||||||
|
//后台不做拦截请求
|
||||||
|
initParameters.put("excludes", "/admin/*");
|
||||||
|
initParameters.put("isIncludeRichText", "true");
|
||||||
|
filterRegistrationBean.setInitParameters(initParameters);
|
||||||
|
return filterRegistrationBean;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,14 +11,13 @@ import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/10
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/10
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_attachment")
|
@Table(name = "halo_attachment")
|
||||||
public class Attachment implements Serializable{
|
public class Attachment implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3060117944880138064L;
|
private static final long serialVersionUID = 3060117944880138064L;
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,13 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/30
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 分类目录实体类
|
* @date : 2017/11/30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_category")
|
@Table(name = "halo_category")
|
||||||
public class Category implements Serializable{
|
public class Category implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 8383678847517271505L;
|
private static final long serialVersionUID = 8383678847517271505L;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.Date;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/22
|
* @date : 2018/1/22
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 评论实体类
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -7,15 +7,12 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/2/26
|
* @date : 2018/2/26
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_gallery")
|
@Table(name = "halo_gallery")
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 友情链接的实体类
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -11,9 +11,8 @@ import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/19
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 操作日志实体类
|
* @date : 2018/1/19
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -49,7 +48,8 @@ public class Logs implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Date logCreated;
|
private Date logCreated;
|
||||||
|
|
||||||
public Logs() { }
|
public Logs() {
|
||||||
|
}
|
||||||
|
|
||||||
public Logs(String logTitle, String logContent, String logIp, Date logCreated) {
|
public Logs(String logTitle, String logContent, String logIp, Date logCreated) {
|
||||||
this.logTitle = logTitle;
|
this.logTitle = logTitle;
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/24
|
* @date : 2018/1/24
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 设置实体类
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -5,18 +5,19 @@ import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 文章实体类
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_post")
|
@Table(name = "halo_post")
|
||||||
public class Post implements Serializable{
|
public class Post implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6019684584665869629L;
|
private static final long serialVersionUID = -6019684584665869629L;
|
||||||
|
|
||||||
|
@ -72,25 +73,25 @@ public class Post implements Serializable{
|
||||||
/**
|
/**
|
||||||
* 文章所属分类
|
* 文章所属分类
|
||||||
*/
|
*/
|
||||||
@ManyToMany(cascade = {CascadeType.PERSIST},fetch = FetchType.LAZY)
|
@ManyToMany(cascade = {CascadeType.PERSIST}, fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "halo_posts_categories",
|
@JoinTable(name = "halo_posts_categories",
|
||||||
joinColumns = {@JoinColumn(name = "post_id",nullable = false)},
|
joinColumns = {@JoinColumn(name = "post_id", nullable = false)},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "cate_id",nullable = false)})
|
inverseJoinColumns = {@JoinColumn(name = "cate_id", nullable = false)})
|
||||||
private List<Category> categories = new ArrayList<>();
|
private List<Category> categories = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章所属标签
|
* 文章所属标签
|
||||||
*/
|
*/
|
||||||
@ManyToMany(cascade = {CascadeType.PERSIST},fetch = FetchType.LAZY)
|
@ManyToMany(cascade = {CascadeType.PERSIST}, fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "halo_posts_tags",
|
@JoinTable(name = "halo_posts_tags",
|
||||||
joinColumns = {@JoinColumn(name = "post_id",nullable = false)},
|
joinColumns = {@JoinColumn(name = "post_id", nullable = false)},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "tag_id",nullable = false)})
|
inverseJoinColumns = {@JoinColumn(name = "tag_id", nullable = false)})
|
||||||
private List<Tag> tags = new ArrayList<>();
|
private List<Tag> tags = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章的评论
|
* 文章的评论
|
||||||
*/
|
*/
|
||||||
@OneToMany(mappedBy = "post",cascade = {CascadeType.REMOVE},fetch = FetchType.EAGER)
|
@OneToMany(mappedBy = "post", cascade = {CascadeType.REMOVE}, fetch = FetchType.EAGER)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private List<Comment> comments = new ArrayList<>();
|
private List<Comment> comments = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,11 @@ import java.util.List;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/12
|
* @date : 2018/1/12
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 文章标签实体类
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_tag")
|
@Table(name = "halo_tag")
|
||||||
public class Tag implements Serializable{
|
public class Tag implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -7501342327884372194L;
|
private static final long serialVersionUID = -7501342327884372194L;
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,22 @@ package cc.ryanc.halo.model.domain;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 用户实体类
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_user")
|
@Table(name = "halo_user")
|
||||||
public class User implements Serializable{
|
public class User implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5144055068797033748L;
|
private static final long serialVersionUID = -5144055068797033748L;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package cc.ryanc.halo.model.dto;
|
package cc.ryanc.halo.model.dto;
|
||||||
|
|
||||||
import cc.ryanc.halo.model.domain.Attachment;
|
import cc.ryanc.halo.model.domain.Attachment;
|
||||||
import cc.ryanc.halo.model.domain.User;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -12,7 +11,7 @@ import java.util.Map;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/12/29
|
* @date : 2017/12/29
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description: 环境常量
|
* description: 常量
|
||||||
*/
|
*/
|
||||||
public class HaloConst {
|
public class HaloConst {
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,8 @@ package cc.ryanc.halo.model.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/19
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/19
|
||||||
*/
|
*/
|
||||||
public interface LogsRecord {
|
public interface LogsRecord {
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.io.Serializable;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/3
|
* @date : 2018/1/3
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 主题数据
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class Theme implements Serializable {
|
public class Theme implements Serializable {
|
||||||
|
|
|
@ -26,17 +26,17 @@ public class ArticleTagDirective implements TemplateDirectiveModel {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
|
public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
|
||||||
DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
|
DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
|
||||||
if(map.containsKey(METHOD_KEY)){
|
if (map.containsKey(METHOD_KEY)) {
|
||||||
String method = map.get(METHOD_KEY).toString();
|
String method = map.get(METHOD_KEY).toString();
|
||||||
switch (method){
|
switch (method) {
|
||||||
case "postsCount":
|
case "postsCount":
|
||||||
environment.setVariable("postsCount",builder.build().wrap(postService.findAllPosts(HaloConst.POST_TYPE_POST).size()));
|
environment.setVariable("postsCount", builder.build().wrap(postService.findAllPosts(HaloConst.POST_TYPE_POST).size()));
|
||||||
break;
|
break;
|
||||||
case "archives":
|
case "archives":
|
||||||
environment.setVariable("archives",builder.build().wrap(postService.findPostGroupByYearAndMonth()));
|
environment.setVariable("archives", builder.build().wrap(postService.findPostGroupByYearAndMonth()));
|
||||||
break;
|
break;
|
||||||
case "archivesLess":
|
case "archivesLess":
|
||||||
environment.setVariable("archivesLess",builder.build().wrap(postService.findPostGroupByYear()));
|
environment.setVariable("archivesLess", builder.build().wrap(postService.findPostGroupByYear()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -33,17 +33,17 @@ public class CommonTagDirective implements TemplateDirectiveModel {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
|
public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
|
||||||
DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
|
DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
|
||||||
if(map.containsKey(METHOD_KEY)){
|
if (map.containsKey(METHOD_KEY)) {
|
||||||
String method = map.get(METHOD_KEY).toString();
|
String method = map.get(METHOD_KEY).toString();
|
||||||
switch (method){
|
switch (method) {
|
||||||
case "menus":
|
case "menus":
|
||||||
environment.setVariable("menus",builder.build().wrap(menuService.findAllMenus()));
|
environment.setVariable("menus", builder.build().wrap(menuService.findAllMenus()));
|
||||||
break;
|
break;
|
||||||
case "categories":
|
case "categories":
|
||||||
environment.setVariable("categories",builder.build().wrap(categoryService.findAllCategories()));
|
environment.setVariable("categories", builder.build().wrap(categoryService.findAllCategories()));
|
||||||
break;
|
break;
|
||||||
case "newComments":
|
case "newComments":
|
||||||
environment.setVariable("newComments",builder.build().wrap(commentService.findAllComments(1)));
|
environment.setVariable("newComments", builder.build().wrap(commentService.findAllComments(1)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -7,17 +7,16 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/10
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/10
|
||||||
*/
|
*/
|
||||||
public interface AttachmentRepository extends JpaRepository<Attachment,Long>{
|
public interface AttachmentRepository extends JpaRepository<Attachment, Long> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有附件,分页
|
* 查询所有附件,分页
|
||||||
*
|
*
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
Page<Attachment> findAll(Pageable pageable);
|
Page<Attachment> findAll(Pageable pageable);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/30
|
* @date : 2017/11/30
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description: 分类目录持久层
|
|
||||||
*/
|
*/
|
||||||
public interface CategoryRepository extends JpaRepository<Category,Long>{
|
public interface CategoryRepository extends JpaRepository<Category,Long>{
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.util.List;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/22
|
* @date : 2018/1/22
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
public interface CommentRepository extends JpaRepository<Comment,Long> {
|
public interface CommentRepository extends JpaRepository<Comment,Long> {
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/2/26
|
* @date : 2018/2/26
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
public interface GalleryRepository extends JpaRepository<Gallery,Long> {
|
public interface GalleryRepository extends JpaRepository<Gallery,Long> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description: 友情链接持久层
|
|
||||||
*/
|
*/
|
||||||
public interface LinkRepository extends JpaRepository<Link,Long>{
|
public interface LinkRepository extends JpaRepository<Link,Long>{
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.List;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/19
|
* @date : 2018/1/19
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
public interface LogsRepository extends JpaRepository<Logs,Long> {
|
public interface LogsRepository extends JpaRepository<Logs,Long> {
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/24
|
* @date : 2018/1/24
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
public interface MenuRepository extends JpaRepository<Menu,Long> {
|
public interface MenuRepository extends JpaRepository<Menu,Long> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description: 设置选项持久层
|
|
||||||
*/
|
*/
|
||||||
public interface OptionsRepository extends JpaRepository<Options,Long>{
|
public interface OptionsRepository extends JpaRepository<Options,Long>{
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.List;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description : 文章持久层
|
|
||||||
*/
|
*/
|
||||||
public interface PostRepository extends JpaRepository<Post,Long>{
|
public interface PostRepository extends JpaRepository<Post,Long>{
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/12
|
* @date : 2018/1/12
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
|
||||||
*/
|
*/
|
||||||
public interface TagRepository extends JpaRepository<Tag,Long>{
|
public interface TagRepository extends JpaRepository<Tag,Long>{
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.util.List;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
|
||||||
*/
|
*/
|
||||||
public interface UserRepository extends JpaRepository<User,Long>{
|
public interface UserRepository extends JpaRepository<User,Long>{
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package cc.ryanc.halo.security;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.safety.Whitelist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2018/5/4
|
||||||
|
*/
|
||||||
|
public class JsoupUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 白名单
|
||||||
|
*/
|
||||||
|
private static final Whitelist whitelist = Whitelist.basicWithImages();
|
||||||
|
|
||||||
|
private static final Document.OutputSettings outputSettings = new Document.OutputSettings().prettyPrint(false);
|
||||||
|
|
||||||
|
static {
|
||||||
|
whitelist.addAttributes(":all", "style");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String clean(String content) {
|
||||||
|
if (StringUtils.isNotBlank(content)) {
|
||||||
|
content = content.trim();
|
||||||
|
}
|
||||||
|
return Jsoup.clean(content, "", whitelist, outputSettings);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package cc.ryanc.halo.security;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2018/5/4
|
||||||
|
*/
|
||||||
|
public class XssFilter implements Filter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否过滤富文本内容
|
||||||
|
*/
|
||||||
|
private static boolean IS_INCLUDE_RICH_TEXT = false;
|
||||||
|
|
||||||
|
private List<String> excludes = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||||
|
HttpServletRequest req = (HttpServletRequest) request;
|
||||||
|
HttpServletResponse resp = (HttpServletResponse) response;
|
||||||
|
if (handleExcludeURL(req, resp)) {
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request, IS_INCLUDE_RICH_TEXT);
|
||||||
|
filterChain.doFilter(xssRequest, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
||||||
|
if (excludes == null || excludes.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = request.getServletPath();
|
||||||
|
for (String pattern : excludes) {
|
||||||
|
Pattern p = Pattern.compile("^" + pattern);
|
||||||
|
Matcher m = p.matcher(url);
|
||||||
|
if (m.find()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
String isIncludeRichText = filterConfig.getInitParameter("isIncludeRichText");
|
||||||
|
if (StringUtils.isNotBlank(isIncludeRichText)) {
|
||||||
|
IS_INCLUDE_RICH_TEXT = BooleanUtils.toBoolean(isIncludeRichText);
|
||||||
|
}
|
||||||
|
String temp = filterConfig.getInitParameter("excludes");
|
||||||
|
if (temp != null) {
|
||||||
|
String[] url = temp.split(",");
|
||||||
|
for (int i = 0; url != null && i < url.length; i++) {
|
||||||
|
excludes.add(url[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package cc.ryanc.halo.security;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletRequestWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2018/5/4
|
||||||
|
*/
|
||||||
|
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
|
HttpServletRequest orgRequest = null;
|
||||||
|
private boolean isIncludeRichText = false;
|
||||||
|
|
||||||
|
public XssHttpServletRequestWrapper(HttpServletRequest request, boolean isIncludeRichText) {
|
||||||
|
super(request);
|
||||||
|
orgRequest = request;
|
||||||
|
this.isIncludeRichText = isIncludeRichText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最原始的request的静态方法
|
||||||
|
*
|
||||||
|
* @param req req
|
||||||
|
* @return HttpServletRequest
|
||||||
|
*/
|
||||||
|
public static HttpServletRequest getOrgRequest(HttpServletRequest req) {
|
||||||
|
if (req instanceof XssHttpServletRequestWrapper) {
|
||||||
|
return ((XssHttpServletRequestWrapper) req).getOrgRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getParameter(String name) {
|
||||||
|
Boolean flag = ("content".equals(name) || name.endsWith("WithHtml"));
|
||||||
|
if (flag && !isIncludeRichText) {
|
||||||
|
return super.getParameter(name);
|
||||||
|
}
|
||||||
|
name = JsoupUtil.clean(name);
|
||||||
|
String value = super.getParameter(name);
|
||||||
|
if (StringUtils.isNotBlank(value)) {
|
||||||
|
value = JsoupUtil.clean(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getParameterValues(String name) {
|
||||||
|
String[] arr = super.getParameterValues(name);
|
||||||
|
if (arr != null) {
|
||||||
|
for (int i = 0; i < arr.length; i++) {
|
||||||
|
arr[i] = JsoupUtil.clean(arr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHeader(String name) {
|
||||||
|
name = JsoupUtil.clean(name);
|
||||||
|
String value = super.getHeader(name);
|
||||||
|
if (StringUtils.isNotBlank(value)) {
|
||||||
|
value = JsoupUtil.clean(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最原始的request
|
||||||
|
*
|
||||||
|
* @return HttpServletRequest
|
||||||
|
*/
|
||||||
|
public HttpServletRequest getOrgRequest() {
|
||||||
|
return orgRequest;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,9 +9,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/10
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/10
|
||||||
*/
|
*/
|
||||||
public interface AttachmentService {
|
public interface AttachmentService {
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/30
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2017/11/30
|
||||||
*/
|
*/
|
||||||
public interface CategoryService {
|
public interface CategoryService {
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/22
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/22
|
||||||
*/
|
*/
|
||||||
public interface CommentService {
|
public interface CommentService {
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ public interface CommentService {
|
||||||
/**
|
/**
|
||||||
* 查询所有的评论,用于后台管理
|
* 查询所有的评论,用于后台管理
|
||||||
*
|
*
|
||||||
* @param status status
|
* @param status status
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
|
@ -59,10 +58,10 @@ public interface CommentService {
|
||||||
* 更改评论的状态
|
* 更改评论的状态
|
||||||
*
|
*
|
||||||
* @param commentId commentId
|
* @param commentId commentId
|
||||||
* @param status status
|
* @param status status
|
||||||
* @return comment
|
* @return comment
|
||||||
*/
|
*/
|
||||||
Comment updateCommentStatus(Long commentId,Integer status);
|
Comment updateCommentStatus(Long commentId, Integer status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据评论编号查询评论
|
* 根据评论编号查询评论
|
||||||
|
@ -75,21 +74,21 @@ public interface CommentService {
|
||||||
/**
|
/**
|
||||||
* 根据文章查询评论
|
* 根据文章查询评论
|
||||||
*
|
*
|
||||||
* @param post post
|
* @param post post
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
Page<Comment> findCommentsByPost(Post post,Pageable pageable);
|
Page<Comment> findCommentsByPost(Post post, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文章和评论状态查询评论
|
* 根据文章和评论状态查询评论
|
||||||
*
|
*
|
||||||
* @param post post
|
* @param post post
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @param status status
|
* @param status status
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
Page<Comment> findCommentsByPostAndCommentStatus(Post post,Pageable pageable,Integer status);
|
Page<Comment> findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询最新的前五条评论
|
* 查询最新的前五条评论
|
||||||
|
|
|
@ -9,9 +9,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/2/26
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/2/26
|
||||||
*/
|
*/
|
||||||
public interface GalleryService {
|
public interface GalleryService {
|
||||||
|
|
||||||
|
@ -48,12 +47,14 @@ public interface GalleryService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有图片 不分页
|
* 查询所有图片 不分页
|
||||||
|
*
|
||||||
* @return list
|
* @return list
|
||||||
*/
|
*/
|
||||||
List<Gallery> findAllGalleries();
|
List<Gallery> findAllGalleries();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据编号查询图片信息
|
* 根据编号查询图片信息
|
||||||
|
*
|
||||||
* @param galleryId galleryId
|
* @param galleryId galleryId
|
||||||
* @return gallery
|
* @return gallery
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,9 +7,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
public interface LinkService {
|
public interface LinkService {
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/19
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/19
|
||||||
*/
|
*/
|
||||||
public interface LogsService {
|
public interface LogsService {
|
||||||
|
|
||||||
|
@ -25,6 +24,7 @@ public interface LogsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据编号移除
|
* 根据编号移除
|
||||||
|
*
|
||||||
* @param logsId logsId
|
* @param logsId logsId
|
||||||
*/
|
*/
|
||||||
void removeByLogsId(Long logsId);
|
void removeByLogsId(Long logsId);
|
||||||
|
|
|
@ -4,27 +4,27 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/23
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/23
|
||||||
*/
|
*/
|
||||||
public interface MailService {
|
public interface MailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送邮件
|
* 发送邮件
|
||||||
*
|
*
|
||||||
* @param to 接收者
|
* @param to 接收者
|
||||||
* @param subject 主题
|
* @param subject 主题
|
||||||
* @param content 内容
|
* @param content 内容
|
||||||
*/
|
*/
|
||||||
void sendMail(String to,String subject,String content);
|
void sendMail(String to, String subject, String content);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送模板邮件
|
* 发送模板邮件
|
||||||
* @param to 接收者
|
*
|
||||||
* @param subject 主题
|
* @param to 接收者
|
||||||
* @param content 内容
|
* @param subject 主题
|
||||||
|
* @param content 内容
|
||||||
* @param templateName 模板路径
|
* @param templateName 模板路径
|
||||||
*/
|
*/
|
||||||
void sendTemplateMail(String to, String subject, Map<String,Object> content,String templateName);
|
void sendTemplateMail(String to, String subject, Map<String, Object> content, String templateName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/24
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/24
|
||||||
*/
|
*/
|
||||||
public interface MenuService {
|
public interface MenuService {
|
||||||
|
|
||||||
|
@ -38,6 +37,7 @@ public interface MenuService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据编号查询菜单
|
* 根据编号查询菜单
|
||||||
|
*
|
||||||
* @param menuId menuId
|
* @param menuId menuId
|
||||||
* @return Menu
|
* @return Menu
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,26 +6,25 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
public interface OptionsService {
|
public interface OptionsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存单个设置选项
|
* 保存单个设置选项
|
||||||
*
|
*
|
||||||
* @param key key
|
* @param key key
|
||||||
* @param value value
|
* @param value value
|
||||||
*/
|
*/
|
||||||
void saveOption(String key,String value);
|
void saveOption(String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存多个设置选项
|
* 保存多个设置选项
|
||||||
*
|
*
|
||||||
* @param options options
|
* @param options options
|
||||||
*/
|
*/
|
||||||
void saveOptions(Map<String,String> options);
|
void saveOptions(Map<String, String> options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除设置选项
|
* 移除设置选项
|
||||||
|
@ -39,7 +38,7 @@ public interface OptionsService {
|
||||||
*
|
*
|
||||||
* @return map
|
* @return map
|
||||||
*/
|
*/
|
||||||
Map<String,String> findAllOptions();
|
Map<String, String> findAllOptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据key查询单个设置
|
* 根据key查询单个设置
|
||||||
|
|
|
@ -5,7 +5,6 @@ import cc.ryanc.halo.model.domain.Tag;
|
||||||
import cc.ryanc.halo.model.dto.Archive;
|
import cc.ryanc.halo.model.dto.Archive;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,9 +12,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
public interface PostService {
|
public interface PostService {
|
||||||
|
|
||||||
|
@ -42,7 +40,7 @@ public interface PostService {
|
||||||
* @param status status
|
* @param status status
|
||||||
* @return Post
|
* @return Post
|
||||||
*/
|
*/
|
||||||
Post updatePostStatus(Long postId,Integer status);
|
Post updatePostStatus(Long postId, Integer status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量修改摘要
|
* 批量修改摘要
|
||||||
|
@ -58,7 +56,7 @@ public interface PostService {
|
||||||
* @param pageable 分页信息
|
* @param pageable 分页信息
|
||||||
* @return Page<Post></>
|
* @return Page<Post></>
|
||||||
*/
|
*/
|
||||||
Page<Post> findAllPosts(String postType,Pageable pageable);
|
Page<Post> findAllPosts(String postType, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文章列表 不分页
|
* 获取文章列表 不分页
|
||||||
|
@ -71,30 +69,30 @@ public interface PostService {
|
||||||
/**
|
/**
|
||||||
* 模糊查询文章
|
* 模糊查询文章
|
||||||
*
|
*
|
||||||
* @param keyWord keyword
|
* @param keyWord keyword
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return list
|
* @return list
|
||||||
*/
|
*/
|
||||||
List<Post> searchPosts(String keyWord,Pageable pageable);
|
List<Post> searchPosts(String keyWord, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文章状态查询 分页
|
* 根据文章状态查询 分页
|
||||||
*
|
*
|
||||||
* @param status 0,1,2
|
* @param status 0,1,2
|
||||||
* @param postType post or page
|
* @param postType post or page
|
||||||
* @param pageable 分页信息
|
* @param pageable 分页信息
|
||||||
* @return Page<Post></>
|
* @return Page<Post></>
|
||||||
*/
|
*/
|
||||||
Page<Post> findPostByStatus(Integer status,String postType,Pageable pageable);
|
Page<Post> findPostByStatus(Integer status, String postType, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文章状态查询
|
* 根据文章状态查询
|
||||||
*
|
*
|
||||||
* @param status 0,1,2
|
* @param status 0,1,2
|
||||||
* @param postType post or page
|
* @param postType post or page
|
||||||
* @return List<Post></>
|
* @return List<Post></>
|
||||||
*/
|
*/
|
||||||
List<Post> findPostByStatus(Integer status,String postType);
|
List<Post> findPostByStatus(Integer status, String postType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据编号查询文章
|
* 根据编号查询文章
|
||||||
|
@ -107,11 +105,11 @@ public interface PostService {
|
||||||
/**
|
/**
|
||||||
* 根据文章路径查询
|
* 根据文章路径查询
|
||||||
*
|
*
|
||||||
* @param postUrl 路径
|
* @param postUrl 路径
|
||||||
* @param postType post or page
|
* @param postType post or page
|
||||||
* @return Post
|
* @return Post
|
||||||
*/
|
*/
|
||||||
Post findByPostUrl(String postUrl,String postType);
|
Post findByPostUrl(String postUrl, String postType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询前五条数据
|
* 查询前五条数据
|
||||||
|
@ -153,21 +151,21 @@ public interface PostService {
|
||||||
/**
|
/**
|
||||||
* 根据年份和月份查询文章
|
* 根据年份和月份查询文章
|
||||||
*
|
*
|
||||||
* @param year year
|
* @param year year
|
||||||
* @param month month
|
* @param month month
|
||||||
* @return list
|
* @return list
|
||||||
*/
|
*/
|
||||||
List<Post> findPostByYearAndMonth(String year,String month);
|
List<Post> findPostByYearAndMonth(String year, String month);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据年份和月份查询文章 分页
|
* 根据年份和月份查询文章 分页
|
||||||
*
|
*
|
||||||
* @param year year
|
* @param year year
|
||||||
* @param month month
|
* @param month month
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
Page<Post> findPostByYearAndMonth(String year,String month, Pageable pageable);
|
Page<Post> findPostByYearAndMonth(String year, String month, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据年份查询文章
|
* 根据年份查询文章
|
||||||
|
@ -180,11 +178,11 @@ public interface PostService {
|
||||||
/**
|
/**
|
||||||
* 根据标签查询文章
|
* 根据标签查询文章
|
||||||
*
|
*
|
||||||
* @param tag tag
|
* @param tag tag
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
Page<Post> findPostsByTags(Tag tag,Pageable pageable);
|
Page<Post> findPostsByTags(Tag tag, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成rss
|
* 生成rss
|
||||||
|
|
|
@ -7,9 +7,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/12
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/12
|
||||||
*/
|
*/
|
||||||
public interface TagService {
|
public interface TagService {
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
|
|
||||||
|
@ -27,15 +26,16 @@ public interface UserService {
|
||||||
* @param userPass userPass
|
* @param userPass userPass
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
List<User> userLoginByName(String userName,String userPass);
|
List<User> userLoginByName(String userName, String userPass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据邮箱和密码查询,用户登录
|
* 根据邮箱和密码查询,用户登录
|
||||||
|
*
|
||||||
* @param userEmail userEmail
|
* @param userEmail userEmail
|
||||||
* @param userPass userPass
|
* @param userPass userPass
|
||||||
* @return list
|
* @return list
|
||||||
*/
|
*/
|
||||||
List<User> userLoginByEmail(String userEmail,String userPass);
|
List<User> userLoginByEmail(String userEmail, String userPass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有用户
|
* 查询所有用户
|
||||||
|
@ -47,11 +47,11 @@ public interface UserService {
|
||||||
/**
|
/**
|
||||||
* 根据用户编号和密码查询
|
* 根据用户编号和密码查询
|
||||||
*
|
*
|
||||||
* @param userId userid
|
* @param userId userid
|
||||||
* @param userPass userpass
|
* @param userPass userpass
|
||||||
* @return user
|
* @return user
|
||||||
*/
|
*/
|
||||||
User findByUserIdAndUserPass(Long userId,String userPass);
|
User findByUserIdAndUserPass(Long userId, String userPass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改禁用状态
|
* 修改禁用状态
|
||||||
|
|
|
@ -4,9 +4,6 @@ import cc.ryanc.halo.model.domain.Attachment;
|
||||||
import cc.ryanc.halo.repository.AttachmentRepository;
|
import cc.ryanc.halo.repository.AttachmentRepository;
|
||||||
import cc.ryanc.halo.service.AttachmentService;
|
import cc.ryanc.halo.service.AttachmentService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.CachePut;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -16,12 +13,11 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/10
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/10
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AttachmentServiceImpl implements AttachmentService{
|
public class AttachmentServiceImpl implements AttachmentService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttachmentRepository attachmentRepository;
|
private AttachmentRepository attachmentRepository;
|
||||||
|
|
|
@ -4,8 +4,6 @@ import cc.ryanc.halo.model.domain.Category;
|
||||||
import cc.ryanc.halo.repository.CategoryRepository;
|
import cc.ryanc.halo.repository.CategoryRepository;
|
||||||
import cc.ryanc.halo.service.CategoryService;
|
import cc.ryanc.halo.service.CategoryService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -14,12 +12,11 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
|
* @version : 1.0=
|
||||||
* @date : 2017/11/30
|
* @date : 2017/11/30
|
||||||
* @version : 1.0
|
|
||||||
* description: Category业务层实现
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class CategoryServiceImpl implements CategoryService{
|
public class CategoryServiceImpl implements CategoryService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryRepository categoryRepository;
|
private CategoryRepository categoryRepository;
|
||||||
|
@ -83,12 +80,12 @@ public class CategoryServiceImpl implements CategoryService{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Category> strListToCateList(List<String> strings) {
|
public List<Category> strListToCateList(List<String> strings) {
|
||||||
if(null==strings){
|
if (null == strings) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Category> categories = new ArrayList<>();
|
List<Category> categories = new ArrayList<>();
|
||||||
Optional<Category> category = null;
|
Optional<Category> category = null;
|
||||||
for(String str:strings){
|
for (String str : strings) {
|
||||||
category = findByCateId(Long.parseLong(str));
|
category = findByCateId(Long.parseLong(str));
|
||||||
categories.add(category.get());
|
categories.add(category.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,13 @@ import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.swing.text.html.Option;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/22
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/22
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class CommentServiceImpl implements CommentService {
|
public class CommentServiceImpl implements CommentService {
|
||||||
|
@ -55,7 +53,7 @@ public class CommentServiceImpl implements CommentService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Comment> findAllComments(Integer status, Pageable pageable) {
|
public Page<Comment> findAllComments(Integer status, Pageable pageable) {
|
||||||
return commentRepository.findCommentsByCommentStatus(status,pageable);
|
return commentRepository.findCommentsByCommentStatus(status, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,13 +105,13 @@ public class CommentServiceImpl implements CommentService {
|
||||||
/**
|
/**
|
||||||
* 根据文章查询评论
|
* 根据文章查询评论
|
||||||
*
|
*
|
||||||
* @param post post
|
* @param post post
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Comment> findCommentsByPost(Post post,Pageable pageable) {
|
public Page<Comment> findCommentsByPost(Post post, Pageable pageable) {
|
||||||
return commentRepository.findCommentsByPost(post,pageable);
|
return commentRepository.findCommentsByPost(post, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +124,7 @@ public class CommentServiceImpl implements CommentService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Comment> findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status) {
|
public Page<Comment> findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status) {
|
||||||
return commentRepository.findCommentsByPostAndCommentStatusNot(post,pageable,status);
|
return commentRepository.findCommentsByPostAndCommentStatusNot(post, pageable, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,12 +13,11 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/2/26
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/2/26
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GalleryServiceImpl implements GalleryService{
|
public class GalleryServiceImpl implements GalleryService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GalleryRepository galleryRepository;
|
private GalleryRepository galleryRepository;
|
||||||
|
|
|
@ -4,8 +4,6 @@ import cc.ryanc.halo.model.domain.Link;
|
||||||
import cc.ryanc.halo.repository.LinkRepository;
|
import cc.ryanc.halo.repository.LinkRepository;
|
||||||
import cc.ryanc.halo.service.LinkService;
|
import cc.ryanc.halo.service.LinkService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,9 +11,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class LinkServiceImpl implements LinkService {
|
public class LinkServiceImpl implements LinkService {
|
||||||
|
|
|
@ -13,9 +13,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/19
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/19
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class LogsServiceImpl implements LogsService {
|
public class LogsServiceImpl implements LogsService {
|
||||||
|
|
|
@ -14,12 +14,11 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/23
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/23
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MailServiceImpl implements MailService{
|
public class MailServiceImpl implements MailService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FreeMarkerConfigurer freeMarker;
|
private FreeMarkerConfigurer freeMarker;
|
||||||
|
@ -27,12 +26,12 @@ public class MailServiceImpl implements MailService{
|
||||||
/**
|
/**
|
||||||
* 发送邮件
|
* 发送邮件
|
||||||
*
|
*
|
||||||
* @param to to 接收者
|
* @param to to 接收者
|
||||||
* @param subject subject 标题
|
* @param subject subject 标题
|
||||||
* @param content content 内容
|
* @param content content 内容
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendMail (String to, String subject, String content){
|
public void sendMail(String to, String subject, String content) {
|
||||||
//配置邮件服务器
|
//配置邮件服务器
|
||||||
HaloUtil.configMail(
|
HaloUtil.configMail(
|
||||||
HaloConst.OPTIONS.get("mail_smtp_host"),
|
HaloConst.OPTIONS.get("mail_smtp_host"),
|
||||||
|
@ -44,7 +43,7 @@ public class MailServiceImpl implements MailService{
|
||||||
.to(to)
|
.to(to)
|
||||||
.text(content)
|
.text(content)
|
||||||
.send();
|
.send();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,28 +51,28 @@ public class MailServiceImpl implements MailService{
|
||||||
/**
|
/**
|
||||||
* 发送模板邮件
|
* 发送模板邮件
|
||||||
*
|
*
|
||||||
* @param to 接收者
|
* @param to 接收者
|
||||||
* @param subject 主题
|
* @param subject 主题
|
||||||
* @param content 内容
|
* @param content 内容
|
||||||
* @param templateName 模板路径
|
* @param templateName 模板路径
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendTemplateMail(String to, String subject, Map<String, Object> content,String templateName) {
|
public void sendTemplateMail(String to, String subject, Map<String, Object> content, String templateName) {
|
||||||
//配置邮件服务器
|
//配置邮件服务器
|
||||||
HaloUtil.configMail(
|
HaloUtil.configMail(
|
||||||
HaloConst.OPTIONS.get("mail_smtp_host"),
|
HaloConst.OPTIONS.get("mail_smtp_host"),
|
||||||
HaloConst.OPTIONS.get("mail_smtp_username"),
|
HaloConst.OPTIONS.get("mail_smtp_username"),
|
||||||
HaloConst.OPTIONS.get("mail_smtp_password"));
|
HaloConst.OPTIONS.get("mail_smtp_password"));
|
||||||
String text = "";
|
String text = "";
|
||||||
try{
|
try {
|
||||||
Template template = freeMarker.getConfiguration().getTemplate(templateName);
|
Template template = freeMarker.getConfiguration().getTemplate(templateName);
|
||||||
text = FreeMarkerTemplateUtils.processTemplateIntoString(template,content);
|
text = FreeMarkerTemplateUtils.processTemplateIntoString(template, content);
|
||||||
OhMyEmail.subject(subject)
|
OhMyEmail.subject(subject)
|
||||||
.from(HaloConst.OPTIONS.get("mail_from_name"))
|
.from(HaloConst.OPTIONS.get("mail_from_name"))
|
||||||
.to(to)
|
.to(to)
|
||||||
.html(text)
|
.html(text)
|
||||||
.send();
|
.send();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,11 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/24
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MenuServiceImpl implements MenuService{
|
public class MenuServiceImpl implements MenuService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MenuRepository menuRepository;
|
private MenuRepository menuRepository;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package cc.ryanc.halo.service.impl;
|
||||||
import cc.ryanc.halo.model.domain.Options;
|
import cc.ryanc.halo.model.domain.Options;
|
||||||
import cc.ryanc.halo.repository.OptionsRepository;
|
import cc.ryanc.halo.repository.OptionsRepository;
|
||||||
import cc.ryanc.halo.service.OptionsService;
|
import cc.ryanc.halo.service.OptionsService;
|
||||||
import cc.ryanc.halo.util.HaloUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -14,9 +13,8 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class OptionsServiceImpl implements OptionsService {
|
public class OptionsServiceImpl implements OptionsService {
|
||||||
|
@ -30,26 +28,26 @@ public class OptionsServiceImpl implements OptionsService {
|
||||||
* @param options options
|
* @param options options
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveOptions(Map<String,String> options){
|
public void saveOptions(Map<String, String> options) {
|
||||||
if(null != options && !options.isEmpty()){
|
if (null != options && !options.isEmpty()) {
|
||||||
options.forEach((k,v) -> saveOption(k,v));
|
options.forEach((k, v) -> saveOption(k, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存单个设置选项
|
* 保存单个设置选项
|
||||||
*
|
*
|
||||||
* @param key key
|
* @param key key
|
||||||
* @param value value
|
* @param value value
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveOption(String key,String value){
|
public void saveOption(String key, String value) {
|
||||||
Options options = null;
|
Options options = null;
|
||||||
if(StringUtils.equals(value,"")){
|
if (StringUtils.equals(value, "")) {
|
||||||
options = new Options();
|
options = new Options();
|
||||||
options.setOptionName(key);
|
options.setOptionName(key);
|
||||||
this.removeOption(options);
|
this.removeOption(options);
|
||||||
}else {
|
} else {
|
||||||
if (StringUtils.isNotEmpty(key)) {
|
if (StringUtils.isNotEmpty(key)) {
|
||||||
//如果查询到有该设置选项则做更新操作,反之保存新的设置选项
|
//如果查询到有该设置选项则做更新操作,反之保存新的设置选项
|
||||||
if (null == optionsRepository.findOptionsByOptionName(key)) {
|
if (null == optionsRepository.findOptionsByOptionName(key)) {
|
||||||
|
@ -83,10 +81,10 @@ public class OptionsServiceImpl implements OptionsService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> findAllOptions() {
|
public Map<String, String> findAllOptions() {
|
||||||
Map<String,String> options = new HashMap<String,String>();
|
Map<String, String> options = new HashMap<String, String>();
|
||||||
List<Options> optionsList = optionsRepository.findAll();
|
List<Options> optionsList = optionsRepository.findAll();
|
||||||
if(null != optionsList){
|
if (null != optionsList) {
|
||||||
optionsList.forEach(option -> options.put(option.getOptionName(),option.getOptionValue()));
|
optionsList.forEach(option -> options.put(option.getOptionName(), option.getOptionValue()));
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +98,7 @@ public class OptionsServiceImpl implements OptionsService {
|
||||||
@Override
|
@Override
|
||||||
public String findOneOption(String key) {
|
public String findOneOption(String key) {
|
||||||
Options options = optionsRepository.findOptionsByOptionName(key);
|
Options options = optionsRepository.findOptionsByOptionName(key);
|
||||||
if(null!=options){
|
if (null != options) {
|
||||||
return options.getOptionValue();
|
return options.getOptionValue();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -9,9 +9,8 @@ import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.util.HaloUtil;
|
import cc.ryanc.halo.util.HaloUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -20,9 +19,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class PostServiceImpl implements PostService {
|
public class PostServiceImpl implements PostService {
|
||||||
|
@ -76,10 +74,10 @@ public class PostServiceImpl implements PostService {
|
||||||
@Override
|
@Override
|
||||||
public void updateAllSummary(Integer postSummary) {
|
public void updateAllSummary(Integer postSummary) {
|
||||||
List<Post> posts = this.findAllPosts(HaloConst.POST_TYPE_POST);
|
List<Post> posts = this.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||||
for(Post post:posts){
|
for (Post post : posts) {
|
||||||
if(!(HaloUtil.htmlToText(post.getPostContent()).length()<postSummary)){
|
if (!(HaloUtil.htmlToText(post.getPostContent()).length() < postSummary)) {
|
||||||
post.setPostSummary(HaloUtil.getSummary(post.getPostContent(),postSummary));
|
post.setPostSummary(HaloUtil.getSummary(post.getPostContent(), postSummary));
|
||||||
}else{
|
} else {
|
||||||
post.setPostSummary(HaloUtil.htmlToText(post.getPostContent()));
|
post.setPostSummary(HaloUtil.htmlToText(post.getPostContent()));
|
||||||
}
|
}
|
||||||
postRepository.save(post);
|
postRepository.save(post);
|
||||||
|
@ -94,8 +92,8 @@ public class PostServiceImpl implements PostService {
|
||||||
* @return Page<Post></>
|
* @return Page<Post></>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Post> findAllPosts(String postType,Pageable pageable) {
|
public Page<Post> findAllPosts(String postType, Pageable pageable) {
|
||||||
return postRepository.findPostsByPostType(postType,pageable);
|
return postRepository.findPostsByPostType(postType, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,38 +110,38 @@ public class PostServiceImpl implements PostService {
|
||||||
/**
|
/**
|
||||||
* 模糊查询文章
|
* 模糊查询文章
|
||||||
*
|
*
|
||||||
* @param keyWord keyword
|
* @param keyWord keyword
|
||||||
* @param pageable pageable
|
* @param pageable pageable
|
||||||
* @return list
|
* @return list
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Post> searchPosts(String keyWord,Pageable pageable) {
|
public List<Post> searchPosts(String keyWord, Pageable pageable) {
|
||||||
return postRepository.findByPostTitleLike(keyWord,pageable);
|
return postRepository.findByPostTitleLike(keyWord, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文章状态查询 分页
|
* 根据文章状态查询 分页
|
||||||
*
|
*
|
||||||
* @param status 0,1,2
|
* @param status 0,1,2
|
||||||
* @param postType post or page
|
* @param postType post or page
|
||||||
* @param pageable 分页信息
|
* @param pageable 分页信息
|
||||||
* @return Page<Post></>
|
* @return Page<Post></>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Post> findPostByStatus(Integer status,String postType, Pageable pageable) {
|
public Page<Post> findPostByStatus(Integer status, String postType, Pageable pageable) {
|
||||||
return postRepository.findPostsByPostStatusAndPostType(status,postType,pageable);
|
return postRepository.findPostsByPostStatusAndPostType(status, postType, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文章状态查询
|
* 根据文章状态查询
|
||||||
*
|
*
|
||||||
* @param status 0,1,2
|
* @param status 0,1,2
|
||||||
* @param postType post or page
|
* @param postType post or page
|
||||||
* @return List<Post></>
|
* @return List<Post></>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Post> findPostByStatus(Integer status,String postType) {
|
public List<Post> findPostByStatus(Integer status, String postType) {
|
||||||
return postRepository.findPostsByPostStatusAndPostType(status,postType);
|
return postRepository.findPostsByPostStatusAndPostType(status, postType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,13 +158,13 @@ public class PostServiceImpl implements PostService {
|
||||||
/**
|
/**
|
||||||
* 根据文章路径查询
|
* 根据文章路径查询
|
||||||
*
|
*
|
||||||
* @param postUrl 路径
|
* @param postUrl 路径
|
||||||
* @param postType post or page
|
* @param postType post or page
|
||||||
* @return Post
|
* @return Post
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Post findByPostUrl(String postUrl,String postType) {
|
public Post findByPostUrl(String postUrl, String postType) {
|
||||||
return postRepository.findPostByPostUrlAndPostType(postUrl,postType);
|
return postRepository.findPostByPostUrlAndPostType(postUrl, postType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,7 +185,7 @@ public class PostServiceImpl implements PostService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Post> findByPostDateAfter(Date postDate) {
|
public List<Post> findByPostDateAfter(Date postDate) {
|
||||||
return postRepository.findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(postDate,0,HaloConst.POST_TYPE_POST);
|
return postRepository.findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(postDate, 0, HaloConst.POST_TYPE_POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +196,7 @@ public class PostServiceImpl implements PostService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Post> findByPostDateBefore(Date postDate) {
|
public List<Post> findByPostDateBefore(Date postDate) {
|
||||||
return postRepository.findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(postDate,0,HaloConst.POST_TYPE_POST);
|
return postRepository.findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(postDate, 0, HaloConst.POST_TYPE_POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,12 +210,12 @@ public class PostServiceImpl implements PostService {
|
||||||
List<Object[]> objects = postRepository.findPostGroupByYearAndMonth();
|
List<Object[]> objects = postRepository.findPostGroupByYearAndMonth();
|
||||||
List<Archive> archives = new ArrayList<>();
|
List<Archive> archives = new ArrayList<>();
|
||||||
Archive archive = null;
|
Archive archive = null;
|
||||||
for(Object[] obj : objects){
|
for (Object[] obj : objects) {
|
||||||
archive = new Archive();
|
archive = new Archive();
|
||||||
archive.setYear(obj[0].toString());
|
archive.setYear(obj[0].toString());
|
||||||
archive.setMonth(obj[1].toString());
|
archive.setMonth(obj[1].toString());
|
||||||
archive.setCount(obj[2].toString());
|
archive.setCount(obj[2].toString());
|
||||||
archive.setPosts(this.findPostByYearAndMonth(obj[0].toString(),obj[1].toString()));
|
archive.setPosts(this.findPostByYearAndMonth(obj[0].toString(), obj[1].toString()));
|
||||||
archives.add(archive);
|
archives.add(archive);
|
||||||
}
|
}
|
||||||
return archives;
|
return archives;
|
||||||
|
@ -233,7 +231,7 @@ public class PostServiceImpl implements PostService {
|
||||||
List<Object[]> objects = postRepository.findPostGroupByYear();
|
List<Object[]> objects = postRepository.findPostGroupByYear();
|
||||||
List<Archive> archives = new ArrayList<>();
|
List<Archive> archives = new ArrayList<>();
|
||||||
Archive archive = null;
|
Archive archive = null;
|
||||||
for(Object[] obj : objects){
|
for (Object[] obj : objects) {
|
||||||
archive = new Archive();
|
archive = new Archive();
|
||||||
archive.setYear(obj[0].toString());
|
archive.setYear(obj[0].toString());
|
||||||
archive.setCount(obj[1].toString());
|
archive.setCount(obj[1].toString());
|
||||||
|
@ -246,13 +244,13 @@ public class PostServiceImpl implements PostService {
|
||||||
/**
|
/**
|
||||||
* 根据年份和月份查询文章
|
* 根据年份和月份查询文章
|
||||||
*
|
*
|
||||||
* @param year year
|
* @param year year
|
||||||
* @param month month
|
* @param month month
|
||||||
* @return list
|
* @return list
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Post> findPostByYearAndMonth(String year, String month) {
|
public List<Post> findPostByYearAndMonth(String year, String month) {
|
||||||
return postRepository.findPostByYearAndMonth(year,month);
|
return postRepository.findPostByYearAndMonth(year, month);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,14 +266,15 @@ public class PostServiceImpl implements PostService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据年份和月份索引文章
|
* 根据年份和月份索引文章
|
||||||
* @param year year year
|
*
|
||||||
* @param month month month
|
* @param year year year
|
||||||
|
* @param month month month
|
||||||
* @param pageable pageable pageable
|
* @param pageable pageable pageable
|
||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Post> findPostByYearAndMonth(String year, String month, Pageable pageable) {
|
public Page<Post> findPostByYearAndMonth(String year, String month, Pageable pageable) {
|
||||||
return postRepository.findPostByYearAndMonth(year,month,null);
|
return postRepository.findPostByYearAndMonth(year, month, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,7 +286,7 @@ public class PostServiceImpl implements PostService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<Post> findPostsByTags(Tag tag, Pageable pageable) {
|
public Page<Post> findPostsByTags(Tag tag, Pageable pageable) {
|
||||||
return postRepository.findPostsByTags(tag,pageable);
|
return postRepository.findPostsByTags(tag, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -299,9 +298,9 @@ public class PostServiceImpl implements PostService {
|
||||||
@Override
|
@Override
|
||||||
public String buildRss(List<Post> posts) {
|
public String buildRss(List<Post> posts) {
|
||||||
String rss = "";
|
String rss = "";
|
||||||
try{
|
try {
|
||||||
rss = HaloUtil.getRss(posts);
|
rss = HaloUtil.getRss(posts);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return rss;
|
return rss;
|
||||||
|
|
|
@ -12,9 +12,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2018/1/12
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description :
|
* @date : 2018/1/12
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TagServiceImpl implements TagService {
|
public class TagServiceImpl implements TagService {
|
||||||
|
@ -97,14 +96,14 @@ public class TagServiceImpl implements TagService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Tag> strListToTagList(String tagList) {
|
public List<Tag> strListToTagList(String tagList) {
|
||||||
String [] tags = tagList.split(",");
|
String[] tags = tagList.split(",");
|
||||||
List<Tag> tagsList = new ArrayList<>();
|
List<Tag> tagsList = new ArrayList<>();
|
||||||
for(String tag:tags){
|
for (String tag : tags) {
|
||||||
Tag t = findTagByTagName(tag);
|
Tag t = findTagByTagName(tag);
|
||||||
Tag nt = null;
|
Tag nt = null;
|
||||||
if(null!=t){
|
if (null != t) {
|
||||||
tagsList.add(t);
|
tagsList.add(t);
|
||||||
}else{
|
} else {
|
||||||
nt = new Tag();
|
nt = new Tag();
|
||||||
nt.setTagName(tag);
|
nt.setTagName(tag);
|
||||||
nt.setTagUrl(tag);
|
nt.setTagUrl(tag);
|
||||||
|
|
|
@ -11,9 +11,8 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/11/14
|
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* description:
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
|
@ -73,7 +72,7 @@ public class UserServiceImpl implements UserService {
|
||||||
/**
|
/**
|
||||||
* 验证修改密码时,密码是否正确
|
* 验证修改密码时,密码是否正确
|
||||||
*
|
*
|
||||||
* @param userId userId
|
* @param userId userId
|
||||||
* @param userPass userPass
|
* @param userPass userPass
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.sun.syndication.io.WireFeedOutput;
|
||||||
import io.github.biezhi.ome.OhMyEmail;
|
import io.github.biezhi.ome.OhMyEmail;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.ResourceUtils;
|
import org.springframework.util.ResourceUtils;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.imageio.ImageReadParam;
|
import javax.imageio.ImageReadParam;
|
||||||
|
@ -25,7 +24,6 @@ import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
|
|
@ -6,7 +6,10 @@ import cc.ryanc.halo.model.domain.Post;
|
||||||
import cc.ryanc.halo.model.domain.User;
|
import cc.ryanc.halo.model.domain.User;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||||
import cc.ryanc.halo.service.*;
|
import cc.ryanc.halo.service.CommentService;
|
||||||
|
import cc.ryanc.halo.service.LogsService;
|
||||||
|
import cc.ryanc.halo.service.PostService;
|
||||||
|
import cc.ryanc.halo.service.UserService;
|
||||||
import cc.ryanc.halo.util.HaloUtil;
|
import cc.ryanc.halo.util.HaloUtil;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -36,7 +39,7 @@ import java.util.regex.Pattern;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/admin")
|
@RequestMapping(value = "/admin")
|
||||||
public class AdminController extends BaseController{
|
public class AdminController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PostService postService;
|
private PostService postService;
|
||||||
|
@ -56,33 +59,33 @@ public class AdminController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* 请求后台页面
|
* 请求后台页面
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param session session
|
* @param session session
|
||||||
* @return 模板路径admin/admin_index
|
* @return 模板路径admin/admin_index
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = {"","/index"})
|
@GetMapping(value = {"", "/index"})
|
||||||
public String index(Model model,HttpSession session){
|
public String index(Model model, HttpSession session) {
|
||||||
//查询文章条数
|
//查询文章条数
|
||||||
Integer postCount = postService.findAllPosts(HaloConst.POST_TYPE_POST).size();
|
Integer postCount = postService.findAllPosts(HaloConst.POST_TYPE_POST).size();
|
||||||
model.addAttribute("postCount",postCount);
|
model.addAttribute("postCount", postCount);
|
||||||
|
|
||||||
//查询评论的条数
|
//查询评论的条数
|
||||||
Integer commentCount = commentService.findAllComments().size();
|
Integer commentCount = commentService.findAllComments().size();
|
||||||
model.addAttribute("commentCount",commentCount);
|
model.addAttribute("commentCount", commentCount);
|
||||||
|
|
||||||
//查询最新的文章
|
//查询最新的文章
|
||||||
List<Post> postsLatest = postService.findPostLatest();
|
List<Post> postsLatest = postService.findPostLatest();
|
||||||
model.addAttribute("postTopFive",postsLatest);
|
model.addAttribute("postTopFive", postsLatest);
|
||||||
|
|
||||||
//查询最新的日志
|
//查询最新的日志
|
||||||
List<Logs> logsLatest = logsService.findLogsLatest();
|
List<Logs> logsLatest = logsService.findLogsLatest();
|
||||||
model.addAttribute("logs",logsLatest);
|
model.addAttribute("logs", logsLatest);
|
||||||
|
|
||||||
//查询最新的评论
|
//查询最新的评论
|
||||||
List<Comment> comments = commentService.findCommentsLatest();
|
List<Comment> comments = commentService.findCommentsLatest();
|
||||||
model.addAttribute("comments",comments);
|
model.addAttribute("comments", comments);
|
||||||
|
|
||||||
model.addAttribute("mediaCount",HaloConst.ATTACHMENTS.size());
|
model.addAttribute("mediaCount", HaloConst.ATTACHMENTS.size());
|
||||||
return "admin/admin_index";
|
return "admin/admin_index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +96,10 @@ public class AdminController extends BaseController{
|
||||||
* @return 模板路径admin/admin_login
|
* @return 模板路径admin/admin_login
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/login")
|
@GetMapping(value = "/login")
|
||||||
public String login(HttpSession session){
|
public String login(HttpSession session) {
|
||||||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
//如果session存在,跳转到后台首页
|
//如果session存在,跳转到后台首页
|
||||||
if(null!=user){
|
if (null != user) {
|
||||||
return "redirect:/admin";
|
return "redirect:/admin";
|
||||||
}
|
}
|
||||||
return "admin/admin_login";
|
return "admin/admin_login";
|
||||||
|
@ -106,47 +109,47 @@ public class AdminController extends BaseController{
|
||||||
* 验证登录信息
|
* 验证登录信息
|
||||||
*
|
*
|
||||||
* @param loginName 登录名:邮箱/用户名
|
* @param loginName 登录名:邮箱/用户名
|
||||||
* @param loginPwd loginPwd 密码
|
* @param loginPwd loginPwd 密码
|
||||||
* @param session session session
|
* @param session session session
|
||||||
* @return String 登录状态
|
* @return String 登录状态
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/getLogin")
|
@PostMapping(value = "/getLogin")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getLogin(@ModelAttribute("loginName") String loginName,
|
public String getLogin(@ModelAttribute("loginName") String loginName,
|
||||||
@ModelAttribute("loginPwd") String loginPwd,
|
@ModelAttribute("loginPwd") String loginPwd,
|
||||||
HttpSession session){
|
HttpSession session) {
|
||||||
String status = "false";
|
String status = "false";
|
||||||
try {
|
try {
|
||||||
User aUser = userService.findUser();
|
User aUser = userService.findUser();
|
||||||
User user = null;
|
User user = null;
|
||||||
if(StringUtils.equals(aUser.getLoginEnable(),"false")){
|
if (StringUtils.equals(aUser.getLoginEnable(), "false")) {
|
||||||
status = "disable";
|
status = "disable";
|
||||||
}else{
|
} else {
|
||||||
//验证是否是邮箱登录
|
//验证是否是邮箱登录
|
||||||
Pattern patternEmail = Pattern.compile("\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}");
|
Pattern patternEmail = Pattern.compile("\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}");
|
||||||
Matcher matcher = patternEmail.matcher(loginName);
|
Matcher matcher = patternEmail.matcher(loginName);
|
||||||
if(matcher.find()){
|
if (matcher.find()) {
|
||||||
user = userService.userLoginByEmail(loginName,HaloUtil.getMD5(loginPwd)).get(0);
|
user = userService.userLoginByEmail(loginName, HaloUtil.getMD5(loginPwd)).get(0);
|
||||||
}else{
|
} else {
|
||||||
user = userService.userLoginByName(loginName,HaloUtil.getMD5(loginPwd)).get(0);
|
user = userService.userLoginByName(loginName, HaloUtil.getMD5(loginPwd)).get(0);
|
||||||
}
|
}
|
||||||
if(aUser==user){
|
if (aUser == user) {
|
||||||
session.setAttribute(HaloConst.USER_SESSION_KEY, user);
|
session.setAttribute(HaloConst.USER_SESSION_KEY, user);
|
||||||
//重置用户的登录状态为正常
|
//重置用户的登录状态为正常
|
||||||
userService.updateUserNormal();
|
userService.updateUserNormal();
|
||||||
userService.updateUserLoginLast(new Date());
|
userService.updateUserLoginLast(new Date());
|
||||||
logsService.saveByLogs(new Logs(LogsRecord.LOGIN,LogsRecord.LOGIN_SUCCESS,HaloUtil.getIpAddr(request), HaloUtil.getDate()));
|
logsService.saveByLogs(new Logs(LogsRecord.LOGIN, LogsRecord.LOGIN_SUCCESS, HaloUtil.getIpAddr(request), HaloUtil.getDate()));
|
||||||
status = "true";
|
status = "true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
Integer errorCount = userService.updateUserLoginError();
|
Integer errorCount = userService.updateUserLoginError();
|
||||||
if(errorCount>=5){
|
if (errorCount >= 5) {
|
||||||
userService.updateUserLoginEnable("false");
|
userService.updateUserLoginEnable("false");
|
||||||
}
|
}
|
||||||
userService.updateUserLoginLast(new Date());
|
userService.updateUserLoginLast(new Date());
|
||||||
logsService.saveByLogs(new Logs(LogsRecord.LOGIN,LogsRecord.LOGIN_ERROR+"["+loginName+","+loginPwd+"]",HaloUtil.getIpAddr(request),new Date()));
|
logsService.saveByLogs(new Logs(LogsRecord.LOGIN, LogsRecord.LOGIN_ERROR + "[" + loginName + "," + loginPwd + "]", HaloUtil.getIpAddr(request), new Date()));
|
||||||
log.error("登录失败!:{0}",e.getMessage());
|
log.error("登录失败!:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -158,11 +161,11 @@ public class AdminController extends BaseController{
|
||||||
* @return 重定向到/admin/login
|
* @return 重定向到/admin/login
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/logOut")
|
@GetMapping(value = "/logOut")
|
||||||
public String logOut(HttpSession session){
|
public String logOut(HttpSession session) {
|
||||||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
logsService.saveByLogs(new Logs(LogsRecord.LOGOUT,user.getUserName(),HaloUtil.getIpAddr(request),HaloUtil.getDate()));
|
logsService.saveByLogs(new Logs(LogsRecord.LOGOUT, user.getUserName(), HaloUtil.getIpAddr(request), HaloUtil.getDate()));
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
log.info("用户["+user.getUserName()+"]退出登录");
|
log.info("用户[" + user.getUserName() + "]退出登录");
|
||||||
return "redirect:/admin/login";
|
return "redirect:/admin/login";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,18 +173,18 @@ public class AdminController extends BaseController{
|
||||||
* 查看所有日志
|
* 查看所有日志
|
||||||
*
|
*
|
||||||
* @param model model model
|
* @param model model model
|
||||||
* @param page page 当前页码
|
* @param page page 当前页码
|
||||||
* @param size size 每页条数
|
* @param size size 每页条数
|
||||||
* @return 模板路径admin/widget/_logs-all
|
* @return 模板路径admin/widget/_logs-all
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/logs")
|
@GetMapping(value = "/logs")
|
||||||
public String logs(Model model,
|
public String logs(Model model,
|
||||||
@RequestParam(value = "page",defaultValue = "0") Integer page,
|
@RequestParam(value = "page", defaultValue = "0") Integer page,
|
||||||
@RequestParam(value = "size",defaultValue = "10") Integer size){
|
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"logId");
|
Sort sort = new Sort(Sort.Direction.DESC, "logId");
|
||||||
Pageable pageable = new PageRequest(page,size,sort);
|
Pageable pageable = new PageRequest(page, size, sort);
|
||||||
Page<Logs> logs = logsService.findAllLogs(pageable);
|
Page<Logs> logs = logsService.findAllLogs(pageable);
|
||||||
model.addAttribute("logs",logs);
|
model.addAttribute("logs", logs);
|
||||||
return "admin/widget/_logs-all";
|
return "admin/widget/_logs-all";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,11 +194,11 @@ public class AdminController extends BaseController{
|
||||||
* @return 重定向到/admin
|
* @return 重定向到/admin
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/logs/clear")
|
@GetMapping(value = "/logs/clear")
|
||||||
public String logsClear(){
|
public String logsClear() {
|
||||||
try {
|
try {
|
||||||
logsService.removeAllLogs();
|
logsService.removeAllLogs();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:"+e.getMessage());
|
log.error("未知错误:" + e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin";
|
return "redirect:/admin";
|
||||||
}
|
}
|
||||||
|
@ -206,7 +209,7 @@ public class AdminController extends BaseController{
|
||||||
* @return 模板路径admin/admin_halo
|
* @return 模板路径admin/admin_halo
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/halo")
|
@GetMapping(value = "/halo")
|
||||||
public String halo(){
|
public String halo() {
|
||||||
return "admin/admin_halo";
|
return "admin/admin_halo";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class AttachmentController {
|
||||||
/**
|
/**
|
||||||
* 刷新HaloConst
|
* 刷新HaloConst
|
||||||
*/
|
*/
|
||||||
private void updateConst(){
|
private void updateConst() {
|
||||||
HaloConst.ATTACHMENTS.clear();
|
HaloConst.ATTACHMENTS.clear();
|
||||||
HaloConst.ATTACHMENTS = attachmentService.findAllAttachments();
|
HaloConst.ATTACHMENTS = attachmentService.findAllAttachments();
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,12 @@ public class AttachmentController {
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String attachments(Model model,
|
public String attachments(Model model,
|
||||||
@RequestParam(value = "page",defaultValue = "0") Integer page,
|
@RequestParam(value = "page", defaultValue = "0") Integer page,
|
||||||
@RequestParam(value = "size",defaultValue = "18") Integer size){
|
@RequestParam(value = "size", defaultValue = "18") Integer size) {
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"attachId");
|
Sort sort = new Sort(Sort.Direction.DESC, "attachId");
|
||||||
Pageable pageable = new PageRequest(page,size,sort);
|
Pageable pageable = new PageRequest(page, size, sort);
|
||||||
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
|
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
|
||||||
model.addAttribute("attachments",attachments);
|
model.addAttribute("attachments", attachments);
|
||||||
|
|
||||||
return "admin/admin_attachment";
|
return "admin/admin_attachment";
|
||||||
}
|
}
|
||||||
|
@ -76,86 +76,86 @@ public class AttachmentController {
|
||||||
* 跳转选择附件页面
|
* 跳转选择附件页面
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param page page 当前页码
|
* @param page page 当前页码
|
||||||
* @return 模板路径admin/widget/_attachment-select
|
* @return 模板路径admin/widget/_attachment-select
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/select")
|
@GetMapping(value = "/select")
|
||||||
public String selectAttachment(Model model,
|
public String selectAttachment(Model model,
|
||||||
@RequestParam(value = "page",defaultValue = "0") Integer page,
|
@RequestParam(value = "page", defaultValue = "0") Integer page,
|
||||||
@RequestParam(value = "id") String id){
|
@RequestParam(value = "id") String id) {
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"attachId");
|
Sort sort = new Sort(Sort.Direction.DESC, "attachId");
|
||||||
Pageable pageable = new PageRequest(page,18,sort);
|
Pageable pageable = new PageRequest(page, 18, sort);
|
||||||
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
|
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
|
||||||
model.addAttribute("attachments",attachments);
|
model.addAttribute("attachments", attachments);
|
||||||
model.addAttribute("id",id);
|
model.addAttribute("id", id);
|
||||||
return "admin/widget/_attachment-select";
|
return "admin/widget/_attachment-select";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传附件
|
* 上传附件
|
||||||
*
|
*
|
||||||
* @param file file
|
* @param file file
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return Map<String,Object></>
|
* @return Map<String , Object></>
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/upload",produces = {"application/json;charset=UTF-8"})
|
@PostMapping(value = "/upload", produces = {"application/json;charset=UTF-8"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String,Object> upload(@RequestParam("file") MultipartFile file,
|
public Map<String, Object> upload(@RequestParam("file") MultipartFile file,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
return uploadAttachment(file,request);
|
return uploadAttachment(file, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editor.md上传图片
|
* editor.md上传图片
|
||||||
*
|
*
|
||||||
* @param file file
|
* @param file file
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return Map<String,Object></>
|
* @return Map<String , Object></>
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/upload/editor",produces = {"application/json;charset=UTF-8"})
|
@PostMapping(value = "/upload/editor", produces = {"application/json;charset=UTF-8"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String,Object> editorUpload(@RequestParam("editormd-image-file") MultipartFile file,
|
public Map<String, Object> editorUpload(@RequestParam("editormd-image-file") MultipartFile file,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
return uploadAttachment(file,request);
|
return uploadAttachment(file, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传图片
|
* 上传图片
|
||||||
*
|
*
|
||||||
* @param file file
|
* @param file file
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return Map<String,Object></>
|
* @return Map<String , Object></>
|
||||||
*/
|
*/
|
||||||
public Map<String,Object> uploadAttachment( MultipartFile file, HttpServletRequest request){
|
public Map<String, Object> uploadAttachment(MultipartFile file, HttpServletRequest request) {
|
||||||
Map<String,Object> result = new HashMap<String,Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
if(!file.isEmpty()){
|
if (!file.isEmpty()) {
|
||||||
try{
|
try {
|
||||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
StringBuffer sbMedia = new StringBuffer("upload/");
|
StringBuffer sbMedia = new StringBuffer("upload/");
|
||||||
sbMedia.append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/");
|
sbMedia.append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/");
|
||||||
File mediaPath = new File(basePath.getAbsolutePath(),sbMedia.toString());
|
File mediaPath = new File(basePath.getAbsolutePath(), sbMedia.toString());
|
||||||
if(!mediaPath.exists()){
|
if (!mediaPath.exists()) {
|
||||||
mediaPath.mkdirs();
|
mediaPath.mkdirs();
|
||||||
}
|
}
|
||||||
file.transferTo(new File(mediaPath.getAbsoluteFile(),file.getOriginalFilename()));
|
file.transferTo(new File(mediaPath.getAbsoluteFile(), file.getOriginalFilename()));
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String nameWithOutSuffix = fileName.substring(0,fileName.lastIndexOf('.'));
|
String nameWithOutSuffix = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
String fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.')+1);
|
String fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.') + 1);
|
||||||
|
|
||||||
//保存在数据库
|
//保存在数据库
|
||||||
Attachment attachment = new Attachment();
|
Attachment attachment = new Attachment();
|
||||||
attachment.setAttachName(fileName);
|
attachment.setAttachName(fileName);
|
||||||
attachment.setAttachPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(fileName).toString());
|
attachment.setAttachPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(fileName).toString());
|
||||||
System.out.println(mediaPath.getAbsolutePath()+"/"+fileName);
|
System.out.println(mediaPath.getAbsolutePath() + "/" + fileName);
|
||||||
//判断图片大小,如果长宽都小于500,则保存原始图片路径
|
//判断图片大小,如果长宽都小于500,则保存原始图片路径
|
||||||
BufferedImage sourceImg = ImageIO.read(new FileInputStream(mediaPath.getPath()+"/"+fileName));
|
BufferedImage sourceImg = ImageIO.read(new FileInputStream(mediaPath.getPath() + "/" + fileName));
|
||||||
if(sourceImg.getWidth()<500 && sourceImg.getHeight()<500){
|
if (sourceImg.getWidth() < 500 && sourceImg.getHeight() < 500) {
|
||||||
attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(fileName).toString());
|
attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(fileName).toString());
|
||||||
}else{
|
} else {
|
||||||
attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(nameWithOutSuffix).append("_small.").append(fileSuffix).toString());
|
attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(nameWithOutSuffix).append("_small.").append(fileSuffix).toString());
|
||||||
//剪裁图片
|
//剪裁图片
|
||||||
HaloUtil.cutCenterImage(new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(fileName).toString(),new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(nameWithOutSuffix).append("_small.").append(fileSuffix).toString(),500,500,fileSuffix);
|
HaloUtil.cutCenterImage(new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(fileName).toString(), new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(nameWithOutSuffix).append("_small.").append(fileSuffix).toString(), 500, 500, fileSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment.setAttachType(file.getContentType());
|
attachment.setAttachType(file.getContentType());
|
||||||
|
@ -164,20 +164,20 @@ public class AttachmentController {
|
||||||
attachmentService.saveByAttachment(attachment);
|
attachmentService.saveByAttachment(attachment);
|
||||||
|
|
||||||
updateConst();
|
updateConst();
|
||||||
log.info("上传文件["+file.getOriginalFilename()+"]到["+mediaPath.getAbsolutePath()+"]成功");
|
log.info("上传文件[" + file.getOriginalFilename() + "]到[" + mediaPath.getAbsolutePath() + "]成功");
|
||||||
logsService.saveByLogs(
|
logsService.saveByLogs(
|
||||||
new Logs(LogsRecord.UPLOAD_FILE,file.getOriginalFilename(),HaloUtil.getIpAddr(request),HaloUtil.getDate())
|
new Logs(LogsRecord.UPLOAD_FILE, file.getOriginalFilename(), HaloUtil.getIpAddr(request), HaloUtil.getDate())
|
||||||
);
|
);
|
||||||
|
|
||||||
result.put("success",1);
|
result.put("success", 1);
|
||||||
result.put("message","上传成功!");
|
result.put("message", "上传成功!");
|
||||||
result.put("url",attachment.getAttachPath());
|
result.put("url", attachment.getAttachPath());
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
result.put("success",0);
|
result.put("success", 0);
|
||||||
result.put("message","上传失败!");
|
result.put("message", "上传失败!");
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
log.error("文件不能为空");
|
log.error("文件不能为空");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -186,17 +186,17 @@ public class AttachmentController {
|
||||||
/**
|
/**
|
||||||
* 处理获取附件详情的请求
|
* 处理获取附件详情的请求
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param attachId 附件编号
|
* @param attachId 附件编号
|
||||||
* @return 模板路径admin/widget/_attachment-detail
|
* @return 模板路径admin/widget/_attachment-detail
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/attachment")
|
@GetMapping(value = "/attachment")
|
||||||
public String attachmentDetail(Model model,@PathParam("attachId") Long attachId){
|
public String attachmentDetail(Model model, @PathParam("attachId") Long attachId) {
|
||||||
Optional<Attachment> attachment = attachmentService.findByAttachId(attachId);
|
Optional<Attachment> attachment = attachmentService.findByAttachId(attachId);
|
||||||
model.addAttribute("attachment",attachment.get());
|
model.addAttribute("attachment", attachment.get());
|
||||||
|
|
||||||
//设置选项
|
//设置选项
|
||||||
model.addAttribute("options",HaloConst.OPTIONS);
|
model.addAttribute("options", HaloConst.OPTIONS);
|
||||||
return "admin/widget/_attachment-detail";
|
return "admin/widget/_attachment-detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,16 +204,16 @@ public class AttachmentController {
|
||||||
* 移除附件的请求
|
* 移除附件的请求
|
||||||
*
|
*
|
||||||
* @param attachId 附件编号
|
* @param attachId 附件编号
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return true:移除附件成功,false:移除附件失败
|
* @return true:移除附件成功,false:移除附件失败
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/remove")
|
@GetMapping(value = "/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean removeAttachment(@PathParam("attachId") Long attachId,
|
public boolean removeAttachment(@PathParam("attachId") Long attachId,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
Optional<Attachment> attachment = attachmentService.findByAttachId(attachId);
|
Optional<Attachment> attachment = attachmentService.findByAttachId(attachId);
|
||||||
String delFileName = attachment.get().getAttachName();
|
String delFileName = attachment.get().getAttachName();
|
||||||
String delSmallFileName = delFileName.substring(0,delFileName.lastIndexOf('.'))+"_small"+attachment.get().getAttachSuffix();
|
String delSmallFileName = delFileName.substring(0, delFileName.lastIndexOf('.')) + "_small" + attachment.get().getAttachSuffix();
|
||||||
try {
|
try {
|
||||||
//删除数据库中的内容
|
//删除数据库中的内容
|
||||||
attachmentService.removeByAttachId(attachId);
|
attachmentService.removeByAttachId(attachId);
|
||||||
|
@ -221,32 +221,32 @@ public class AttachmentController {
|
||||||
updateConst();
|
updateConst();
|
||||||
//删除文件
|
//删除文件
|
||||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
File mediaPath = new File(basePath.getAbsolutePath(),attachment.get().getAttachPath().substring(0,attachment.get().getAttachPath().lastIndexOf('/')));
|
File mediaPath = new File(basePath.getAbsolutePath(), attachment.get().getAttachPath().substring(0, attachment.get().getAttachPath().lastIndexOf('/')));
|
||||||
File delFile = new File(new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(delFileName).toString());
|
File delFile = new File(new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(delFileName).toString());
|
||||||
File delSmallFile = new File(new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(delSmallFileName).toString());
|
File delSmallFile = new File(new StringBuffer(mediaPath.getAbsolutePath()).append("/").append(delSmallFileName).toString());
|
||||||
|
|
||||||
BufferedImage sourceImg = ImageIO.read(new FileInputStream(delFile));
|
BufferedImage sourceImg = ImageIO.read(new FileInputStream(delFile));
|
||||||
if(sourceImg.getWidth()>500 && sourceImg.getHeight()>500){
|
if (sourceImg.getWidth() > 500 && sourceImg.getHeight() > 500) {
|
||||||
if(delSmallFile.exists()){
|
if (delSmallFile.exists()) {
|
||||||
if(delSmallFile.delete()){
|
if (delSmallFile.delete()) {
|
||||||
updateConst();
|
updateConst();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(delFile.exists() && delFile.isFile()){
|
if (delFile.exists() && delFile.isFile()) {
|
||||||
if(delFile.delete()){
|
if (delFile.delete()) {
|
||||||
updateConst();
|
updateConst();
|
||||||
log.info("删除文件["+delFileName+"]成功!");
|
log.info("删除文件[" + delFileName + "]成功!");
|
||||||
logsService.saveByLogs(
|
logsService.saveByLogs(
|
||||||
new Logs(LogsRecord.REMOVE_FILE,delFileName,HaloUtil.getIpAddr(request),HaloUtil.getDate())
|
new Logs(LogsRecord.REMOVE_FILE, delFileName, HaloUtil.getIpAddr(request), HaloUtil.getDate())
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
log.error("删除附件["+delFileName+"]失败!");
|
log.error("删除附件[" + delFileName + "]失败!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("删除附件["+delFileName+"]失败!:",e.getMessage());
|
log.error("删除附件[" + delFileName + "]失败!:", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class BackupController {
|
||||||
* @return 模板路径admin/admin_backup
|
* @return 模板路径admin/admin_backup
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String backup(){
|
public String backup() {
|
||||||
return "admin/admin_backup";
|
return "admin/admin_backup";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,14 +45,14 @@ public class BackupController {
|
||||||
* @return 重定向到/admin/backup
|
* @return 重定向到/admin/backup
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/backupDb")
|
@GetMapping(value = "/backupDb")
|
||||||
public String backupDatabase(){
|
public String backupDatabase() {
|
||||||
String fileName = "db_backup_"+HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss")+".sql";
|
String fileName = "db_backup_" + HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss") + ".sql";
|
||||||
try {
|
try {
|
||||||
File path = new File(ResourceUtils.getURL("classpath:").getPath());
|
File path = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
String savePath = path.getAbsolutePath()+"/backup/database";
|
String savePath = path.getAbsolutePath() + "/backup/database";
|
||||||
HaloUtil.exportDatabase("localhost","root","123456",savePath,fileName,"testdb");
|
HaloUtil.exportDatabase("localhost", "root", "123456", savePath, fileName, "testdb");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/backup";
|
return "redirect:/admin/backup";
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class BackupController {
|
||||||
* @return return
|
* @return return
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/backupRe")
|
@GetMapping(value = "/backupRe")
|
||||||
public String backupResources(){
|
public String backupResources() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,15 +73,15 @@ public class BackupController {
|
||||||
* @return 重定向到/admin/backup
|
* @return 重定向到/admin/backup
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/backupPost")
|
@GetMapping(value = "/backupPost")
|
||||||
public String backupPosts(){
|
public String backupPosts() {
|
||||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||||
try {
|
try {
|
||||||
File path = new File(ResourceUtils.getURL("classpath:").getPath());
|
File path = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
String savePath = path.getAbsolutePath()+"/backup/posts/posts_backup_"+HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss");
|
String savePath = path.getAbsolutePath() + "/backup/posts/posts_backup_" + HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss");
|
||||||
for(Post post : posts){
|
for (Post post : posts) {
|
||||||
HaloUtil.dbToFile(post.getPostContentMd(),savePath,post.getPostTitle()+".md");
|
HaloUtil.dbToFile(post.getPostContentMd(), savePath, post.getPostTitle() + ".md");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return "redirect:/admin/backup";
|
return "redirect:/admin/backup";
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class CategoryController {
|
||||||
* @return 模板路径admin/admin_category
|
* @return 模板路径admin/admin_category
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String categories(Model model){
|
public String categories(Model model) {
|
||||||
model.addAttribute("statusName","添加");
|
model.addAttribute("statusName", "添加");
|
||||||
return "admin/admin_category";
|
return "admin/admin_category";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,11 +44,11 @@ public class CategoryController {
|
||||||
* @return 重定向到/admin/category
|
* @return 重定向到/admin/category
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/save")
|
@PostMapping(value = "/save")
|
||||||
public String saveCategory(@ModelAttribute Category category){
|
public String saveCategory(@ModelAttribute Category category) {
|
||||||
try{
|
try {
|
||||||
categoryService.saveByCategory(category);
|
categoryService.saveByCategory(category);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/category";
|
return "redirect:/admin/category";
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ public class CategoryController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/checkUrl")
|
@GetMapping(value = "/checkUrl")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean checkCateUrlExists(@RequestParam("cateUrl") String cateUrl){
|
public boolean checkCateUrlExists(@RequestParam("cateUrl") String cateUrl) {
|
||||||
Category category = categoryService.findByCateUrl(cateUrl);
|
Category category = categoryService.findByCateUrl(cateUrl);
|
||||||
return null!=category;
|
return null != category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,12 +73,12 @@ public class CategoryController {
|
||||||
* @return 重定向到/admin/category
|
* @return 重定向到/admin/category
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/remove")
|
@GetMapping(value = "/remove")
|
||||||
public String removeCategory(@PathParam("cateId") Long cateId){
|
public String removeCategory(@PathParam("cateId") Long cateId) {
|
||||||
try{
|
try {
|
||||||
Category category = categoryService.removeByCateId(cateId);
|
Category category = categoryService.removeByCateId(cateId);
|
||||||
log.info("删除的分类目录:"+category);
|
log.info("删除的分类目录:" + category);
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/category";
|
return "redirect:/admin/category";
|
||||||
}
|
}
|
||||||
|
@ -87,14 +87,14 @@ public class CategoryController {
|
||||||
* 跳转到修改页面
|
* 跳转到修改页面
|
||||||
*
|
*
|
||||||
* @param cateId cateId
|
* @param cateId cateId
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return 模板路径admin/admin_category
|
* @return 模板路径admin/admin_category
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/edit")
|
@GetMapping(value = "/edit")
|
||||||
public String toEditCategory(Model model,@PathParam("cateId") Long cateId){
|
public String toEditCategory(Model model, @PathParam("cateId") Long cateId) {
|
||||||
Optional<Category> category = categoryService.findByCateId(cateId);
|
Optional<Category> category = categoryService.findByCateId(cateId);
|
||||||
model.addAttribute("updateCategory",category.get());
|
model.addAttribute("updateCategory", category.get());
|
||||||
model.addAttribute("statusName","修改");
|
model.addAttribute("statusName", "修改");
|
||||||
return "admin/admin_category";
|
return "admin/admin_category";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import cc.ryanc.halo.model.domain.User;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.service.CommentService;
|
import cc.ryanc.halo.service.CommentService;
|
||||||
import cc.ryanc.halo.service.MailService;
|
import cc.ryanc.halo.service.MailService;
|
||||||
|
import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.service.UserService;
|
import cc.ryanc.halo.service.UserService;
|
||||||
import cc.ryanc.halo.util.HaloUtil;
|
import cc.ryanc.halo.util.HaloUtil;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
|
@ -52,6 +53,9 @@ public class CommentController extends BaseController{
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PostService postService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染评论管理页面
|
* 渲染评论管理页面
|
||||||
*
|
*
|
||||||
|
@ -81,18 +85,18 @@ public class CommentController extends BaseController{
|
||||||
* 将评论移到回收站
|
* 将评论移到回收站
|
||||||
*
|
*
|
||||||
* @param commentId 评论编号
|
* @param commentId 评论编号
|
||||||
* @param session session
|
* @param status 评论状态
|
||||||
* @return 重定向到/admin/comments
|
* @return 重定向到/admin/comments
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/throw")
|
@GetMapping(value = "/throw")
|
||||||
public String moveToTrash(@PathParam("commentId") Long commentId,
|
public String moveToTrash(@PathParam("commentId") Long commentId,
|
||||||
HttpSession session){
|
@PathParam("status") String status){
|
||||||
try {
|
try {
|
||||||
commentService.updateCommentStatus(commentId,2);
|
commentService.updateCommentStatus(commentId,2);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}",e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/comments";
|
return "redirect:/admin/comments?status="+status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +121,7 @@ public class CommentController extends BaseController{
|
||||||
try {
|
try {
|
||||||
if (status == 1 && matcher.find()) {
|
if (status == 1 && matcher.find()) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("pageUrl", comment.getPost().getPostUrl());
|
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url")+"/archives/"+comment.getPost().getPostUrl()+"#comment-id-"+comment.getCommentId());
|
||||||
map.put("pageName", comment.getPost().getPostTitle());
|
map.put("pageName", comment.getPost().getPostTitle());
|
||||||
map.put("commentContent", comment.getCommentContent());
|
map.put("commentContent", comment.getCommentContent());
|
||||||
map.put("blogUrl", HaloConst.OPTIONS.get("blog_url"));
|
map.put("blogUrl", HaloConst.OPTIONS.get("blog_url"));
|
||||||
|
@ -169,8 +173,7 @@ public class CommentController extends BaseController{
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpSession session){
|
HttpSession session){
|
||||||
try {
|
try {
|
||||||
Post post = new Post();
|
Post post = postService.findByPostId(postId).get();
|
||||||
post.setPostId(postId);
|
|
||||||
|
|
||||||
//博主信息
|
//博主信息
|
||||||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
|
@ -191,7 +194,7 @@ public class CommentController extends BaseController{
|
||||||
comment.setCommentAuthorIp(HaloUtil.getIpAddr(request));
|
comment.setCommentAuthorIp(HaloUtil.getIpAddr(request));
|
||||||
comment.setCommentAuthorAvatarMd5(HaloUtil.getMD5(userService.findUser().getUserEmail()));
|
comment.setCommentAuthorAvatarMd5(HaloUtil.getMD5(userService.findUser().getUserEmail()));
|
||||||
comment.setCommentDate(new Date());
|
comment.setCommentDate(new Date());
|
||||||
String lastContent = " //<a href='#'>@"+lastComment.getCommentAuthor()+"</a>:"+lastComment.getCommentContent();
|
String lastContent = " //<a href='#comment-id-"+lastComment.getCommentId()+"'>@"+lastComment.getCommentAuthor()+"</a>:"+lastComment.getCommentContent();
|
||||||
comment.setCommentContent(commentContent+lastContent);
|
comment.setCommentContent(commentContent+lastContent);
|
||||||
comment.setCommentAgent(userAgent);
|
comment.setCommentAgent(userAgent);
|
||||||
comment.setCommentParent(commentId);
|
comment.setCommentParent(commentId);
|
||||||
|
@ -210,6 +213,7 @@ public class CommentController extends BaseController{
|
||||||
map.put("blogTitle",HaloConst.OPTIONS.get("blog_title"));
|
map.put("blogTitle",HaloConst.OPTIONS.get("blog_title"));
|
||||||
map.put("commentAuthor",lastComment.getCommentAuthor());
|
map.put("commentAuthor",lastComment.getCommentAuthor());
|
||||||
map.put("pageName",lastComment.getPost().getPostTitle());
|
map.put("pageName",lastComment.getPost().getPostTitle());
|
||||||
|
map.put("pageUrl",HaloConst.OPTIONS.get("blog_url")+"/archives/"+post.getPostUrl()+"#comment-id-"+comment.getCommentId());
|
||||||
map.put("commentContent",lastComment.getCommentContent());
|
map.put("commentContent",lastComment.getCommentContent());
|
||||||
map.put("replyAuthor",user.getUserDisplayName());
|
map.put("replyAuthor",user.getUserDisplayName());
|
||||||
map.put("replyContent",commentContent);
|
map.put("replyContent",commentContent);
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class MenuController {
|
||||||
* @return 模板路径/admin/admin_menu
|
* @return 模板路径/admin/admin_menu
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String menus(Model model){
|
public String menus(Model model) {
|
||||||
model.addAttribute("statusName","添加");
|
model.addAttribute("statusName", "添加");
|
||||||
return "/admin/admin_menu";
|
return "/admin/admin_menu";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ public class MenuController {
|
||||||
* @return 重定向到/admin/menus
|
* @return 重定向到/admin/menus
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/save")
|
@PostMapping(value = "/save")
|
||||||
public String saveMenu(@ModelAttribute Menu menu){
|
public String saveMenu(@ModelAttribute Menu menu) {
|
||||||
try{
|
try {
|
||||||
menuService.saveByMenu(menu);
|
menuService.saveByMenu(menu);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("保存菜单失败:"+e.getMessage());
|
log.error("保存菜单失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/menus";
|
return "redirect:/admin/menus";
|
||||||
}
|
}
|
||||||
|
@ -56,14 +56,14 @@ public class MenuController {
|
||||||
* 跳转到修改页面
|
* 跳转到修改页面
|
||||||
*
|
*
|
||||||
* @param menuId 菜单编号
|
* @param menuId 菜单编号
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return 模板路径/admin/admin_menu
|
* @return 模板路径/admin/admin_menu
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/edit")
|
@GetMapping(value = "/edit")
|
||||||
public String updateMenu(@RequestParam("menuId") Long menuId,Model model){
|
public String updateMenu(@RequestParam("menuId") Long menuId, Model model) {
|
||||||
Menu menu = menuService.findByMenuId(menuId).get();
|
Menu menu = menuService.findByMenuId(menuId).get();
|
||||||
model.addAttribute("statusName","修改");
|
model.addAttribute("statusName", "修改");
|
||||||
model.addAttribute("updateMenu",menu);
|
model.addAttribute("updateMenu", menu);
|
||||||
return "/admin/admin_menu";
|
return "/admin/admin_menu";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ public class MenuController {
|
||||||
* @return 重定向到/admin/menus
|
* @return 重定向到/admin/menus
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/remove")
|
@GetMapping(value = "/remove")
|
||||||
public String removeMenu(@PathParam("menuId") Long menuId){
|
public String removeMenu(@PathParam("menuId") Long menuId) {
|
||||||
try {
|
try {
|
||||||
menuService.removeByMenuId(menuId);
|
menuService.removeByMenuId(menuId);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("删除菜单失败:{0}",e.getMessage());
|
log.error("删除菜单失败:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/menus";
|
return "redirect:/admin/menus";
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class OptionController {
|
||||||
* @return 模板路径admin/admin_option
|
* @return 模板路径admin/admin_option
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String options(){
|
public String options() {
|
||||||
return "admin/admin_option";
|
return "admin/admin_option";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,17 +45,17 @@ public class OptionController {
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/save")
|
@PostMapping(value = "/save")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean saveOptions(@RequestParam Map<String,String> options){
|
public boolean saveOptions(@RequestParam Map<String, String> options) {
|
||||||
try {
|
try {
|
||||||
optionsService.saveOptions(options);
|
optionsService.saveOptions(options);
|
||||||
//刷新options
|
//刷新options
|
||||||
configuration.setSharedVariable("options",optionsService.findAllOptions());
|
configuration.setSharedVariable("options", optionsService.findAllOptions());
|
||||||
HaloConst.OPTIONS.clear();
|
HaloConst.OPTIONS.clear();
|
||||||
HaloConst.OPTIONS = optionsService.findAllOptions();
|
HaloConst.OPTIONS = optionsService.findAllOptions();
|
||||||
log.info("所保存的设置选项列表:"+options);
|
log.info("所保存的设置选项列表:" + options);
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,9 @@ public class PageController {
|
||||||
* @return 模板路径admin/admin_page
|
* @return 模板路径admin/admin_page
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String pages(Model model){
|
public String pages(Model model) {
|
||||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_PAGE);
|
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_PAGE);
|
||||||
model.addAttribute("pages",posts);
|
model.addAttribute("pages", posts);
|
||||||
return "admin/admin_page";
|
return "admin/admin_page";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,27 +71,27 @@ public class PageController {
|
||||||
* @return 模板路径admin/admin_page_link
|
* @return 模板路径admin/admin_page_link
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/links")
|
@GetMapping(value = "/links")
|
||||||
public String links(Model model){
|
public String links(Model model) {
|
||||||
List<Link> links = linkService.findAllLinks();
|
List<Link> links = linkService.findAllLinks();
|
||||||
model.addAttribute("links",links);
|
model.addAttribute("links", links);
|
||||||
model.addAttribute("statusName","添加");
|
model.addAttribute("statusName", "添加");
|
||||||
return "admin/admin_page_link";
|
return "admin/admin_page_link";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转到修改页面
|
* 跳转到修改页面
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param linkId linkId 友情链接编号
|
* @param linkId linkId 友情链接编号
|
||||||
* @return String 模板路径admin/admin_page_link
|
* @return String 模板路径admin/admin_page_link
|
||||||
*/
|
*/
|
||||||
@GetMapping("/links/edit")
|
@GetMapping("/links/edit")
|
||||||
public String toEditLink(Model model,@PathParam("linkId") Long linkId){
|
public String toEditLink(Model model, @PathParam("linkId") Long linkId) {
|
||||||
List<Link> links = linkService.findAllLinks();
|
List<Link> links = linkService.findAllLinks();
|
||||||
Optional<Link> link = linkService.findByLinkId(linkId);
|
Optional<Link> link = linkService.findByLinkId(linkId);
|
||||||
model.addAttribute("updateLink",link.get());
|
model.addAttribute("updateLink", link.get());
|
||||||
model.addAttribute("statusName","修改");
|
model.addAttribute("statusName", "修改");
|
||||||
model.addAttribute("links",links);
|
model.addAttribute("links", links);
|
||||||
return "admin/admin_page_link";
|
return "admin/admin_page_link";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +102,12 @@ public class PageController {
|
||||||
* @return 重定向到/admin/page/links
|
* @return 重定向到/admin/page/links
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/links/save")
|
@PostMapping(value = "/links/save")
|
||||||
public String saveLink(@ModelAttribute Link link){
|
public String saveLink(@ModelAttribute Link link) {
|
||||||
try{
|
try {
|
||||||
Link backLink = linkService.saveByLink(link);
|
Link backLink = linkService.saveByLink(link);
|
||||||
log.info("保存成功,数据为:"+backLink);
|
log.info("保存成功,数据为:" + backLink);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/page/links";
|
return "redirect:/admin/page/links";
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,12 @@ public class PageController {
|
||||||
* @return 重定向到/admin/page/links
|
* @return 重定向到/admin/page/links
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/links/remove")
|
@GetMapping(value = "/links/remove")
|
||||||
public String removeLink(@PathParam("linkId") Long linkId){
|
public String removeLink(@PathParam("linkId") Long linkId) {
|
||||||
try{
|
try {
|
||||||
Link link = linkService.removeByLinkId(linkId);
|
Link link = linkService.removeByLinkId(linkId);
|
||||||
log.info("删除的友情链接:"+link);
|
log.info("删除的友情链接:" + link);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/page/links";
|
return "redirect:/admin/page/links";
|
||||||
}
|
}
|
||||||
|
@ -133,18 +133,18 @@ public class PageController {
|
||||||
* 图库管理
|
* 图库管理
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param page 当前页码
|
* @param page 当前页码
|
||||||
* @param size 每页显示的条数
|
* @param size 每页显示的条数
|
||||||
* @return 模板路径admin/admin_page_gallery
|
* @return 模板路径admin/admin_page_gallery
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/galleries")
|
@GetMapping(value = "/galleries")
|
||||||
public String gallery(Model model,
|
public String gallery(Model model,
|
||||||
@RequestParam(value = "page",defaultValue = "0") Integer page,
|
@RequestParam(value = "page", defaultValue = "0") Integer page,
|
||||||
@RequestParam(value = "size",defaultValue = "18") Integer size){
|
@RequestParam(value = "size", defaultValue = "18") Integer size) {
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"galleryId");
|
Sort sort = new Sort(Sort.Direction.DESC, "galleryId");
|
||||||
Pageable pageable = new PageRequest(page,size,sort);
|
Pageable pageable = new PageRequest(page, size, sort);
|
||||||
Page<Gallery> galleries = galleryService.findAllGalleries(pageable);
|
Page<Gallery> galleries = galleryService.findAllGalleries(pageable);
|
||||||
model.addAttribute("galleries",galleries);
|
model.addAttribute("galleries", galleries);
|
||||||
return "admin/admin_page_gallery";
|
return "admin/admin_page_gallery";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,13 +155,13 @@ public class PageController {
|
||||||
* @return 重定向到/admin/page/gallery
|
* @return 重定向到/admin/page/gallery
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/gallery/save")
|
@PostMapping(value = "/gallery/save")
|
||||||
public String saveGallery(@ModelAttribute Gallery gallery){
|
public String saveGallery(@ModelAttribute Gallery gallery) {
|
||||||
try {
|
try {
|
||||||
if(StringUtils.isEmpty(gallery.getGalleryThumbnailUrl())){
|
if (StringUtils.isEmpty(gallery.getGalleryThumbnailUrl())) {
|
||||||
gallery.setGalleryThumbnailUrl(gallery.getGalleryUrl());
|
gallery.setGalleryThumbnailUrl(gallery.getGalleryUrl());
|
||||||
}
|
}
|
||||||
galleryService.saveByGallery(gallery);
|
galleryService.saveByGallery(gallery);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return "redirect:/admin/page/gallery";
|
return "redirect:/admin/page/gallery";
|
||||||
|
@ -170,14 +170,14 @@ public class PageController {
|
||||||
/**
|
/**
|
||||||
* 处理获取图片详情的请求
|
* 处理获取图片详情的请求
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param galleryId 图片编号
|
* @param galleryId 图片编号
|
||||||
* @return 模板路径admin/widget/_gallery-detail
|
* @return 模板路径admin/widget/_gallery-detail
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/gallery")
|
@GetMapping(value = "/gallery")
|
||||||
public String gallery(Model model,@PathParam("galleryId") Long galleryId){
|
public String gallery(Model model, @PathParam("galleryId") Long galleryId) {
|
||||||
Optional<Gallery> gallery = galleryService.findByGalleryId(galleryId);
|
Optional<Gallery> gallery = galleryService.findByGalleryId(galleryId);
|
||||||
model.addAttribute("gallery",gallery.get());
|
model.addAttribute("gallery", gallery.get());
|
||||||
return "admin/widget/_gallery-detail";
|
return "admin/widget/_gallery-detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,11 +189,11 @@ public class PageController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/gallery/remove")
|
@GetMapping(value = "/gallery/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean removeGallery(@RequestParam("galleryId") Long galleryId){
|
public boolean removeGallery(@RequestParam("galleryId") Long galleryId) {
|
||||||
try {
|
try {
|
||||||
galleryService.removeByGalleryId(galleryId);
|
galleryService.removeByGalleryId(galleryId);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("删除图片失败:{0}",e.getMessage());
|
log.error("删除图片失败:{0}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -206,28 +206,29 @@ public class PageController {
|
||||||
* @return 模板路径admin/admin_page_md_editor
|
* @return 模板路径admin/admin_page_md_editor
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/new")
|
@GetMapping(value = "/new")
|
||||||
public String newPage(Model model){
|
public String newPage(Model model) {
|
||||||
return "admin/admin_page_md_editor";
|
return "admin/admin_page_md_editor";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发表页面
|
* 发表页面
|
||||||
* @param post post
|
*
|
||||||
|
* @param post post
|
||||||
* @param session session
|
* @param session session
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/new/push")
|
@PostMapping(value = "/new/push")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void pushPage(@ModelAttribute Post post, HttpSession session){
|
public void pushPage(@ModelAttribute Post post, HttpSession session) {
|
||||||
try{
|
try {
|
||||||
post.setPostDate(HaloUtil.getDate());
|
post.setPostDate(HaloUtil.getDate());
|
||||||
//发表用户
|
//发表用户
|
||||||
User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
|
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
post.setUser(user);
|
post.setUser(user);
|
||||||
post.setPostType(HaloConst.POST_TYPE_PAGE);
|
post.setPostType(HaloConst.POST_TYPE_PAGE);
|
||||||
postService.saveByPost(post);
|
postService.saveByPost(post);
|
||||||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST,post.getPostTitle(),HaloUtil.getIpAddr(request),HaloUtil.getDate()));
|
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST, post.getPostTitle(), HaloUtil.getIpAddr(request), HaloUtil.getDate()));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,13 +236,13 @@ public class PageController {
|
||||||
* 跳转到修改页面
|
* 跳转到修改页面
|
||||||
*
|
*
|
||||||
* @param pageId 页面编号
|
* @param pageId 页面编号
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return admin/admin_page_md_editor
|
* @return admin/admin_page_md_editor
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/edit")
|
@GetMapping(value = "/edit")
|
||||||
public String editPage(@PathParam("pageId") Long pageId,Model model){
|
public String editPage(@PathParam("pageId") Long pageId, Model model) {
|
||||||
Optional<Post> post = postService.findByPostId(pageId);
|
Optional<Post> post = postService.findByPostId(pageId);
|
||||||
model.addAttribute("post",post.get());
|
model.addAttribute("post", post.get());
|
||||||
return "admin/admin_page_md_editor";
|
return "admin/admin_page_md_editor";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,10 +254,10 @@ public class PageController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/checkUrl")
|
@GetMapping(value = "/checkUrl")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean checkUrlExists(@PathParam("postUrl") String postUrl){
|
public boolean checkUrlExists(@PathParam("postUrl") String postUrl) {
|
||||||
Post post = postService.findByPostUrl(postUrl,HaloConst.POST_TYPE_PAGE);
|
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_PAGE);
|
||||||
// TODO 还没写完
|
// TODO 还没写完
|
||||||
if(null!=post || StringUtils.equals("archives",postUrl) || StringUtils.equals("galleries",postUrl)){
|
if (null != post || StringUtils.equals("archives", postUrl) || StringUtils.equals("galleries", postUrl)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -141,11 +141,12 @@ public class PostController extends BaseController{
|
||||||
@PostMapping(value = "/new/push")
|
@PostMapping(value = "/new/push")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void pushPost(@ModelAttribute Post post, @RequestParam("cateList") List<String> cateList, @RequestParam("tagList") String tagList, HttpSession session){
|
public void pushPost(@ModelAttribute Post post, @RequestParam("cateList") List<String> cateList, @RequestParam("tagList") String tagList, HttpSession session){
|
||||||
//发表用户
|
//判断博主是否登录
|
||||||
User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
|
User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
if(null==user){
|
if(null==user){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//判断是否为更新文章操作
|
||||||
if(null!=post.getPostId()){
|
if(null!=post.getPostId()){
|
||||||
post = postService.findByPostId(post.getPostId()).get();
|
post = postService.findByPostId(post.getPostId()).get();
|
||||||
}
|
}
|
||||||
|
@ -299,11 +300,17 @@ public class PostController extends BaseController{
|
||||||
}
|
}
|
||||||
String blogUrl = HaloConst.OPTIONS.get("blog_url");
|
String blogUrl = HaloConst.OPTIONS.get("blog_url");
|
||||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||||
String urls = "";
|
StringBuilder urls = new StringBuilder();
|
||||||
for(Post post:posts){
|
for(Post post:posts){
|
||||||
urls+=blogUrl+"/archives/"+post.getPostUrl()+"\n";
|
urls.append(blogUrl);
|
||||||
|
urls.append("/archives/");
|
||||||
|
urls.append(post.getPostUrl());
|
||||||
|
urls.append("\n");
|
||||||
|
}
|
||||||
|
String result = HaloUtil.baiduPost(blogUrl, baiduToken, urls.toString());
|
||||||
|
if (StringUtils.isEmpty(result)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
HaloUtil.baiduPost(blogUrl,baiduToken,urls);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,10 @@ public class TagController {
|
||||||
* @return 模板路径admin/admin_tag
|
* @return 模板路径admin/admin_tag
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String tags(Model model){
|
public String tags(Model model) {
|
||||||
List<Tag> tags = tagService.findAllTags();
|
List<Tag> tags = tagService.findAllTags();
|
||||||
model.addAttribute("tags",tags);
|
model.addAttribute("tags", tags);
|
||||||
model.addAttribute("statusName","新增");
|
model.addAttribute("statusName", "新增");
|
||||||
return "admin/admin_tag";
|
return "admin/admin_tag";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ public class TagController {
|
||||||
* @return 重定向到/admin/tag
|
* @return 重定向到/admin/tag
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/save")
|
@PostMapping(value = "/save")
|
||||||
public String saveTag(@ModelAttribute Tag tag){
|
public String saveTag(@ModelAttribute Tag tag) {
|
||||||
try{
|
try {
|
||||||
tagService.saveByTag(tag);
|
tagService.saveByTag(tag);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/tag";
|
return "redirect:/admin/tag";
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,9 @@ public class TagController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/checkUrl")
|
@GetMapping(value = "/checkUrl")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean checkTagUrlExists(@RequestParam("tagUrl") String tagUrl){
|
public boolean checkTagUrlExists(@RequestParam("tagUrl") String tagUrl) {
|
||||||
Tag tag = tagService.findByTagUrl(tagUrl);
|
Tag tag = tagService.findByTagUrl(tagUrl);
|
||||||
return null!=tag;
|
return null != tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,12 +75,12 @@ public class TagController {
|
||||||
* @return 重定向到/admin/tag
|
* @return 重定向到/admin/tag
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/remove")
|
@GetMapping(value = "/remove")
|
||||||
public String removeTag(@PathParam("tagId") Long tagId){
|
public String removeTag(@PathParam("tagId") Long tagId) {
|
||||||
try{
|
try {
|
||||||
Tag tag = tagService.removeByTagId(tagId);
|
Tag tag = tagService.removeByTagId(tagId);
|
||||||
log.info("删除的标签:"+tag);
|
log.info("删除的标签:" + tag);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/tag";
|
return "redirect:/admin/tag";
|
||||||
}
|
}
|
||||||
|
@ -93,12 +93,12 @@ public class TagController {
|
||||||
* @return 模板路径admin/admin_tag
|
* @return 模板路径admin/admin_tag
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/edit")
|
@GetMapping(value = "/edit")
|
||||||
public String toEditTag(Model model,@PathParam("tagId") Long tagId){
|
public String toEditTag(Model model, @PathParam("tagId") Long tagId) {
|
||||||
List<Tag> tags = tagService.findAllTags();
|
List<Tag> tags = tagService.findAllTags();
|
||||||
Tag tag = tagService.findByTagId(tagId).get();
|
Tag tag = tagService.findByTagId(tagId).get();
|
||||||
model.addAttribute("statusName","修改");
|
model.addAttribute("statusName", "修改");
|
||||||
model.addAttribute("updateTag",tag);
|
model.addAttribute("updateTag", tag);
|
||||||
model.addAttribute("tags",tags);
|
model.addAttribute("tags", tags);
|
||||||
return "admin/admin_tag";
|
return "admin/admin_tag";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/admin/themes")
|
@RequestMapping(value = "/admin/themes")
|
||||||
public class ThemeController extends BaseController{
|
public class ThemeController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OptionsService optionsService;
|
private OptionsService optionsService;
|
||||||
|
@ -47,10 +47,10 @@ public class ThemeController extends BaseController{
|
||||||
* @return 模板路径admin/admin_theme
|
* @return 模板路径admin/admin_theme
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String themes(Model model){
|
public String themes(Model model) {
|
||||||
model.addAttribute("activeTheme",BaseController.THEME);
|
model.addAttribute("activeTheme", BaseController.THEME);
|
||||||
if(null!=HaloConst.THEMES){
|
if (null != HaloConst.THEMES) {
|
||||||
model.addAttribute("themes",HaloConst.THEMES);
|
model.addAttribute("themes", HaloConst.THEMES);
|
||||||
}
|
}
|
||||||
return "admin/admin_theme";
|
return "admin/admin_theme";
|
||||||
}
|
}
|
||||||
|
@ -59,25 +59,25 @@ public class ThemeController extends BaseController{
|
||||||
* 激活主题
|
* 激活主题
|
||||||
*
|
*
|
||||||
* @param siteTheme 主题名称
|
* @param siteTheme 主题名称
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return true:激活成功,false:激活失败
|
* @return true:激活成功,false:激活失败
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/set")
|
@GetMapping(value = "/set")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean activeTheme(@PathParam("siteTheme") String siteTheme,
|
public boolean activeTheme(@PathParam("siteTheme") String siteTheme,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
//保存主题设置项
|
//保存主题设置项
|
||||||
optionsService.saveOption("theme",siteTheme);
|
optionsService.saveOption("theme", siteTheme);
|
||||||
//设置主题
|
//设置主题
|
||||||
BaseController.THEME = siteTheme;
|
BaseController.THEME = siteTheme;
|
||||||
log.info("已将主题改变为:"+siteTheme);
|
log.info("已将主题改变为:" + siteTheme);
|
||||||
logsService.saveByLogs(
|
logsService.saveByLogs(
|
||||||
new Logs(LogsRecord.CHANGE_THEME,"更换为"+siteTheme,HaloUtil.getIpAddr(request),HaloUtil.getDate())
|
new Logs(LogsRecord.CHANGE_THEME, "更换为" + siteTheme, HaloUtil.getIpAddr(request), HaloUtil.getDate())
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("主题设置失败,当前主题为:"+siteTheme);
|
log.error("主题设置失败,当前主题为:" + siteTheme);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,27 +92,27 @@ public class ThemeController extends BaseController{
|
||||||
@RequestMapping(value = "/upload", method = RequestMethod.POST)
|
@RequestMapping(value = "/upload", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean uploadTheme(@RequestParam("file") MultipartFile file,
|
public boolean uploadTheme(@RequestParam("file") MultipartFile file,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
if(!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
//获取项目根路径
|
//获取项目根路径
|
||||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
File themePath = new File(basePath.getAbsolutePath(), new StringBuffer("templates/themes/").append(file.getOriginalFilename()).toString());
|
File themePath = new File(basePath.getAbsolutePath(), new StringBuffer("templates/themes/").append(file.getOriginalFilename()).toString());
|
||||||
file.transferTo(themePath);
|
file.transferTo(themePath);
|
||||||
log.info("上传主题成功,路径:" + themePath.getAbsolutePath());
|
log.info("上传主题成功,路径:" + themePath.getAbsolutePath());
|
||||||
logsService.saveByLogs(
|
logsService.saveByLogs(
|
||||||
new Logs(LogsRecord.UPLOAD_THEME,file.getOriginalFilename(),HaloUtil.getIpAddr(request),HaloUtil.getDate())
|
new Logs(LogsRecord.UPLOAD_THEME, file.getOriginalFilename(), HaloUtil.getIpAddr(request), HaloUtil.getDate())
|
||||||
);
|
);
|
||||||
HaloUtil.unZip(themePath.getAbsolutePath(),new File(basePath.getAbsolutePath(),"templates/themes/").getAbsolutePath());
|
HaloUtil.unZip(themePath.getAbsolutePath(), new File(basePath.getAbsolutePath(), "templates/themes/").getAbsolutePath());
|
||||||
HaloUtil.removeFile(themePath.getAbsolutePath());
|
HaloUtil.removeFile(themePath.getAbsolutePath());
|
||||||
HaloConst.THEMES.clear();
|
HaloConst.THEMES.clear();
|
||||||
HaloConst.THEMES = HaloUtil.getThemes();
|
HaloConst.THEMES = HaloUtil.getThemes();
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
log.error("上传主题失败,没有选择文件");
|
log.error("上传主题失败,没有选择文件");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("上传主题失败:{0}",e.getMessage());
|
log.error("上传主题失败:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,15 +124,15 @@ public class ThemeController extends BaseController{
|
||||||
* @return string 重定向到/admin/themes
|
* @return string 重定向到/admin/themes
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/remove")
|
@GetMapping(value = "/remove")
|
||||||
public String removeTheme(@RequestParam("themeName") String themeName){
|
public String removeTheme(@RequestParam("themeName") String themeName) {
|
||||||
try{
|
try {
|
||||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
File themePath = new File(basePath.getAbsolutePath(),"templates/themes/"+themeName);
|
File themePath = new File(basePath.getAbsolutePath(), "templates/themes/" + themeName);
|
||||||
HaloUtil.removeDir(themePath);
|
HaloUtil.removeDir(themePath);
|
||||||
HaloConst.THEMES.clear();
|
HaloConst.THEMES.clear();
|
||||||
HaloConst.THEMES = HaloUtil.getThemes();
|
HaloConst.THEMES = HaloUtil.getThemes();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("删除主题失败:{0}",e.getMessage());
|
log.error("删除主题失败:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return "redirect:/admin/themes";
|
return "redirect:/admin/themes";
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,9 @@ public class ThemeController extends BaseController{
|
||||||
* @param theme theme名称
|
* @param theme theme名称
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/options")
|
@GetMapping(value = "/options")
|
||||||
public String setting(Model model,@RequestParam("theme") String theme){
|
public String setting(Model model, @RequestParam("theme") String theme) {
|
||||||
model.addAttribute("themeDir",theme);
|
model.addAttribute("themeDir", theme);
|
||||||
return "themes/"+theme+"/module/options";
|
return "themes/" + theme + "/module/options";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,9 +155,9 @@ public class ThemeController extends BaseController{
|
||||||
* @return 模板路径admin/admin_theme-editor
|
* @return 模板路径admin/admin_theme-editor
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/editor")
|
@GetMapping(value = "/editor")
|
||||||
public String editor(Model model){
|
public String editor(Model model) {
|
||||||
List<String> tpls = HaloUtil.getTplName(BaseController.THEME);
|
List<String> tpls = HaloUtil.getTplName(BaseController.THEME);
|
||||||
model.addAttribute("tpls",tpls);
|
model.addAttribute("tpls", tpls);
|
||||||
return "admin/admin_theme-editor";
|
return "admin/admin_theme-editor";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,18 +167,18 @@ public class ThemeController extends BaseController{
|
||||||
* @param tplName 模板文件名
|
* @param tplName 模板文件名
|
||||||
* @return 模板内容
|
* @return 模板内容
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/getTpl",produces = "text/text;charset=UTF-8")
|
@GetMapping(value = "/getTpl", produces = "text/text;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getTplContent(@RequestParam("tplName") String tplName){
|
public String getTplContent(@RequestParam("tplName") String tplName) {
|
||||||
String tplContent = "";
|
String tplContent = "";
|
||||||
try {
|
try {
|
||||||
//获取项目根路径
|
//获取项目根路径
|
||||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
//获取主题路径
|
//获取主题路径
|
||||||
File themesPath = new File(basePath.getAbsolutePath(),new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString());
|
File themesPath = new File(basePath.getAbsolutePath(), new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString());
|
||||||
tplContent = HaloUtil.getFileContent(themesPath.getAbsolutePath());
|
tplContent = HaloUtil.getFileContent(themesPath.getAbsolutePath());
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("获取模板文件错误:{0}",e.getMessage());
|
log.error("获取模板文件错误:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return tplContent;
|
return tplContent;
|
||||||
}
|
}
|
||||||
|
@ -186,26 +186,26 @@ public class ThemeController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* 保存修改模板
|
* 保存修改模板
|
||||||
*
|
*
|
||||||
* @param tplName 模板名称
|
* @param tplName 模板名称
|
||||||
* @param tplContent 模板内容
|
* @param tplContent 模板内容
|
||||||
* @return boolean true:修改成功,false:修改失败
|
* @return boolean true:修改成功,false:修改失败
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/editor/save")
|
@PostMapping(value = "/editor/save")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean saveTpl(@RequestParam("tplName") String tplName,
|
public boolean saveTpl(@RequestParam("tplName") String tplName,
|
||||||
@RequestParam("tplContent") String tplContent){
|
@RequestParam("tplContent") String tplContent) {
|
||||||
if(StringUtils.isBlank(tplContent)){
|
if (StringUtils.isBlank(tplContent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//获取项目根路径
|
//获取项目根路径
|
||||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||||
//获取主题路径
|
//获取主题路径
|
||||||
File tplPath = new File(basePath.getAbsolutePath(),new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString());
|
File tplPath = new File(basePath.getAbsolutePath(), new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString());
|
||||||
byte[] tplContentByte = tplContent.getBytes("UTF-8");
|
byte[] tplContentByte = tplContent.getBytes("UTF-8");
|
||||||
Files.write(Paths.get(tplPath.getAbsolutePath()),tplContentByte);
|
Files.write(Paths.get(tplPath.getAbsolutePath()), tplContentByte);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("文件保存失败:{0}",e.getMessage());
|
log.error("文件保存失败:{0}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,30 +34,30 @@ public class UserController {
|
||||||
* @return 模板路径admin/admin_profile
|
* @return 模板路径admin/admin_profile
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String profile(){
|
public String profile() {
|
||||||
return "admin/admin_profile";
|
return "admin/admin_profile";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理修改用户资料的请求
|
* 处理修改用户资料的请求
|
||||||
*
|
*
|
||||||
* @param user user
|
* @param user user
|
||||||
* @param session session
|
* @param session session
|
||||||
* @return true:修改成功,false:修改失败
|
* @return true:修改成功,false:修改失败
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "save")
|
@PostMapping(value = "save")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean saveProfile(@ModelAttribute User user,HttpSession session){
|
public boolean saveProfile(@ModelAttribute User user, HttpSession session) {
|
||||||
try{
|
try {
|
||||||
if(null!=user){
|
if (null != user) {
|
||||||
userService.saveByUser(user);
|
userService.saveByUser(user);
|
||||||
configuration.setSharedVariable("user",userService.findUser());
|
configuration.setSharedVariable("user", userService.findUser());
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
log.error("未知错误:{0}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -67,28 +67,28 @@ public class UserController {
|
||||||
* 处理修改密码的请求
|
* 处理修改密码的请求
|
||||||
*
|
*
|
||||||
* @param beforePass 旧密码
|
* @param beforePass 旧密码
|
||||||
* @param newPass 新密码
|
* @param newPass 新密码
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param session session
|
* @param session session
|
||||||
* @return true:修改密码成功,false:修改密码失败
|
* @return true:修改密码成功,false:修改密码失败
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "changePass")
|
@PostMapping(value = "changePass")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean changePass(@ModelAttribute("beforePass") String beforePass,
|
public boolean changePass(@ModelAttribute("beforePass") String beforePass,
|
||||||
@ModelAttribute("newPass") String newPass,
|
@ModelAttribute("newPass") String newPass,
|
||||||
@ModelAttribute("userId") Long userId,
|
@ModelAttribute("userId") Long userId,
|
||||||
HttpSession session){
|
HttpSession session) {
|
||||||
try {
|
try {
|
||||||
User user = userService.findByUserIdAndUserPass(userId,HaloUtil.getMD5(beforePass));
|
User user = userService.findByUserIdAndUserPass(userId, HaloUtil.getMD5(beforePass));
|
||||||
if(null!=user){
|
if (null != user) {
|
||||||
user.setUserPass(HaloUtil.getMD5(newPass));
|
user.setUserPass(HaloUtil.getMD5(newPass));
|
||||||
userService.saveByUser(user);
|
userService.saveByUser(user);
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("修改密码:未知错误,{0}",e.getMessage());
|
log.error("修改密码:未知错误,{0}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -19,7 +19,7 @@ public abstract class BaseController {
|
||||||
* @param pageName pageName
|
* @param pageName pageName
|
||||||
* @return 返回拼接好的模板路径
|
* @return 返回拼接好的模板路径
|
||||||
*/
|
*/
|
||||||
public String render(String pageName){
|
public String render(String pageName) {
|
||||||
StringBuffer themeStr = new StringBuffer("themes/");
|
StringBuffer themeStr = new StringBuffer("themes/");
|
||||||
themeStr.append(THEME);
|
themeStr.append(THEME);
|
||||||
themeStr.append("/");
|
themeStr.append("/");
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/12/26
|
* @date : 2017/12/26
|
||||||
|
@ -16,7 +17,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
public class CommonController implements ErrorController{
|
public class CommonController implements ErrorController {
|
||||||
|
|
||||||
private static final String ERROR_PATH = "/error";
|
private static final String ERROR_PATH = "/error";
|
||||||
|
|
||||||
|
@ -27,11 +28,11 @@ public class CommonController implements ErrorController{
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = ERROR_PATH)
|
@GetMapping(value = ERROR_PATH)
|
||||||
public String handleError(HttpServletRequest request){
|
public String handleError(HttpServletRequest request) {
|
||||||
Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
|
Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
|
||||||
if(statusCode==404) {
|
if (statusCode == 404) {
|
||||||
return "redirect:/404";
|
return "redirect:/404";
|
||||||
}else{
|
} else {
|
||||||
return "redirect:/500";
|
return "redirect:/500";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +44,7 @@ public class CommonController implements ErrorController{
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/404")
|
@GetMapping(value = "/404")
|
||||||
public String fourZeroFour(Model model){
|
public String fourZeroFour(Model model) {
|
||||||
//设置选项
|
//设置选项
|
||||||
model.addAttribute("options", HaloConst.OPTIONS);
|
model.addAttribute("options", HaloConst.OPTIONS);
|
||||||
return "common/404";
|
return "common/404";
|
||||||
|
@ -56,7 +57,7 @@ public class CommonController implements ErrorController{
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/500")
|
@GetMapping(value = "/500")
|
||||||
public String fiveZeroZero(Model model){
|
public String fiveZeroZero(Model model) {
|
||||||
//设置选项
|
//设置选项
|
||||||
model.addAttribute("options", HaloConst.OPTIONS);
|
model.addAttribute("options", HaloConst.OPTIONS);
|
||||||
return "common/500";
|
return "common/500";
|
||||||
|
|
|
@ -60,14 +60,14 @@ public class InstallController {
|
||||||
* @return 模板路径
|
* @return 模板路径
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String install(Model model){
|
public String install(Model model) {
|
||||||
try{
|
try {
|
||||||
if(StringUtils.equals("true",HaloConst.OPTIONS.get("is_install"))){
|
if (StringUtils.equals("true", HaloConst.OPTIONS.get("is_install"))) {
|
||||||
model.addAttribute("isInstall",true);
|
model.addAttribute("isInstall", true);
|
||||||
}else{
|
} else {
|
||||||
model.addAttribute("isInstall",false);
|
model.addAttribute("isInstall", false);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return "common/install";
|
return "common/install";
|
||||||
|
@ -76,32 +76,32 @@ public class InstallController {
|
||||||
/**
|
/**
|
||||||
* 执行安装
|
* 执行安装
|
||||||
*
|
*
|
||||||
* @param siteTitle 博客标题
|
* @param siteTitle 博客标题
|
||||||
* @param siteUrl 博客网址
|
* @param siteUrl 博客网址
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @param userDisplayName 用户名显示名
|
* @param userDisplayName 用户名显示名
|
||||||
* @param userEmail 用户邮箱
|
* @param userEmail 用户邮箱
|
||||||
* @param userPwd 用户密码
|
* @param userPwd 用户密码
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return true:安装成功,false:安装失败
|
* @return true:安装成功,false:安装失败
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/do")
|
@PostMapping(value = "/do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean doInstall(@RequestParam("blogTitle") String blogTitle,
|
public boolean doInstall(@RequestParam("blogTitle") String blogTitle,
|
||||||
@RequestParam("blogUrl") String blogUrl,
|
@RequestParam("blogUrl") String blogUrl,
|
||||||
@RequestParam("userName") String userName,
|
@RequestParam("userName") String userName,
|
||||||
@RequestParam("userDisplayName") String userDisplayName,
|
@RequestParam("userDisplayName") String userDisplayName,
|
||||||
@RequestParam("userEmail") String userEmail,
|
@RequestParam("userEmail") String userEmail,
|
||||||
@RequestParam("userPwd") String userPwd,
|
@RequestParam("userPwd") String userPwd,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
try{
|
try {
|
||||||
if(StringUtils.equals("true",HaloConst.OPTIONS.get("is_install"))){
|
if (StringUtils.equals("true", HaloConst.OPTIONS.get("is_install"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//创建新的用户
|
//创建新的用户
|
||||||
User user= new User();
|
User user = new User();
|
||||||
user.setUserName(userName);
|
user.setUserName(userName);
|
||||||
if(StringUtils.isBlank(userDisplayName)){
|
if (StringUtils.isBlank(userDisplayName)) {
|
||||||
userDisplayName = userName;
|
userDisplayName = userName;
|
||||||
}
|
}
|
||||||
user.setUserDisplayName(userDisplayName);
|
user.setUserDisplayName(userDisplayName);
|
||||||
|
@ -146,28 +146,28 @@ public class InstallController {
|
||||||
comment.setIsAdmin(0);
|
comment.setIsAdmin(0);
|
||||||
commentService.saveByComment(comment);
|
commentService.saveByComment(comment);
|
||||||
|
|
||||||
optionsService.saveOption("is_install","true");
|
optionsService.saveOption("is_install", "true");
|
||||||
|
|
||||||
//保存博客标题和博客地址设置
|
//保存博客标题和博客地址设置
|
||||||
optionsService.saveOption("blog_title",blogTitle);
|
optionsService.saveOption("blog_title", blogTitle);
|
||||||
optionsService.saveOption("blog_url",blogUrl);
|
optionsService.saveOption("blog_url", blogUrl);
|
||||||
|
|
||||||
//设置默认主题
|
//设置默认主题
|
||||||
optionsService.saveOption("theme","anatole");
|
optionsService.saveOption("theme", "anatole");
|
||||||
|
|
||||||
//建立网站时间
|
//建立网站时间
|
||||||
optionsService.saveOption("blog_start",HaloUtil.getStringDate("yyyy-MM-dd"));
|
optionsService.saveOption("blog_start", HaloUtil.getStringDate("yyyy-MM-dd"));
|
||||||
|
|
||||||
//默认评论系统
|
//默认评论系统
|
||||||
optionsService.saveOption("comment_system","native");
|
optionsService.saveOption("comment_system", "native");
|
||||||
|
|
||||||
//默认不配置邮件系统
|
//默认不配置邮件系统
|
||||||
optionsService.saveOption("smtp_email_enable","false");
|
optionsService.saveOption("smtp_email_enable", "false");
|
||||||
|
|
||||||
//新评论,审核通过,回复,默认不通知
|
//新评论,审核通过,回复,默认不通知
|
||||||
optionsService.saveOption("new_comment_notice","false");
|
optionsService.saveOption("new_comment_notice", "false");
|
||||||
optionsService.saveOption("comment_pass_notice","false");
|
optionsService.saveOption("comment_pass_notice", "false");
|
||||||
optionsService.saveOption("comment_reply_notice","false");
|
optionsService.saveOption("comment_reply_notice", "false");
|
||||||
|
|
||||||
//更新日志
|
//更新日志
|
||||||
logsService.saveByLogs(
|
logsService.saveByLogs(
|
||||||
|
@ -196,9 +196,9 @@ public class InstallController {
|
||||||
HaloConst.OPTIONS.clear();
|
HaloConst.OPTIONS.clear();
|
||||||
HaloConst.OPTIONS = optionsService.findAllOptions();
|
HaloConst.OPTIONS = optionsService.findAllOptions();
|
||||||
|
|
||||||
configuration.setSharedVariable("options",optionsService.findAllOptions());
|
configuration.setSharedVariable("options", optionsService.findAllOptions());
|
||||||
configuration.setSharedVariable("user",userService.findUser());
|
configuration.setSharedVariable("user", userService.findUser());
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package cc.ryanc.halo.web.controller.front;
|
package cc.ryanc.halo.web.controller.front;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.domain.Comment;
|
||||||
import cc.ryanc.halo.model.domain.Post;
|
import cc.ryanc.halo.model.domain.Post;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
|
import cc.ryanc.halo.service.CommentService;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -32,6 +34,9 @@ public class ArchivesController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PostService postService;
|
private PostService postService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommentService commentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章归档
|
* 文章归档
|
||||||
*
|
*
|
||||||
|
@ -39,26 +44,26 @@ public class ArchivesController extends BaseController {
|
||||||
* @return 模板路径
|
* @return 模板路径
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String archives(Model model){
|
public String archives(Model model) {
|
||||||
return this.archives(model,1);
|
return this.archives(model, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章归档分页
|
* 文章归档分页
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param page page 当前页码
|
* @param page page 当前页码
|
||||||
* @return 模板路径/themes/{theme}/archives
|
* @return 模板路径/themes/{theme}/archives
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "page/{page}")
|
@GetMapping(value = "page/{page}")
|
||||||
public String archives(Model model,
|
public String archives(Model model,
|
||||||
@PathVariable(value = "page") Integer page){
|
@PathVariable(value = "page") Integer page) {
|
||||||
|
|
||||||
//所有文章数据,分页,material主题适用
|
//所有文章数据,分页,material主题适用
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||||
Pageable pageable = new PageRequest(page-1,5,sort);
|
Pageable pageable = new PageRequest(page - 1, 5, sort);
|
||||||
Page<Post> posts = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||||
model.addAttribute("posts",posts);
|
model.addAttribute("posts", posts);
|
||||||
return this.render("archives");
|
return this.render("archives");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,16 +71,16 @@ public class ArchivesController extends BaseController {
|
||||||
* 文章归档,根据年月
|
* 文章归档,根据年月
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param year year 年份
|
* @param year year 年份
|
||||||
* @param month month 月份
|
* @param month month 月份
|
||||||
* @return 模板路径/themes/{theme}/archives
|
* @return 模板路径/themes/{theme}/archives
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{year}/{month}")
|
@GetMapping(value = "{year}/{month}")
|
||||||
public String archives(Model model,
|
public String archives(Model model,
|
||||||
@PathVariable(value = "year") String year,
|
@PathVariable(value = "year") String year,
|
||||||
@PathVariable(value = "month") String month){
|
@PathVariable(value = "month") String month) {
|
||||||
Page<Post> posts = postService.findPostByYearAndMonth(year,month,null);
|
Page<Post> posts = postService.findPostByYearAndMonth(year, month, null);
|
||||||
model.addAttribute("posts",posts);
|
model.addAttribute("posts", posts);
|
||||||
return this.render("archives");
|
return this.render("archives");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,31 +88,32 @@ public class ArchivesController extends BaseController {
|
||||||
* 渲染文章详情
|
* 渲染文章详情
|
||||||
*
|
*
|
||||||
* @param postUrl 文章路径名
|
* @param postUrl 文章路径名
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return 模板路径/themes/{theme}/post
|
* @return 模板路径/themes/{theme}/post
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{postUrl}")
|
@GetMapping(value = "{postUrl}")
|
||||||
public String getPost(@PathVariable String postUrl, Model model){
|
public String getPost(@PathVariable String postUrl, Model model) {
|
||||||
Post post = postService.findByPostUrl(postUrl,HaloConst.POST_TYPE_POST);
|
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_POST);
|
||||||
//获得当前文章的发布日期
|
//获得当前文章的发布日期
|
||||||
Date postDate = post.getPostDate();
|
Date postDate = post.getPostDate();
|
||||||
try {
|
//查询当前文章日期之前的所有文章
|
||||||
//查询当前文章日期之前的所有文章
|
List<Post> beforePosts = postService.findByPostDateBefore(postDate);
|
||||||
List<Post> beforePosts = postService.findByPostDateBefore(postDate);
|
|
||||||
|
|
||||||
//查询当前文章日期之后的所有文章
|
//查询当前文章日期之后的所有文章
|
||||||
List<Post> afterPosts = postService.findByPostDateAfter(postDate);
|
List<Post> afterPosts = postService.findByPostDateAfter(postDate);
|
||||||
|
|
||||||
if(null!=beforePosts&&beforePosts.size()>0){
|
if (null != beforePosts && beforePosts.size() > 0) {
|
||||||
model.addAttribute("beforePost",beforePosts.get(beforePosts.size()-1));
|
model.addAttribute("beforePost", beforePosts.get(beforePosts.size() - 1));
|
||||||
}
|
|
||||||
if(null!=afterPosts&&afterPosts.size()>0){
|
|
||||||
model.addAttribute("afterPost",afterPosts.get(afterPosts.size()-1));
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error("未知错误:{0}",e.getMessage());
|
|
||||||
}
|
}
|
||||||
model.addAttribute("post",post);
|
if (null != afterPosts && afterPosts.size() > 0) {
|
||||||
|
model.addAttribute("afterPost", afterPosts.get(afterPosts.size() - 1));
|
||||||
|
}
|
||||||
|
Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
|
||||||
|
Pageable pageable = new PageRequest(0,999,sort);
|
||||||
|
Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,2);
|
||||||
|
|
||||||
|
model.addAttribute("post", post);
|
||||||
|
model.addAttribute("comments",comments);
|
||||||
|
|
||||||
return this.render("post");
|
return this.render("post");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@ public class CategoriesController {
|
||||||
/**
|
/**
|
||||||
* 根据分类路径查询文章
|
* 根据分类路径查询文章
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param cateUrl cateUrl
|
* @param cateUrl cateUrl
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{cateUrl}")
|
@GetMapping(value = "{cateUrl}")
|
||||||
public String categories(Model model,
|
public String categories(Model model,
|
||||||
@PathVariable("cateUrl") String cateUrl){
|
@PathVariable("cateUrl") String cateUrl) {
|
||||||
List<Post> posts;
|
List<Post> posts;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,14 @@ public class CommentsController {
|
||||||
* @param postId postId 文章编号
|
* @param postId postId 文章编号
|
||||||
* @return List<Comment>集合</>
|
* @return List<Comment>集合</>
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/getComment/{postId}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@GetMapping(value = "/getComment/{postId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Comment> getComment(@PathVariable Long postId){
|
public List<Comment> getComment(@PathVariable Long postId) {
|
||||||
Optional<Post> post = postService.findByPostId(postId);
|
Optional<Post> post = postService.findByPostId(postId);
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "commentDate");
|
||||||
Pageable pageable = new PageRequest(0,10,sort);
|
Pageable pageable = new PageRequest(0, 10, sort);
|
||||||
List<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post.get(),pageable,2).getContent();
|
List<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post.get(), pageable, 2).getContent();
|
||||||
if(null==comments){
|
if (null == comments) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return comments;
|
return comments;
|
||||||
|
@ -65,7 +65,7 @@ public class CommentsController {
|
||||||
* 提交新评论
|
* 提交新评论
|
||||||
*
|
*
|
||||||
* @param comment comment实体
|
* @param comment comment实体
|
||||||
* @param post post实体
|
* @param post post实体
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return true:评论成功,false:评论失败
|
* @return true:评论成功,false:评论失败
|
||||||
*/
|
*/
|
||||||
|
@ -73,8 +73,8 @@ public class CommentsController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean newComment(@ModelAttribute("comment") Comment comment,
|
public boolean newComment(@ModelAttribute("comment") Comment comment,
|
||||||
@ModelAttribute("post") Post post,
|
@ModelAttribute("post") Post post,
|
||||||
HttpServletRequest request){
|
HttpServletRequest request) {
|
||||||
if(StringUtils.isBlank(comment.getCommentAuthor())){
|
if (StringUtils.isBlank(comment.getCommentAuthor())) {
|
||||||
comment.setCommentAuthor("小猪佩琪");
|
comment.setCommentAuthor("小猪佩琪");
|
||||||
}
|
}
|
||||||
comment.setCommentAuthorEmail(comment.getCommentAuthorEmail().toLowerCase());
|
comment.setCommentAuthorEmail(comment.getCommentAuthorEmail().toLowerCase());
|
||||||
|
@ -84,18 +84,18 @@ public class CommentsController {
|
||||||
comment.setIsAdmin(0);
|
comment.setIsAdmin(0);
|
||||||
commentService.saveByComment(comment);
|
commentService.saveByComment(comment);
|
||||||
|
|
||||||
if(StringUtils.equals(HaloConst.OPTIONS.get("smtp_email_enable"),"true") && StringUtils.equals(HaloConst.OPTIONS.get("new_comment_notice"),"true")){
|
if (StringUtils.equals(HaloConst.OPTIONS.get("smtp_email_enable"), "true") && StringUtils.equals(HaloConst.OPTIONS.get("new_comment_notice"), "true")) {
|
||||||
try {
|
try {
|
||||||
//发送邮件到博主
|
//发送邮件到博主
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("author",userService.findUser().getUserDisplayName());
|
map.put("author", userService.findUser().getUserDisplayName());
|
||||||
map.put("pageName",postService.findByPostId(post.getPostId()).get().getPostTitle());
|
map.put("pageName", postService.findByPostId(post.getPostId()).get().getPostTitle());
|
||||||
map.put("blogUrl",HaloConst.OPTIONS.get("blog_url"));
|
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url")+"/archives/"+post.getPostUrl()+"#comment-id-"+comment.getCommentId());
|
||||||
map.put("visitor",comment.getCommentAuthor());
|
map.put("visitor", comment.getCommentAuthor());
|
||||||
map.put("commentContent",comment.getCommentContent());
|
map.put("commentContent", comment.getCommentContent());
|
||||||
mailService.sendTemplateMail(userService.findUser().getUserEmail(),"有新的评论",map,"common/mail/mail_admin.ftl");
|
mailService.sendTemplateMail(userService.findUser().getUserEmail(), "有新的评论", map, "common/mail/mail_admin.ftl");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("邮件服务器未配置:{0}",e.getMessage());
|
log.error("邮件服务器未配置:{0}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = {"/","index"})
|
@RequestMapping(value = {"/", "index"})
|
||||||
public class IndexController extends BaseController {
|
public class IndexController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -42,34 +42,33 @@ public class IndexController extends BaseController {
|
||||||
* @return 模板路径
|
* @return 模板路径
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String index(Model model){
|
public String index(Model model) {
|
||||||
//调用方法渲染首页
|
//调用方法渲染首页
|
||||||
return this.index(model,1);
|
return this.index(model, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页分页
|
* 首页分页
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param page 当前页码
|
* @param page 当前页码
|
||||||
* @param size 每页数量
|
* @param size 每页数量
|
||||||
* @return 模板路径/themes/{theme}/index
|
* @return 模板路径/themes/{theme}/index
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "page/{page}")
|
@GetMapping(value = "page/{page}")
|
||||||
public String index(Model model,
|
public String index(Model model,
|
||||||
@PathVariable(value = "page") Integer page){
|
@PathVariable(value = "page") Integer page) {
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
//尝试加载设置选项,用于设置显示条数
|
//尝试加载设置选项,用于设置显示条数
|
||||||
if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){
|
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||||
}
|
}
|
||||||
//所有文章数据,分页
|
//所有文章数据,分页
|
||||||
Pageable pageable = new PageRequest(page-1,size,sort);
|
Pageable pageable = new PageRequest(page - 1, size, sort);
|
||||||
Page<Post> posts = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||||
model.addAttribute("posts",posts);
|
model.addAttribute("posts", posts);
|
||||||
|
|
||||||
return this.render("index");
|
return this.render("index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,18 +80,18 @@ public class IndexController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "next")
|
@GetMapping(value = "next")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Post> ajaxIndex(@PathParam(value = "page") Integer page){
|
public List<Post> ajaxIndex(@PathParam(value = "page") Integer page) {
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
//尝试加载设置选项,用于设置显示条数
|
//尝试加载设置选项,用于设置显示条数
|
||||||
if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){
|
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//文章数据,只获取文章,没有分页
|
//文章数据,只获取文章,没有分页
|
||||||
Pageable pageable = new PageRequest(page-1,size,sort);
|
Pageable pageable = new PageRequest(page - 1, size, sort);
|
||||||
List<Post> posts = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable).getContent();
|
List<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable).getContent();
|
||||||
return posts;
|
return posts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ public class OthersController {
|
||||||
*
|
*
|
||||||
* @return rss
|
* @return rss
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = {"feed","feed.xml","atom","atom.xml"},produces = "application/xml;charset=UTF-8")
|
@GetMapping(value = {"feed", "feed.xml", "atom", "atom.xml"}, produces = "application/xml;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String feed(){
|
public String feed() {
|
||||||
String rssPosts = HaloConst.OPTIONS.get("rss_posts");
|
String rssPosts = HaloConst.OPTIONS.get("rss_posts");
|
||||||
if(StringUtils.isBlank(rssPosts)){
|
if (StringUtils.isBlank(rssPosts)) {
|
||||||
rssPosts = "20";
|
rssPosts = "20";
|
||||||
}
|
}
|
||||||
//获取文章列表并根据时间排序
|
//获取文章列表并根据时间排序
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||||
Pageable pageable = new PageRequest(0,Integer.parseInt(rssPosts),sort);
|
Pageable pageable = new PageRequest(0, Integer.parseInt(rssPosts), sort);
|
||||||
Page<Post> postsPage = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||||
List<Post> posts = postsPage.getContent();
|
List<Post> posts = postsPage.getContent();
|
||||||
return postService.buildRss(posts);
|
return postService.buildRss(posts);
|
||||||
}
|
}
|
||||||
|
@ -51,13 +51,13 @@ public class OthersController {
|
||||||
*
|
*
|
||||||
* @return sitemap
|
* @return sitemap
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = {"sitemap","sitemap.xml"},produces = "application/xml;charset=UTF-8")
|
@GetMapping(value = {"sitemap", "sitemap.xml"}, produces = "application/xml;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String siteMap(){
|
public String siteMap() {
|
||||||
//获取文章列表并根据时间排序
|
//获取文章列表并根据时间排序
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||||
Pageable pageable = new PageRequest(0,999,sort);
|
Pageable pageable = new PageRequest(0, 999, sort);
|
||||||
Page<Post> postsPage = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
|
||||||
List<Post> posts = postsPage.getContent();
|
List<Post> posts = postsPage.getContent();
|
||||||
return postService.buildSiteMap(posts);
|
return postService.buildSiteMap(posts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
package cc.ryanc.halo.web.controller.front;
|
package cc.ryanc.halo.web.controller.front;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.domain.Comment;
|
||||||
import cc.ryanc.halo.model.domain.Gallery;
|
import cc.ryanc.halo.model.domain.Gallery;
|
||||||
import cc.ryanc.halo.model.domain.Link;
|
import cc.ryanc.halo.model.domain.Link;
|
||||||
import cc.ryanc.halo.model.domain.Post;
|
import cc.ryanc.halo.model.domain.Post;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
|
import cc.ryanc.halo.service.CommentService;
|
||||||
import cc.ryanc.halo.service.GalleryService;
|
import cc.ryanc.halo.service.GalleryService;
|
||||||
import cc.ryanc.halo.service.LinkService;
|
import cc.ryanc.halo.service.LinkService;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -33,15 +39,18 @@ public class PagesController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private LinkService linkService;
|
private LinkService linkService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommentService commentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转到图库页面
|
* 跳转到图库页面
|
||||||
*
|
*
|
||||||
* @return 模板路径/themes/{theme}/gallery
|
* @return 模板路径/themes/{theme}/gallery
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/gallery")
|
@GetMapping(value = "/gallery")
|
||||||
public String gallery(Model model){
|
public String gallery(Model model) {
|
||||||
List<Gallery> galleries = galleryService.findAllGalleries();
|
List<Gallery> galleries = galleryService.findAllGalleries();
|
||||||
model.addAttribute("galleries",galleries);
|
model.addAttribute("galleries", galleries);
|
||||||
return this.render("gallery");
|
return this.render("gallery");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +61,10 @@ public class PagesController extends BaseController {
|
||||||
* @return 模板路径/themes/{theme}/links
|
* @return 模板路径/themes/{theme}/links
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/links")
|
@GetMapping(value = "/links")
|
||||||
public String links(Model model){
|
public String links(Model model) {
|
||||||
//所有友情链接
|
//所有友情链接
|
||||||
List<Link> links = linkService.findAllLinks();
|
List<Link> links = linkService.findAllLinks();
|
||||||
model.addAttribute("links",links);
|
model.addAttribute("links", links);
|
||||||
return this.render("links");
|
return this.render("links");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,13 +72,19 @@ public class PagesController extends BaseController {
|
||||||
* 渲染自定义页面
|
* 渲染自定义页面
|
||||||
*
|
*
|
||||||
* @param postUrl 页面路径
|
* @param postUrl 页面路径
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return 模板路径/themes/{theme}/post
|
* @return 模板路径/themes/{theme}/post
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/p/{postUrl}")
|
@GetMapping(value = "/p/{postUrl}")
|
||||||
public String getPage(@PathVariable(value = "postUrl") String postUrl,Model model){
|
public String getPage(@PathVariable(value = "postUrl") String postUrl, Model model) {
|
||||||
Post post = postService.findByPostUrl(postUrl,HaloConst.POST_TYPE_PAGE);
|
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_PAGE);
|
||||||
model.addAttribute("post",post);
|
|
||||||
|
Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
|
||||||
|
Pageable pageable = new PageRequest(0,999,sort);
|
||||||
|
Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,2);
|
||||||
|
|
||||||
|
model.addAttribute("comments",comments);
|
||||||
|
model.addAttribute("post", post);
|
||||||
return this.render("post");
|
return this.render("post");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/tags")
|
@RequestMapping(value = "/tags")
|
||||||
public class TagsController extends BaseController {
|
public class TagsController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TagService tagService;
|
private TagService tagService;
|
||||||
|
@ -42,10 +42,10 @@ public class TagsController extends BaseController {
|
||||||
* @return 模板路径/themes/{theme}/tags
|
* @return 模板路径/themes/{theme}/tags
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String tags(Model model){
|
public String tags(Model model) {
|
||||||
//所有标签
|
//所有标签
|
||||||
List<Tag> tags = tagService.findAllTags();
|
List<Tag> tags = tagService.findAllTags();
|
||||||
model.addAttribute("tags",tags);
|
model.addAttribute("tags", tags);
|
||||||
return this.render("tags");
|
return this.render("tags");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,36 +53,37 @@ public class TagsController extends BaseController {
|
||||||
* 根据标签路径查询所有文章
|
* 根据标签路径查询所有文章
|
||||||
*
|
*
|
||||||
* @param tagUrl 标签路径
|
* @param tagUrl 标签路径
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{tagUrl}")
|
@GetMapping(value = "{tagUrl}")
|
||||||
public String tags(Model model,
|
public String tags(Model model,
|
||||||
@PathVariable("tagUrl") String tagUrl){
|
@PathVariable("tagUrl") String tagUrl) {
|
||||||
return this.tags(model,tagUrl,1);
|
return this.tags(model, tagUrl, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据标签路径查询所有文章 分页
|
* 根据标签路径查询所有文章 分页
|
||||||
* @param model model
|
*
|
||||||
|
* @param model model
|
||||||
* @param tagUrl 标签路径
|
* @param tagUrl 标签路径
|
||||||
* @param page 页码
|
* @param page 页码
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{tagUrl}/page/{page}")
|
@GetMapping(value = "{tagUrl}/page/{page}")
|
||||||
public String tags(Model model,
|
public String tags(Model model,
|
||||||
@PathVariable("tagUrl") String tagUrl,
|
@PathVariable("tagUrl") String tagUrl,
|
||||||
@PathVariable("page") Integer page){
|
@PathVariable("page") Integer page) {
|
||||||
Tag tag = tagService.findByTagUrl(tagUrl);
|
Tag tag = tagService.findByTagUrl(tagUrl);
|
||||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){
|
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||||
}
|
}
|
||||||
Pageable pageable = new PageRequest(page-1,size,sort);
|
Pageable pageable = new PageRequest(page - 1, size, sort);
|
||||||
Page<Post> posts = postService.findPostsByTags(tag,pageable);
|
Page<Post> posts = postService.findPostsByTags(tag, pageable);
|
||||||
model.addAttribute("posts",posts);
|
model.addAttribute("posts", posts);
|
||||||
model.addAttribute("tag",tag);
|
model.addAttribute("tag", tag);
|
||||||
return this.render("index");
|
return this.render("index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package cc.ryanc.halo.web.interceptor;
|
package cc.ryanc.halo.web.interceptor;
|
||||||
|
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.service.OptionsService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
@ -20,12 +18,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
@Component
|
@Component
|
||||||
public class InstallInterceptor implements HandlerInterceptor {
|
public class InstallInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OptionsService optionsService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
|
||||||
if(StringUtils.equals("true",HaloConst.OPTIONS.get("is_install"))){
|
if (StringUtils.equals("true", HaloConst.OPTIONS.get("is_install"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
response.sendRedirect("/install");
|
response.sendRedirect("/install");
|
||||||
|
@ -33,8 +28,10 @@ public class InstallInterceptor implements HandlerInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { }
|
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { }
|
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
* description: 登录拦截器
|
* description: 登录拦截器
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class LoginInterceptor implements HandlerInterceptor{
|
public class LoginInterceptor implements HandlerInterceptor {
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
Object obj = request.getSession().getAttribute(HaloConst.USER_SESSION_KEY);
|
Object obj = request.getSession().getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
//如果user不为空则放行
|
//如果user不为空则放行
|
||||||
if(null!=obj){
|
if (null != obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//否则拦截并跳转到登录
|
//否则拦截并跳转到登录
|
||||||
|
@ -29,8 +29,10 @@ public class LoginInterceptor implements HandlerInterceptor{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { }
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { }
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,22 +7,28 @@ server:
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
|
||||||
# H2database 配置
|
# H2database 配置
|
||||||
driver-class-name: org.h2.Driver
|
#driver-class-name: org.h2.Driver
|
||||||
url: jdbc:h2:file:~/halo/halo
|
#url: jdbc:h2:file:~/halo/halo
|
||||||
username: admin
|
#username: admin
|
||||||
|
#password: 123456
|
||||||
|
|
||||||
|
# MySql配置
|
||||||
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
|
url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false
|
||||||
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
h2:
|
#h2:
|
||||||
console:
|
#console:
|
||||||
settings:
|
#settings:
|
||||||
web-allow-others: true
|
#web-allow-others: true
|
||||||
path: /h2-console
|
#path: /h2-console
|
||||||
enabled: true
|
#enabled: true
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: update
|
ddl-auto: update
|
||||||
show-sql: true
|
show-sql: false
|
||||||
database-platform: org.hibernate.dialect.H2Dialect
|
|
||||||
freemarker:
|
freemarker:
|
||||||
allow-request-override: false
|
allow-request-override: false
|
||||||
cache: false
|
cache: false
|
||||||
|
|
|
@ -33,4 +33,19 @@ function stringEncode(str){
|
||||||
div.textContent=str;
|
div.textContent=str;
|
||||||
}
|
}
|
||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存设置选项
|
||||||
|
*/
|
||||||
|
function saveOptions(option) {
|
||||||
|
var param = $('#'+option).serialize();
|
||||||
|
$.ajax({
|
||||||
|
type: 'post',
|
||||||
|
url: '/admin/option/save',
|
||||||
|
data: param,
|
||||||
|
success: function (result) {
|
||||||
|
showMsg("保存成功!","success",1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
|
@ -58,12 +58,12 @@
|
||||||
<#switch comment.commentStatus>
|
<#switch comment.commentStatus>
|
||||||
<#case 0>
|
<#case 0>
|
||||||
<button class="btn btn-primary btn-xs " onclick="replyShow('${comment.commentId}','${comment.post.postId}')" <#if comment.isAdmin==1>disabled</#if>>回复</button>
|
<button class="btn btn-primary btn-xs " onclick="replyShow('${comment.commentId}','${comment.post.postId}')" <#if comment.isAdmin==1>disabled</#if>>回复</button>
|
||||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId}','确定移动到回收站?')">丢弃</button>
|
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId}&status=1','确定移动到回收站?')">丢弃</button>
|
||||||
<#break >
|
<#break >
|
||||||
<#case 1>
|
<#case 1>
|
||||||
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId}&status=1">通过</a>
|
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId}&status=1">通过</a>
|
||||||
<button class="btn btn-info btn-xs " onclick="replyShow('${comment.commentId}','${comment.post.postId}')">通过并回复</button>
|
<button class="btn btn-info btn-xs " onclick="replyShow('${comment.commentId}','${comment.post.postId}')">通过并回复</button>
|
||||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId}','确定移动到回收站?')">丢弃</button>
|
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId}&status=1','确定移动到回收站?')">丢弃</button>
|
||||||
<#break >
|
<#break >
|
||||||
<#case 2>
|
<#case 2>
|
||||||
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId}&status=2">还原</a>
|
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId}&status=2">还原</a>
|
||||||
|
|
|
@ -333,6 +333,7 @@
|
||||||
</section>
|
</section>
|
||||||
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
||||||
<script src="/static/plugins/layer/layer.js"></script>
|
<script src="/static/plugins/layer/layer.js"></script>
|
||||||
|
<script src="/static/js/app.js"></script>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var dateBegin = new Date("${options.blog_start?default('0000-00-00')}");
|
var dateBegin = new Date("${options.blog_start?default('0000-00-00')}");
|
||||||
|
@ -356,32 +357,6 @@
|
||||||
$('#btnWidgetsOption').click(function () {
|
$('#btnWidgetsOption').click(function () {
|
||||||
$('#widgetOptionsPanel').slideToggle(400);
|
$('#widgetOptionsPanel').slideToggle(400);
|
||||||
});
|
});
|
||||||
function saveOptions(option) {
|
|
||||||
var param = $('#'+option).serialize();
|
|
||||||
$.ajax({
|
|
||||||
type: 'post',
|
|
||||||
url: '/admin/option/save',
|
|
||||||
data: param,
|
|
||||||
success: function (result) {
|
|
||||||
$.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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
<#include "module/_footer.ftl">
|
<#include "module/_footer.ftl">
|
||||||
|
|
|
@ -76,11 +76,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="blogLogo" class="col-sm-2 control-label">LOGO:
|
<label for="blogLogo" class="col-sm-2 control-label">LOGO:</label>
|
||||||
<span data-toggle="tooltip" data-placement="top" title="如果不设置图片Logo,将使用网站标题作为Logo" style="cursor: pointer">
|
|
||||||
<i class="fa fa-question-circle" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control selectData" id="blogLogo" name="blog_logo" value="${options.blog_logo?if_exists}">
|
<input type="text" class="form-control selectData" id="blogLogo" name="blog_logo" value="${options.blog_logo?if_exists}">
|
||||||
|
@ -121,14 +117,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="desc" class="col-sm-2 control-label">站点描述:</label>
|
<label for="desc" class="col-sm-2 control-label">博客描述:</label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="text" class="form-control" id="desc" name="seo_desc" value="${options.seo_desc?if_exists}">
|
<input type="text" class="form-control" id="desc" name="seo_desc" value="${options.seo_desc?if_exists}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="baiduToken" class="col-sm-2 control-label">百度推送token:
|
<label for="baiduToken" class="col-sm-2 control-label">百度推送token:
|
||||||
<span data-toggle="tooltip" data-placement="top" title="自行百度获取" style="cursor: pointer">
|
<span data-toggle="tooltip" data-placement="top" title="百度站长平台获取" style="cursor: pointer">
|
||||||
<i class="fa fa-question-circle" aria-hidden="true"></i>
|
<i class="fa fa-question-circle" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
@ -432,17 +428,17 @@
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<select class="form-control" id="adminTheme" name="admin_theme">
|
<select class="form-control" id="adminTheme" name="admin_theme">
|
||||||
<option value="skin-blue" ${((options.admin_theme?default('skin-blue'))=='skin-blue')?string('selected','')}>默认主题</option>
|
<option value="skin-blue" ${((options.admin_theme?default('skin-blue'))=='skin-blue')?string('selected','')}>默认主题</option>
|
||||||
<option value="skin-blue-light" ${((options.admin_theme?default('skin-blue'))=='skin-blue-light')?string('selected','')}>上蓝左白</option>
|
<option value="skin-blue-light" ${((options.admin_theme?if_exists)=='skin-blue-light')?string('selected','')}>上蓝左白</option>
|
||||||
<option value="skin-black" ${((options.admin_theme?default('skin-blue'))=='skin-black')?string('selected','')}>上白左黑</option>
|
<option value="skin-black" ${((options.admin_theme?if_exists)=='skin-black')?string('selected','')}>上白左黑</option>
|
||||||
<option value="skin-black-light" ${((options.admin_theme?default('skin-blue'))=='skin-black-light')?string('selected','')}>上白左白</option>
|
<option value="skin-black-light" ${((options.admin_theme?if_exists)=='skin-black-light')?string('selected','')}>上白左白</option>
|
||||||
<option value="skin-green" ${((options.admin_theme?default('skin-blue'))=='skin-green')?string('selected','')}>上绿左黑</option>
|
<option value="skin-green" ${((options.admin_theme?if_exists)=='skin-green')?string('selected','')}>上绿左黑</option>
|
||||||
<option value="skin-green-light" ${((options.admin_theme?default('skin-blue'))=='skin-green-light')?string('selected','')}>上绿左白</option>
|
<option value="skin-green-light" ${((options.admin_theme?if_exists)=='skin-green-light')?string('selected','')}>上绿左白</option>
|
||||||
<option value="skin-purple" ${((options.admin_theme?default('skin-blue'))=='skin-purple')?string('selected','')}>上紫左黑</option>
|
<option value="skin-purple" ${((options.admin_theme?if_exists)=='skin-purple')?string('selected','')}>上紫左黑</option>
|
||||||
<option value="skin-purple-light" ${((options.admin_theme?default('skin-blue'))=='skin-purple-light')?string('selected','')}>上紫左白</option>
|
<option value="skin-purple-light" ${((options.admin_theme?if_exists)=='skin-purple-light')?string('selected','')}>上紫左白</option>
|
||||||
<option value="skin-red" ${((options.admin_theme?default('skin-blue'))=='skin-red')?string('selected','')}>上红左黑</option>
|
<option value="skin-red" ${((options.admin_theme?if_exists)=='skin-red')?string('selected','')}>上红左黑</option>
|
||||||
<option value="skin-red-light" ${((options.admin_theme?default('skin-blue'))=='skin-red-light')?string('selected','')}>上红左白</option>
|
<option value="skin-red-light" ${((options.admin_theme?if_exists)=='skin-red-light')?string('selected','')}>上红左白</option>
|
||||||
<option value="skin-yellow" ${((options.admin_theme?default('skin-blue'))=='skin-yellow')?string('selected','')}>上黄左黑</option>
|
<option value="skin-yellow" ${((options.admin_theme?if_exists)=='skin-yellow')?string('selected','')}>上黄左黑</option>
|
||||||
<option value="skin-yellow-light" ${((options.admin_theme?default('skin-blue'))=='skin-yellow-light')?string('selected','')}>上黄左白</option>
|
<option value="skin-yellow-light" ${((options.admin_theme?if_exists)=='skin-yellow-light')?string('selected','')}>上黄左白</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -457,32 +453,32 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<#--<div class="form-group">-->
|
||||||
<label for="postEditor" class="col-sm-2 control-label">文章编辑器:
|
<#--<label for="postEditor" class="col-sm-2 control-label">文章编辑器:-->
|
||||||
<span data-toggle="tooltip" data-placement="top" title="请勿将它们混用" style="cursor: pointer">
|
<#--<span data-toggle="tooltip" data-placement="top" title="请勿将它们混用" style="cursor: pointer">-->
|
||||||
<i class="fa fa-question-circle" aria-hidden="true"></i>
|
<#--<i class="fa fa-question-circle" aria-hidden="true"></i>-->
|
||||||
</span>
|
<#--</span>-->
|
||||||
</label>
|
<#--</label>-->
|
||||||
<div class="col-sm-4">
|
<#--<div class="col-sm-4">-->
|
||||||
<select class="form-control" id="postEditor" name="post_editor">
|
<#--<select class="form-control" id="postEditor" name="post_editor">-->
|
||||||
<option value="editor.md" ${((options.post_editor?default('editor.md'))=='editor.md')?string('selected','')}>Markdown</option>
|
<#--<option value="editor.md" ${((options.post_editor?default('editor.md'))=='editor.md')?string('selected','')}>Markdown</option>-->
|
||||||
<option value="ckeditor" ${((options.post_editor?default('editor.md'))=='ckeditor')?string('selected','')}>富文本</option>
|
<#--<option value="ckeditor" ${((options.post_editor?default('editor.md'))=='ckeditor')?string('selected','')}>富文本</option>-->
|
||||||
</select>
|
<#--</select>-->
|
||||||
</div>
|
<#--</div>-->
|
||||||
</div>
|
<#--</div>-->
|
||||||
<div class="form-group">
|
<#--<div class="form-group">-->
|
||||||
<label for="pageEditor" class="col-sm-2 control-label">页面编辑器:
|
<#--<label for="pageEditor" class="col-sm-2 control-label">页面编辑器:-->
|
||||||
<span data-toggle="tooltip" data-placement="top" title="请勿将它们混用" style="cursor: pointer">
|
<#--<span data-toggle="tooltip" data-placement="top" title="请勿将它们混用" style="cursor: pointer">-->
|
||||||
<i class="fa fa-question-circle" aria-hidden="true"></i>
|
<#--<i class="fa fa-question-circle" aria-hidden="true"></i>-->
|
||||||
</span>
|
<#--</span>-->
|
||||||
</label>
|
<#--</label>-->
|
||||||
<div class="col-sm-4">
|
<#--<div class="col-sm-4">-->
|
||||||
<select class="form-control" id="pageEditor" name="page_editor">
|
<#--<select class="form-control" id="pageEditor" name="page_editor">-->
|
||||||
<option value="editor.md" ${((options.page_editor?default('editor.md'))=='editor.md')?string('selected','')}>Markdown</option>
|
<#--<option value="editor.md" ${((options.page_editor?default('editor.md'))=='editor.md')?string('selected','')}>Markdown</option>-->
|
||||||
<option value="ckeditor" ${((options.page_editor?default('editor.md'))=='ckeditor')?string('selected','')}>富文本</option>
|
<#--<option value="ckeditor" ${((options.page_editor?default('editor.md'))=='ckeditor')?string('selected','')}>富文本</option>-->
|
||||||
</select>
|
<#--</select>-->
|
||||||
</div>
|
<#--</div>-->
|
||||||
</div>
|
<#--</div>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<button type="button" class="btn btn-primary btn-sm " onclick="saveOptions('adminOptions')">保存</button>
|
<button type="button" class="btn btn-primary btn-sm " onclick="saveOptions('adminOptions')">保存</button>
|
||||||
|
@ -562,12 +558,17 @@
|
||||||
</section>
|
</section>
|
||||||
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
||||||
<script src="/static/plugins/layer/layer.js"></script>
|
<script src="/static/plugins/layer/layer.js"></script>
|
||||||
|
<script src="/static/js/app.js"></script>
|
||||||
<@compress single_line=true>
|
<@compress single_line=true>
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
checkCommentOption();
|
checkCommentOption();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开附件
|
||||||
|
*/
|
||||||
function openAttach(id) {
|
function openAttach(id) {
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 2,
|
type: 2,
|
||||||
|
@ -580,17 +581,10 @@
|
||||||
scrollbar: false
|
scrollbar: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function saveOptions(option) {
|
|
||||||
var param = $('#'+option).serialize();
|
/**
|
||||||
$.ajax({
|
* 更新所有文章的摘要
|
||||||
type: 'post',
|
*/
|
||||||
url: '/admin/option/save',
|
|
||||||
data: param,
|
|
||||||
success: function (result) {
|
|
||||||
showMsg("保存成功!","success",1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function updateAllSummary() {
|
function updateAllSummary() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -607,6 +601,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主动提交文章到百度
|
||||||
|
*/
|
||||||
function pushAllToBaidu() {
|
function pushAllToBaidu() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -623,6 +621,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论切换
|
||||||
|
*/
|
||||||
function checkCommentOption() {
|
function checkCommentOption() {
|
||||||
var native = $('input:radio[value=native]:checked').val();
|
var native = $('input:radio[value=native]:checked').val();
|
||||||
var valine = $('input:radio[value=valine]:checked').val();
|
var valine = $('input:radio[value=valine]:checked').val();
|
||||||
|
@ -655,6 +657,10 @@
|
||||||
$('.changyan-options').hide();
|
$('.changyan-options').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台布局切换
|
||||||
|
*/
|
||||||
function viewLayout() {
|
function viewLayout() {
|
||||||
var layout = $('input:radio[value=layout-boxed]:checked').val();
|
var layout = $('input:radio[value=layout-boxed]:checked').val();
|
||||||
if(layout!=null){
|
if(layout!=null){
|
||||||
|
@ -663,6 +669,10 @@
|
||||||
$('body').removeClass('layout-boxed');
|
$('body').removeClass('layout-boxed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预览侧边栏
|
||||||
|
*/
|
||||||
function viewSideBar() {
|
function viewSideBar() {
|
||||||
var layout = $('input:radio[value=sidebar-collapse]:checked').val();
|
var layout = $('input:radio[value=sidebar-collapse]:checked').val();
|
||||||
if(layout!=null){
|
if(layout!=null){
|
||||||
|
@ -680,6 +690,10 @@
|
||||||
$('input[name=sidebar_style]').click(function () {
|
$('input[name=sidebar_style]').click(function () {
|
||||||
viewSideBar();
|
viewSideBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预览后台样式切换
|
||||||
|
*/
|
||||||
$(function () {
|
$(function () {
|
||||||
var beforeTheme;
|
var beforeTheme;
|
||||||
$('#adminTheme').change(function () {
|
$('#adminTheme').change(function () {
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<img src="http://www.gravatar.com/avatar/${comment.commentAuthorAvatarMd5?default("hash")}?s=256&d=${options.native_comment_avatar?default("mm")}" class="img-circle" alt="User Image">
|
<img src="http://www.gravatar.com/avatar/${comment.commentAuthorAvatarMd5?default("hash")}?s=256&d=${options.native_comment_avatar?default("mm")}" class="img-circle" alt="User Image">
|
||||||
</div>
|
</div>
|
||||||
<h5>${comment.commentAuthor}<small> ${comment.commentDate}</small></h5>
|
<h4>${comment.commentAuthor}
|
||||||
|
<small> ${comment.commentDate?string("yyyy/MM/dd HH:mm")}</small>
|
||||||
|
</h4>
|
||||||
<p>${comment.commentContent}</p>
|
<p>${comment.commentContent}</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
<style>
|
<style>
|
||||||
*{
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-comment{
|
.native-comment {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-wrap{
|
.native-wrap {
|
||||||
border: 1px solid #f0f0f0;
|
border: 1px solid #f0f0f0;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
input,textarea,button{
|
input, textarea, button {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-header{
|
.comment-header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-input-who,.comment-input-email,.comment-input-website{
|
.comment-input-who, .comment-input-email, .comment-input-website {
|
||||||
width: 33.33%;
|
width: 33.33%;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
font-size: .8rem;
|
font-size: .8rem;
|
||||||
|
@ -32,11 +32,11 @@
|
||||||
border-bottom: 1px dashed #dedede;
|
border-bottom: 1px dashed #dedede;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-input:focus{
|
.comment-input:focus {
|
||||||
border-bottom: 1px dashed red;
|
border-bottom: 1px dashed red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-input-content{
|
.comment-input-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 120px;
|
min-height: 120px;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
|
@ -44,12 +44,12 @@
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-footer{
|
.comment-footer {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-submit{
|
.comment-submit {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 7px 14px;
|
padding: 7px 14px;
|
||||||
|
@ -60,21 +60,21 @@
|
||||||
color: #313131;
|
color: #313131;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list{
|
.native-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list .native-list-one{
|
.native-list .native-list-one {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
transition: all .3s ease-in-out;
|
transition: all .3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list .native-list-one .native-list-one-img{
|
.native-list .native-list-one .native-list-one-img {
|
||||||
width: 2.5rem;
|
width: 2.5rem;
|
||||||
height: 2.5rem;
|
height: 2.5rem;
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -82,28 +82,37 @@
|
||||||
margin-right: .7rem;
|
margin-right: .7rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list .native-list-one section{
|
.native-list .native-list-one section {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding-bottom: 1.5rem;
|
padding-bottom: 1.5rem;
|
||||||
border-bottom: 1px dashed #f5f5f5;
|
border-bottom: 1px dashed #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list .native-list-one section .native-list-one-head{
|
.native-list .native-list-one section .native-list-one-head {
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
margin-bottom: .625rem;
|
margin-bottom: .625rem;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list-one-head-name{
|
.native-list-one-head-name {
|
||||||
font-size: .875rem;
|
font-size: .875rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
margin-right: .875rem;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #555;
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ua{
|
.native-list-one-head-admin{
|
||||||
|
padding: .1em 0.2em;
|
||||||
|
border-radius: 2px;
|
||||||
|
font-size: 70%;
|
||||||
|
font-weight: 700;
|
||||||
|
background-color: #87ceeb;
|
||||||
|
color: #fff;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ua {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: .2rem .5rem;
|
padding: .2rem .5rem;
|
||||||
background: #ededed;
|
background: #ededed;
|
||||||
|
@ -113,27 +122,27 @@
|
||||||
margin-right: .3rem;
|
margin-right: .3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list-one-content p{
|
.native-list-one-content p {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
letter-spacing: 0;
|
letter-spacing: 0;
|
||||||
margin: 0 0 1pc;
|
margin: 0 0 1pc;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list-one-footer-time{
|
.native-list-one-footer-time {
|
||||||
color: #b3b3b3;
|
color: #b3b3b3;
|
||||||
font-size: .75rem;
|
font-size: .75rem;
|
||||||
margin-right: .875rem;
|
margin-right: .875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-list-one-footer-reback{
|
.native-list-one-footer-reback {
|
||||||
font-size: .8125rem;
|
font-size: .8125rem;
|
||||||
color: #ef2f11;
|
color: #ef2f11;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
${options.native_css?if_exists}
|
${options.native_css?if_exists}
|
||||||
@media screen and (max-width:560px){
|
@media screen and (max-width: 560px) {
|
||||||
.comment-input-who,.comment-input-email,.comment-input-website{
|
.comment-input-who, .comment-input-email, .comment-input-website {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,85 +151,106 @@
|
||||||
<div class="native-wrap">
|
<div class="native-wrap">
|
||||||
<div class="comment-header">
|
<div class="comment-header">
|
||||||
<input type="hidden" name="postId" value="${post.postId}">
|
<input type="hidden" name="postId" value="${post.postId}">
|
||||||
<input type="text" class="comment-input comment-input-who" name="commentAuthor" id="commentAuthor" placeholder="昵称">
|
<input type="text" class="comment-input comment-input-who" name="commentAuthor" id="commentAuthor"
|
||||||
|
placeholder="昵称">
|
||||||
<input type="text" class="comment-input comment-input-email" name="commentAuthorEmail" placeholder="邮箱">
|
<input type="text" class="comment-input comment-input-email" name="commentAuthorEmail" placeholder="邮箱">
|
||||||
<input type="text" class="comment-input comment-input-website" name="commentAuthorUrl" placeholder="网址(https/http)">
|
<input type="text" class="comment-input comment-input-website" name="commentAuthorUrl"
|
||||||
|
placeholder="网址(https/http)">
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-content">
|
<div class="comment-content">
|
||||||
<textarea class="comment-input comment-input-content" name="commentContent" id="commentContent" placeholder="come on"></textarea>
|
<textarea class="comment-input comment-input-content" name="commentContent" id="commentContent"
|
||||||
|
placeholder="come on"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-footer">
|
<div class="comment-footer">
|
||||||
<button type="button" class="comment-submit" id="btn-push">提交</button>
|
<button type="button" class="comment-submit" id="btn-push">提交</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="native-info" style="padding-top: 5px;font-size: 12px;color: #0F192A;">
|
<div class="native-info" style="padding-top: 5px;font-size: 12px;color: #0F192A;">
|
||||||
<span id="native-info-total">${post.comments?size}</span>条评论
|
<span id="native-info-total">${comments.getTotalElements()}</span>条评论
|
||||||
</div>
|
</div>
|
||||||
<ul class="native-list">
|
<ul class="native-list">
|
||||||
|
<#list comments.content as comment>
|
||||||
|
<li class="native-list-one" id="comment-id-${comment.commentId}">
|
||||||
|
<img class="native-list-one-img" src="//www.gravatar.com/avatar/${comment.commentAuthorAvatarMd5?if_exists}?s=256&d=${options.native_comment_avatar?default('mm')}">
|
||||||
|
<section>
|
||||||
|
<div class="native-list-one-head">
|
||||||
|
<a class="native-list-one-head-name" rel="nofollow" href="${comment.commentAuthorUrl?if_exists}">${comment.commentAuthor?if_exists}</a>
|
||||||
|
<#if comment.isAdmin==1>
|
||||||
|
<label class="native-list-one-head-admin">博主</label>
|
||||||
|
</#if>
|
||||||
|
<#--<span class="ua"></span>-->
|
||||||
|
<#--<span class="ua"></span>-->
|
||||||
|
</div>
|
||||||
|
<div class="native-list-one-content">
|
||||||
|
<p>${comment.commentContent?if_exists}</p>
|
||||||
|
</div>
|
||||||
|
<div class="native-list-one-footer">
|
||||||
|
<span class="native-list-one-footer-time">${comment.commentDate?string("yyyy-MM-dd HH:mm")}</span>
|
||||||
|
<span rid="" at="@${comment.commentAuthor?if_exists}" class="native-list-one-footer-reback">回复</span>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</li>
|
||||||
|
</#list>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="native-loading" style="text-align: center;padding-top: 5px">
|
|
||||||
<img src="/static/images/tail-spin.svg" width="36" alt="">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<script src="//cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
<script src="//cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
||||||
<script src="//cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
|
<script src="//cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
|
||||||
<script src="//cdn.bootcss.com/UAParser.js/0.7.17/ua-parser.min.js"></script>
|
<script src="//cdn.bootcss.com/UAParser.js/0.7.17/ua-parser.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
<#--$(document).ready(function () {-->
|
||||||
$.ajax({
|
<#--$.ajax({-->
|
||||||
type: "get",
|
<#--type: "get",-->
|
||||||
async: true,
|
<#--async: true,-->
|
||||||
url: "/getComment/${post.postId}",
|
<#--url: "/getComment/${post.postId}",-->
|
||||||
dataType: "json",
|
<#--dataType: "json",-->
|
||||||
success: function(data){
|
<#--success: function (data) {-->
|
||||||
setTimeout(function(){
|
<#--setTimeout(function () {-->
|
||||||
$('.native-loading').hide();
|
<#--$('.native-loading').hide();-->
|
||||||
},1000);
|
<#--}, 1000);-->
|
||||||
var parser = new UAParser();
|
<#--var parser = new UAParser();-->
|
||||||
$.each(data,function(i,element){
|
<#--$.each(data, function (i, element) {-->
|
||||||
parser.setUA(element.commentAgent);
|
<#--parser.setUA(element.commentAgent);-->
|
||||||
var result = parser.getResult();
|
<#--var result = parser.getResult();-->
|
||||||
var browser = result.browser.name+' '+result.browser.version;
|
<#--var browser = result.browser.name + ' ' + result.browser.version;-->
|
||||||
var os = result.os.name + ' ' + result.os.version;
|
<#--var os = result.os.name + ' ' + result.os.version;-->
|
||||||
var author = element.commentAuthor;
|
<#--var author = element.commentAuthor;-->
|
||||||
var authorEmail = element.commentAuthorEmail;
|
<#--var authorEmail = element.commentAuthorEmail;-->
|
||||||
var authorUrl = element.commentAuthorUrl;
|
<#--var authorUrl = element.commentAuthorUrl;-->
|
||||||
var timestamp = element.commentDate;
|
<#--var timestamp = element.commentDate;-->
|
||||||
var date = new Date(timestamp).toLocaleDateString();
|
<#--var date = new Date(timestamp).toLocaleDateString();-->
|
||||||
var content = element.commentContent;
|
<#--var content = element.commentContent;-->
|
||||||
var authorPic = md5(authorEmail);
|
<#--var authorPic = md5(authorEmail);-->
|
||||||
$('.native-list').append("<li class=\"native-list-one\"><img class=\"native-list-one-img\" src=\"//www.gravatar.com/avatar/"+authorPic+"?s=256&d=${options.native_comment_avatar?default('default')}\"><section><div class=\"native-list-one-head\"><a class=\"native-list-one-head-name\" rel=\"nofollow\" href=\""+authorUrl+"\" target=\"_blank\">"+author+"</a> <span class=\"ua\">"+browser+"</span> <span class=\"ua\">"+os+"</span></div><div class=\"native-list-one-content\"><p>"+content+"</p></div><div class=\"native-list-one-footer\"><span class=\"native-list-one-footer-time\">"+date+"</span> <span rid=\"\" at=\"@"+author+"\" mail=\""+authorEmail+"\" class=\"native-list-one-footer-reback\">回复</span></div></section></li>");
|
<#--$('.native-list').append("<li class=\"native-list-one\"><img class=\"native-list-one-img\" src=\"//www.gravatar.com/avatar/" + authorPic + "?s=256&d=${options.native_comment_avatar?default('default')}\"><section><div class=\"native-list-one-head\"><a class=\"native-list-one-head-name\" rel=\"nofollow\" href=\"" + authorUrl + "\" target=\"_blank\">" + author + "</a> <span class=\"ua\">" + browser + "</span> <span class=\"ua\">" + os + "</span></div><div class=\"native-list-one-content\"><p>" + content + "</p></div><div class=\"native-list-one-footer\"><span class=\"native-list-one-footer-time\">" + date + "</span> <span rid=\"\" at=\"@" + author + "\" mail=\"" + authorEmail + "\" class=\"native-list-one-footer-reback\">回复</span></div></section></li>");-->
|
||||||
});
|
<#--});-->
|
||||||
}
|
<#--}-->
|
||||||
});
|
<#--});-->
|
||||||
});
|
<#--});-->
|
||||||
$('#btn-push').click(function () {
|
$('#btn-push').click(function () {
|
||||||
var author = $("#commentAuthor");
|
var author = $("#commentAuthor");
|
||||||
if(author.val()==''){
|
if (author.val() == '') {
|
||||||
$(author).css("border-bottom","1px dashed red");
|
$(author).css("border-bottom", "1px dashed red");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var content = $("#commentContent");
|
var content = $("#commentContent");
|
||||||
if(content.val()==''){
|
if (content.val() == '') {
|
||||||
$(content).css("border-bottom","1px dashed red");
|
$(content).css("border-bottom", "1px dashed red");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '/newComment',
|
url: '/newComment',
|
||||||
async: false,
|
async: false,
|
||||||
data:{
|
data: {
|
||||||
'postId' : $('input[name=postId]').val(),
|
'postId': $('input[name=postId]').val(),
|
||||||
'commentContent' : $('textarea[name=commentContent]').val(),
|
'commentContent': $('textarea[name=commentContent]').val(),
|
||||||
'commentAuthor' : $('input[name=commentAuthor]').val(),
|
'commentAuthor': $('input[name=commentAuthor]').val(),
|
||||||
'commentAuthorEmail' : $('input[name=commentAuthorEmail]').val(),
|
'commentAuthorEmail': $('input[name=commentAuthorEmail]').val(),
|
||||||
'commentAuthorUrl' : $('input[name=commentAuthorUrl]').val(),
|
'commentAuthorUrl': $('input[name=commentAuthorUrl]').val(),
|
||||||
'commentAgent' : navigator.userAgent,
|
'commentAgent': navigator.userAgent,
|
||||||
'commentAuthorAvatarMd5' : md5($('input[name=commentAuthorEmail]').val())
|
'commentAuthorAvatarMd5': md5($('input[name=commentAuthorEmail]').val())
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if(data==true){
|
if (data == true) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
${visitor}:${commentContent}
|
${visitor}:${commentContent}
|
||||||
</p>
|
</p>
|
||||||
<br />
|
<br />
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">你可以点击<a href="${blogUrl}">查看完整内容</a></p>
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">你可以点击<a href="${pageUrl}">查看完整内容</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
留言审核通过通知
|
留言审核通过通知
|
||||||
</h1>
|
</h1>
|
||||||
<div class="emailtext" style="background:#fff;padding:20px 32px 40px;">
|
<div class="emailtext" style="background:#fff;padding:20px 32px 40px;">
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">您在${blogTitle}《
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">您在${blogTitle}《<a href="${pageUrl}">${pageName}</a>》发表的评论:</p>
|
||||||
<a href="${pageUrl}">${pageName}</a>》发表的评论:</p>
|
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;padding:10px 20px;background:#f8f8f8;margin:0px">${commentContent}</p>
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;padding:10px 20px;background:#f8f8f8;margin:0px">${commentContent}</p>
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">已通过管理员审核并显示。
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">已通过管理员审核并显示。
|
||||||
<br /> 您可在此查看您的评论:
|
<br /> 您可在此查看您的评论:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<br />
|
<br />
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;padding:10px 20px;background:#f8f8f8;margin:0px">${replyContent}</p>
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;padding:10px 20px;background:#f8f8f8;margin:0px">${replyContent}</p>
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">你可以点击
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">你可以点击
|
||||||
<a href="${blogUrl}">查看完整内容</a>
|
<a href="${pageUrl}">查看完整内容</a>
|
||||||
</p>
|
</p>
|
||||||
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">欢迎再度光临
|
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">欢迎再度光临
|
||||||
<a href="${blogUrl}">${blogTitle}</a>
|
<a href="${blogUrl}">${blogTitle}</a>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<div class="information">
|
<div class="information">
|
||||||
<div class="back_btn">
|
<div class="back_btn">
|
||||||
<li>
|
<li>
|
||||||
<a onclick="window.history.go(-1)" style="display:none;" class="fa fa-chevron-left"></a>
|
<a onclick="window.history.go(-1)" style="display: none" class="fa fa-chevron-left"></a>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
<span class="date">${post.postDate?string("yyyy-MM-dd")}</span>
|
<span class="date">${post.postDate?string("yyyy-MM-dd")}</span>
|
||||||
<i class="fa fa-comment-o"></i>
|
<i class="fa fa-comment-o"></i>
|
||||||
<a href="/archives/${post.postUrl}#comment_widget">Comments</a>
|
<a href="/archives/${post.postUrl}#comment_widget">Comments</a>
|
||||||
<if post.tags?size gt 0>
|
<#if post.tags?size gt 0>
|
||||||
<i class="fa fa-tag"></i>
|
<i class="fa fa-tag"></i>
|
||||||
<#list post.tags as tag>
|
<#list post.tags as tag>
|
||||||
<a href="/tags/${tag.tagUrl}" class="tag"> ${tag.tagName}</a>
|
<a href="/tags/${tag.tagUrl}" class="tag"> ${tag.tagName}</a>
|
||||||
</#list>
|
</#list>
|
||||||
</if>
|
</#if>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<#include "module/macro.ftl">
|
|
||||||
<@layout title="${post.postTitle?if_exists} | ${options.blog_title?if_exists}" keywords="${options.seo_keywords?if_exists}" description="${options.seo_desc?if_exists}">
|
|
||||||
<!-- Post Module -->
|
|
||||||
<div class="material-post_container">
|
|
||||||
<div class="material-post mdl-grid">
|
|
||||||
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">
|
|
||||||
|
|
||||||
<!-- Post Header(Thumbnail & Title) -->
|
|
||||||
<#include "_partial/post-header.ftl">
|
|
||||||
|
|
||||||
<#if options.theme_material_scheme?if_exists == "Paradox">
|
|
||||||
<!-- Paradox Post Info -->
|
|
||||||
<#include "_partial/Paradox-post-info.ftl">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<!-- Post Content -->
|
|
||||||
<#include "_partial/post-content.ftl">
|
|
||||||
|
|
||||||
<#if options.theme_material_scheme?if_exists == "Isolation">
|
|
||||||
<#include "_partial/Isolation-post-info.ftl">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#include "_partial/comment.ftl">
|
|
||||||
</div>
|
|
||||||
<!-- Post Prev & Next Nav -->
|
|
||||||
<#include "_partial/post-nav.ftl">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</@layout>
|
|
Loading…
Reference in New Issue