🎨 代码优化

pull/73/head
ruibaby 2018-12-27 13:11:39 +08:00
parent 82dbbbba02
commit c4334e6174
7 changed files with 191 additions and 187 deletions

View File

@ -53,6 +53,7 @@ public class FrontArchiveController extends BaseController {
*
*
* @param model model
*
* @return
*/
@GetMapping
@ -65,6 +66,7 @@ public class FrontArchiveController extends BaseController {
*
* @param model model
* @param page page
*
* @return /themes/{theme}/archives
*/
@GetMapping(value = "page/{page}")
@ -89,6 +91,7 @@ public class FrontArchiveController extends BaseController {
* @param model model
* @param year year
* @param month month
*
* @return /themes/{theme}/archives
*/
@GetMapping(value = "{year}/{month}")
@ -109,6 +112,7 @@ public class FrontArchiveController extends BaseController {
*
* @param postUrl
* @param model model
*
* @return /themes/{theme}/post
*/
@GetMapping(value = "{postUrl}")
@ -147,7 +151,7 @@ public class FrontArchiveController extends BaseController {
}
}
//默认显示10条
Integer size = 10;
int size = 10;
//获取每页评论条数
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()))) {
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()));

View File

@ -5,10 +5,7 @@ import cc.ryanc.halo.model.domain.Gallery;
import cc.ryanc.halo.model.domain.Post;
import cc.ryanc.halo.model.dto.HaloConst;
import cc.ryanc.halo.model.dto.ListPage;
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
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.model.enums.*;
import cc.ryanc.halo.service.CommentService;
import cc.ryanc.halo.service.GalleryService;
import cc.ryanc.halo.service.PostService;
@ -72,6 +69,7 @@ public class FrontPageController extends BaseController {
*
* @param postUrl
* @param model model
*
* @return /themes/{theme}/post
*/
@GetMapping(value = "/p/{postUrl}")
@ -79,7 +77,7 @@ public class FrontPageController extends BaseController {
@RequestParam(value = "cp", defaultValue = "1") Integer cp,
Model model) {
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();
}
List<Comment> comments = null;
@ -89,7 +87,7 @@ public class FrontPageController extends BaseController {
comments = commentService.findCommentsByPostAndCommentStatusNot(post, CommentStatusEnum.RECYCLE.getCode());
}
//默认显示10条
Integer size = 10;
int size = 10;
//获取每页评论条数
if (StrUtil.isNotBlank(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()))) {
size = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.INDEX_COMMENTS.getProp()));

View File

@ -29,17 +29,17 @@
<div class="box-body">
<div class="form-group">
<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>
</div>
<div class="form-group">
<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>
</div>
<div class="form-group">
<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>
</div>
</div>
@ -96,9 +96,9 @@
<#if categories?? && categories?size gt 0>
<#list categories as cate>
<tr>
<td>${cate.cateName}</td>
<td>${cate.cateUrl}</td>
<td>${(cate.cateDesc)!}</td>
<td>${cate.cateName!}</td>
<td>${cate.cateUrl!}</td>
<td>${cate.cateDesc!}</td>
<td>
<span class="label" style="background-color: #d6cdcd;">${cate.posts?size}</span>
</td>

View File

