mirror of https://github.com/halo-dev/halo
v1.0
parent
9c08c268c9
commit
418e98dfa1
|
@ -0,0 +1,169 @@
|
||||||
|
package cc.ryanc.halo.model.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @date : 2019-03-17
|
||||||
|
*/
|
||||||
|
public enum BlogProperties implements ValueEnum<String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 博客语言
|
||||||
|
*/
|
||||||
|
BLOG_LOCALE("blog_locale"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 博客标题
|
||||||
|
*/
|
||||||
|
BLOG_TITLE("blog_title"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 博客地址
|
||||||
|
*/
|
||||||
|
BLOG_URL("blog_url"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章摘要字数
|
||||||
|
*/
|
||||||
|
POST_SUMMARY("post_summary"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页文章条数
|
||||||
|
*/
|
||||||
|
INDEX_POSTS("index_posts"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页评论条数
|
||||||
|
*/
|
||||||
|
INDEX_COMMENTS("index_comments"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已经安装
|
||||||
|
*/
|
||||||
|
IS_INSTALL("is_install"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSS显示文章条数
|
||||||
|
*/
|
||||||
|
RSS_POSTS("rss_posts"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API状态
|
||||||
|
*/
|
||||||
|
API_STATUS("api_status"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱服务器地址
|
||||||
|
*/
|
||||||
|
MAIL_SMTP_HOST("mail_smtp_host"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱地址
|
||||||
|
*/
|
||||||
|
MAIL_SMTP_USERNAME("mail_smtp_username"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱密码/授权码
|
||||||
|
*/
|
||||||
|
MAIL_SMTP_PASSWORD("mail_smtp_password"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者名称
|
||||||
|
*/
|
||||||
|
MAIL_FROM_NAME("mail_from_name"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用邮件服务
|
||||||
|
*/
|
||||||
|
SMTP_EMAIL_ENABLE("smtp_email_enable"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件回复通知
|
||||||
|
*/
|
||||||
|
COMMENT_REPLY_NOTICE("comment_reply_notice"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新评论是否需要审核
|
||||||
|
*/
|
||||||
|
NEW_COMMENT_NEED_CHECK("new_comment_need_check"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新评论通知
|
||||||
|
*/
|
||||||
|
NEW_COMMENT_NOTICE("new_comment_notice"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件审核通过通知
|
||||||
|
*/
|
||||||
|
COMMENT_PASS_NOTICE("comment_pass_notice"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点描述
|
||||||
|
*/
|
||||||
|
SEO_DESC("seo_desc"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 博客主题
|
||||||
|
*/
|
||||||
|
THEME("theme"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 博客搭建日期
|
||||||
|
*/
|
||||||
|
BLOG_START("blog_start"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仪表盘部件 文章总数
|
||||||
|
*/
|
||||||
|
WIDGET_POSTCOUNT("widget_postcount"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仪表盘部件 评论总数
|
||||||
|
*/
|
||||||
|
WIDGET_COMMENTCOUNT("widget_commentcount"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仪表盘部件 附件总数
|
||||||
|
*/
|
||||||
|
WIDGET_ATTACHMENTCOUNT("widget_attachmentcount"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仪表盘部件 成立天数
|
||||||
|
*/
|
||||||
|
WIDGET_DAYCOUNT("widget_daycount"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认缩略图地址
|
||||||
|
*/
|
||||||
|
DEFAULT_THUMBNAIL("/static/halo-content/images/thumbnail/thumbnail.png"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动备份
|
||||||
|
*/
|
||||||
|
AUTO_BACKUP("auto_backup"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API Token
|
||||||
|
*/
|
||||||
|
API_TOKEN("api_token"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件存储位置
|
||||||
|
*/
|
||||||
|
ATTACH_LOC("attach_loc");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
BlogProperties(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get enum value.
|
||||||
|
*
|
||||||
|
* @return enum value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package cc.ryanc.halo.service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail server
|
||||||
|
*
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @date : 2019-03-17
|
||||||
|
*/
|
||||||
|
public interface MailService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a simple email
|
||||||
|
*
|
||||||
|
* @param to recipient
|
||||||
|
* @param subject subject
|
||||||
|
* @param content content
|
||||||
|
*/
|
||||||
|
void sendMail(String to, String subject, String content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a email with html
|
||||||
|
*
|
||||||
|
* @param to recipient
|
||||||
|
* @param subject subject
|
||||||
|
* @param content content
|
||||||
|
* @param templateName template name
|
||||||
|
*/
|
||||||
|
void sendTemplateMail(String to, String subject, Map<String, Object> content, String templateName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send mail with attachments
|
||||||
|
*
|
||||||
|
* @param to recipient
|
||||||
|
* @param subject subject
|
||||||
|
* @param content content
|
||||||
|
* @param templateName template name
|
||||||
|
* @param attachSrc attachment path
|
||||||
|
*/
|
||||||
|
void sendAttachMail(String to, String subject, Map<String, Object> content, String templateName, String attachSrc);
|
||||||
|
}
|
|
@ -18,14 +18,14 @@ public interface OptionService extends CrudService<Option, Integer> {
|
||||||
* @param key key
|
* @param key key
|
||||||
* @param value value
|
* @param value value
|
||||||
*/
|
*/
|
||||||
void saveOption(String key, String value);
|
void save(String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save multiple options
|
* Save multiple options
|
||||||
*
|
*
|
||||||
* @param options options
|
* @param options options
|
||||||
*/
|
*/
|
||||||
void saveOptions(Map<String, String> options);
|
void save(Map<String, String> options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all options
|
* Get all options
|
||||||
|
|
|
@ -37,7 +37,7 @@ public interface PostService extends CrudService<Post, Integer> {
|
||||||
* @return Page<PostSimpleOutputDTO>
|
* @return Page<PostSimpleOutputDTO>
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Page<PostSimpleOutputDTO> pageByStatusAndType(PostStatus status, PostType type, Pageable pageable);
|
Page<PostSimpleOutputDTO> pageByStatus(PostStatus status, PostType type, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count posts by status and type
|
* Count posts by status and type
|
||||||
|
@ -46,5 +46,5 @@ public interface PostService extends CrudService<Post, Integer> {
|
||||||
* @param type type
|
* @param type type
|
||||||
* @return posts count
|
* @return posts count
|
||||||
*/
|
*/
|
||||||
Long countByStatusAndType(PostStatus status, PostType type);
|
Long countByStatus(PostStatus status, PostType type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
package cc.ryanc.halo.service.impl;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||||
|
import cc.ryanc.halo.service.MailService;
|
||||||
|
import cc.ryanc.halo.utils.HaloUtils;
|
||||||
|
import cn.hutool.core.text.StrBuilder;
|
||||||
|
import freemarker.template.Template;
|
||||||
|
import io.github.biezhi.ome.OhMyEmail;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||||
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cc.ryanc.halo.model.support.HaloConst.OPTIONS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : RYAN0UP
|
||||||
|
* @date : 2019-03-17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MailServiceImpl implements MailService {
|
||||||
|
|
||||||
|
private final FreeMarkerConfigurer freeMarker;
|
||||||
|
|
||||||
|
public MailServiceImpl(FreeMarkerConfigurer freeMarker) {
|
||||||
|
this.freeMarker = freeMarker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a simple email
|
||||||
|
*
|
||||||
|
* @param to recipient
|
||||||
|
* @param subject subject
|
||||||
|
* @param content content
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendMail(String to, String subject, String content) {
|
||||||
|
HaloUtils.configMail(
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_HOST.getValue()),
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_USERNAME.getValue()),
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_PASSWORD.getValue()));
|
||||||
|
try {
|
||||||
|
OhMyEmail.subject(subject)
|
||||||
|
.from(OPTIONS.get(BlogProperties.MAIL_FROM_NAME.getValue()))
|
||||||
|
.to(to)
|
||||||
|
.text(content)
|
||||||
|
.send();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send template mail
|
||||||
|
*
|
||||||
|
* @param to recipient
|
||||||
|
* @param subject subject
|
||||||
|
* @param content content
|
||||||
|
* @param templateName template name
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendTemplateMail(String to, String subject, Map<String, Object> content, String templateName) {
|
||||||
|
HaloUtils.configMail(
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_HOST.getValue()),
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_USERNAME.getValue()),
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_PASSWORD.getValue()));
|
||||||
|
StrBuilder text = new StrBuilder();
|
||||||
|
try {
|
||||||
|
final Template template = freeMarker.getConfiguration().getTemplate(templateName);
|
||||||
|
text.append(FreeMarkerTemplateUtils.processTemplateIntoString(template, content));
|
||||||
|
OhMyEmail.subject(subject)
|
||||||
|
.from(OPTIONS.get(BlogProperties.MAIL_FROM_NAME.getValue()))
|
||||||
|
.to(to)
|
||||||
|
.html(text.toString())
|
||||||
|
.send();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send mail with attachments
|
||||||
|
*
|
||||||
|
* @param to recipient
|
||||||
|
* @param subject subject
|
||||||
|
* @param content content
|
||||||
|
* @param templateName template name
|
||||||
|
* @param attachSrc attachment path
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendAttachMail(String to, String subject, Map<String, Object> content, String templateName, String attachSrc) {
|
||||||
|
HaloUtils.configMail(
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_HOST.getValue()),
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_USERNAME.getValue()),
|
||||||
|
OPTIONS.get(BlogProperties.MAIL_SMTP_PASSWORD.getValue()));
|
||||||
|
File file = new File(attachSrc);
|
||||||
|
StrBuilder text = new StrBuilder();
|
||||||
|
try {
|
||||||
|
final Template template = freeMarker.getConfiguration().getTemplate(templateName);
|
||||||
|
text.append(FreeMarkerTemplateUtils.processTemplateIntoString(template, content));
|
||||||
|
OhMyEmail.subject(subject)
|
||||||
|
.from(OPTIONS.get(BlogProperties.MAIL_FROM_NAME.getValue()))
|
||||||
|
.to(to)
|
||||||
|
.html(text.toString())
|
||||||
|
.attach(file, file.getName())
|
||||||
|
.send();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,7 +34,7 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
|
||||||
* @param value value
|
* @param value value
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveOption(String key, String value) {
|
public void save(String key, String value) {
|
||||||
if (StrUtil.equals(value, "")) {
|
if (StrUtil.equals(value, "")) {
|
||||||
optionRepository.removeByOptionKey(key);
|
optionRepository.removeByOptionKey(key);
|
||||||
} else if (StrUtil.isNotEmpty(key)) {
|
} else if (StrUtil.isNotEmpty(key)) {
|
||||||
|
@ -61,9 +61,9 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
|
||||||
* @param options options
|
* @param options options
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveOptions(Map<String, String> options) {
|
public void save(Map<String, String> options) {
|
||||||
if (!CollectionUtils.isEmpty(options)) {
|
if (!CollectionUtils.isEmpty(options)) {
|
||||||
options.forEach(this::saveOption);
|
options.forEach(this::save);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
|
||||||
* @return Page<PostSimpleOutputDTO>
|
* @return Page<PostSimpleOutputDTO>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<PostSimpleOutputDTO> pageByStatusAndType(PostStatus status, PostType type, Pageable pageable) {
|
public Page<PostSimpleOutputDTO> pageByStatus(PostStatus status, PostType type, Pageable pageable) {
|
||||||
Page<Post> posts = postRepository.findAllByStatusAndType(status, type, pageable);
|
Page<Post> posts = postRepository.findAllByStatusAndType(status, type, pageable);
|
||||||
return posts.map(post -> new PostSimpleOutputDTO().convertFrom(post));
|
return posts.map(post -> new PostSimpleOutputDTO().convertFrom(post));
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
|
||||||
* @return posts count
|
* @return posts count
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long countByStatusAndType(PostStatus status, PostType type) {
|
public Long countByStatus(PostStatus status, PostType type) {
|
||||||
return postRepository.countByStatusAndType(status,type);
|
return postRepository.countByStatusAndType(status,type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,11 +107,7 @@ public class ThemeUtils {
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public static File getThemesPath(String themeName) throws FileNotFoundException {
|
public static File getThemesPath(String themeName) throws FileNotFoundException {
|
||||||
if (isInternal(themeName)) {
|
return isInternal(themeName)?getInternalThemesPath():getUsersThemesPath();
|
||||||
return getInternalThemesPath();
|
|
||||||
} else {
|
|
||||||
return getUsersThemesPath();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,12 +43,12 @@ public class PostController {
|
||||||
public String listPosts(Model model,
|
public String listPosts(Model model,
|
||||||
@PageableDefault(sort = {"topPriority", "createTime"}, direction = DESC) Pageable pageable,
|
@PageableDefault(sort = {"topPriority", "createTime"}, direction = DESC) Pageable pageable,
|
||||||
@RequestParam(value = "status", defaultValue = "published") PostStatus status) {
|
@RequestParam(value = "status", defaultValue = "published") PostStatus status) {
|
||||||
final Page<PostSimpleOutputDTO> postPage = postService.pageByStatusAndType(status, PostType.POST, pageable);
|
final Page<PostSimpleOutputDTO> postPage = postService.pageByStatus(status, PostType.POST, pageable);
|
||||||
|
|
||||||
model.addAttribute("posts", postPage);
|
model.addAttribute("posts", postPage);
|
||||||
model.addAttribute("publishedCount", postService.countByStatusAndType(PostStatus.PUBLISHED, PostType.POST));
|
model.addAttribute("publishedCount", postService.countByStatus(PostStatus.PUBLISHED, PostType.POST));
|
||||||
model.addAttribute("draftCount", postService.countByStatusAndType(PostStatus.DRAFT, PostType.POST));
|
model.addAttribute("draftCount", postService.countByStatus(PostStatus.DRAFT, PostType.POST));
|
||||||
model.addAttribute("recycleCount", postService.countByStatusAndType(PostStatus.RECYCLE, PostType.POST));
|
model.addAttribute("recycleCount", postService.countByStatus(PostStatus.RECYCLE, PostType.POST));
|
||||||
model.addAttribute("status", status);
|
model.addAttribute("status", status);
|
||||||
return "admin/admin_post";
|
return "admin/admin_post";
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ThemeController extends BaseController {
|
||||||
public JsonResult activeTheme(@RequestParam("themeName") String themeName,
|
public JsonResult activeTheme(@RequestParam("themeName") String themeName,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
optionService.saveOption("theme", themeName);
|
optionService.save("theme", themeName);
|
||||||
BaseContentController.THEME = themeName;
|
BaseContentController.THEME = themeName;
|
||||||
configuration.setSharedVariable("themeName", themeName);
|
configuration.setSharedVariable("themeName", themeName);
|
||||||
log.info("Changed theme to {}", themeName);
|
log.info("Changed theme to {}", themeName);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cc.ryanc.halo.web.controller.content;
|
package cc.ryanc.halo.web.controller.content;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,4 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
|
|
||||||
|
@GetMapping(value = "/sweetalert")
|
||||||
|
public String sweetalert(){
|
||||||
|
return "sweetalert";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class CommonController implements ErrorController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/404")
|
@GetMapping(value = "/404")
|
||||||
public String contentNotFround() throws FileNotFoundException {
|
public String contentNotFround() throws FileNotFoundException {
|
||||||
if (ThemeUtils.isTemplateExist(NOT_FROUND_TEMPLATE)) {
|
if (!ThemeUtils.isTemplateExist(NOT_FROUND_TEMPLATE)) {
|
||||||
return "common/error/404";
|
return "common/error/404";
|
||||||
}
|
}
|
||||||
StrBuilder path = new StrBuilder("themes/");
|
StrBuilder path = new StrBuilder("themes/");
|
||||||
|
@ -116,8 +116,8 @@ public class CommonController implements ErrorController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/500")
|
@GetMapping(value = "/500")
|
||||||
public String contentInternalError() throws FileNotFoundException {
|
public String contentInternalError() throws FileNotFoundException {
|
||||||
if (ThemeUtils.isTemplateExist(INTERNAL_ERROR_TEMPLATE)) {
|
if (!ThemeUtils.isTemplateExist(INTERNAL_ERROR_TEMPLATE)) {
|
||||||
return "common/error/404";
|
return "common/error/500";
|
||||||
}
|
}
|
||||||
StrBuilder path = new StrBuilder("themes/");
|
StrBuilder path = new StrBuilder("themes/");
|
||||||
path.append(BaseContentController.THEME);
|
path.append(BaseContentController.THEME);
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package cc.ryanc.halo.web.controller.core;
|
package cc.ryanc.halo.web.controller.core;
|
||||||
|
|
||||||
import cc.ryanc.halo.model.entity.*;
|
import cc.ryanc.halo.model.entity.*;
|
||||||
|
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||||
import cc.ryanc.halo.model.enums.CommentStatus;
|
import cc.ryanc.halo.model.enums.CommentStatus;
|
||||||
import cc.ryanc.halo.model.enums.PostStatus;
|
import cc.ryanc.halo.model.enums.PostStatus;
|
||||||
import cc.ryanc.halo.model.support.JsonResult;
|
import cc.ryanc.halo.model.support.JsonResult;
|
||||||
import cc.ryanc.halo.service.*;
|
import cc.ryanc.halo.service.*;
|
||||||
import cc.ryanc.halo.utils.MarkdownUtils;
|
import cc.ryanc.halo.utils.MarkdownUtils;
|
||||||
|
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.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
@ -152,19 +154,19 @@ public class InstallController {
|
||||||
comment.setIsAdmin(false);
|
comment.setIsAdmin(false);
|
||||||
commentService.create(comment);
|
commentService.create(comment);
|
||||||
|
|
||||||
final Map<String, String> options = new HashMap<>();
|
final Map<BlogProperties, Object> options = new HashMap<>();
|
||||||
// options.put(BlogPropertiesEnum.IS_INSTALL.getProp(), TrueFalseEnum.TRUE.getDesc());
|
// options.put(BlogProperties.IS_INSTALL, TrueFalseEnum.TRUE.getDesc());
|
||||||
// options.put(BlogPropertiesEnum.BLOG_LOCALE.getProp(), blogLocale);
|
// options.put(BlogProperties.BLOG_LOCALE, blogLocale);
|
||||||
// options.put(BlogPropertiesEnum.BLOG_TITLE.getProp(), blogTitle);
|
// options.put(BlogProperties.BLOG_TITLE, blogTitle);
|
||||||
// options.put(BlogPropertiesEnum.BLOG_URL.getProp(), blogUrl);
|
// options.put(BlogProperties.BLOG_URL, blogUrl);
|
||||||
// options.put(BlogPropertiesEnum.THEME.getProp(), "anatole");
|
// options.put(BlogProperties.THEME, "anatole");
|
||||||
// options.put(BlogPropertiesEnum.BLOG_START.getProp(), DateUtil.format(DateUtil.date(), "yyyy-MM-dd"));
|
// options.put(BlogProperties.BLOG_START, DateUtil.format(DateUtil.date(), "yyyy-MM-dd"));
|
||||||
// options.put(BlogPropertiesEnum.SMTP_EMAIL_ENABLE.getProp(), TrueFalseEnum.FALSE.getDesc());
|
// options.put(BlogProperties.SMTP_EMAIL_ENABLE, TrueFalseEnum.FALSE.getDesc());
|
||||||
// options.put(BlogPropertiesEnum.NEW_COMMENT_NOTICE.getProp(), TrueFalseEnum.FALSE.getDesc());
|
// options.put(BlogProperties.NEW_COMMENT_NOTICE, TrueFalseEnum.FALSE.getDesc());
|
||||||
// options.put(BlogPropertiesEnum.COMMENT_PASS_NOTICE.getProp(), TrueFalseEnum.FALSE.getDesc());
|
// options.put(BlogProperties.COMMENT_PASS_NOTICE, TrueFalseEnum.FALSE.getDesc());
|
||||||
// options.put(BlogPropertiesEnum.COMMENT_REPLY_NOTICE.getProp(), TrueFalseEnum.FALSE.getDesc());
|
// options.put(BlogProperties.COMMENT_REPLY_NOTICE, TrueFalseEnum.FALSE.getDesc());
|
||||||
// options.put(BlogPropertiesEnum.ATTACH_LOC.getProp(), AttachLocationEnum.SERVER.getDesc());
|
// options.put(BlogProperties.ATTACH_LOC, AttachLocationEnum.SERVER.getDesc());
|
||||||
optionService.saveOptions(options);
|
// optionService.saveOptions(options);
|
||||||
|
|
||||||
//更新日志
|
//更新日志
|
||||||
// logsService.save(LogsRecord.INSTALL, "安装成功,欢迎使用Halo。", request);
|
// logsService.save(LogsRecord.INSTALL, "安装成功,欢迎使用Halo。", request);
|
||||||
|
|
|
@ -258,3 +258,61 @@ function saveOptions(option) {
|
||||||
}
|
}
|
||||||
}, 'JSON');
|
}, 'JSON');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sweetalert 封装
|
||||||
|
$.halo.prototype.alertChoose = function (title,text,btnCancel,btnConfirm,ajaxUrl,ajaxType,data) {
|
||||||
|
swal({
|
||||||
|
title: title,
|
||||||
|
text: text,
|
||||||
|
icon: "warning",
|
||||||
|
buttons: [btnCancel, btnConfirm],
|
||||||
|
dangerMode: true
|
||||||
|
}).then(function (isOk) {
|
||||||
|
if (isOk) {
|
||||||
|
$.ajax({
|
||||||
|
type: ajaxType,
|
||||||
|
url: ajaxUrl,
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: data,
|
||||||
|
async: false,
|
||||||
|
success: function (data) {
|
||||||
|
if(data.code===1){
|
||||||
|
swal(data.msg, {
|
||||||
|
icon: "success",
|
||||||
|
button: button
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
swal(data.msg, {
|
||||||
|
icon: "error",
|
||||||
|
button: button
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
$.halo.prototype.alertSimple = function (ajaxUrl,ajaxType,data,button) {
|
||||||
|
$.ajax({
|
||||||
|
type: ajaxType,
|
||||||
|
url: ajaxUrl,
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: data,
|
||||||
|
async: false,
|
||||||
|
success: function (data) {
|
||||||
|
if(data.code===1){
|
||||||
|
swal(data.msg, {
|
||||||
|
icon: "success",
|
||||||
|
button: button
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
swal(data.msg, {
|
||||||
|
icon: "error",
|
||||||
|
button: button
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,31 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
<script src="/static/halo-admin/plugins/sweetalert/sweetalert.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button onclick="choise()">选择框</button>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
function choise() {
|
||||||
|
swal({
|
||||||
|
title: "Are you sure?",
|
||||||
|
text: "Once deleted, you will not be able to recover this imaginary file!",
|
||||||
|
icon: "warning",
|
||||||
|
buttons: ["取消", "确定"],
|
||||||
|
dangerMode: true
|
||||||
|
}).then(function (action) {
|
||||||
|
if (action) {
|
||||||
|
swal("Poof! Your imaginary file has been deleted!", {
|
||||||
|
icon: "success",
|
||||||
|
button: "确定"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
swal("Your imaginary file is safe!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
Loading…
Reference in New Issue