mirror of https://github.com/halo-dev/halo
🎨 代码优化
parent
64a5eb792e
commit
dff55aca9e
|
@ -82,7 +82,7 @@ public class StartupConfig implements ApplicationListener<ApplicationStartedEven
|
|||
* 加载OwO表情
|
||||
*/
|
||||
private void loadOwo() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
Map<String, String> map = new HashMap<>(135);
|
||||
map.put("@[nico]", "<img src='/static/plugins/OwO/paopao/nico.png' alt='nico.png' style='vertical-align: middle;'>");
|
||||
map.put("@[OK]", "<img src='/static/plugins/OwO/paopao/OK.png' alt='OK.png' style='vertical-align: middle;'>");
|
||||
map.put("@[what]", "<img src='/static/plugins/OwO/paopao/what.png' alt='what.png' style='vertical-align: middle;'>");
|
||||
|
|
|
@ -84,7 +84,7 @@ public class OptionsServiceImpl implements OptionsService {
|
|||
*/
|
||||
@Override
|
||||
public Map<String, String> findAllOptions() {
|
||||
Map<String, String> options = new HashMap<String, String>();
|
||||
Map<String, String> options = new HashMap<>();
|
||||
List<Options> optionsList = optionsRepository.findAll();
|
||||
if (null != optionsList) {
|
||||
optionsList.forEach(option -> options.put(option.getOptionName(), option.getOptionValue()));
|
||||
|
|
|
@ -46,36 +46,6 @@ import java.util.*;
|
|||
@Slf4j
|
||||
public class HaloUtils {
|
||||
|
||||
private static ArrayList<String> FILE_LIST = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 获取所有附件
|
||||
*
|
||||
* @param filePath filePath
|
||||
* @return ArrayList
|
||||
*/
|
||||
public static ArrayList<String> getFiles(String filePath) {
|
||||
try {
|
||||
//获取项目根路径
|
||||
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||
//获取目标路径
|
||||
File targetPath = new File(basePath.getAbsolutePath(), filePath);
|
||||
File[] files = targetPath.listFiles();
|
||||
//遍历文件
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
getFiles(filePath + "/" + file.getName());
|
||||
} else {
|
||||
String abPath = file.getAbsolutePath().substring(file.getAbsolutePath().indexOf("/upload"));
|
||||
FILE_LIST.add(abPath);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
}
|
||||
return FILE_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取备份文件信息
|
||||
*
|
||||
|
@ -205,7 +175,7 @@ public class HaloUtils {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("主题获取失败:", e.getMessage());
|
||||
log.error("主题获取失败:{}", e.getMessage());
|
||||
}
|
||||
return themes;
|
||||
}
|
||||
|
@ -241,7 +211,7 @@ public class HaloUtils {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("获取主题模板失败:{}", e.getMessage());
|
||||
}
|
||||
return tpls;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class AttachmentController {
|
|||
* @return Map
|
||||
*/
|
||||
private Map<String, Object> uploadAttachment(MultipartFile file, HttpServletRequest request) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>(3);
|
||||
if (!file.isEmpty()) {
|
||||
try {
|
||||
//程序根路径,也就是/resources
|
||||
|
|
|
@ -226,7 +226,7 @@ public class BackupController {
|
|||
@Override
|
||||
public void run() {
|
||||
File file = new File(srcPath);
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
Map<String, Object> content = new HashMap<>(3);
|
||||
try {
|
||||
content.put("fileName", file.getName());
|
||||
content.put("createAt", HaloUtils.getCreateTime(srcPath));
|
||||
|
|
|
@ -221,7 +221,7 @@ public class CommentController extends BaseController {
|
|||
public void run() {
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.COMMENT_REPLY_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(8);
|
||||
map.put("blogTitle", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_TITLE.getProp()));
|
||||
map.put("commentAuthor", lastComment.getCommentAuthor());
|
||||
map.put("pageName", lastComment.getPost().getPostTitle());
|
||||
|
@ -263,7 +263,7 @@ public class CommentController extends BaseController {
|
|||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.COMMENT_REPLY_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||
try {
|
||||
if (status == 1 && Validator.isEmail(comment.getCommentAuthorEmail())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(6);
|
||||
if (StringUtils.equals(post.getPostType(), PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||
} else {
|
||||
|
|
|
@ -265,8 +265,7 @@ public class PageController {
|
|||
@ResponseBody
|
||||
public JsonResult checkUrlExists(@PathParam("postUrl") String postUrl) {
|
||||
Post post = postService.findByPostUrl(postUrl, PostTypeEnum.POST_TYPE_PAGE.getDesc());
|
||||
// TODO 还没写完
|
||||
if (null != post || StringUtils.equals("archives", postUrl) || StringUtils.equals("galleries", postUrl)) {
|
||||
if (null != post) {
|
||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), "该路径已经存在!");
|
||||
}
|
||||
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "");
|
||||
|
|
|
@ -165,7 +165,7 @@ public class FrontCommentController {
|
|||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||
try {
|
||||
//发送邮件到博主
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(5);
|
||||
map.put("author", userService.findUser().getUserDisplayName());
|
||||
map.put("pageName", post.getPostTitle());
|
||||
if (StringUtils.equals(post.getPostType(), PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
||||
|
@ -202,7 +202,7 @@ public class FrontCommentController {
|
|||
//发送通知给对方
|
||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(8);
|
||||
map.put("blogTitle", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_TITLE.getProp()));
|
||||
map.put("commentAuthor", lastComment.getCommentAuthor());
|
||||
map.put("pageName", lastComment.getPost().getPostTitle());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!-- changyan comment -->
|
||||
<#-- changyan comment -->
|
||||
<!--PC和WAP自适应版-->
|
||||
<style type="text/css" rel="stylesheet">
|
||||
${options.changyan_css?if_exists}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!--disqus comment-->
|
||||
<#--disqus comment-->
|
||||
<style type="text/css" rel="stylesheet">
|
||||
${options.disqus_css?if_exists}
|
||||
</style>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!-- livere_comment -->
|
||||
<#-- livere_comment -->
|
||||
<style type="text/css" rel="stylesheet">
|
||||
${options.livere_css?if_exists}
|
||||
</style>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!-- Valine comment -->
|
||||
<#-- Valine comment -->
|
||||
<style type="text/css" rel="stylesheet">
|
||||
${options.valine_css?if_exists}
|
||||
</style>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<!-- 统计代码 -->
|
||||
<#-- 统计代码 -->
|
||||
<#macro statistics>
|
||||
${options.statistics_code?if_exists}
|
||||
</#macro>
|
||||
|
||||
<!-- 页脚信息 -->
|
||||
<#-- 页脚信息 -->
|
||||
<#macro footer_info>
|
||||
${options.blog_footer_info?if_exists}
|
||||
</#macro>
|
||||
|
||||
<!-- favicon -->
|
||||
<#-- favicon -->
|
||||
<#macro favicon>
|
||||
<#if options.blog_favicon??>
|
||||
<link rel="shortcut icon" type="images/x-icon" href="${options.blog_favicon}">
|
||||
|
|
|
@ -14,7 +14,12 @@
|
|||
<@commonTag method="links">
|
||||
<#if links?? && links?size gt 0>
|
||||
<#list links as link>
|
||||
<p><a href="${link.linkUrl}" target="_blank" rel="external">${link.linkName}</a> – ${link.linkDesc}</p>
|
||||
<p>
|
||||
<a href="${link.linkUrl}" target="_blank" rel="external">${link.linkName}</a>
|
||||
<#if link.linkDesc!=''>
|
||||
– ${link.linkDesc}
|
||||
</#if>
|
||||
</p>
|
||||
</#list>
|
||||
</#if>
|
||||
</@commonTag>
|
||||
|
|
Loading…
Reference in New Issue