@ -1,137 +1,147 @@
<#compress >
<#include "module/_macro.ftl">
<@head>${options.blog_title!} | <@spring.message code='admin.pages.title' /></@head>
<div class="content-wrapper">
<section class="content-header" id="animated-header">
<h1 style="display: inline-block;"><@spring.message code='admin.pages.title' /><small></small></h1>
<a class="btn-header" id="btnNewPage" href="/admin/page/new">
<@spring.message code='admin.pages.btn.new-page' />
</a>
<ol class="breadcrumb">
<li>
<a data-pjax="true" href="/admin"><i class="fa fa-dashboard"></i> <@spring.message code='admin.index.bread.index' /></a>
</li>
<li><a data-pjax="true" href="javascript:void(0)"><@spring.message code='admin.pages.title' /></a></li>
<li class="active"><@spring.message code='admin.pages.bread.all-pages' /></li>
</ol>
</section>
<section class="content container-fluid" id="animated-content">
<div class="row">
<div class="col-md-12">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active">
<a href="#internal" data-toggle="tab"><@spring.message code='admin.pages.tab.internal-page' /></a>
</li>
<li>
<a href="#pages" data-toggle="tab"><@spring.message code='admin.pages.tab.custom-page' /></a>
</li>
</ul>
<div class="tab-content" style="padding: 0;">
<div class="tab-pane active" id="internal">
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th><@spring.message code='common.th.title' /></th>
<th><@spring.message code='common.th.url' /></th>
<th><@spring.message code='common.th.control' /></th>
</tr>
<tr>
<td><@spring.message code='admin.pages.links' /></td>
<td>/links</td>
<td>
<a href="/links" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
<a data-pjax="true" href="/admin/page/links" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
</td>
</tr>
<tr>
<td><@spring.message code='admin.pages.gallery' /></td>
<td>/gallery</td>
<td>
<a href="/gallery" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
<a data-pjax="true" href="/admin/page/galleries" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="pages">
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th><@spring.message code='common.th.title' /></th>
<th><@spring.message code='common.th.url' /></th>
<th><@spring.message code='common.th.comments' /></th>
<td><@spring.message code='common.th.views' /></td>
<th><@spring.message code='common.th.date' /></th>
<th><@spring.message code='common.th.control' /></th>
</tr>
<#if pages?size gt 0>
<#list pages as page>
<tr>
<td>${page.postTitle}</td>
<td>/p/${page.postUrl}</td>
<td>
<span class="label" style="background-color: #d6cdcd;">${page.comments?size}</span>
</td>
<td>
<span class="label" style="background-color: #d6cdcd;">${page.postViews}</span>
</td>
<td>${page.postDate?string("yyyy-MM-dd HH:mm")}</td>
<td>
<a href="/p/${page.postUrl}" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
<a href="/admin/page/edit?pageId=${page.postId?c}" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/posts/remove?postId=${page.postId?c}&postType=${page.postType}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code='common.btn.delete' /></button>
</td>
</tr>
</#list>
<#else>
<tr>
<td colspan="6" style="text-align: center;"><@spring.message code='common.text.no-data' /></td>
</tr>
</#if>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- 删除确认弹出层 -->
<div class="modal fade" id="removePostModal">
<div class="modal-dialog">
<div class="modal-content message_align">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"><@spring.message code='common.text.tips' /></h4>
</div>
<div class="modal-body">
<p id="message"></p>
</div>
<div class="modal-footer">
<input type="hidden" id="url"/>
<button type="button" class="btn btn-default" data-dismiss="modal"><@spring.message code='common.btn.cancel' /></button>
<a onclick="removeIt()" class="btn btn-danger" data-dismiss="modal"><@spring.message code='common.btn.define' /></a>
</div>
</div>
</div>
</div>
<script>
function modelShow(url,message) {
$('#url').val(url);
$('#message').html(message);
$('#removePostModal').modal();
}
function removeIt(){
var url=$.trim($("#url").val());
window.location.href=url;
}
</script>
</div>
<@footer></@footer>
</#compress>
<#compress >
<#include "module/_macro.ftl">
<@head>${options.blog_title!} | <@spring.message code='admin.pages.title' /></@head>
<div class="content-wrapper">
<section class="content-header" id="animated-header">
<h1 style="display: inline-block;"><@spring.message code='admin.pages.title' /><small></small></h1>
<a class="btn-header" id="btnNewPage" href="/admin/page/new">
<@spring.message code='admin.pages.btn.new-page' />
</a>
<ol class="breadcrumb">
<li>
<a data-pjax="true" href="/admin"><i class="fa fa-dashboard"></i> <@spring.message code='admin.index.bread.index' /></a>
</li>
<li><a data-pjax="true" href="javascript:void(0)"><@spring.message code='admin.pages.title' /></a></li>
<li class="active"><@spring.message code='admin.pages.bread.all-pages' /></li>
</ol>
</section>
<section class="content container-fluid" id="animated-content">
<div class="row">
<div class="col-md-12">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active">
<a href="#internal" data-toggle="tab"><@spring.message code='admin.pages.tab.internal-page' /></a>
</li>
<li>
<a href="#pages" data-toggle="tab"><@spring.message code='admin.pages.tab.custom-page' /></a>
</li>
</ul>
<div class="tab-content" style="padding: 0;">
<div class="tab-pane active" id="internal">
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th><@spring.message code='common.th.title' /></th>
<th><@spring.message code='common.th.url' /></th>
<th><@spring.message code='common.th.control' /></th>
</tr>
<tr>
<td><@spring.message code='admin.pages.links' /></td>
<td>/links</td>
<td>
<a href="/links" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
<a data-pjax="true" href="/admin/page/links" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
</td>
</tr>
<tr>
<td><@spring.message code='admin.pages.gallery' /></td>
<td>/gallery</td>
<td>
<a href="/gallery" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
<a data-pjax="true" href="/admin/page/galleries" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="pages">
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th><@spring.message code='common.th.title' /></th>
<th><@spring.message code='common.th.url' /></th>
<th><@spring.message code='common.th.comments' /></th>
<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.control' /></th>
</tr>
<#if pages?size gt 0>
<#list pages as page>
<tr>
<td>${page.postTitle}</td>
<td>/p/${page.postUrl}</td>
<td>
<span class="label" style="background-color: #d6cdcd;">${page.comments?size}</span>
</td>
<td>
<span class="label" style="background-color: #d6cdcd;">${page.postViews}</span>
</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>
<a href="/p/${page.postUrl}" class="btn btn-info btn-xs " target="_blank"><@spring.message code='common.btn.view' /></a>
<a href="/admin/page/edit?pageId=${page.postId?c}" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/posts/remove?postId=${page.postId?c}&postType=${page.postType}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code='common.btn.delete' /></button>
</td>
</tr>
</#list>
<#else>
<tr>
<td colspan="6" style="text-align: center;"><@spring.message code='common.text.no-data' /></td>
</tr>
</#if>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- 删除确认弹出层 -->
<div class="modal fade" id="removePostModal">
<div class="modal-dialog">
<div class="modal-content message_align">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"><@spring.message code='common.text.tips' /></h4>
</div>
<div class="modal-body">
<p id="message"></p>
</div>
<div class="modal-footer">
<input type="hidden" id="url"/>
<button type="button" class="btn btn-default" data-dismiss="modal"><@spring.message code='common.btn.cancel' /></button>
<a onclick="removeIt()" class="btn btn-danger" data-dismiss="modal"><@spring.message code='common.btn.define' /></a>
</div>
</div>
</div>
</div>
<script>
function modelShow(url,message) {
$('#url').val(url);
$('#message').html(message);
$('#removePostModal').modal();
}
function removeIt(){
var url=$.trim($("#url").val());
window.location.href=url;
}
</script>
</div>
<@footer></@footer>
</#compress>

