👽 修改判断是否安装的方式

pull/5/head
RYAN0UP_ 2018-05-03 20:37:21 +08:00
parent f8597a3406
commit 767fa132b6
26 changed files with 2803 additions and 2168 deletions

View File

@ -104,6 +104,11 @@ public class Post implements Serializable{
*/
private Date postDate;
/**
*
*/
private Date postUpdate;
/**
* 0
* 1 稿

View File

@ -79,8 +79,10 @@ public class PostServiceImpl implements PostService {
for(Post post:posts){
if(!(HaloUtil.htmlToText(post.getPostContent()).length()<postSummary)){
post.setPostSummary(HaloUtil.getSummary(post.getPostContent(),postSummary));
postRepository.save(post);
}else{
post.setPostSummary(HaloUtil.htmlToText(post.getPostContent()));
}
postRepository.save(post);
}
}

View File

@ -1,5 +1,6 @@
package cc.ryanc.halo.web.controller.admin;
import cc.ryanc.halo.model.dto.HaloConst;
import cc.ryanc.halo.service.OptionsService;
import freemarker.template.Configuration;
import lombok.extern.slf4j.Slf4j;
@ -49,6 +50,8 @@ public class OptionController {
optionsService.saveOptions(options);
//刷新options
configuration.setSharedVariable("options",optionsService.findAllOptions());
HaloConst.OPTIONS.clear();
HaloConst.OPTIONS = optionsService.findAllOptions();
log.info("所保存的设置选项列表:"+options);
return true;
}catch (Exception e){

View File

@ -3,7 +3,10 @@ package cc.ryanc.halo.web.controller.admin;
import cc.ryanc.halo.model.domain.*;
import cc.ryanc.halo.model.dto.HaloConst;
import cc.ryanc.halo.model.dto.LogsRecord;
import cc.ryanc.halo.service.*;
import cc.ryanc.halo.service.CategoryService;
import cc.ryanc.halo.service.LogsService;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.service.TagService;
import cc.ryanc.halo.util.HaloUtil;
import cc.ryanc.halo.web.controller.core.BaseController;
import lombok.extern.slf4j.Slf4j;
@ -21,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.websocket.server.PathParam;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
@ -47,9 +49,6 @@ public class PostController extends BaseController{
@Autowired
private LogsService logsService;
@Autowired
private OptionsService optionsService;
@Autowired
private HttpServletRequest request;
@ -142,19 +141,33 @@ public class PostController extends BaseController{
@PostMapping(value = "/new/push")
@ResponseBody
public void pushPost(@ModelAttribute Post post, @RequestParam("cateList") List<String> cateList, @RequestParam("tagList") String tagList, HttpSession session){
//发表用户
User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
if(null==user){
return;
}
if(null!=post.getPostId()){
post = postService.findByPostId(post.getPostId()).get();
}
try{
//提取摘要
int postSummary = 50;
if(HaloUtil.isNotNull(HaloConst.OPTIONS.get("post_summary"))){
postSummary = Integer.parseInt(HaloConst.OPTIONS.get("post_summary"));
}
if(HaloUtil.htmlToText(post.getPostContent()).length()>postSummary){
String summaryText = HaloUtil.htmlToText(post.getPostContent());
if(summaryText.length()>postSummary){
String summary = HaloUtil.getSummary(post.getPostContent(), postSummary);
post.setPostSummary(summary);
}else{
post.setPostSummary(summaryText);
}
if(null!=post.getPostId()){
post.setPostUpdate(HaloUtil.getDate());
}else{
post.setPostDate(HaloUtil.getDate());
post.setPostUpdate(HaloUtil.getDate());
}
post.setPostDate(HaloUtil.getDate());
//发表用户
User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
post.setUser(user);
List<Category> categories = categoryService.strListToCateList(cateList);
post.setCategories(categories);
@ -274,6 +287,7 @@ public class PostController extends BaseController{
/**
*
*
* @param baiduToken baiduToken
* @return true or false
*/
@ -283,14 +297,13 @@ public class PostController extends BaseController{
if(StringUtils.isEmpty(baiduToken)){
return false;
}
String blogUrl = optionsService.findOneOption("blog_url");
String blogUrl = HaloConst.OPTIONS.get("blog_url");
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
String urls = "";
for(Post post:posts){
urls+=blogUrl+"/archives/"+post.getPostUrl()+"\n";
}
String result = HaloUtil.baiduPost(blogUrl,baiduToken,urls);
log.info(result);
HaloUtil.baiduPost(blogUrl,baiduToken,urls);
return true;
}
}

