👽 修复文章不可修改的问题

pull/18/head
RYAN0UP_ 2018-05-10 11:58:55 +08:00
parent bcfe0c9f5a
commit e406219701
12 changed files with 112 additions and 29 deletions

View File

@ -150,7 +150,7 @@ public class AttachmentController {
System.out.println(mediaPath.getAbsolutePath() + "/" + fileName); System.out.println(mediaPath.getAbsolutePath() + "/" + fileName);
//判断图片大小如果长宽都小于500则保存原始图片路径 //判断图片大小如果长宽都小于500则保存原始图片路径
BufferedImage sourceImg = ImageIO.read(new FileInputStream(mediaPath.getPath() + "/" + fileName)); BufferedImage sourceImg = ImageIO.read(new FileInputStream(mediaPath.getPath() + "/" + fileName));
if (sourceImg.getWidth() < 500 && sourceImg.getHeight() < 500) { if (sourceImg.getWidth() < 500 || sourceImg.getHeight() < 500) {
attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(fileName).toString()); attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(fileName).toString());
} else { } else {
attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(nameWithOutSuffix).append("_small.").append(fileSuffix).toString()); attachment.setAttachSmallPath(new StringBuffer("/upload/").append(HaloUtil.YEAR).append("/").append(HaloUtil.MONTH).append("/").append(nameWithOutSuffix).append("_small.").append(fileSuffix).toString());

View File