View File

@ -5,7 +5,7 @@
<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">
<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-fullscreen,.editor-toolbar.fullscreen{z-index: 1030;}
.CodeMirror, .CodeMirror-scroll {min-height: 480px;}
@ -37,7 +37,7 @@
<input type="hidden" id="postId" name="postId" value="">
</#if>
<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 style="display: block;margin-bottom: 10px;">
<span>
@ -215,24 +215,20 @@
$(this).hide();
$('#btn_change_postUrl').show();
});
var postTitle = $("#post_title");
/**
* 提交文章
* @param status 文章状态
*/
function push(status) {
var Title = "";
if(postTitle.val()){
Title = postTitle.val();
}else{
var postTitle = $("#postTitle");
var postUrl = $("#postUrl");
if(!postTitle.val()){
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
return;
}
$('input[name="categories"]:checked').each(function(){
cateList.push($(this).val());
});
if($('#postUrl').html()===""){
if(!postUrl.html()){
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
return;
}
@ -240,8 +236,8 @@
$.post('/admin/page/new/push',{
'postId': $('#postId').val(),
'postStatus': status,
'postTitle': Title,
'postUrl' : $('#postUrl').html().toString(),
'postTitle': postTitle.val(),
'postUrl' : postUrl.html().toString(),
'postContentMd': simplemde.value(),
'postThumbnail': $('#selectImg').attr('src'),
'allowComment' : $('#allowComment').val(),

View File

@ -273,33 +273,31 @@
$(this).hide();
$('#btn_change_postUrl').show();
});
var postTitle = $("#postTitle");
var cateList = new Array();
/**
* 提交文章
* @param status 文章状态
*/
function push(status) {
var Title = "";
if(postTitle.val()){
Title = postTitle.val();
}else{
var postTitle = $("#postTitle");
var postUrl = $("#postUrl");
var cateList = new Array();
if(!postTitle.val()){
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
return;
}
if(!postUrl.html()){
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
return;
}
$('input[name="categories"]:checked').each(function(){
cateList.push($(this).val());
});
if($('#postUrl').html()===""){
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
return;
}
$.post('/admin/posts/update',{
'postId': $('#postId').val(),
'postStatus': status,
'postTitle': Title,
'postUrl' : $('#postUrl').html().toString(),
'postTitle': postTitle.val(),
'postUrl' : postUrl.html().toString(),
'postContentMd': simplemde.value(),
'postThumbnail': $('#selectImg').attr('src'),
'cateList' : cateList.toString(),

View File

@ -249,32 +249,30 @@
$(this).hide();
$('#btn_change_postUrl').show();
});
var postTitle = $("#postTitle");
var cateList = new Array();
/**
* 提交文章
* @param status 文章状态
*/
function push(status) {
var Title = "";
if(postTitle.val()){
Title = postTitle.val();
}else{
var postTitle = $("#postTitle");
var postUrl = $("#postUrl");
var cateList = new Array();
if(!postTitle.val()){
halo.showMsg("<@spring.message code='admin.editor.js.no-title' />",'info',2000);
return;
}
if(!postUrl.html()){
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
return;
}
$('input[name="categories"]:checked').each(function(){
cateList.push($(this).val());
});
if($('#postUrl').html()===""){
halo.showMsg("<@spring.message code='admin.editor.js.no-url' />",'info',2000);
return;
}
$.post('/admin/posts/save',{
'postStatus': status,
'postTitle': Title,
'postUrl' : $('#postUrl').html().toString(),
'postTitle': postTitle.val(),
'postUrl' : postUrl.html().toString(),
'postContentMd': simplemde.value(),
'postThumbnail': $('#selectImg').attr('src'),
'cateList' : cateList.toString(),