mirror of https://github.com/halo-dev/halo
🎨 代码优化
parent
82dbbbba02
commit
c4334e6174
|
@ -53,6 +53,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
* 文章归档
|
* 文章归档
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
|
*
|
||||||
* @return 模板路径
|
* @return 模板路径
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
|
@ -65,6 +66,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param page page 当前页码
|
* @param page page 当前页码
|
||||||
|
*
|
||||||
* @return 模板路径/themes/{theme}/archives
|
* @return 模板路径/themes/{theme}/archives
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "page/{page}")
|
@GetMapping(value = "page/{page}")
|
||||||
|
@ -89,6 +91,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
* @param model model
|
* @param model model
|
||||||
* @param year year 年份
|
* @param year year 年份
|
||||||
* @param month month 月份
|
* @param month month 月份
|
||||||
|
*
|
||||||
* @return 模板路径/themes/{theme}/archives
|
* @return 模板路径/themes/{theme}/archives
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{year}/{month}")
|
@GetMapping(value = "{year}/{month}")
|
||||||
|
@ -109,6 +112,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
*
|
*
|
||||||
* @param postUrl 文章路径名
|
* @param postUrl 文章路径名
|
||||||
* @param model model
|
* @param model model
|
||||||
|
*
|
||||||
* @return 模板路径/themes/{theme}/post
|
* @return 模板路径/themes/{theme}/post
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "{postUrl}")
|
@GetMapping(value = "{postUrl}")
|
||||||
|
@ -147,7 +151,7 @@ public class FrontArchiveController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
int size = 10;
|
||||||
//获取每页评论条数
|
//获取每页评论条数
|
||||||
if (StrUtil.isNotBlank(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()));
|
||||||
|
|
|
@ -5,10 +5,7 @@ import cc.ryanc.halo.model.domain.Gallery;
|
||||||
import cc.ryanc.halo.model.domain.Post;
|
import cc.ryanc.halo.model.domain.Post;
|
||||||
import cc.ryanc.halo.model.dto.HaloConst;
|
import cc.ryanc.halo.model.dto.HaloConst;
|
||||||
import cc.ryanc.halo.model.dto.ListPage;
|
import cc.ryanc.halo.model.dto.ListPage;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.*;
|
||||||
import cc.ryanc.halo.model.enums.CommentStatusEnum;
|
|
||||||
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
|
||||||
import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
|
||||||
import cc.ryanc.halo.service.CommentService;
|
import cc.ryanc.halo.service.CommentService;
|
||||||
import cc.ryanc.halo.service.GalleryService;
|
import cc.ryanc.halo.service.GalleryService;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
|
@ -72,6 +69,7 @@ public class FrontPageController extends BaseController {
|
||||||
*
|
*
|
||||||
* @param postUrl 页面路径
|
* @param postUrl 页面路径
|
||||||
* @param model model
|
* @param model model
|
||||||
|
*
|
||||||
* @return 模板路径/themes/{theme}/post
|
* @return 模板路径/themes/{theme}/post
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/p/{postUrl}")
|
@GetMapping(value = "/p/{postUrl}")
|
||||||
|
@ -79,7 +77,7 @@ public class FrontPageController extends BaseController {
|
||||||
@RequestParam(value = "cp", defaultValue = "1") Integer cp,
|
@RequestParam(value = "cp", defaultValue = "1") Integer cp,
|
||||||
Model model) {
|
Model model) {
|
||||||
Post post = postService.findByPostUrl(postUrl, PostTypeEnum.POST_TYPE_PAGE.getDesc());
|
Post post = postService.findByPostUrl(postUrl, PostTypeEnum.POST_TYPE_PAGE.getDesc());
|
||||||
if (null == post) {
|
if (null == post || !post.getPostStatus().equals(PostStatusEnum.PUBLISHED.getCode())) {
|
||||||
return this.renderNotFound();
|
return this.renderNotFound();
|
||||||
}
|
}
|
||||||
List<Comment> comments = null;
|
List<Comment> comments = null;
|
||||||
|
@ -89,7 +87,7 @@ public class FrontPageController extends BaseController {
|
||||||
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
|
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
|
||||||
}
|
}
|
||||||
//默认显示10条
|
//默认显示10条
|
||||||
Integer size = 10;
|
int size = 10;
|
||||||
//获取每页评论条数
|
//获取每页评论条数
|
||||||
if (StrUtil.isNotBlank(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()));
|
||||||
|
|
|
@ -29,17 +29,17 @@
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="cateName"><@spring.message code='admin.categories.form.cate-name' /></label>
|
<label for="cateName"><@spring.message code='admin.categories.form.cate-name' /></label>
|
||||||
<input type="text" class="form-control" id="cateName" name="cateName" value="${updateCategory.cateName}">
|
<input type="text" class="form-control" id="cateName" name="cateName" value="${updateCategory.cateName!}">
|
||||||
<small><@spring.message code='admin.categories.form.cate-name-tips' /></small>
|
<small><@spring.message code='admin.categories.form.cate-name-tips' /></small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="cateUrl"><@spring.message code='admin.categories.form.cate-url' /></label>
|
<label for="cateUrl"><@spring.message code='admin.categories.form.cate-url' /></label>
|
||||||
<input type="text" class="form-control" id="cateUrl" name="cateUrl" value="${updateCategory.cateUrl}">
|
<input type="text" class="form-control" id="cateUrl" name="cateUrl" value="${updateCategory.cateUrl!}">
|
||||||
<small><@spring.message code='admin.categories.form.cate-url-tips' /></small>
|
<small><@spring.message code='admin.categories.form.cate-url-tips' /></small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="cateDesc" class="control-label"><@spring.message code='admin.categories.form.cate-desc' /></label>
|
<label for="cateDesc" class="control-label"><@spring.message code='admin.categories.form.cate-desc' /></label>
|
||||||
<textarea class="form-control" rows="3" id="cateDesc" name="cateDesc" style="resize: none">${updateCategory.cateDesc}</textarea>
|
<textarea class="form-control" rows="3" id="cateDesc" name="cateDesc" style="resize: none">${updateCategory.cateDesc!}</textarea>
|
||||||
<small><@spring.message code='admin.categories.form.cate-desc-tips' /></small>
|
<small><@spring.message code='admin.categories.form.cate-desc-tips' /></small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -96,9 +96,9 @@
|
||||||
<#if categories?? && categories?size gt 0>
|
<#if categories?? && categories?size gt 0>
|
||||||
<#list categories as cate>
|
<#list categories as cate>
|
||||||
<tr>
|
<tr>
|
||||||
<td>${cate.cateName}</td>
|
<td>${cate.cateName!}</td>
|
||||||
<td>${cate.cateUrl}</td>
|
<td>${cate.cateUrl!}</td>
|
||||||
<td>${(cate.cateDesc)!}</td>
|
<td>${cate.cateDesc!}</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="label" style="background-color: #d6cdcd;">${cate.posts?size}</span>
|
<span class="label" style="background-color: #d6cdcd;">${cate.posts?size}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
<th><@spring.message code='common.th.url' /></th>
|
<th><@spring.message code='common.th.url' /></th>
|
||||||
<th><@spring.message code='common.th.comments' /></th>
|
<th><@spring.message code='common.th.comments' /></th>
|
||||||
<td><@spring.message code='common.th.views' /></td>
|
<td><@spring.message code='common.th.views' /></td>
|
||||||
|
<th><@spring.message code='common.th.status' /></th>
|
||||||
<th><@spring.message code='common.th.date' /></th>
|
<th><@spring.message code='common.th.date' /></th>
|
||||||
<th><@spring.message code='common.th.control' /></th>
|
<th><@spring.message code='common.th.control' /></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -80,6 +81,15 @@
|
||||||
<td>
|
<td>
|
||||||
<span class="label" style="background-color: #d6cdcd;">${page.postViews}</span>
|
<span class="label" style="background-color: #d6cdcd;">${page.postViews}</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<#if page.postStatus==0>
|
||||||
|
<span class="label bg-green"><@spring.message code='common.status.published' /></span>
|
||||||
|
<#elseif page.postStatus==1>
|
||||||
|
<span class="label bg-yellow"><@spring.message code='common.status.draft' /></span>
|
||||||
|
<#else>
|
||||||
|
<span class="label bg-red"><@spring.message code='common.status.recycle-bin' /></span>
|
||||||
|
</#if>
|
||||||
|
</td>
|
||||||
<td>${page.postDate?string("yyyy-MM-dd HH:mm")}</td>
|
<td>${page.postDate?string("yyyy-MM-dd HH:mm")}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="/p/${page.postUrl}" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
|
<a href="/p/${page.postUrl}" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<link rel="stylesheet" href="/static/halo-backend/plugins/simplemde/simplemde.min.css">
|
<link rel="stylesheet" href="/static/halo-backend/plugins/simplemde/simplemde.min.css">
|
||||||
<link rel="stylesheet" href="/static/halo-backend/plugins/datetimepicker/css/bootstrap-datetimepicker.min.css">
|
<link rel="stylesheet" href="/static/halo-backend/plugins/datetimepicker/css/bootstrap-datetimepicker.min.css">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#post_title{font-weight: 400;}
|
#postTitle{font-weight: 400;}
|
||||||
.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word) {background: none;}
|
.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word) {background: none;}
|
||||||
.CodeMirror-fullscreen,.editor-toolbar.fullscreen{z-index: 1030;}
|
.CodeMirror-fullscreen,.editor-toolbar.fullscreen{z-index: 1030;}
|
||||||
.CodeMirror, .CodeMirror-scroll {min-height: 480px;}
|
.CodeMirror, .CodeMirror-scroll {min-height: 480px;}
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<input type="hidden" id="postId" name="postId" value="">
|
<input type="hidden" id="postId" name="postId" value="">
|
||||||
</#if>
|
</#if>
|
||||||
<div style="margin-bottom: 10px;">
|
<div style="margin-bottom: 10px;">
|
||||||
<input type="text" class="form-control input-lg" id="post_title" name="post_title" placeholder="<@spring.message code='admin.pages.edit.form.title.placeholder' />" value="<#if post??>${post.postTitle}</#if>">
|
<input type="text" class="form-control input-lg" id="postTitle" name="postTitle" placeholder="<@spring.message code='admin.pages.edit.form.title.placeholder' />" value="<#if post??>${post.postTitle}</#if>">
|
||||||
</div>
|
</div>
|
||||||
<div style="display: block;margin-bottom: 10px;">
|
<div style="display: block;margin-bottom: 10px;">
|
||||||
<span>
|
<span>
|
||||||
|
@ -215,24 +215,20 @@
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$('#btn_change_postUrl').show();
|
$('#btn_change_postUrl').show();
|
||||||
});
|
});
|
||||||
var postTitle = $("#post_title");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交文章
|
* 提交文章
|
||||||
* @param status 文章状态
|
* @param status 文章状态
|
||||||
*/
|
*/
|
||||||
function push(status) {
|
function push(status) {
|
||||||
var Title = "";
|
var postTitle = $("#postTitle");
|
||||||
if(postTitle.val()){
|
var postUrl = $("#postUrl");
|
||||||
Title = postTitle.val();
|
if(!postTitle.val()){
|
||||||
}else{
|
|
||||||
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
|
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$('input[name="categories"]:checked').each(function(){
|
if(!postUrl.html()){
|
||||||
cateList.push($(this).val());
|
|
||||||
});
|
|
||||||
if($('#postUrl').html()===""){
|
|
||||||
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
|
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -240,8 +236,8 @@
|
||||||
$.post('/admin/page/new/push',{
|
$.post('/admin/page/new/push',{
|
||||||
'postId': $('#postId').val(),
|
'postId': $('#postId').val(),
|
||||||
'postStatus': status,
|
'postStatus': status,
|
||||||
'postTitle': Title,
|
'postTitle': postTitle.val(),
|
||||||
'postUrl' : $('#postUrl').html().toString(),
|
'postUrl' : postUrl.html().toString(),
|
||||||
'postContentMd': simplemde.value(),
|
'postContentMd': simplemde.value(),
|
||||||
'postThumbnail': $('#selectImg').attr('src'),
|
'postThumbnail': $('#selectImg').attr('src'),
|
||||||
'allowComment' : $('#allowComment').val(),
|
'allowComment' : $('#allowComment').val(),
|
||||||
|
|
|
@ -273,33 +273,31 @@
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$('#btn_change_postUrl').show();
|
$('#btn_change_postUrl').show();
|
||||||
});
|
});
|
||||||
var postTitle = $("#postTitle");
|
|
||||||
var cateList = new Array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交文章
|
* 提交文章
|
||||||
* @param status 文章状态
|
* @param status 文章状态
|
||||||
*/
|
*/
|
||||||
function push(status) {
|
function push(status) {
|
||||||
var Title = "";
|
var postTitle = $("#postTitle");
|
||||||
if(postTitle.val()){
|
var postUrl = $("#postUrl");
|
||||||
Title = postTitle.val();
|
var cateList = new Array();
|
||||||
}else{
|
if(!postTitle.val()){
|
||||||
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
|
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!postUrl.html()){
|
||||||
|
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$('input[name="categories"]:checked').each(function(){
|
$('input[name="categories"]:checked').each(function(){
|
||||||
cateList.push($(this).val());
|
cateList.push($(this).val());
|
||||||
});
|
});
|
||||||
if($('#postUrl').html()===""){
|
|
||||||
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$.post('/admin/posts/update',{
|
$.post('/admin/posts/update',{
|
||||||
'postId': $('#postId').val(),
|
'postId': $('#postId').val(),
|
||||||
'postStatus': status,
|
'postStatus': status,
|
||||||
'postTitle': Title,
|
'postTitle': postTitle.val(),
|
||||||
'postUrl' : $('#postUrl').html().toString(),
|
'postUrl' : postUrl.html().toString(),
|
||||||
'postContentMd': simplemde.value(),
|
'postContentMd': simplemde.value(),
|
||||||
'postThumbnail': $('#selectImg').attr('src'),
|
'postThumbnail': $('#selectImg').attr('src'),
|
||||||
'cateList' : cateList.toString(),
|
'cateList' : cateList.toString(),
|
||||||
|
|
|
@ -249,32 +249,30 @@
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$('#btn_change_postUrl').show();
|
$('#btn_change_postUrl').show();
|
||||||
});
|
});
|
||||||
var postTitle = $("#postTitle");
|
|
||||||
var cateList = new Array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交文章
|
* 提交文章
|
||||||
* @param status 文章状态
|
* @param status 文章状态
|
||||||
*/
|
*/
|
||||||
function push(status) {
|
function push(status) {
|
||||||
var Title = "";
|
var postTitle = $("#postTitle");
|
||||||
if(postTitle.val()){
|
var postUrl = $("#postUrl");
|
||||||
Title = postTitle.val();
|
var cateList = new Array();
|
||||||
}else{
|
if(!postTitle.val()){
|
||||||
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
|
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!postUrl.html()){
|
||||||
|
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$('input[name="categories"]:checked').each(function(){
|
$('input[name="categories"]:checked').each(function(){
|
||||||
cateList.push($(this).val());
|
cateList.push($(this).val());
|
||||||
});
|
});
|
||||||
if($('#postUrl').html()===""){
|
|
||||||
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$.post('/admin/posts/save',{
|
$.post('/admin/posts/save',{
|
||||||
'postStatus': status,
|
'postStatus': status,
|
||||||
'postTitle': Title,
|
'postTitle': postTitle.val(),
|
||||||
'postUrl' : $('#postUrl').html().toString(),
|
'postUrl' : postUrl.html().toString(),
|
||||||
'postContentMd': simplemde.value(),
|
'postContentMd': simplemde.value(),
|
||||||
'postThumbnail': $('#selectImg').attr('src'),
|
'postThumbnail': $('#selectImg').attr('src'),
|
||||||
'cateList' : cateList.toString(),
|
'cateList' : cateList.toString(),
|
||||||
|
|
Loading…
Reference in New Issue