@ -130,6 +130,22 @@ public class PostController extends BaseController{
return "admin/admin_post_md_editor"; return "admin/admin_post_md_editor";
} }
/**
* htmlhtm
*
* @param url url
* @return String
*/
private static String urlFilter(String url) {
if (null != url) {
final boolean urlEndsWithHtmlPostFix = url.endsWith(".html") || url.endsWith(".htm");
if (urlEndsWithHtmlPostFix) {
return url.substring(0, url.lastIndexOf("."));
}
}
return url;
}
/** /**
* *
* *
@ -141,15 +157,7 @@ public class PostController extends BaseController{
@PostMapping(value = "/new/push") @PostMapping(value = "/new/push")
@ResponseBody @ResponseBody
public void pushPost(@ModelAttribute Post post, @RequestParam("cateList") List<String> cateList, @RequestParam("tagList") String tagList, HttpSession session){ 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); User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
if(null==user){
return;
}
//判断是否为更新文章操作
if(null!=post.getPostId()){
post = postService.findByPostId(post.getPostId()).get();
}
try{ try{
//提取摘要 //提取摘要
int postSummary = 50; int postSummary = 50;
@ -164,6 +172,7 @@ public class PostController extends BaseController{
post.setPostSummary(summaryText); post.setPostSummary(summaryText);
} }
if(null!=post.getPostId()){ if(null!=post.getPostId()){
post.setPostDate(postService.findByPostId(post.getPostId()).get().getPostDate());
post.setPostUpdate(HaloUtil.getDate()); post.setPostUpdate(HaloUtil.getDate());
}else{ }else{
post.setPostDate(HaloUtil.getDate()); post.setPostDate(HaloUtil.getDate());
@ -180,20 +189,10 @@ public class PostController extends BaseController{
postService.saveByPost(post); postService.saveByPost(post);
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST,post.getPostTitle(),HaloUtil.getIpAddr(request),HaloUtil.getDate())); logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST,post.getPostTitle(),HaloUtil.getIpAddr(request),HaloUtil.getDate()));
}catch (Exception e){ }catch (Exception e){
log.error("未知错误:{0}",e.getMessage()); log.error("未知错误:", e.getMessage());
} }
} }
private static String urlFilter(String url) {
if (null != url) {
final boolean urlEndsWithHtmlPostFix = url.endsWith(".html") || url.endsWith(".htm");
if (urlEndsWithHtmlPostFix) {
return url.substring(0, url.lastIndexOf("."));
}
}
return url;
}
/** /**
* *

View File

@ -29,7 +29,7 @@ import java.util.List;
@Slf4j @Slf4j
@Controller @Controller
@RequestMapping(value = "/archives") @RequestMapping(value = "/archives")
public class ArchivesController extends BaseController { public class FrontArchiveController extends BaseController {
@Autowired @Autowired
private PostService postService; private PostService postService;

View File

@ -27,7 +27,7 @@ import java.util.List;
*/ */
@Controller @Controller
@RequestMapping(value = "categories") @RequestMapping(value = "categories")
public class CategoriesController extends BaseController { public class FrontCategoryController extends BaseController {
@Autowired @Autowired
private CategoryService categoryService; private CategoryService categoryService;

View File

@ -28,7 +28,7 @@ import java.util.*;
*/ */
@Slf4j @Slf4j
@Controller @Controller
public class CommentsController { public class FrontCommentController {
@Autowired @Autowired
private CommentService commentService; private CommentService commentService;

View File

@ -29,7 +29,7 @@ import java.util.List;
@Slf4j @Slf4j
@Controller @Controller
@RequestMapping(value = {"/", "index"}) @RequestMapping(value = {"/", "index"})
public class IndexController extends BaseController { public class FrontIndexController extends BaseController {
@Autowired @Autowired
private PostService postService; private PostService postService;

View File

@ -21,7 +21,7 @@ import java.util.List;
* @date : 2018/4/26 * @date : 2018/4/26
*/ */
@Controller @Controller
public class OthersController { public class FrontOthersController {
@Autowired @Autowired
private PostService postService; private PostService postService;

View File

@ -28,7 +28,7 @@ import java.util.List;
* @date : 2018/4/26 * @date : 2018/4/26
*/ */
@Controller @Controller
public class PagesController extends BaseController { public class FrontPageController extends BaseController {
@Autowired @Autowired
private GalleryService galleryService; private GalleryService galleryService;
@ -85,6 +85,6 @@ public class PagesController extends BaseController {
model.addAttribute("comments",comments); model.addAttribute("comments",comments);
model.addAttribute("post", post); model.addAttribute("post", post);
return this.render("post"); return this.render("page");
} }
} }

View File

@ -27,7 +27,7 @@ import java.util.List;
*/ */
@Controller @Controller
@RequestMapping(value = "/tags") @RequestMapping(value = "/tags")
public class TagsController extends BaseController { public class FrontTagController extends BaseController {
@Autowired @Autowired
private TagService tagService; private TagService tagService;

View File

@ -0,0 +1,57 @@
<#include "module/macro.ftl">
<@head title="${post.postTitle} · ${options.blog_title?default('Anatole')}" keywords="${post.postTitle},${options.seo_keywords?default('Anatole')}" description="${post.postSummary?if_exists}"></@head>
<#include "module/sidebar.ftl">
<div class="main">
<link href="/anatole/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
<style>
code, tt {
font-size: 1.2em;
}
</style>
<#include "module/page-top.ftl">
<div class="autopagerize_page_element">
<div class="content">
<div class="post-page">
<div class="post animated fadeInDown">
<div class="post-title">
<h3>
<a>${post.postTitle}</a>
</h3>
</div>
<div class="post-content">
${post.postContent}
</div>
<div class="post-footer">
<div class="meta">
<div class="info">
<i class="fa fa-sun-o"></i>
<span class="date">${post.postDate?string("yyyy-MM-dd")}</span>
<i class="fa fa-comment-o"></i>
<a href="/archives/${post.postUrl}#comment_widget">Comments</a>
</div>
</div>
</div>
</div>
<div class="share">
<div class="evernote">
<a href="javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();"
ref="nofollow" target="_blank" class="fa fa-bookmark"></a>
</div>
<div class="weibo">
<a href="javascript:void((function(s,d,e){try{}catch(e){}var f='http://service.weibo.com/share/share.php?',u=d.location.href,p=['url=',e(u),'&title=',e(d.title),'&appkey=2924220432'].join('');function a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=620,height=450,left=',(s.width-620)/2,',top=',(s.height-450)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})(screen,document,encodeURIComponent));"
class="fa fa-weibo"></a>
</div>
<div class="twitter">
<a href="http://twitter.com/home?status=${options.blog_url}/archives/${post.postUrl} ,${options.blog_title?if_exists},${post.postTitle},;"
class="fa fa-twitter"></a>
</div>
</div>
<div id="comment_widget">
<#include "module/comment.ftl">
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="/anatole/source/plugins/prism/prism.js"></script>
<@footer></@footer>

View File

@ -0,0 +1,27 @@
<#include "module/macro.ftl">
<@layout title="${post.postTitle?if_exists} | ${options.blog_title?default('Material')}" keywords="${options.seo_keywords?default('Material')}" description="${post.postSummary?if_exists}">
<!-- Post Module -->
<div class="material-post_container">
<div class="material-post mdl-grid">
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">
<!-- Post Header(Thumbnail & Title) -->
<#include "_partial/post-header.ftl">
<#if options.theme_material_scheme?if_exists == "Paradox">
<!-- Paradox Post Info -->
<#include "_partial/Paradox-post-info.ftl">
</#if>
<!-- Post Content -->
<#include "_partial/post-content.ftl">
<#if options.theme_material_scheme?if_exists == "Isolation">
<#include "_partial/Isolation-post-info.ftl">
</#if>
<#include "_partial/comment.ftl">
</div>
</div>
</div>
</@layout>

View File

@ -1,5 +1,5 @@
<#include "module/macro.ftl"> <#include "module/macro.ftl">
<@layout title="${post.postTitle?if_exists} | ${options.blog_title?default('Material')}" keywords="${options.seo_keywords?default('Material')}" description="${options.seo_desc?default('Material')}"> <@layout title="${post.postTitle?if_exists} | ${options.blog_title?default('Material')}" keywords="${options.seo_keywords?default('Material')}" description="${post.postSummary?if_exists}">
<!-- Post Module --> <!-- Post Module -->
<div class="material-post_container"> <div class="material-post_container">
<div class="material-post mdl-grid"> <div class="material-post mdl-grid">