View File

@ -11,11 +11,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -64,9 +62,7 @@ public class InstallController {
@GetMapping
public String install(Model model){
try{
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
File installFile = new File(basePath.getAbsolutePath(), "install.lock");
if(installFile.exists()){
if(StringUtils.equals("true",HaloConst.OPTIONS.get("is_install"))){
model.addAttribute("isInstall",true);
}else{
model.addAttribute("isInstall",false);
@ -99,15 +95,9 @@ public class InstallController {
@RequestParam("userPwd") String userPwd,
HttpServletRequest request){
try{
//创建install.lock文件
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
File installFile = new File(basePath.getAbsolutePath(), "install.lock");
if(installFile.exists()){
if(StringUtils.equals("true",HaloConst.OPTIONS.get("is_install"))){
return false;
}else{
installFile.createNewFile();
}
//创建新的用户
User user= new User();
user.setUserName(userName);
@ -156,12 +146,14 @@ public class InstallController {
comment.setIsAdmin(0);
commentService.saveByComment(comment);
optionsService.saveOption("is_install","true");
//保存博客标题和博客地址设置
optionsService.saveOption("blog_title",blogTitle);
optionsService.saveOption("blog_url",blogUrl);
//设置默认主题
optionsService.saveOption("theme","halo");
optionsService.saveOption("theme","anatole");
//建立网站时间
optionsService.saveOption("blog_start",HaloUtil.getStringDate("yyyy-MM-dd"));

View File

@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.Post;
import cc.ryanc.halo.model.dto.HaloConst;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.web.controller.core.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -25,6 +26,7 @@ import java.util.List;
* @version : 1.0
* @date : 2018/4/26
*/
@Slf4j
@Controller
@RequestMapping(value = {"/","index"})
public class IndexController extends BaseController {

View File

@ -31,7 +31,7 @@ public class OthersController {
*
* @return rss
*/
@GetMapping(value = {"feed","feed.xml","atom","atom.xml"},produces = "application/rss+xml;charset=UTF-8")
@GetMapping(value = {"feed","feed.xml","atom","atom.xml"},produces = "application/xml;charset=UTF-8")
@ResponseBody
public String feed(){
String rssPosts = HaloConst.OPTIONS.get("rss_posts");

View File

@ -1,13 +1,15 @@
package cc.ryanc.halo.web.interceptor;
import cc.ryanc.halo.model.dto.HaloConst;
import cc.ryanc.halo.service.OptionsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
/**
* @author : RYAN0UP
@ -17,11 +19,13 @@ import java.io.File;
*/
@Component
public class InstallInterceptor implements HandlerInterceptor {
@Autowired
private OptionsService optionsService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
File basePath = new File(ResourceUtils.getURL("classpath:").getPath());
File installFile = new File(basePath.getAbsolutePath(), "install.lock");
if(installFile.exists()){
if(StringUtils.equals("true",HaloConst.OPTIONS.get("is_install"))){
return true;
}
response.sendRedirect("/install");

View File

@ -409,10 +409,10 @@
<label class="col-sm-2 control-label">后台加载动画:</label>
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" name="admin_loading" value="true" ${((options.admin_loading?default('true'))=='true')?string('checked','')}> 启用
<input type="radio" name="admin_loading" value="true" ${((options.admin_loading?if_exists)=='true')?string('checked','')}> 启用
</label>
<label class="radio-inline">
<input type="radio" name="admin_loading" value="false" ${((options.admin_loading?if_exists)=='false')?string('checked','')}> 禁用
<input type="radio" name="admin_loading" value="false" ${((options.admin_loading?default('false'))=='false')?string('checked','')}> 禁用
</label>
</div>
</div>

View File

@ -65,14 +65,6 @@
<a data-pjax="true" href="/admin/page/galleries" class="btn btn-primary btn-xs ">配置</a>
</td>
</tr>
<tr>
<td>关于页面</td>
<td>/about</td>
<td>
<a href="/about" class="btn btn-info btn-xs " target="_blank">预览</a>
<a data-pjax="true" href="/admin/page/about" class="btn btn-primary btn-xs ">配置</a>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -144,9 +144,7 @@
function isNull() {
var name = $('#linkName').val();
var url = $('#linkUrl').val();
var pic = $('#linkPic').val();
var desc = $('#linkDesc').val();
if(name==""||url==""||pic==""){
if(name==""||url==""){
showMsg("请输入完整信息!","info",2000);
return false;
}

View File

@ -21,7 +21,7 @@
<script src="/static/plugins/bootstrap/js/bootstrap.min.js"></script>
</head>
<body class="hold-transition sidebar-mini ${options.admin_theme?default('skin-blue')} ${options.admin_layout?default('')} ${options.sidebar_style?default('')}">
<#if options.admin_loading?default("true") == "true">
<#if options.admin_loading?default("false") == "true">
<!-- 页面加载动画 -->
<div id="loading">
<div id="loading-center">
@ -49,7 +49,7 @@
<#if options.admin_pjax?default("true") == "true">
$(document).pjax('a[data-pjax=true]', '.content-wrapper', {fragment: '.content-wrapper',timeout: 8000});
</#if>
<#if options.admin_loading?default("true") == "true">
<#if options.admin_loading?default("false") == "true">
$(window).on('load', function(){
$('body').addClass('loaded');
setTimeout(function () {

View File

@ -190,7 +190,7 @@
var date = new Date(timestamp).toLocaleDateString();
var content = element.commentContent;
var authorPic = md5(authorEmail);
$('.native-list').append("<li class=\"native-list-one\"><img class=\"native-list-one-img\" src=\"http://www.gravatar.com/avatar/"+authorPic+"?s=256&d=${options.native_comment_avatar?default('default')}\"><section><div class=\"native-list-one-head\"><a class=\"native-list-one-head-name\" rel=\"nofollow\" href=\""+authorUrl+"\" target=\"_blank\">"+author+"</a> <span class=\"ua\">"+browser+"</span> <span class=\"ua\">"+os+"</span></div><div class=\"native-list-one-content\"><p>"+content+"</p></div><div class=\"native-list-one-footer\"><span class=\"native-list-one-footer-time\">"+date+"</span> <span rid=\"\" at=\"@"+author+"\" mail=\""+authorEmail+"\" class=\"native-list-one-footer-reback\">回复</span></div></section></li>");
$('.native-list').append("<li class=\"native-list-one\"><img class=\"native-list-one-img\" src=\"//www.gravatar.com/avatar/"+authorPic+"?s=256&d=${options.native_comment_avatar?default('default')}\"><section><div class=\"native-list-one-head\"><a class=\"native-list-one-head-name\" rel=\"nofollow\" href=\""+authorUrl+"\" target=\"_blank\">"+author+"</a> <span class=\"ua\">"+browser+"</span> <span class=\"ua\">"+os+"</span></div><div class=\"native-list-one-content\"><p>"+content+"</p></div><div class=\"native-list-one-footer\"><span class=\"native-list-one-footer-time\">"+date+"</span> <span rid=\"\" at=\"@"+author+"\" mail=\""+authorEmail+"\" class=\"native-list-one-footer-reback\">回复</span></div></section></li>");
});
}
});

View File

@ -41,6 +41,17 @@
<div class="tab-pane active" id="sns">
<form method="post" class="form-horizontal" id="anatoleSnsOptions">
<div class="box-body">
<div class="form-group">
<label for="anatoleSnsRss" class="col-sm-4 control-label">RSS</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="theme_anatole_sns_rss" id="anatoleSnsRss" value="true" ${((options.theme_anatole_sns_rss?default('true'))=='true')?string('checked','')}> 显示
</label>
<label class="radio-inline">
<input type="radio" name="theme_anatole_sns_rss" id="anatoleSnsRss" value="false" ${((options.theme_anatole_sns_rss?if_exists)=='false')?string('checked','')}> 隐藏
</label>
</div>
</div>
<div class="form-group">
<label for="anatoleSnsTwitter" class="col-sm-4 control-label">Twitter</label>
<div class="col-sm-8">
@ -83,6 +94,18 @@
<input type="text" class="form-control" id="anatoleSnsGithub" name="theme_anatole_sns_github" value="${options.theme_anatole_sns_github?if_exists}" >
</div>
</div>
<div class="form-group">
<label for="anatoleSnsQQ" class="col-sm-4 control-label">QQ</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="anatoleSnsQQ" name="theme_anatole_sns_qq" value="${options.theme_anatole_sns_qq?if_exists}" >
</div>
</div>
<div class="form-group">
<label for="anatoleSnsTelegram" class="col-sm-4 control-label">Telegram</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="anatoleSnsTelegram" name="theme_anatole_sns_telegram" value="${options.theme_anatole_sns_telegram?if_exists}" >
</div>
</div>
</div>
<div class="box-footer">
<button type="button" class="btn btn-primary btn-sm pull-right" onclick="saveThemeOptions('anatoleSnsOptions')">保存设置</button>
@ -115,6 +138,17 @@
</label>
</div>
</div>
<div class="form-group">
<label for="anatoleStyleAvatarCircle" class="col-sm-4 control-label">圆形头像:</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="anatole_style_avatar_circle" id="anatoleStyleAvatarCircle" value="true" ${((options.anatole_style_avatar_circle?if_exists)=='true')?string('checked','')}> 开启
</label>
<label class="radio-inline">
<input type="radio" name="anatole_style_avatar_circle" id="anatoleStyleAvatarCircle" value="false" ${((options.anatole_style_avatar_circle?default('false'))=='false')?string('checked','')}> 关闭
</label>
</div>
</div>
<div class="form-group">
<label for="anatoleStyleHitokoto" class="col-sm-4 control-label">博客描述开启一言:</label>
<div class="col-sm-8">

View File

@ -1,7 +1,7 @@
<div class="sidebar animated fadeInDown">
<div class="logo-title">
<div class="title">
<img src="${options.blog_logo?default("/anatole/source/images/logo@2x.png")}" style="width:127px;" />
<img src="${options.blog_logo?default("/anatole/source/images/logo@2x.png")}" style="width:127px;<#if options.anatole_style_avatar_circle?default('false')=='true'>border-radius:50%</#if>" />
<h3 title="">
<a href="/">${options.blog_title?default("ANATOLE")}</a>
</h3>

View File

@ -1,4 +1,13 @@
<ul class="social-links">
<#if options.theme_anatole_sns_rss?default('true')=='true'>
<li>
<a target="_blank" href="/atom.xml">
<i class="fa fa-rss"></i>
</a>
</li>
</#if>
<#if options.theme_anatole_sns_twitter??>
<li>
<a target="_blank" href="${options.theme_anatole_sns_twitter}">
@ -39,19 +48,35 @@
</li>
</#if>
<#if options.theme_anatole_sns_qq??>
<li>
<a target="_blank" href="${options.theme_anatole_sns_qq}">
<i class="fa fa-qq"></i>
</a>
</li>
</#if>
<#if options.theme_anatole_sns_telegram??>
<li>
<a target="_blank" href="${options.theme_anatole_sns_telegram}">
<i class="fa fa-telegram"></i>
</a>
</li>
</#if>
<#if options.theme_anatole_sns_email??>
<li>
<a target="_blank" href="mailto:${options.theme_anatole_sns_email}">
<i class="fa fa-envelope"></i>
</a>
</li>
<li>
<a target="_blank" href="mailto:${options.theme_anatole_sns_email}">
<i class="fa fa-envelope"></i>
</a>
</li>
</#if>
<#if options.theme_anatole_sns_github??>
<li>
<a target="_blank" href="${options.theme_anatole_sns_github}">
<i class="fa fa-github"></i>
</a>
</li>
<li>
<a target="_blank" href="${options.theme_anatole_sns_github}">
<i class="fa fa-github"></i>
</a>
</li>
</#if>
</ul>

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 280 KiB

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

View File

@ -7,7 +7,7 @@
<!-- LOGO -->
<div class="something-else-logo mdl-color--white mdl-color-text--grey-600">
<a href="#" target="_blank">
<img src="${options.blog_logo?default('/material/source/img/avatar.png')}" alt="logo" />
<img src="${options.blog_logo?default('/material/source/img/logo.png')}" alt="logo" />
</a>
</div>

View File

@ -2,7 +2,7 @@
<!-- Prev Nav -->
<#if afterPost??>
<a href="/article/${afterPost.postUrl?if_exists}" id="post_nav-newer" class="prev-content">
<a href="/archives/${afterPost.postUrl?if_exists}" id="post_nav-newer" class="prev-content">
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
<i class="material-icons">arrow_back</i>
</button>
@ -15,7 +15,7 @@
<!-- Next Nav -->
<#if beforePost??>
<a href="/article/${beforePost.postUrl?if_exists}" id="post_nav-older" class="next-content">
<a href="/archives/${beforePost.postUrl?if_exists}" id="post_nav-older" class="next-content">
旧篇
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">

View File

@ -41,5 +41,6 @@
<script src="anatole/source/plugins/gallery/js/jquery.min.js"></script>
<script src="anatole/source/plugins/gallery/js/skel.min.js"></script>
<script src="anatole/source/plugins/gallery/js/main.js"></script>
${options.statistics_code?if_exists}
</body>
</html>