mirror of https://github.com/halo-dev/halo
👽 代码优化
parent
2f3d64f8b6
commit
99e204fb18
26
pom.xml
26
pom.xml
|
@ -32,12 +32,15 @@
|
|||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<oh-my-email.version>0.0.3</oh-my-email.version>
|
||||
<druid.version>1.1.9</druid.version>
|
||||
<lombok.version>1.16.20</lombok.version>
|
||||
<druid.version>1.1.10</druid.version>
|
||||
<lombok.version>1.18.0</lombok.version>
|
||||
<ehcache.version>3.5.2</ehcache.version>
|
||||
<rome.version>1.0</rome.version>
|
||||
<commons-lang3.version>3.7</commons-lang3.version>
|
||||
<hutool-all.version>4.0.12</hutool-all.version>
|
||||
<hutool-all.version>4.1.1</hutool-all.version>
|
||||
<upyun-java-sdk.version>4.0.1</upyun-java-sdk.version>
|
||||
<qiniu-java-sdk.version>7.2.14</qiniu-java-sdk.version>
|
||||
<thumbnailator.version>0.4.8</thumbnailator.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -118,7 +121,7 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- ehCache -->
|
||||
<!-- EhCache -->
|
||||
<dependency>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
|
@ -146,18 +149,25 @@
|
|||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 又拍云 -->
|
||||
<!-- 又拍云SDK -->
|
||||
<dependency>
|
||||
<groupId>com.upyun</groupId>
|
||||
<artifactId>java-sdk</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<version>${upyun-java-sdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 七牛云SDK -->
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
<version>${qiniu-java-sdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 图片操作 -->
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.8</version>
|
||||
<version>${thumbnailator.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -234,7 +244,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.config;
|
|||
import cc.ryanc.halo.model.domain.Attachment;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.Theme;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.service.AttachmentService;
|
||||
import cc.ryanc.halo.service.OptionsService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -53,7 +54,7 @@ public class StartupConfig implements ApplicationListener<ApplicationStartedEven
|
|||
* 加载主题设置
|
||||
*/
|
||||
private void loadActiveTheme() {
|
||||
String themeValue = optionsService.findOneOption("theme");
|
||||
String themeValue = optionsService.findOneOption(BlogProperties.THEME.getProp());
|
||||
if (StringUtils.isNotEmpty(themeValue) && !StringUtils.equals(themeValue, null)) {
|
||||
BaseController.THEME = themeValue;
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/14
|
||||
*/
|
||||
public enum BlogProperties {
|
||||
|
||||
/**
|
||||
* 博客标题
|
||||
*/
|
||||
BLOG_TITLE("blog_title"),
|
||||
|
||||
/**
|
||||
* 博客地址
|
||||
*/
|
||||
BLOG_URL("blog_url"),
|
||||
|
||||
/**
|
||||
* 文章摘要字数
|
||||
*/
|
||||
POST_SUMMARY("post_summary"),
|
||||
|
||||
/**
|
||||
* 首页文章条数
|
||||
*/
|
||||
INDEX_POSTS("index_posts"),
|
||||
|
||||
/**
|
||||
* 是否已经安装
|
||||
*/
|
||||
IS_INSTALL("is_install"),
|
||||
|
||||
/**
|
||||
* RSS显示文章条数
|
||||
*/
|
||||
RSS_POSTS("rss_posts"),
|
||||
|
||||
/**
|
||||
* API状态
|
||||
*/
|
||||
API_STATUS("api_status"),
|
||||
|
||||
/**
|
||||
* 邮箱服务器地址
|
||||
*/
|
||||
MAIL_SMTP_HOST("mail_smtp_host"),
|
||||
|
||||
/**
|
||||
* 邮箱地址
|
||||
*/
|
||||
MAIL_SMTP_USERNAME("smtp_username"),
|
||||
|
||||
/**
|
||||
* 邮箱密码/授权码
|
||||
*/
|
||||
MAIL_SMTP_PASSWORD("smtp_password"),
|
||||
|
||||
/**
|
||||
* 发送者名称
|
||||
*/
|
||||
MAIL_FROM_NAME("mail_from_name"),
|
||||
|
||||
/**
|
||||
* 启用邮件服务
|
||||
*/
|
||||
SMTP_EMAIL_ENABLE("smtp_email_enable"),
|
||||
|
||||
/**
|
||||
* 邮件回复通知
|
||||
*/
|
||||
COMMENT_REPLY_NOTICE("comment_reply_notice"),
|
||||
|
||||
/**
|
||||
* 新评论通知
|
||||
*/
|
||||
NEW_COMMENT_NOTICE("new_comment_notice"),
|
||||
|
||||
/**
|
||||
* 邮件审核通过通知
|
||||
*/
|
||||
COMMENT_PASS_NOTICE("comment_pass_notice"),
|
||||
|
||||
/**
|
||||
* 站点描述
|
||||
*/
|
||||
SEO_DESC("seo_desc"),
|
||||
|
||||
/**
|
||||
* 博客主题
|
||||
*/
|
||||
THEME("theme"),
|
||||
|
||||
/**
|
||||
* 博客搭建日期
|
||||
*/
|
||||
BLOG_START("blog_start"),
|
||||
|
||||
/**
|
||||
* 博客评论系统
|
||||
*/
|
||||
COMMENT_SYSTEM("comment_system");
|
||||
|
||||
private String prop;
|
||||
|
||||
BlogProperties(String prop) {
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public String getProp() {
|
||||
return prop;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/14
|
||||
*/
|
||||
public enum QiniuProperties {
|
||||
|
||||
/**
|
||||
* 七牛云域名
|
||||
*/
|
||||
QINIU_DOMAIN("qiniu_domain"),
|
||||
|
||||
/**
|
||||
* 七牛云AccessKey
|
||||
*/
|
||||
QINIU_ACCESS_KEY("qiniu_access_key"),
|
||||
|
||||
/**
|
||||
* 七牛云SecretKey
|
||||
*/
|
||||
QINIU_SECRET_KEY("qiniu_secret_key"),
|
||||
|
||||
/**
|
||||
* 七牛云空间名
|
||||
*/
|
||||
QINIU_BUCKET("qiniu_bucket");
|
||||
|
||||
private String prop;
|
||||
|
||||
QiniuProperties(String prop) {
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public String getProp() {
|
||||
return prop;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/14
|
||||
*/
|
||||
public enum ResultCode {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS(1),
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAIL(0);
|
||||
|
||||
Integer code;
|
||||
|
||||
ResultCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.service.impl;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.service.MailService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
import freemarker.template.Template;
|
||||
|
@ -34,12 +35,12 @@ public class MailServiceImpl implements MailService {
|
|||
public void sendMail(String to, String subject, String content) {
|
||||
//配置邮件服务器
|
||||
HaloUtils.configMail(
|
||||
HaloConst.OPTIONS.get("mail_smtp_host"),
|
||||
HaloConst.OPTIONS.get("mail_smtp_username"),
|
||||
HaloConst.OPTIONS.get("mail_smtp_password"));
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_HOST.getProp()),
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_USERNAME.getProp()),
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_PASSWORD.getProp()));
|
||||
try {
|
||||
OhMyEmail.subject(subject)
|
||||
.from(HaloConst.OPTIONS.get("mail_from_name"))
|
||||
.from(HaloConst.OPTIONS.get(BlogProperties.MAIL_FROM_NAME.getProp()))
|
||||
.to(to)
|
||||
.text(content)
|
||||
.send();
|
||||
|
@ -60,15 +61,15 @@ public class MailServiceImpl implements MailService {
|
|||
public void sendTemplateMail(String to, String subject, Map<String, Object> content, String templateName) {
|
||||
//配置邮件服务器
|
||||
HaloUtils.configMail(
|
||||
HaloConst.OPTIONS.get("mail_smtp_host"),
|
||||
HaloConst.OPTIONS.get("mail_smtp_username"),
|
||||
HaloConst.OPTIONS.get("mail_smtp_password"));
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_HOST.getProp()),
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_USERNAME.getProp()),
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_PASSWORD.getProp()));
|
||||
String text = "";
|
||||
try {
|
||||
Template template = freeMarker.getConfiguration().getTemplate(templateName);
|
||||
text = FreeMarkerTemplateUtils.processTemplateIntoString(template, content);
|
||||
OhMyEmail.subject(subject)
|
||||
.from(HaloConst.OPTIONS.get("mail_from_name"))
|
||||
.from(HaloConst.OPTIONS.get(BlogProperties.MAIL_FROM_NAME.getProp()))
|
||||
.to(to)
|
||||
.html(text)
|
||||
.send();
|
||||
|
@ -90,16 +91,16 @@ public class MailServiceImpl implements MailService {
|
|||
public void sendAttachMail(String to, String subject, Map<String, Object> content, String templateName, String attachSrc) {
|
||||
//配置邮件服务器
|
||||
HaloUtils.configMail(
|
||||
HaloConst.OPTIONS.get("mail_smtp_host"),
|
||||
HaloConst.OPTIONS.get("mail_smtp_username"),
|
||||
HaloConst.OPTIONS.get("mail_smtp_password"));
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_HOST.getProp()),
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_USERNAME.getProp()),
|
||||
HaloConst.OPTIONS.get(BlogProperties.MAIL_SMTP_PASSWORD.getProp()));
|
||||
File file = new File(attachSrc);
|
||||
String text = "";
|
||||
try{
|
||||
Template template = freeMarker.getConfiguration().getTemplate(templateName);
|
||||
text = FreeMarkerTemplateUtils.processTemplateIntoString(template,content);
|
||||
OhMyEmail.subject(subject)
|
||||
.from(HaloConst.OPTIONS.get("mail_from_name"))
|
||||
.from(HaloConst.OPTIONS.get(BlogProperties.MAIL_FROM_NAME.getProp()))
|
||||
.to(to)
|
||||
.html(text)
|
||||
.attach(file,file.getName())
|
||||
|
|
|
@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.Post;
|
|||
import cc.ryanc.halo.model.dto.BackupDto;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.Theme;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.sun.syndication.feed.rss.Channel;
|
||||
import com.sun.syndication.feed.rss.Content;
|
||||
|
@ -372,20 +373,20 @@ public class HaloUtils {
|
|||
*/
|
||||
public static String getRss(List<Post> posts) throws FeedException {
|
||||
Channel channel = new Channel("rss_2.0");
|
||||
if (null == HaloConst.OPTIONS.get("blog_title")) {
|
||||
if (null == HaloConst.OPTIONS.get(BlogProperties.BLOG_TITLE.getProp())) {
|
||||
channel.setTitle("");
|
||||
} else {
|
||||
channel.setTitle(HaloConst.OPTIONS.get("blog_title"));
|
||||
channel.setTitle(HaloConst.OPTIONS.get(BlogProperties.BLOG_TITLE.getProp()));
|
||||
}
|
||||
if (null == HaloConst.OPTIONS.get("blog_url")) {
|
||||
if (null == HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp())) {
|
||||
channel.setLink("");
|
||||
} else {
|
||||
channel.setLink(HaloConst.OPTIONS.get("blog_url"));
|
||||
channel.setLink(HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()));
|
||||
}
|
||||
if (null == HaloConst.OPTIONS.get("seo_desc")) {
|
||||
if (null == HaloConst.OPTIONS.get(BlogProperties.SEO_DESC.getProp())) {
|
||||
channel.setDescription("");
|
||||
} else {
|
||||
channel.setDescription(HaloConst.OPTIONS.get("seo_desc"));
|
||||
channel.setDescription(HaloConst.OPTIONS.get(BlogProperties.SEO_DESC.getProp()));
|
||||
}
|
||||
channel.setLanguage("zh-CN");
|
||||
List<Item> items = new ArrayList<>();
|
||||
|
@ -405,7 +406,7 @@ public class HaloUtils {
|
|||
value = new String(xmlChar);
|
||||
content.setValue(value);
|
||||
item.setContent(content);
|
||||
item.setLink(HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl());
|
||||
item.setLink(HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl());
|
||||
item.setPubDate(post.getPostDate());
|
||||
items.add(item);
|
||||
}
|
||||
|
@ -424,7 +425,7 @@ public class HaloUtils {
|
|||
String head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
|
||||
String urlBody = "";
|
||||
String urlItem;
|
||||
String urlPath = HaloConst.OPTIONS.get("blog_url") + "/archives/";
|
||||
String urlPath = HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/archives/";
|
||||
for (Post post : posts) {
|
||||
urlItem = "<url><loc>" + urlPath + post.getPostUrl() + "</loc><lastmod>" + getStringDate(post.getPostDate(), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX") + "</lastmod>" + "</url>";
|
||||
urlBody += urlItem;
|
||||
|
|
|
@ -8,6 +8,7 @@ import cc.ryanc.halo.model.dto.HaloConst;
|
|||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -134,7 +135,7 @@ public class AdminController extends BaseController {
|
|||
}
|
||||
Long between = DateUtil.between(loginLast, DateUtil.date(), DateUnit.MINUTE);
|
||||
if (StringUtils.equals(aUser.getLoginEnable(), "false") && (between < 10)) {
|
||||
return new JsonResult(0, "已禁止登录,请10分钟后再试");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "已禁止登录,请10分钟后再试");
|
||||
}
|
||||
//验证用户名和密码
|
||||
User user = null;
|
||||
|
@ -150,7 +151,7 @@ public class AdminController extends BaseController {
|
|||
//重置用户的登录状态为正常
|
||||
userService.updateUserNormal();
|
||||
logsService.saveByLogs(new Logs(LogsRecord.LOGIN, LogsRecord.LOGIN_SUCCESS, ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
return new JsonResult(1, "登录成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "登录成功!");
|
||||
} else {
|
||||
//更新失败次数
|
||||
Integer errorCount = userService.updateUserLoginError();
|
||||
|
@ -166,7 +167,7 @@ public class AdminController extends BaseController {
|
|||
DateUtil.date()
|
||||
)
|
||||
);
|
||||
return new JsonResult(0, "登录失败,你还有" + (5 - errorCount) + "次机会。");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "登录失败,你还有" + (5 - errorCount) + "次机会。");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.ryanc.halo.model.domain.Logs;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.AttachmentService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -198,9 +199,6 @@ public class AttachmentController {
|
|||
public String attachmentDetail(Model model, @PathParam("attachId") Long attachId) {
|
||||
Optional<Attachment> attachment = attachmentService.findByAttachId(attachId);
|
||||
model.addAttribute("attachment", attachment.get());
|
||||
|
||||
//设置选项
|
||||
model.addAttribute("options", HaloConst.OPTIONS);
|
||||
return "admin/widget/_attachment-detail";
|
||||
}
|
||||
|
||||
|
@ -237,13 +235,13 @@ public class AttachmentController {
|
|||
);
|
||||
} else {
|
||||
log.error("删除附件[" + delFileName + "]失败!");
|
||||
return new JsonResult(0,"删除失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"删除失败!");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("删除附件[" + delFileName + "]失败!:", e.getMessage());
|
||||
return new JsonResult(0,"删除失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"删除失败!");
|
||||
}
|
||||
return new JsonResult(1,"删除成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"删除成功!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import cc.ryanc.halo.model.dto.BackupDto;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.MailService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -85,7 +86,7 @@ public class BackupController {
|
|||
} else if (StringUtils.equals("posts", type)) {
|
||||
return this.backupPosts();
|
||||
} else {
|
||||
return new JsonResult(0, "备份失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,10 +105,10 @@ public class BackupController {
|
|||
//压缩文件
|
||||
ZipUtil.zip(srcPath + "halo.mv.db", System.getProperties().getProperty("user.home") + "/halo/backup/databases/" + distName + ".zip");
|
||||
log.info("当前时间:"+DateUtil.now()+",执行了数据库备份。");
|
||||
return new JsonResult(1, "备份成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "备份成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
return new JsonResult(0, "备份失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,10 +128,10 @@ public class BackupController {
|
|||
//执行打包
|
||||
ZipUtil.zip(srcPath, System.getProperties().getProperty("user.home") + "/halo/backup/resources/" + distName + ".zip");
|
||||
log.info("当前时间:"+DateUtil.now()+",执行了资源文件备份。");
|
||||
return new JsonResult(1, "备份成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "备份成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new JsonResult(0, "备份失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,10 +157,10 @@ public class BackupController {
|
|||
ZipUtil.zip(srcPath, srcPath + ".zip");
|
||||
FileUtil.del(srcPath);
|
||||
log.info("当前时间:"+DateUtil.now()+",执行了文章备份。");
|
||||
return new JsonResult(1, "备份成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "备份成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new JsonResult(0, "备份失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,9 +178,9 @@ public class BackupController {
|
|||
String srcPath = System.getProperties().getProperty("user.home") + "/halo/backup/" + type + "/" + fileName;
|
||||
try {
|
||||
FileUtil.del(srcPath);
|
||||
return new JsonResult(1, "删除成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "删除成功!");
|
||||
} catch (Exception e) {
|
||||
return new JsonResult(0, "删除失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "删除失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,13 +199,13 @@ public class BackupController {
|
|||
String srcPath = System.getProperties().getProperty("user.home") + "/halo/backup/" + type + "/" + fileName;
|
||||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||
if (null == user.getUserEmail() || StringUtils.equals(user.getUserEmail(), "")) {
|
||||
return new JsonResult(0, "博主邮箱没有配置!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "博主邮箱没有配置!");
|
||||
}
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get("smtp_email_enable"), "false")) {
|
||||
return new JsonResult(0, "发信邮箱没有配置!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "发信邮箱没有配置!");
|
||||
}
|
||||
new EmailToAdmin(srcPath, user).start();
|
||||
return new JsonResult(1, "邮件发送成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "邮件发送成功!");
|
||||
}
|
||||
|
||||
class EmailToAdmin extends Thread {
|
||||
|
|
|
@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.Comment;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.User;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.model.enums.CommentStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
|
@ -117,23 +118,23 @@ public class CommentController extends BaseController {
|
|||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||
|
||||
//判断是否启用邮件服务
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get("smtp_email_enable"), "true") && StringUtils.equals(HaloConst.OPTIONS.get("comment_pass_notice"), "true")) {
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogProperties.SMTP_EMAIL_ENABLE.getProp()), "true") && StringUtils.equals(HaloConst.OPTIONS.get(BlogProperties.COMMENT_REPLY_NOTICE.getProp()), "true")) {
|
||||
try {
|
||||
if (status == 1 && Validator.isEmail(comment.getCommentAuthorEmail())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
}
|
||||
map.put("pageName", post.getPostTitle());
|
||||
map.put("commentContent", comment.getCommentContent());
|
||||
map.put("blogUrl", HaloConst.OPTIONS.get("blog_url"));
|
||||
map.put("blogTitle", HaloConst.OPTIONS.get("blog_title"));
|
||||
map.put("blogUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()));
|
||||
map.put("blogTitle", HaloConst.OPTIONS.get(BlogProperties.BLOG_TITLE.getProp()));
|
||||
map.put("author", user.getUserDisplayName());
|
||||
mailService.sendTemplateMail(
|
||||
comment.getCommentAuthorEmail(),
|
||||
"您在" + HaloConst.OPTIONS.get("blog_title") + "的评论已审核通过!", map, "common/mail/mail_passed.ftl");
|
||||
"您在" + HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "的评论已审核通过!", map, "common/mail/mail_passed.ftl");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("邮件服务器未配置:", e.getMessage());
|
||||
|
@ -194,7 +195,7 @@ public class CommentController extends BaseController {
|
|||
comment.setPost(post);
|
||||
comment.setCommentAuthor(user.getUserDisplayName());
|
||||
comment.setCommentAuthorEmail(user.getUserEmail());
|
||||
comment.setCommentAuthorUrl(HaloConst.OPTIONS.get("blog_url"));
|
||||
comment.setCommentAuthorUrl(HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()));
|
||||
comment.setCommentAuthorIp(ServletUtil.getClientIP(request));
|
||||
comment.setCommentAuthorAvatarMd5(SecureUtil.md5(user.getUserEmail()));
|
||||
comment.setCommentDate(DateUtil.date());
|
||||
|
@ -207,23 +208,23 @@ public class CommentController extends BaseController {
|
|||
commentService.saveByComment(comment);
|
||||
|
||||
//邮件通知
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get("smtp_email_enable"), "true") && StringUtils.equals(HaloConst.OPTIONS.get("comment_reply_notice"), "true")) {
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogProperties.SMTP_EMAIL_ENABLE.getProp()), "true") && StringUtils.equals(HaloConst.OPTIONS.get(BlogProperties.COMMENT_REPLY_NOTICE.getProp()), "true")) {
|
||||
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("blogTitle", HaloConst.OPTIONS.get("blog_title"));
|
||||
map.put("blogTitle", HaloConst.OPTIONS.get(BlogProperties.BLOG_TITLE.getProp()));
|
||||
map.put("commentAuthor", lastComment.getCommentAuthor());
|
||||
map.put("pageName", lastComment.getPost().getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
}
|
||||
map.put("commentContent", lastComment.getCommentContent());
|
||||
map.put("replyAuthor", user.getUserDisplayName());
|
||||
map.put("replyContent", commentContent);
|
||||
map.put("blogUrl", HaloConst.OPTIONS.get("blog_url"));
|
||||
map.put("blogUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()));
|
||||
mailService.sendTemplateMail(
|
||||
lastComment.getCommentAuthorEmail(), "您在" + HaloConst.OPTIONS.get("blog_title") + "的评论有了新回复", map, "common/mail/mail_reply.ftl");
|
||||
lastComment.getCommentAuthorEmail(), "您在" + HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "的评论有了新回复", map, "common/mail/mail_reply.ftl");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.admin;
|
|||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.OptionsService;
|
||||
import freemarker.template.Configuration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -52,10 +53,10 @@ public class OptionController {
|
|||
HaloConst.OPTIONS.clear();
|
||||
HaloConst.OPTIONS = optionsService.findAllOptions();
|
||||
log.info("所保存的设置选项列表:" + options);
|
||||
return new JsonResult(1,"保存成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"保存成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
return new JsonResult(0,"保存失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"保存失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.ryanc.halo.model.dto.HaloConst;
|
|||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
|
@ -231,10 +232,10 @@ public class PageController {
|
|||
}
|
||||
postService.saveByPost(post);
|
||||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_PAGE, post.getPostTitle(), ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
return new JsonResult(1,msg);
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),msg);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
return new JsonResult(0,"保存失败");
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ import cc.ryanc.halo.model.domain.*;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.CategoryService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -162,8 +164,8 @@ public class PostController extends BaseController {
|
|||
try {
|
||||
//提取摘要
|
||||
int postSummary = 50;
|
||||
if (StringUtils.isNotEmpty(HaloConst.OPTIONS.get("post_summary"))) {
|
||||
postSummary = Integer.parseInt(HaloConst.OPTIONS.get("post_summary"));
|
||||
if (StringUtils.isNotEmpty(BlogProperties.POST_SUMMARY.getProp())) {
|
||||
postSummary = Integer.parseInt(BlogProperties.POST_SUMMARY.getProp());
|
||||
}
|
||||
//文章摘要
|
||||
String summaryText = HtmlUtil.cleanHtmlTag(post.getPostContent());
|
||||
|
@ -194,10 +196,10 @@ public class PostController extends BaseController {
|
|||
post.setPostUrl(urlFilter(post.getPostUrl()));
|
||||
postService.saveByPost(post);
|
||||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST, post.getPostTitle(), ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
return new JsonResult(1, msg);
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), msg);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
return new JsonResult(0, "保存失败");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,9 +248,9 @@ public class PostController extends BaseController {
|
|||
post.setUser(user);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
return new JsonResult(0, "保存失败");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "保存失败");
|
||||
}
|
||||
return new JsonResult(1, "保存成功", postService.saveByPost(post));
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "保存成功", postService.saveByPost(post));
|
||||
}
|
||||
|
||||
|
||||
|
@ -366,7 +368,7 @@ public class PostController extends BaseController {
|
|||
if (StringUtils.isEmpty(baiduToken)) {
|
||||
return false;
|
||||
}
|
||||
String blogUrl = HaloConst.OPTIONS.get("blog_url");
|
||||
String blogUrl = HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp());
|
||||
List<Post> posts = postService.findAllPosts(PostType.POST_TYPE_POST.getDesc());
|
||||
StringBuilder urls = new StringBuilder();
|
||||
for (Post post : posts) {
|
||||
|
|
|
@ -4,6 +4,8 @@ import cc.ryanc.halo.model.domain.Logs;
|
|||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.service.OptionsService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -73,17 +75,17 @@ public class ThemeController extends BaseController {
|
|||
HttpServletRequest request) {
|
||||
try {
|
||||
//保存主题设置项
|
||||
optionsService.saveOption("theme", siteTheme);
|
||||
optionsService.saveOption(BlogProperties.THEME.getProp(), siteTheme);
|
||||
//设置主题
|
||||
BaseController.THEME = siteTheme;
|
||||
log.info("已将主题改变为:" + siteTheme);
|
||||
logsService.saveByLogs(
|
||||
new Logs(LogsRecord.CHANGE_THEME, "更换为" + siteTheme, ServletUtil.getClientIP(request), DateUtil.date())
|
||||
);
|
||||
return new JsonResult(1,"主题已设置为"+siteTheme);
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"主题已设置为"+siteTheme);
|
||||
} catch (Exception e) {
|
||||
log.error("主题设置失败,当前主题为:" + siteTheme);
|
||||
return new JsonResult(0,"主题设置失败");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"主题设置失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,13 +116,13 @@ public class ThemeController extends BaseController {
|
|||
HaloConst.THEMES = HaloUtils.getThemes();
|
||||
} else {
|
||||
log.error("上传主题失败,没有选择文件");
|
||||
return new JsonResult(0,"请选择上传的主题!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"请选择上传的主题!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("上传主题失败:", e.getMessage());
|
||||
return new JsonResult(0,"主题上传失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"主题上传失败!");
|
||||
}
|
||||
return new JsonResult(1,"主题上传成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"主题上传成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +140,7 @@ public class ThemeController extends BaseController {
|
|||
HaloConst.THEMES.clear();
|
||||
HaloConst.THEMES = HaloUtils.getThemes();
|
||||
} catch (Exception e) {
|
||||
log.error("删除主题失败:{0}", e.getMessage());
|
||||
log.error("删除主题失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/themes";
|
||||
}
|
||||
|
@ -184,7 +186,7 @@ public class ThemeController extends BaseController {
|
|||
File themesPath = new File(basePath.getAbsolutePath(), new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString());
|
||||
tplContent = HaloUtils.getFileContent(themesPath.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
log.error("获取模板文件错误:{0}", e.getMessage());
|
||||
log.error("获取模板文件错误:{}", e.getMessage());
|
||||
}
|
||||
return tplContent;
|
||||
}
|
||||
|
@ -201,7 +203,7 @@ public class ThemeController extends BaseController {
|
|||
public JsonResult saveTpl(@RequestParam("tplName") String tplName,
|
||||
@RequestParam("tplContent") String tplContent) {
|
||||
if (StringUtils.isBlank(tplContent)) {
|
||||
return new JsonResult(0,"模板不能为空!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"模板不能为空!");
|
||||
}
|
||||
try {
|
||||
//获取项目根路径
|
||||
|
@ -211,9 +213,9 @@ public class ThemeController extends BaseController {
|
|||
byte[] tplContentByte = tplContent.getBytes("UTF-8");
|
||||
Files.write(Paths.get(tplPath.getAbsolutePath()), tplContentByte);
|
||||
} catch (Exception e) {
|
||||
log.error("模板保存失败:{0}", e.getMessage());
|
||||
return new JsonResult(0,"模板保存失败!");
|
||||
log.error("模板保存失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"模板保存失败!");
|
||||
}
|
||||
return new JsonResult(1,"模板保存成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"模板保存成功!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.admin;
|
|||
|
||||
import cc.ryanc.halo.model.domain.User;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.UserService;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import freemarker.template.Configuration;
|
||||
|
@ -53,13 +54,13 @@ public class UserController {
|
|||
configuration.setSharedVariable("user", userService.findUser());
|
||||
session.invalidate();
|
||||
} else {
|
||||
return new JsonResult(0,"修改失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"修改失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
return new JsonResult(0,"修改失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"修改失败!");
|
||||
}
|
||||
return new JsonResult(1,"修改成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"修改成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,12 +85,12 @@ public class UserController {
|
|||
userService.saveByUser(user);
|
||||
session.invalidate();
|
||||
} else {
|
||||
return new JsonResult(0,"原密码错误!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"原密码错误!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("修改密码:未知错误,{0}", e.getMessage());
|
||||
return new JsonResult(0,"密码修改失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"密码修改失败!");
|
||||
}
|
||||
return new JsonResult(1,"修改密码成功!");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"修改密码成功!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.web.controller.api;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatus;
|
||||
|
@ -41,8 +42,8 @@ public class ApiPostController {
|
|||
public JsonResult posts(@PathVariable(value = "page") Integer page){
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Integer size = 10;
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()));
|
||||
}
|
||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||
Page<Post> posts = postService.findPostByStatus(PostStatus.PUBLISHED.getCode(), PostType.POST_TYPE_POST.getDesc(), pageable);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package cc.ryanc.halo.web.controller.core;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -42,9 +40,7 @@ public class CommonController implements ErrorController {
|
|||
* @return String
|
||||
*/
|
||||
@GetMapping(value = "/404")
|
||||
public String fourZeroFour(Model model) {
|
||||
//设置选项
|
||||
model.addAttribute("options", HaloConst.OPTIONS);
|
||||
public String fourZeroFour() {
|
||||
return "common/404";
|
||||
}
|
||||
|
||||
|
@ -55,9 +51,7 @@ public class CommonController implements ErrorController {
|
|||
* @return String
|
||||
*/
|
||||
@GetMapping(value = "/500")
|
||||
public String fiveZeroZero(Model model) {
|
||||
//设置选项
|
||||
model.addAttribute("options", HaloConst.OPTIONS);
|
||||
public String fiveZeroZero() {
|
||||
return "common/500";
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.web.controller.core;
|
|||
import cc.ryanc.halo.model.domain.*;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.service.*;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
|
@ -62,7 +63,7 @@ public class InstallController {
|
|||
@GetMapping
|
||||
public String install(Model model) {
|
||||
try {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get("is_install"))) {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get(BlogProperties.IS_INSTALL.getProp()))) {
|
||||
model.addAttribute("isInstall", true);
|
||||
} else {
|
||||
model.addAttribute("isInstall", false);
|
||||
|
@ -95,7 +96,7 @@ public class InstallController {
|
|||
@RequestParam("userPwd") String userPwd,
|
||||
HttpServletRequest request) {
|
||||
try {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get("is_install"))) {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get(BlogProperties.IS_INSTALL.getProp()))) {
|
||||
return false;
|
||||
}
|
||||
//创建新的用户
|
||||
|
@ -147,28 +148,28 @@ public class InstallController {
|
|||
comment.setIsAdmin(0);
|
||||
commentService.saveByComment(comment);
|
||||
|
||||
optionsService.saveOption("is_install", "true");
|
||||
optionsService.saveOption(BlogProperties.IS_INSTALL.getProp(), "true");
|
||||
|
||||
//保存博客标题和博客地址设置
|
||||
optionsService.saveOption("blog_title", blogTitle);
|
||||
optionsService.saveOption("blog_url", blogUrl);
|
||||
optionsService.saveOption(BlogProperties.BLOG_TITLE.getProp(), blogTitle);
|
||||
optionsService.saveOption(BlogProperties.BLOG_URL.getProp(), blogUrl);
|
||||
|
||||
//设置默认主题
|
||||
optionsService.saveOption("theme", "anatole");
|
||||
optionsService.saveOption(BlogProperties.THEME.getProp(), "anatole");
|
||||
|
||||
//建立网站时间
|
||||
optionsService.saveOption("blog_start", HaloUtils.getStringDate("yyyy-MM-dd"));
|
||||
optionsService.saveOption(BlogProperties.BLOG_START.getProp(), HaloUtils.getStringDate("yyyy-MM-dd"));
|
||||
|
||||
//默认评论系统
|
||||
optionsService.saveOption("comment_system", "native");
|
||||
optionsService.saveOption(BlogProperties.COMMENT_SYSTEM.getProp(), "native");
|
||||
|
||||
//默认不配置邮件系统
|
||||
optionsService.saveOption("smtp_email_enable", "false");
|
||||
optionsService.saveOption(BlogProperties.SMTP_EMAIL_ENABLE.getProp(), "false");
|
||||
|
||||
//新评论,审核通过,回复,默认不通知
|
||||
optionsService.saveOption("new_comment_notice", "false");
|
||||
optionsService.saveOption("comment_pass_notice", "false");
|
||||
optionsService.saveOption("comment_reply_notice", "false");
|
||||
optionsService.saveOption(BlogProperties.NEW_COMMENT_NOTICE.getProp(), "false");
|
||||
optionsService.saveOption(BlogProperties.COMMENT_PASS_NOTICE.getProp(), "false");
|
||||
optionsService.saveOption(BlogProperties.COMMENT_REPLY_NOTICE.getProp(), "false");
|
||||
|
||||
//更新日志
|
||||
logsService.saveByLogs(
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
import cc.ryanc.halo.model.domain.Category;
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.service.CategoryService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||
|
@ -77,8 +78,8 @@ public class FrontCategoryController extends BaseController {
|
|||
}
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Integer size = 10;
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()));
|
||||
}
|
||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||
Page<Post> posts = postService.findPostByCategories(category, pageable);
|
||||
|
|
|
@ -4,8 +4,10 @@ import cc.ryanc.halo.model.domain.Comment;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.model.enums.CommentStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.model.enums.ResultCode;
|
||||
import cc.ryanc.halo.service.CommentService;
|
||||
import cc.ryanc.halo.service.MailService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -128,9 +130,9 @@ public class FrontCommentController {
|
|||
}else{
|
||||
new EmailToAdmin(comment,post).start();
|
||||
}
|
||||
return new JsonResult(1,"你的评论已经提交,待博主审核之后可显示。");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"你的评论已经提交,待博主审核之后可显示。");
|
||||
}catch (Exception e){
|
||||
return new JsonResult(0,"评论失败!");
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"评论失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,9 +155,9 @@ public class FrontCommentController {
|
|||
map.put("author", userService.findUser().getUserDisplayName());
|
||||
map.put("pageName", post.getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
}
|
||||
map.put("visitor", comment.getCommentAuthor());
|
||||
map.put("commentContent", comment.getCommentContent());
|
||||
|
@ -186,20 +188,20 @@ public class FrontCommentController {
|
|||
if(StringUtils.equals(HaloConst.OPTIONS.get("smtp_email_enable"),"true") && StringUtils.equals(HaloConst.OPTIONS.get("comment_reply_notice"),"true")) {
|
||||
if(Validator.isEmail(lastComment.getCommentAuthorEmail())){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("blogTitle",HaloConst.OPTIONS.get("blog_title"));
|
||||
map.put("blogTitle",HaloConst.OPTIONS.get(BlogProperties.BLOG_TITLE.getProp()));
|
||||
map.put("commentAuthor",lastComment.getCommentAuthor());
|
||||
map.put("pageName",lastComment.getPost().getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), PostType.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get("blog_url") + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
}
|
||||
map.put("commentContent",lastComment.getCommentContent());
|
||||
map.put("replyAuthor",comment.getCommentAuthor());
|
||||
map.put("replyContent",comment.getCommentContent());
|
||||
map.put("blogUrl",HaloConst.OPTIONS.get("blog_url"));
|
||||
map.put("blogUrl",HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp()));
|
||||
mailService.sendTemplateMail(
|
||||
lastComment.getCommentAuthorEmail(),"您在"+HaloConst.OPTIONS.get("blog_title")+"的评论有了新回复",map,"common/mail/mail_reply.ftl");
|
||||
lastComment.getCommentAuthorEmail(),"您在"+HaloConst.OPTIONS.get(BlogProperties.BLOG_TITLE.getProp())+"的评论有了新回复",map,"common/mail/mail_reply.ftl");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -61,8 +62,8 @@ public class FrontIndexController extends BaseController {
|
|||
//默认显示10条
|
||||
Integer size = 10;
|
||||
//尝试加载设置选项,用于设置显示条数
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()));
|
||||
}
|
||||
//所有文章数据,分页
|
||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||
|
@ -87,8 +88,8 @@ public class FrontIndexController extends BaseController {
|
|||
//默认显示10条
|
||||
Integer size = 10;
|
||||
//尝试加载设置选项,用于设置显示条数
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()));
|
||||
}
|
||||
|
||||
//文章数据,只获取文章,没有分页
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -34,7 +35,7 @@ public class FrontOthersController {
|
|||
@GetMapping(value = {"feed", "feed.xml", "atom", "atom.xml"}, produces = "application/xml;charset=UTF-8")
|
||||
@ResponseBody
|
||||
public String feed() {
|
||||
String rssPosts = HaloConst.OPTIONS.get("rss_posts");
|
||||
String rssPosts = HaloConst.OPTIONS.get(BlogProperties.RSS_POSTS.getProp());
|
||||
if (StringUtils.isBlank(rssPosts)) {
|
||||
rssPosts = "20";
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.Tag;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.service.TagService;
|
||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||
|
@ -73,8 +74,8 @@ public class FrontTagController extends BaseController {
|
|||
}
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "postDate");
|
||||
Integer size = 10;
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
|
||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()))) {
|
||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogProperties.INDEX_POSTS.getProp()));
|
||||
}
|
||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||
Page<Post> posts = postService.findPostsByTags(tag, pageable);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.web.interceptor;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
@ -17,7 +18,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
public class ApiInterceptor implements HandlerInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get("api_status"))) {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get(BlogProperties.API_STATUS.getProp()))) {
|
||||
return true;
|
||||
}
|
||||
response.sendRedirect("/404");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.web.interceptor;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
@ -18,7 +19,7 @@ public class InstallInterceptor implements HandlerInterceptor {
|
|||
|
||||
@Override
|
||||
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(BlogProperties.IS_INSTALL.getProp()))) {
|
||||
return true;
|
||||
}
|
||||
response.sendRedirect("/install");
|
||||
|
|
|
@ -395,66 +395,89 @@
|
|||
<!-- 附件设置 -->
|
||||
<div class="tab-pane" id="attach">
|
||||
<form method="post" class="form-horizontal" id="attachOptions">
|
||||
<#--<div class="box-body">-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label class="col-lg-2 col-sm-4 control-label">存储位置:</label>-->
|
||||
<#--<div class="col-lg-4 col-sm-8">-->
|
||||
<#--<label class="radio-inline">-->
|
||||
<#--<input type="radio" name="attach_loc" value="server" ${((options.attach_loc?default('server'))=='server')?string('checked','')}> 本地服务器-->
|
||||
<#--</label>-->
|
||||
<#--<label class="radio-inline">-->
|
||||
<#--<input type="radio" name="attach_loc" value="upyun" ${((options.attach_loc?if_exists)=='upyun')?string('checked','')}> 又拍云-->
|
||||
<#--</label>-->
|
||||
<#--<label class="radio-inline">-->
|
||||
<#--<input type="radio" name="attach_loc" value="qiniu" ${((options.attach_loc?if_exists)=='qiniu')?string('checked','')}> 七牛云-->
|
||||
<#--</label>-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 col-sm-4 control-label">存储位置:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="attach_loc" value="server" ${((options.attach_loc?default('server'))=='server')?string('checked','')}> 本地服务器
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="attach_loc" value="upyun" ${((options.attach_loc?if_exists)=='upyun')?string('checked','')} disabled="disabled"> 又拍云
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="attach_loc" value="qiniu" ${((options.attach_loc?if_exists)=='qiniu')?string('checked','')} disabled="disabled"> 七牛云
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<#--<!-- 原生设置 –>-->
|
||||
<#--<div class="server-options" style="display: none">-->
|
||||
<!-- 原生设置 -->
|
||||
<div class="server-options" style="display: none">
|
||||
|
||||
<#--</div>-->
|
||||
</div>
|
||||
|
||||
<#--<!-- 又拍云选项 –>-->
|
||||
<#--<div class="upyun-options" style="display: none">-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssDomain" class="col-lg-2 col-sm-4 control-label">域名绑定:</label>-->
|
||||
<#--<div class="col-lg-4 col-sm-8">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssDomain" name="upyun_oss_domain" value="${options.upyun_oss_domain?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssBucket" class="col-lg-2 col-sm-4 control-label">空间名称:</label>-->
|
||||
<#--<div class="col-lg-4 col-sm-8">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssBucket" name="upyun_oss_bucket" value="${options.upyun_oss_bucket?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssOperator" class="col-lg-2 col-sm-4 control-label">操作员名称:</label>-->
|
||||
<#--<div class="col-lg-4 col-sm-8">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssOperator" name="upyun_oss_operator" value="${options.upyun_oss_operator?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssPwd" class="col-lg-2 col-sm-4 control-label">操作员密码:</label>-->
|
||||
<#--<div class="col-lg-4 col-sm-8">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssPwd" name="upyun_oss_pwd" value="${options.upyun_oss_pwd?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssSrc" class="col-lg-2 col-sm-4 control-label">文件目录:</label>-->
|
||||
<#--<div class="col-lg-4 col-sm-8">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssSrc" name="upyun_oss_src" value="${options.upyun_oss_src?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<!-- 又拍云选项 -->
|
||||
<div class="upyun-options" style="display: none">
|
||||
<div class="form-group">
|
||||
<label for="upyunOssDomain" class="col-lg-2 col-sm-4 control-label">域名绑定:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="upyunOssDomain" name="upyun_oss_domain" value="${options.upyun_oss_domain?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="upyunOssBucket" class="col-lg-2 col-sm-4 control-label">空间名称:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="upyunOssBucket" name="upyun_oss_bucket" value="${options.upyun_oss_bucket?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="upyunOssOperator" class="col-lg-2 col-sm-4 control-label">操作员名称:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="upyunOssOperator" name="upyun_oss_operator" value="${options.upyun_oss_operator?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="upyunOssPwd" class="col-lg-2 col-sm-4 control-label">操作员密码:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="upyunOssPwd" name="upyun_oss_pwd" value="${options.upyun_oss_pwd?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="upyunOssSrc" class="col-lg-2 col-sm-4 control-label">文件目录:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="upyunOssSrc" name="upyun_oss_src" value="${options.upyun_oss_src?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<#--<!-- 七牛云 –>-->
|
||||
<#--<div class="qiniu-options" style="display: none">-->
|
||||
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<!-- 七牛云 -->
|
||||
<div class="qiniu-options" style="display: none">
|
||||
<div class="form-group">
|
||||
<label for="qiniuDomain" class="col-lg-2 col-sm-4 control-label">域名:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="qiniuDomain" name="qiniu_domain" value="${options.qiniu_domain?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="qiniuAccessKey" class="col-lg-2 col-sm-4 control-label">Access Key:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="qiniuAccessKey" name="qiniu_access_key" value="${options.qiniu_access_key?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="qiniuSecretKey" class="col-lg-2 col-sm-4 control-label">Secret Key:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="qiniuSecretKey" name="qiniu_secret_key" value="${options.qiniu_secret_key?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="qiniuBucket" class="col-lg-2 col-sm-4 control-label">Bucket:</label>
|
||||
<div class="col-lg-4 col-sm-8">
|
||||
<input type="text" class="form-control" id="qiniuBucket" name="qiniu_bucket" value="${options.qiniu_bucket?if_exists}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="button" class="btn btn-primary btn-sm " onclick="saveOptions('attachOptions')">保存</button>
|
||||
</div>
|
||||
|
@ -620,6 +643,7 @@
|
|||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
checkCommentOption();
|
||||
checkAttachOption();
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -679,7 +703,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* 评论切换
|
||||
* 评论选项切换
|
||||
*/
|
||||
function checkCommentOption() {
|
||||
var native = $('input:radio[value=native]:checked').val();
|
||||
|
@ -714,6 +738,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件选项切换
|
||||
*/
|
||||
function checkAttachOption() {
|
||||
var server = $('input:radio[value=server]:checked').val();
|
||||
var upyun = $('input:radio[value=upyun]:checked').val();
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<link rel="stylesheet" href="/static/css/loader.css">
|
||||
<link rel="stylesheet" href="/static/plugins/toast/css/jquery.toast.min.css">
|
||||
<link rel="stylesheet" href="/static/plugins/fileinput/fileinput.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="/static/plugins/OwO/OwO.min.css">
|
||||
<link rel="stylesheet" href="/static/plugins/OwO/OwO.min.css">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
|
|
Loading…
Reference in New Issue