mirror of https://github.com/halo-dev/halo
🎨 移除Apache common Lang3包,改用Hutool
parent
b6714966a1
commit
036b17f57d
|
@ -108,15 +108,12 @@ The birth of Halo is inseparable from the following projects:
|
||||||
- [Spring-data-jpa](https://github.com/spring-projects/spring-data-jpa.git):Do not need to write a sql script persistence layer framework.
|
- [Spring-data-jpa](https://github.com/spring-projects/spring-data-jpa.git):Do not need to write a sql script persistence layer framework.
|
||||||
- [Ehcache](http://www.ehcache.org/):Cache framework.
|
- [Ehcache](http://www.ehcache.org/):Cache framework.
|
||||||
- [Lombok](https://www.projectlombok.org/):Make the code simpler.
|
- [Lombok](https://www.projectlombok.org/):Make the code simpler.
|
||||||
- [Apache Commons](http://commons.apache.org/):Very easy to use Java tool library.
|
|
||||||
- [oh-my-email](https://github.com/biezhi/oh-my-email):Probably the smallest Java mailing library, support for CC, attachments, templates, etc.
|
- [oh-my-email](https://github.com/biezhi/oh-my-email):Probably the smallest Java mailing library, support for CC, attachments, templates, etc.
|
||||||
- [Hutool](https://github.com/looly/hutool):A Java base tool library.
|
- [Hutool](https://github.com/looly/hutool):A Java base tool library.
|
||||||
- [Thumbnailator](https://github.com/coobird/thumbnailator):Thumbnail generation library.
|
- [Thumbnailator](https://github.com/coobird/thumbnailator):Thumbnail generation library.
|
||||||
- [AdminLTE](https://github.com/almasaeed2010/AdminLTE):Background template based on Bootstrap.
|
- [AdminLTE](https://github.com/almasaeed2010/AdminLTE):Background template based on Bootstrap.
|
||||||
- [Bootstrap](https://github.com/twbs/bootstrap.git):Use the most extensive front-end ui framework.
|
- [Bootstrap](https://github.com/twbs/bootstrap.git):Use the most extensive front-end ui framework.
|
||||||
- [Animate](https://github.com/daneden/animate.css.git):Very easy to use css motion library.
|
- [Animate](https://github.com/daneden/animate.css.git):Very easy to use css motion library.
|
||||||
- [Editor.md](https://github.com/pandao/editor.md.git):Markdown front-end editor, sorry for the author abandoned.
|
|
||||||
- [Editor.md](https://github.com/hawtim/editor.md):Editor.md, the version that hawtim took over to maintain.
|
|
||||||
- [SimpleMDE - Markdown Editor](https://github.com/sparksuite/simplemde-markdown-editor):Simple, functional, and lightweight Markdown editor.
|
- [SimpleMDE - Markdown Editor](https://github.com/sparksuite/simplemde-markdown-editor):Simple, functional, and lightweight Markdown editor.
|
||||||
- [Bootstrap-FileInput](https://github.com/kartik-v/bootstrap-fileinput.git):Personally think that the best upload component.
|
- [Bootstrap-FileInput](https://github.com/kartik-v/bootstrap-fileinput.git):Personally think that the best upload component.
|
||||||
- [Font-awesome](https://github.com/FortAwesome/Font-Awesome.git):The most widely used font icon library.
|
- [Font-awesome](https://github.com/FortAwesome/Font-Awesome.git):The most widely used font icon library.
|
||||||
|
|
|
@ -110,15 +110,12 @@ Halo的诞生离不开下面这些项目:
|
||||||
- [Spring-data-jpa](https://github.com/spring-projects/spring-data-jpa.git):不需要写sql语句的持久层框架
|
- [Spring-data-jpa](https://github.com/spring-projects/spring-data-jpa.git):不需要写sql语句的持久层框架
|
||||||
- [Ehcache](http://www.ehcache.org/):缓存框架
|
- [Ehcache](http://www.ehcache.org/):缓存框架
|
||||||
- [Lombok](https://www.projectlombok.org/):让代码更简洁
|
- [Lombok](https://www.projectlombok.org/):让代码更简洁
|
||||||
- [Apache Commons](http://commons.apache.org/):非常好用的Java工具库
|
|
||||||
- [oh-my-email](https://github.com/biezhi/oh-my-email):可能是最小的Java邮件发送库了,支持抄送、附件、模板等
|
- [oh-my-email](https://github.com/biezhi/oh-my-email):可能是最小的Java邮件发送库了,支持抄送、附件、模板等
|
||||||
- [Hutool](https://github.com/looly/hutool):一个Java基础工具类库
|
- [Hutool](https://github.com/looly/hutool):一个Java基础工具类库
|
||||||
- [Thumbnailator](https://github.com/coobird/thumbnailator):缩略图生成库
|
- [Thumbnailator](https://github.com/coobird/thumbnailator):缩略图生成库
|
||||||
- [AdminLTE](https://github.com/almasaeed2010/AdminLTE):基于Bootstrap的后台模板
|
- [AdminLTE](https://github.com/almasaeed2010/AdminLTE):基于Bootstrap的后台模板
|
||||||
- [Bootstrap](https://github.com/twbs/bootstrap.git):使用最广泛的前端ui框架
|
- [Bootstrap](https://github.com/twbs/bootstrap.git):使用最广泛的前端ui框架
|
||||||
- [Animate](https://github.com/daneden/animate.css.git):非常好用的css动效库
|
- [Animate](https://github.com/daneden/animate.css.git):非常好用的css动效库
|
||||||
- [Editor.md](https://github.com/pandao/editor.md.git):Markdown前端编辑器,遗憾作者弃坑了
|
|
||||||
- [Editor.md](https://github.com/hawtim/editor.md):Editor.md,hawtim接过来维护的版本
|
|
||||||
- [SimpleMDE - Markdown Editor](https://github.com/sparksuite/simplemde-markdown-editor):简洁,功能够用,且轻量级的Markdown编辑器
|
- [SimpleMDE - Markdown Editor](https://github.com/sparksuite/simplemde-markdown-editor):简洁,功能够用,且轻量级的Markdown编辑器
|
||||||
- [Bootstrap-FileInput](https://github.com/kartik-v/bootstrap-fileinput.git):个人认为最好用的上传组件,没有之一
|
- [Bootstrap-FileInput](https://github.com/kartik-v/bootstrap-fileinput.git):个人认为最好用的上传组件,没有之一
|
||||||
- [Font-awesome](https://github.com/FortAwesome/Font-Awesome.git):使用最广泛的字体图标库
|
- [Font-awesome](https://github.com/FortAwesome/Font-Awesome.git):使用最广泛的字体图标库
|
||||||
|
|
10
pom.xml
10
pom.xml
|
@ -36,8 +36,7 @@
|
||||||
<lombok.version>1.18.2</lombok.version>
|
<lombok.version>1.18.2</lombok.version>
|
||||||
<ehcache.version>3.6.0</ehcache.version>
|
<ehcache.version>3.6.0</ehcache.version>
|
||||||
<rome.version>1.0</rome.version>
|
<rome.version>1.0</rome.version>
|
||||||
<commons-lang3.version>3.8</commons-lang3.version>
|
<hutool-all.version>4.1.14</hutool-all.version>
|
||||||
<hutool-all.version>4.1.13</hutool-all.version>
|
|
||||||
<upyun-java-sdk.version>4.0.1</upyun-java-sdk.version>
|
<upyun-java-sdk.version>4.0.1</upyun-java-sdk.version>
|
||||||
<qiniu-java-sdk.version>7.2.14</qiniu-java-sdk.version>
|
<qiniu-java-sdk.version>7.2.14</qiniu-java-sdk.version>
|
||||||
<thumbnailator.version>0.4.8</thumbnailator.version>
|
<thumbnailator.version>0.4.8</thumbnailator.version>
|
||||||
|
@ -136,13 +135,6 @@
|
||||||
<version>${rome.version}</version>
|
<version>${rome.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- commons-lang3工具包 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>${commons-lang3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- hutool工具包 -->
|
<!-- hutool工具包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.web.servlet.LocaleResolver;
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.*;
|
import org.springframework.web.servlet.config.annotation.*;
|
||||||
|
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||||
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -66,6 +67,8 @@ public class MvcConfig implements WebMvcConfigurer {
|
||||||
registry.addInterceptor(localeInterceptor)
|
registry.addInterceptor(localeInterceptor)
|
||||||
.addPathPatterns("/admin/**")
|
.addPathPatterns("/admin/**")
|
||||||
.addPathPatterns("/install");
|
.addPathPatterns("/install");
|
||||||
|
registry.addInterceptor(localeChangeInterceptor())
|
||||||
|
.addPathPatterns("/install");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,4 +106,11 @@ public class MvcConfig implements WebMvcConfigurer {
|
||||||
slr.setDefaultLocale(Locale.CHINA);
|
slr.setDefaultLocale(Locale.CHINA);
|
||||||
return slr;
|
return slr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocaleChangeInterceptor localeChangeInterceptor() {
|
||||||
|
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
|
||||||
|
lci.setParamName("lang");
|
||||||
|
return lci;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.service.OptionsService;
|
import cc.ryanc.halo.service.OptionsService;
|
||||||
import cc.ryanc.halo.utils.HaloUtils;
|
import cc.ryanc.halo.utils.HaloUtils;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.cron.CronUtil;
|
import cn.hutool.cron.CronUtil;
|
||||||
import freemarker.template.TemplateModelException;
|
import freemarker.template.TemplateModelException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
@ -57,7 +57,7 @@ public class StartupConfig implements ApplicationListener<ApplicationStartedEven
|
||||||
*/
|
*/
|
||||||
private void loadActiveTheme() throws TemplateModelException {
|
private void loadActiveTheme() throws TemplateModelException {
|
||||||
String themeValue = optionsService.findOneOption(BlogPropertiesEnum.THEME.getProp());
|
String themeValue = optionsService.findOneOption(BlogPropertiesEnum.THEME.getProp());
|
||||||
if (StringUtils.isNotEmpty(themeValue) && !StringUtils.equals(themeValue, null)) {
|
if (StrUtil.isNotEmpty(themeValue) && !StrUtil.equals(themeValue, null)) {
|
||||||
BaseController.THEME = themeValue;
|
BaseController.THEME = themeValue;
|
||||||
} else {
|
} else {
|
||||||
//以防万一
|
//以防万一
|
||||||
|
|
|
@ -3,7 +3,7 @@ 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 org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -46,12 +46,12 @@ public class OptionsServiceImpl implements OptionsService {
|
||||||
@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 (StrUtil.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 (StrUtil.isNotEmpty(key)) {
|
||||||
//如果查询到有该设置选项则做更新操作,反之保存新的设置选项
|
//如果查询到有该设置选项则做更新操作,反之保存新的设置选项
|
||||||
if (null == optionsRepository.findOptionsByOptionName(key)) {
|
if (null == optionsRepository.findOptionsByOptionName(key)) {
|
||||||
options = new Options();
|
options = new Options();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import cc.ryanc.halo.model.dto.Theme;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.model.enums.CommonParamsEnum;
|
import cc.ryanc.halo.model.enums.CommonParamsEnum;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.sun.syndication.feed.rss.Channel;
|
import com.sun.syndication.feed.rss.Channel;
|
||||||
import com.sun.syndication.feed.rss.Content;
|
import com.sun.syndication.feed.rss.Content;
|
||||||
import com.sun.syndication.feed.rss.Item;
|
import com.sun.syndication.feed.rss.Item;
|
||||||
|
@ -14,7 +15,6 @@ import com.sun.syndication.io.FeedException;
|
||||||
import com.sun.syndication.io.WireFeedOutput;
|
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.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.util.ResourceUtils;
|
import org.springframework.util.ResourceUtils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
@ -62,7 +62,7 @@ public class HaloUtils {
|
||||||
if (null != files) {
|
if (null != files) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
if (StringUtils.equals(file.getName(), ".DS_Store")) {
|
if (StrUtil.equals(file.getName(), ".DS_Store")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
backupDto = new BackupDto();
|
backupDto = new BackupDto();
|
||||||
|
@ -159,7 +159,7 @@ public class HaloUtils {
|
||||||
Theme theme = null;
|
Theme theme = null;
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
if (StringUtils.equals("__MACOSX", file.getName())) {
|
if (StrUtil.equals("__MACOSX", file.getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
theme = new Theme();
|
theme = new Theme();
|
||||||
|
|
|
@ -17,11 +17,11 @@ import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -142,7 +142,7 @@ public class AdminController extends BaseController {
|
||||||
loginLast = aUser.getLoginLast();
|
loginLast = aUser.getLoginLast();
|
||||||
}
|
}
|
||||||
Long between = DateUtil.between(loginLast, DateUtil.date(), DateUnit.MINUTE);
|
Long between = DateUtil.between(loginLast, DateUtil.date(), DateUnit.MINUTE);
|
||||||
if (StringUtils.equals(aUser.getLoginEnable(), TrueFalseEnum.FALSE.getDesc()) && (between < CommonParamsEnum.TEN.getValue())) {
|
if (StrUtil.equals(aUser.getLoginEnable(), TrueFalseEnum.FALSE.getDesc()) && (between < CommonParamsEnum.TEN.getValue())) {
|
||||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.login.disabled"));
|
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.login.disabled"));
|
||||||
}
|
}
|
||||||
//验证用户名和密码
|
//验证用户名和密码
|
||||||
|
|
|
@ -11,10 +11,10 @@ import cc.ryanc.halo.service.LogsService;
|
||||||
import cc.ryanc.halo.utils.HaloUtils;
|
import cc.ryanc.halo.utils.HaloUtils;
|
||||||
import cc.ryanc.halo.utils.LocaleMessageUtil;
|
import cc.ryanc.halo.utils.LocaleMessageUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.coobird.thumbnailator.Thumbnails;
|
import net.coobird.thumbnailator.Thumbnails;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -89,7 +89,7 @@ public class AttachmentController {
|
||||||
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);
|
||||||
if (StringUtils.equals(type, PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
if (StrUtil.equals(type, PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
||||||
return "admin/widget/_attachment-select-post";
|
return "admin/widget/_attachment-select-post";
|
||||||
}
|
}
|
||||||
return "admin/widget/_attachment-select";
|
return "admin/widget/_attachment-select";
|
||||||
|
|
|
@ -12,9 +12,9 @@ import cc.ryanc.halo.utils.HaloUtils;
|
||||||
import cc.ryanc.halo.utils.LocaleMessageUtil;
|
import cc.ryanc.halo.utils.LocaleMessageUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.ZipUtil;
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
@ -63,11 +63,11 @@ public class BackupController {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String backup(@RequestParam(value = "type", defaultValue = "resources") String type, Model model) {
|
public String backup(@RequestParam(value = "type", defaultValue = "resources") String type, Model model) {
|
||||||
List<BackupDto> backups = null;
|
List<BackupDto> backups = null;
|
||||||
if (StringUtils.equals(type, BackupTypeEnum.RESOURCES.getDesc())) {
|
if (StrUtil.equals(type, BackupTypeEnum.RESOURCES.getDesc())) {
|
||||||
backups = HaloUtils.getBackUps(BackupTypeEnum.RESOURCES.getDesc());
|
backups = HaloUtils.getBackUps(BackupTypeEnum.RESOURCES.getDesc());
|
||||||
} else if (StringUtils.equals(type, BackupTypeEnum.DATABASES.getDesc())) {
|
} else if (StrUtil.equals(type, BackupTypeEnum.DATABASES.getDesc())) {
|
||||||
backups = HaloUtils.getBackUps(BackupTypeEnum.DATABASES.getDesc());
|
backups = HaloUtils.getBackUps(BackupTypeEnum.DATABASES.getDesc());
|
||||||
} else if (StringUtils.equals(type, BackupTypeEnum.POSTS.getDesc())) {
|
} else if (StrUtil.equals(type, BackupTypeEnum.POSTS.getDesc())) {
|
||||||
backups = HaloUtils.getBackUps(BackupTypeEnum.POSTS.getDesc());
|
backups = HaloUtils.getBackUps(BackupTypeEnum.POSTS.getDesc());
|
||||||
} else {
|
} else {
|
||||||
backups = new ArrayList<>();
|
backups = new ArrayList<>();
|
||||||
|
@ -86,11 +86,11 @@ public class BackupController {
|
||||||
@GetMapping(value = "doBackup")
|
@GetMapping(value = "doBackup")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JsonResult doBackup(@RequestParam("type") String type) {
|
public JsonResult doBackup(@RequestParam("type") String type) {
|
||||||
if (StringUtils.equals(BackupTypeEnum.RESOURCES.getDesc(), type)) {
|
if (StrUtil.equals(BackupTypeEnum.RESOURCES.getDesc(), type)) {
|
||||||
return this.backupResources();
|
return this.backupResources();
|
||||||
} else if (StringUtils.equals(BackupTypeEnum.DATABASES.getDesc(), type)) {
|
} else if (StrUtil.equals(BackupTypeEnum.DATABASES.getDesc(), type)) {
|
||||||
return this.backupDatabase();
|
return this.backupDatabase();
|
||||||
} else if (StringUtils.equals(BackupTypeEnum.POSTS.getDesc(), type)) {
|
} else if (StrUtil.equals(BackupTypeEnum.POSTS.getDesc(), type)) {
|
||||||
return this.backupPosts();
|
return this.backupPosts();
|
||||||
} else {
|
} else {
|
||||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.backup.backup-failed"));
|
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.backup.backup-failed"));
|
||||||
|
@ -205,10 +205,10 @@ public class BackupController {
|
||||||
HttpSession session) {
|
HttpSession session) {
|
||||||
String srcPath = System.getProperties().getProperty("user.home") + "/halo/backup/" + type + "/" + fileName;
|
String srcPath = System.getProperties().getProperty("user.home") + "/halo/backup/" + type + "/" + fileName;
|
||||||
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||||
if (null == user.getUserEmail() || StringUtils.equals(user.getUserEmail(), "")) {
|
if (null == user.getUserEmail() || StrUtil.equals(user.getUserEmail(), "")) {
|
||||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.backup.no-email"));
|
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.backup.no-email"));
|
||||||
}
|
}
|
||||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.FALSE.getDesc())) {
|
if (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.FALSE.getDesc())) {
|
||||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.no-post"));
|
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.no-post"));
|
||||||
}
|
}
|
||||||
new EmailToAdmin(srcPath, user).start();
|
new EmailToAdmin(srcPath, user).start();
|
||||||
|
|
|
@ -15,11 +15,11 @@ import cc.ryanc.halo.utils.OwoUtil;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -218,13 +218,13 @@ public class CommentController extends BaseController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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 (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.COMMENT_REPLY_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||||
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
||||||
Map<String, Object> map = new HashMap<>(8);
|
Map<String, Object> map = new HashMap<>(8);
|
||||||
map.put("blogTitle", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_TITLE.getProp()));
|
map.put("blogTitle", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_TITLE.getProp()));
|
||||||
map.put("commentAuthor", lastComment.getCommentAuthor());
|
map.put("commentAuthor", lastComment.getCommentAuthor());
|
||||||
map.put("pageName", lastComment.getPost().getPostTitle());
|
map.put("pageName", lastComment.getPost().getPostTitle());
|
||||||
if (StringUtils.equals(post.getPostType(), PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
if (StrUtil.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());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
} else {
|
} else {
|
||||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
|
@ -259,11 +259,11 @@ public class CommentController extends BaseController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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 (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.COMMENT_REPLY_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||||
try {
|
try {
|
||||||
if (status == 1 && Validator.isEmail(comment.getCommentAuthorEmail())) {
|
if (status == 1 && Validator.isEmail(comment.getCommentAuthorEmail())) {
|
||||||
Map<String, Object> map = new HashMap<>(6);
|
Map<String, Object> map = new HashMap<>(6);
|
||||||
if (StringUtils.equals(post.getPostType(), PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
if (StrUtil.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());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
} else {
|
} else {
|
||||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
|
|
|
@ -14,9 +14,9 @@ import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.utils.LocaleMessageUtil;
|
import cc.ryanc.halo.utils.LocaleMessageUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -159,7 +159,7 @@ public class PageController {
|
||||||
@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 (StrUtil.isEmpty(gallery.getGalleryThumbnailUrl())) {
|
||||||
gallery.setGalleryThumbnailUrl(gallery.getGalleryUrl());
|
gallery.setGalleryThumbnailUrl(gallery.getGalleryUrl());
|
||||||
}
|
}
|
||||||
galleryService.saveByGallery(gallery);
|
galleryService.saveByGallery(gallery);
|
||||||
|
@ -238,7 +238,7 @@ public class PageController {
|
||||||
post.setPostUpdate(DateUtil.date());
|
post.setPostUpdate(DateUtil.date());
|
||||||
}
|
}
|
||||||
//当没有选择文章缩略图的时候,自动分配一张内置的缩略图
|
//当没有选择文章缩略图的时候,自动分配一张内置的缩略图
|
||||||
if (StringUtils.equals(post.getPostThumbnail(), BlogPropertiesEnum.DEFAULT_THUMBNAIL.getProp())) {
|
if (StrUtil.equals(post.getPostThumbnail(), BlogPropertiesEnum.DEFAULT_THUMBNAIL.getProp())) {
|
||||||
post.setPostThumbnail("/static/images/thumbnail/thumbnail-" + RandomUtil.randomInt(1, 10) + ".jpg");
|
post.setPostThumbnail("/static/images/thumbnail/thumbnail-" + RandomUtil.randomInt(1, 10) + ".jpg");
|
||||||
}
|
}
|
||||||
postService.saveByPost(post);
|
postService.saveByPost(post);
|
||||||
|
|
|
@ -17,10 +17,11 @@ import cc.ryanc.halo.utils.LocaleMessageUtil;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
|
import com.alibaba.druid.util.StringUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -80,7 +81,7 @@ public class PostController extends BaseController {
|
||||||
return url.substring(0, url.lastIndexOf("."));
|
return url.substring(0, url.lastIndexOf("."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.replaceAll(url, " ", "-");
|
return StrUtil.replace(url, " ", "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +173,7 @@ public class PostController extends BaseController {
|
||||||
try {
|
try {
|
||||||
//提取摘要
|
//提取摘要
|
||||||
int postSummary = 50;
|
int postSummary = 50;
|
||||||
if (StringUtils.isNotEmpty(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()))) {
|
if (StrUtil.isNotEmpty(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()))) {
|
||||||
postSummary = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()));
|
postSummary = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()));
|
||||||
}
|
}
|
||||||
//文章摘要
|
//文章摘要
|
||||||
|
@ -197,13 +198,13 @@ public class PostController extends BaseController {
|
||||||
post.setUser(user);
|
post.setUser(user);
|
||||||
List<Category> categories = categoryService.strListToCateList(cateList);
|
List<Category> categories = categoryService.strListToCateList(cateList);
|
||||||
post.setCategories(categories);
|
post.setCategories(categories);
|
||||||
if (StringUtils.isNotEmpty(tagList)) {
|
if (StrUtil.isNotEmpty(tagList)) {
|
||||||
List<Tag> tags = tagService.strListToTagList(StringUtils.deleteWhitespace(tagList));
|
List<Tag> tags = tagService.strListToTagList(StrUtil.trim(tagList));
|
||||||
post.setTags(tags);
|
post.setTags(tags);
|
||||||
}
|
}
|
||||||
post.setPostUrl(urlFilter(post.getPostUrl()));
|
post.setPostUrl(urlFilter(post.getPostUrl()));
|
||||||
//当没有选择文章缩略图的时候,自动分配一张内置的缩略图
|
//当没有选择文章缩略图的时候,自动分配一张内置的缩略图
|
||||||
if (StringUtils.equals(post.getPostThumbnail(), BlogPropertiesEnum.DEFAULT_THUMBNAIL.getProp())) {
|
if (StrUtil.equals(post.getPostThumbnail(), BlogPropertiesEnum.DEFAULT_THUMBNAIL.getProp())) {
|
||||||
post.setPostThumbnail("/static/images/thumbnail/thumbnail-" + RandomUtil.randomInt(1, 10) + ".jpg");
|
post.setPostThumbnail("/static/images/thumbnail/thumbnail-" + RandomUtil.randomInt(1, 10) + ".jpg");
|
||||||
}
|
}
|
||||||
postService.saveByPost(post);
|
postService.saveByPost(post);
|
||||||
|
@ -243,13 +244,13 @@ public class PostController extends BaseController {
|
||||||
post = postService.findByPostId(postId).get();
|
post = postService.findByPostId(postId).get();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isEmpty(postTitle)) {
|
if (StrUtil.isBlank(postTitle)) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
post.setPostTitle("草稿:" + dateFormat.format(DateUtil.date()));
|
post.setPostTitle("草稿:" + dateFormat.format(DateUtil.date()));
|
||||||
} else {
|
} else {
|
||||||
post.setPostTitle(postTitle);
|
post.setPostTitle(postTitle);
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(postUrl)) {
|
if (StrUtil.isBlank(postUrl)) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
post.setPostUrl(dateFormat.format(DateUtil.date()));
|
post.setPostUrl(dateFormat.format(DateUtil.date()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -320,7 +321,7 @@ public class PostController extends BaseController {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("删除文章失败:{}", e.getMessage());
|
log.error("删除文章失败:{}", e.getMessage());
|
||||||
}
|
}
|
||||||
if (StringUtils.equals(PostTypeEnum.POST_TYPE_POST.getDesc(), postType)) {
|
if (StrUtil.equals(PostTypeEnum.POST_TYPE_POST.getDesc(), postType)) {
|
||||||
return "redirect:/admin/posts?status=2";
|
return "redirect:/admin/posts?status=2";
|
||||||
}
|
}
|
||||||
return "redirect:/admin/page";
|
return "redirect:/admin/page";
|
||||||
|
@ -385,7 +386,7 @@ public class PostController extends BaseController {
|
||||||
@GetMapping(value = "/pushAllToBaidu")
|
@GetMapping(value = "/pushAllToBaidu")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JsonResult pushAllToBaidu(@RequestParam("baiduToken") String baiduToken) {
|
public JsonResult pushAllToBaidu(@RequestParam("baiduToken") String baiduToken) {
|
||||||
if (StringUtils.isEmpty(baiduToken)) {
|
if (StrUtil.isBlank(baiduToken)) {
|
||||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.post.no-baidu-token"));
|
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.post.no-baidu-token"));
|
||||||
}
|
}
|
||||||
String blogUrl = HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp());
|
String blogUrl = HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp());
|
||||||
|
|
|
@ -17,11 +17,11 @@ import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.file.FileReader;
|
import cn.hutool.core.io.file.FileReader;
|
||||||
import cn.hutool.core.io.file.FileWriter;
|
import cn.hutool.core.io.file.FileWriter;
|
||||||
import cn.hutool.core.util.RuntimeUtil;
|
import cn.hutool.core.util.RuntimeUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.ZipUtil;
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.CacheEvict;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -185,7 +185,7 @@ public class ThemeController extends BaseController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JsonResult cloneFromRemote(@RequestParam(value = "remoteAddr") String remoteAddr,
|
public JsonResult cloneFromRemote(@RequestParam(value = "remoteAddr") String remoteAddr,
|
||||||
@RequestParam(value = "themeName") String themeName) {
|
@RequestParam(value = "themeName") String themeName) {
|
||||||
if (StringUtils.isBlank(remoteAddr) || StringUtils.isBlank(themeName)) {
|
if (StrUtil.isBlank(remoteAddr) || StrUtil.isBlank(themeName)) {
|
||||||
return new JsonResult(0, localeMessageUtil.getMessage("code.admin.common.info-no-complete"));
|
return new JsonResult(0, localeMessageUtil.getMessage("code.admin.common.info-no-complete"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -239,7 +239,7 @@ public class ThemeController extends BaseController {
|
||||||
@RequestParam("theme") String theme,
|
@RequestParam("theme") String theme,
|
||||||
@RequestParam("hasUpdate") String hasUpdate) {
|
@RequestParam("hasUpdate") String hasUpdate) {
|
||||||
model.addAttribute("themeDir", theme);
|
model.addAttribute("themeDir", theme);
|
||||||
if (StringUtils.equals(hasUpdate, TrueFalseEnum.TRUE.getDesc())) {
|
if (StrUtil.equals(hasUpdate, TrueFalseEnum.TRUE.getDesc())) {
|
||||||
model.addAttribute("hasUpdate", true);
|
model.addAttribute("hasUpdate", true);
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("hasUpdate", false);
|
model.addAttribute("hasUpdate", false);
|
||||||
|
@ -294,7 +294,7 @@ public class ThemeController extends BaseController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JsonResult saveTpl(@RequestParam("tplName") String tplName,
|
public JsonResult saveTpl(@RequestParam("tplName") String tplName,
|
||||||
@RequestParam("tplContent") String tplContent) {
|
@RequestParam("tplContent") String tplContent) {
|
||||||
if (StringUtils.isBlank(tplContent)) {
|
if (StrUtil.isBlank(tplContent)) {
|
||||||
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.theme.edit.no-content"));
|
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.theme.edit.no-content"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import cc.ryanc.halo.model.enums.PostStatusEnum;
|
||||||
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
||||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -46,7 +46,7 @@ public class ApiPostController {
|
||||||
public JsonResult posts(@PathVariable(value = "page") Integer page) {
|
public JsonResult posts(@PathVariable(value = "page") Integer page) {
|
||||||
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(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
||||||
}
|
}
|
||||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||||
|
|
|
@ -9,11 +9,11 @@ import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
||||||
import cc.ryanc.halo.service.*;
|
import cc.ryanc.halo.service.*;
|
||||||
import cc.ryanc.halo.utils.HaloUtils;
|
import cc.ryanc.halo.utils.HaloUtils;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
@ -69,7 +69,7 @@ public class InstallController {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String install(Model model) {
|
public String install(Model model) {
|
||||||
try {
|
try {
|
||||||
if (StringUtils.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.IS_INSTALL.getProp()))) {
|
if (StrUtil.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.IS_INSTALL.getProp()))) {
|
||||||
model.addAttribute("isInstall", true);
|
model.addAttribute("isInstall", true);
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("isInstall", false);
|
model.addAttribute("isInstall", false);
|
||||||
|
@ -104,13 +104,13 @@ public class InstallController {
|
||||||
@RequestParam("userPwd") String userPwd,
|
@RequestParam("userPwd") String userPwd,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
if (StringUtils.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.IS_INSTALL.getProp()))) {
|
if (StrUtil.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.IS_INSTALL.getProp()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//创建新的用户
|
//创建新的用户
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUserName(userName);
|
user.setUserName(userName);
|
||||||
if (StringUtils.isBlank(userDisplayName)) {
|
if (StrUtil.isBlank(userDisplayName)) {
|
||||||
userDisplayName = userName;
|
userDisplayName = userName;
|
||||||
}
|
}
|
||||||
user.setUserDisplayName(userDisplayName);
|
user.setUserDisplayName(userDisplayName);
|
||||||
|
|
|
@ -12,8 +12,8 @@ import cc.ryanc.halo.utils.CommentUtil;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -133,7 +133,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
model.addAttribute("afterPost", afterPosts.get(afterPosts.size() - 1));
|
model.addAttribute("afterPost", afterPosts.get(afterPosts.size() - 1));
|
||||||
}
|
}
|
||||||
List<Comment> comments = null;
|
List<Comment> comments = null;
|
||||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
if (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
||||||
comments = commentService.findCommentsByPostAndCommentStatus(post, CommentStatusEnum.PUBLISHED.getCode());
|
comments = commentService.findCommentsByPostAndCommentStatus(post, CommentStatusEnum.PUBLISHED.getCode());
|
||||||
} else {
|
} else {
|
||||||
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
|
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
|
||||||
|
@ -149,7 +149,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
//获取每页评论条数
|
//获取每页评论条数
|
||||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()));
|
||||||
}
|
}
|
||||||
//评论分页
|
//评论分页
|
||||||
|
|
|
@ -8,7 +8,7 @@ import cc.ryanc.halo.service.CategoryService;
|
||||||
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 cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -84,7 +84,7 @@ public class FrontCategoryController extends BaseController {
|
||||||
}
|
}
|
||||||
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(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
||||||
}
|
}
|
||||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||||
|
|
|
@ -13,12 +13,12 @@ import cc.ryanc.halo.utils.CommentUtil;
|
||||||
import cc.ryanc.halo.utils.OwoUtil;
|
import cc.ryanc.halo.utils.OwoUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
@ -121,18 +121,18 @@ public class FrontCommentController {
|
||||||
comment.setCommentAuthorIp(ServletUtil.getClientIP(request));
|
comment.setCommentAuthorIp(ServletUtil.getClientIP(request));
|
||||||
comment.setIsAdmin(0);
|
comment.setIsAdmin(0);
|
||||||
comment.setCommentAuthor(HtmlUtil.escape(comment.getCommentAuthor()));
|
comment.setCommentAuthor(HtmlUtil.escape(comment.getCommentAuthor()));
|
||||||
if(StringUtils.isNotBlank(comment.getCommentAuthorEmail())) {
|
if (StrUtil.isNotBlank(comment.getCommentAuthorEmail())) {
|
||||||
comment.setCommentAuthorAvatarMd5(SecureUtil.md5(comment.getCommentAuthorEmail()));
|
comment.setCommentAuthorAvatarMd5(SecureUtil.md5(comment.getCommentAuthorEmail()));
|
||||||
}
|
}
|
||||||
if (comment.getCommentParent() > 0) {
|
if (comment.getCommentParent() > 0) {
|
||||||
lastComment = commentService.findCommentById(comment.getCommentParent()).get();
|
lastComment = commentService.findCommentById(comment.getCommentParent()).get();
|
||||||
String lastContent = "<a href='#comment-id-" + lastComment.getCommentId() + "'>@" + lastComment.getCommentAuthor() + "</a>";
|
String lastContent = "<a href='#comment-id-" + lastComment.getCommentId() + "'>@" + lastComment.getCommentAuthor() + "</a>";
|
||||||
comment.setCommentContent(lastContent + StringUtils.substringAfter(OwoUtil.markToImg(HtmlUtil.escape(comment.getCommentContent())), ":"));
|
comment.setCommentContent(lastContent + StrUtil.subAfter(OwoUtil.markToImg(HtmlUtil.escape(comment.getCommentContent())), ":", true));
|
||||||
} else {
|
} else {
|
||||||
//将评论内容的字符专为安全字符
|
//将评论内容的字符专为安全字符
|
||||||
comment.setCommentContent(OwoUtil.markToImg(HtmlUtil.escape(comment.getCommentContent())));
|
comment.setCommentContent(OwoUtil.markToImg(HtmlUtil.escape(comment.getCommentContent())));
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(comment.getCommentAuthorUrl())) {
|
if (StrUtil.isNotEmpty(comment.getCommentAuthorUrl())) {
|
||||||
comment.setCommentAuthorUrl(URLUtil.formatUrl(comment.getCommentAuthorUrl()));
|
comment.setCommentAuthorUrl(URLUtil.formatUrl(comment.getCommentAuthorUrl()));
|
||||||
}
|
}
|
||||||
commentService.saveByComment(comment);
|
commentService.saveByComment(comment);
|
||||||
|
@ -142,7 +142,7 @@ public class FrontCommentController {
|
||||||
} else {
|
} else {
|
||||||
new EmailToAdmin(comment, post).start();
|
new EmailToAdmin(comment, post).start();
|
||||||
}
|
}
|
||||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
if (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
||||||
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "你的评论已经提交,待博主审核之后可显示。");
|
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "你的评论已经提交,待博主审核之后可显示。");
|
||||||
} else {
|
} else {
|
||||||
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "你的评论已经提交,刷新后即可显示。");
|
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "你的评论已经提交,刷新后即可显示。");
|
||||||
|
@ -166,13 +166,13 @@ public class FrontCommentController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
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 (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||||
try {
|
try {
|
||||||
//发送邮件到博主
|
//发送邮件到博主
|
||||||
Map<String, Object> map = new HashMap<>(5);
|
Map<String, Object> map = new HashMap<>(5);
|
||||||
map.put("author", userService.findUser().getUserDisplayName());
|
map.put("author", userService.findUser().getUserDisplayName());
|
||||||
map.put("pageName", post.getPostTitle());
|
map.put("pageName", post.getPostTitle());
|
||||||
if (StringUtils.equals(post.getPostType(), PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
if (StrUtil.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());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
} else {
|
} else {
|
||||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
|
@ -204,13 +204,13 @@ public class FrontCommentController {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//发送通知给对方
|
//发送通知给对方
|
||||||
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 (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp()), TrueFalseEnum.TRUE.getDesc()) && StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NOTICE.getProp()), TrueFalseEnum.TRUE.getDesc())) {
|
||||||
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
if (Validator.isEmail(lastComment.getCommentAuthorEmail())) {
|
||||||
Map<String, Object> map = new HashMap<>(8);
|
Map<String, Object> map = new HashMap<>(8);
|
||||||
map.put("blogTitle", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_TITLE.getProp()));
|
map.put("blogTitle", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_TITLE.getProp()));
|
||||||
map.put("commentAuthor", lastComment.getCommentAuthor());
|
map.put("commentAuthor", lastComment.getCommentAuthor());
|
||||||
map.put("pageName", lastComment.getPost().getPostTitle());
|
map.put("pageName", lastComment.getPost().getPostTitle());
|
||||||
if (StringUtils.equals(post.getPostType(), PostTypeEnum.POST_TYPE_POST.getDesc())) {
|
if (StrUtil.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());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/archives/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
} else {
|
} else {
|
||||||
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
map.put("pageUrl", HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp()) + "/p/" + post.getPostUrl() + "#comment-id-" + comment.getCommentId());
|
||||||
|
|
|
@ -6,8 +6,8 @@ import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
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 cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -63,7 +63,7 @@ public class FrontIndexController extends BaseController {
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
//尝试加载设置选项,用于设置显示条数
|
//尝试加载设置选项,用于设置显示条数
|
||||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
||||||
}
|
}
|
||||||
//所有文章数据,分页
|
//所有文章数据,分页
|
||||||
|
@ -92,7 +92,7 @@ public class FrontIndexController extends BaseController {
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
//尝试加载设置选项,用于设置显示条数
|
//尝试加载设置选项,用于设置显示条数
|
||||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -40,7 +40,7 @@ public class FrontOthersController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String feed() {
|
public String feed() {
|
||||||
String rssPosts = HaloConst.OPTIONS.get(BlogPropertiesEnum.RSS_POSTS.getProp());
|
String rssPosts = HaloConst.OPTIONS.get(BlogPropertiesEnum.RSS_POSTS.getProp());
|
||||||
if (StringUtils.isBlank(rssPosts)) {
|
if (StrUtil.isBlank(rssPosts)) {
|
||||||
rssPosts = "20";
|
rssPosts = "20";
|
||||||
}
|
}
|
||||||
//获取文章列表并根据时间排序
|
//获取文章列表并根据时间排序
|
||||||
|
|
|
@ -15,7 +15,7 @@ import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.utils.CommentUtil;
|
import cc.ryanc.halo.utils.CommentUtil;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
@ -83,7 +83,7 @@ public class FrontPageController extends BaseController {
|
||||||
return this.renderNotFound();
|
return this.renderNotFound();
|
||||||
}
|
}
|
||||||
List<Comment> comments = null;
|
List<Comment> comments = null;
|
||||||
if (StringUtils.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
if (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
||||||
comments = commentService.findCommentsByPostAndCommentStatus(post, CommentStatusEnum.PUBLISHED.getCode());
|
comments = commentService.findCommentsByPostAndCommentStatus(post, CommentStatusEnum.PUBLISHED.getCode());
|
||||||
} else {
|
} else {
|
||||||
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
|
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
|
||||||
|
@ -91,7 +91,7 @@ public class FrontPageController extends BaseController {
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
Integer size = 10;
|
||||||
//获取每页评论条数
|
//获取每页评论条数
|
||||||
if (!StringUtils.isBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()));
|
||||||
}
|
}
|
||||||
//评论分页
|
//评论分页
|
||||||
|
|
|
@ -8,7 +8,7 @@ import cc.ryanc.halo.service.PostService;
|
||||||
import cc.ryanc.halo.service.TagService;
|
import cc.ryanc.halo.service.TagService;
|
||||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||||
import cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -79,7 +79,7 @@ public class FrontTagController extends BaseController {
|
||||||
}
|
}
|
||||||
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(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
||||||
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
||||||
}
|
}
|
||||||
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||||
|
|
|
@ -3,7 +3,7 @@ package cc.ryanc.halo.web.interceptor;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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;
|
||||||
|
@ -24,7 +24,7 @@ public class ApiInterceptor 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 {
|
||||||
if (StringUtils.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.API_STATUS.getProp()))) {
|
if (StrUtil.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.API_STATUS.getProp()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
response.sendRedirect("/404");
|
response.sendRedirect("/404");
|
||||||
|
|
|
@ -3,7 +3,7 @@ package cc.ryanc.halo.web.interceptor;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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;
|
||||||
|
@ -24,7 +24,7 @@ public class InstallInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
@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(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.IS_INSTALL.getProp()))) {
|
if (StrUtil.equals(TrueFalseEnum.TRUE.getDesc(), HaloConst.OPTIONS.get(BlogPropertiesEnum.IS_INSTALL.getProp()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
response.sendRedirect("/install");
|
response.sendRedirect("/install");
|
||||||
|
|
|
@ -3,7 +3,7 @@ package cc.ryanc.halo.web.interceptor;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.model.enums.LocaleEnum;
|
import cc.ryanc.halo.model.enums.LocaleEnum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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;
|
||||||
|
@ -23,7 +23,7 @@ public class LocaleInterceptor 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 {
|
||||||
if (StringUtils.equals(LocaleEnum.EN_US.getValue(), HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_LOCALE.getProp()))) {
|
if (StrUtil.equals(LocaleEnum.EN_US.getValue(), HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_LOCALE.getProp()))) {
|
||||||
request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale("en", "US"));
|
request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale("en", "US"));
|
||||||
} else {
|
} else {
|
||||||
request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale("zh", "CN"));
|
request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale("zh", "CN"));
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
Halo<small style="font-size: 14px;"><@spring.message code='install.page.title'/></small>
|
Halo<small style="font-size: 14px;"><@spring.message code='install.page.title'/></small>
|
||||||
</div>
|
</div>
|
||||||
<#if isInstall==false>
|
<#if isInstall==false>
|
||||||
|
<#if RequestParameters['lang']??>
|
||||||
|
<#assign lang ="${RequestParameters['lang']}">
|
||||||
|
</#if>
|
||||||
<form method="post" action="/install/do" class="form-horizontal" id="installForm">
|
<form method="post" action="/install/do" class="form-horizontal" id="installForm">
|
||||||
<div class="box box-solid animated" id="installFirst">
|
<div class="box box-solid animated" id="installFirst">
|
||||||
<div class="box-body" style="padding: 30px;">
|
<div class="box-body" style="padding: 30px;">
|
||||||
|
@ -42,8 +45,8 @@
|
||||||
<label for="blogLocale" class="col-sm-4 control-label"><@spring.message code='install.form.language'/></label>
|
<label for="blogLocale" class="col-sm-4 control-label"><@spring.message code='install.form.language'/></label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select class="form-control" id="blogLocale" name="blogLocale">
|
<select class="form-control" id="blogLocale" name="blogLocale">
|
||||||
<option value="zh_CN" ${((options.blog_locale?default('zh_CN'))=='zh_CN')?string('selected','')}>简体中文</option>
|
<option value="zh_CN" <#if lang?default('zh_CN') = 'zh_CN'>selected</#if>>简体中文</option>
|
||||||
<option value="en_US" ${((options.blog_locale?if_exists)=='en_US')?string('selected','')}>English</option>
|
<option value="en_US" <#if lang?default('zh_CN') = 'en_US'>selected</#if>>English</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -309,6 +312,10 @@
|
||||||
},'json');
|
},'json');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$('#blogLocale').on('change',function(){
|
||||||
|
var lang = $(this).val();
|
||||||
|
window.location.href="/install?lang="+lang;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<#else>
|
<#else>
|
||||||
<noscript>Not have Script!</noscript>
|
<noscript>Not have Script!</noscript>
|
||||||
|
|
Loading…
Reference in New Issue