mirror of https://github.com/halo-dev/halo
👽 初步搞了一下页面系统,修改了很多Service
parent
2967569f32
commit
42ff37b6c2
|
@ -35,4 +35,8 @@ public class HaloConst {
|
|||
* user_session
|
||||
*/
|
||||
public static String USER_SESSION_KEY = "user_session";
|
||||
|
||||
public static String POST_TYPE_POST = "post";
|
||||
|
||||
public static String POST_TYPE_PAGE = "page";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.ryanc.halo.model.tag;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.*;
|
||||
|
@ -29,7 +30,7 @@ public class ArticleTagDirective implements TemplateDirectiveModel {
|
|||
String method = map.get(METHOD_KEY).toString();
|
||||
switch (method){
|
||||
case "postsCount":
|
||||
environment.setVariable("postsCount",builder.build().wrap(postService.findAllPosts().size()));
|
||||
environment.setVariable("postsCount",builder.build().wrap(postService.findAllPosts(HaloConst.POST_TYPE_POST).size()));
|
||||
break;
|
||||
case "archives":
|
||||
environment.setVariable("archives",builder.build().wrap(postService.findPostGroupByYearAndMonth()));
|
||||
|
|
|
@ -25,17 +25,25 @@ public interface PostRepository extends JpaRepository<Post,Long>{
|
|||
*
|
||||
* @return list
|
||||
*/
|
||||
@Query(value = "SELECT * FROM halo_post ORDER BY post_date DESC LIMIT 5",nativeQuery = true)
|
||||
@Query(value = "SELECT * FROM halo_post where post_type='post' ORDER BY post_date DESC LIMIT 5",nativeQuery = true)
|
||||
List<Post> findTopFive();
|
||||
|
||||
/**
|
||||
* 查询所有文章 根据文章类型
|
||||
*
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
List<Post> findPostsByPostType(String postType);
|
||||
|
||||
/**
|
||||
* 分页查询文章
|
||||
*
|
||||
* @param pageable pageable
|
||||
* @return page
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
@Override
|
||||
Page<Post> findAll(Pageable pageable);
|
||||
Page<Post> findPostsByPostType(String postType,Pageable pageable);
|
||||
|
||||
/**
|
||||
* 模糊查询
|
||||
|
@ -49,19 +57,21 @@ public interface PostRepository extends JpaRepository<Post,Long>{
|
|||
/**
|
||||
* 根据文章的状态查询 分页
|
||||
*
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
* @return page
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
Page<Post> findPostsByPostStatus(Integer status,Pageable pageable);
|
||||
Page<Post> findPostsByPostStatusAndPostType(Integer status,String postType,Pageable pageable);
|
||||
|
||||
/**
|
||||
* 根据文章的状态查询
|
||||
*
|
||||
* @param status status
|
||||
* @return List
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
List<Post> findPostsByPostStatus(Integer status);
|
||||
List<Post> findPostsByPostStatusAndPostType(Integer status,String postType);
|
||||
|
||||
/**
|
||||
* 根据路径查询文章
|
||||
|
@ -74,35 +84,37 @@ public interface PostRepository extends JpaRepository<Post,Long>{
|
|||
/**
|
||||
* 查询之后文章
|
||||
*
|
||||
* @param postDate postDate
|
||||
* @param postStatus postStatus
|
||||
* @return list
|
||||
* @param postDate 发布时间
|
||||
* @param postStatus 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
List<Post> findByPostDateAfterAndPostStatusOrderByPostDateDesc(Date postDate, Integer postStatus);
|
||||
List<Post> findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(Date postDate, Integer postStatus,String postType);
|
||||
|
||||
|
||||
/**
|
||||
* 查询之前的文章
|
||||
*
|
||||
* @param postDate postDate
|
||||
* @param postStatus postStatus
|
||||
* @return list
|
||||
* @param postDate 发布时间
|
||||
* @param postStatus 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
List<Post> findByPostDateBeforeAndPostStatusOrderByPostDateAsc(Date postDate,Integer postStatus);
|
||||
List<Post> findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(Date postDate,Integer postStatus,String postType);
|
||||
|
||||
/**
|
||||
* 查询文章归档信息 根据年份和月份
|
||||
*
|
||||
* @return list
|
||||
* @return List<Object[]></>
|
||||
*/
|
||||
@Query(value = "select year(post_date) as year,month(post_date) as month,count(*) as count from halo_post where post_status=0 group by year(post_date),month(post_date) order by year desc,month desc",nativeQuery = true)
|
||||
@Query(value = "select year(post_date) as year,month(post_date) as month,count(*) as count from halo_post where post_status=0 and post_type='post' group by year(post_date),month(post_date) order by year desc,month desc",nativeQuery = true)
|
||||
List<Object[]> findPostGroupByYearAndMonth();
|
||||
|
||||
/**
|
||||
* 查询文章归档信息 根据年份
|
||||
* @return
|
||||
* @return List<Object[]></>
|
||||
*/
|
||||
@Query(value = "select year(post_date) as year,count(*) as count from halo_post where post_status=0 group by year(post_date) order by year desc",nativeQuery = true)
|
||||
@Query(value = "select year(post_date) as year,count(*) as count from halo_post where post_status=0 and post_type='post' group by year(post_date) order by year desc",nativeQuery = true)
|
||||
List<Object[]> findPostGroupByYear();
|
||||
|
||||
/**
|
||||
|
@ -110,18 +122,18 @@ public interface PostRepository extends JpaRepository<Post,Long>{
|
|||
*
|
||||
* @param year year
|
||||
* @param month month
|
||||
* @return list
|
||||
* @return List<Post></>
|
||||
*/
|
||||
@Query(value = "select *,year(post_date) as year,month(post_date) as month from halo_post where post_status=0 and year(post_date)=:year and month(post_date)=:month order by post_date desc",nativeQuery = true)
|
||||
@Query(value = "select *,year(post_date) as year,month(post_date) as month from halo_post where post_status=0 and post_type='post' and year(post_date)=:year and month(post_date)=:month order by post_date desc",nativeQuery = true)
|
||||
List<Post> findPostByYearAndMonth(@Param("year") String year,@Param("month") String month);
|
||||
|
||||
/**
|
||||
* 根据年份查询文章
|
||||
*
|
||||
* @param year year
|
||||
* @return list
|
||||
* @return List<Post></>
|
||||
*/
|
||||
@Query(value = "select *,year(post_date) as year from halo_post where post_status=0 and year(post_date)=:year order by post_date desc",nativeQuery = true)
|
||||
@Query(value = "select *,year(post_date) as year from halo_post where post_status=0 and post_type='post' and year(post_date)=:year order by post_date desc",nativeQuery = true)
|
||||
List<Post> findPostByYear(@Param("year") String year);
|
||||
|
||||
/**
|
||||
|
@ -130,9 +142,9 @@ public interface PostRepository extends JpaRepository<Post,Long>{
|
|||
* @param year year
|
||||
* @param month month
|
||||
* @param pageable pageable
|
||||
* @return page
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
@Query(value = "select * from halo_post where post_status=0 and year(post_date)=:year and month(post_date)=:month order by post_date desc",countQuery = "select count(*) from halo_post where post_status=0 and year(post_date)=:year and month(post_date)=:month",nativeQuery = true)
|
||||
@Query(value = "select * from halo_post where post_status=0 and post_type='post' and year(post_date)=:year and month(post_date)=:month order by post_date desc",countQuery = "select count(*) from halo_post where post_status=0 and year(post_date)=:year and month(post_date)=:month",nativeQuery = true)
|
||||
Page<Post> findPostByYearAndMonth(@Param("year") String year,@Param("month") String month,Pageable pageable);
|
||||
|
||||
List<Post> findPostByCategories(Category category);
|
||||
|
|
|
@ -35,14 +35,6 @@ public interface PostService {
|
|||
*/
|
||||
Post removeByPostId(Long postId);
|
||||
|
||||
/**
|
||||
* 修改文章
|
||||
*
|
||||
* @param post Post
|
||||
* @return Post
|
||||
*/
|
||||
Post updateByPost(Post post);
|
||||
|
||||
/**
|
||||
* 修改文章状态
|
||||
*
|
||||
|
@ -62,17 +54,19 @@ public interface PostService {
|
|||
/**
|
||||
* 获取文章列表 分页
|
||||
*
|
||||
* @param pageable Pageable
|
||||
* @return Page
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
Page<Post> findAllPosts(Pageable pageable);
|
||||
Page<Post> findAllPosts(String postType,Pageable pageable);
|
||||
|
||||
/**
|
||||
* 获取文章列表 不分页
|
||||
*
|
||||
* @return List
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
List<Post> findAllPosts();
|
||||
List<Post> findAllPosts(String postType);
|
||||
|
||||
/**
|
||||
* 模糊查询文章
|
||||
|
@ -86,19 +80,21 @@ public interface PostService {
|
|||
/**
|
||||
* 根据文章状态查询 分页
|
||||
*
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
* @return page
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
Page<Post> findPostByStatus(Integer status,Pageable pageable);
|
||||
Page<Post> findPostByStatus(Integer status,String postType,Pageable pageable);
|
||||
|
||||
/**
|
||||
* 根据文章状态查询
|
||||
*
|
||||
* @param status status
|
||||
* @return list
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
List<Post> findPostByStatus(Integer status);
|
||||
List<Post> findPostByStatus(Integer status,String postType);
|
||||
|
||||
/**
|
||||
* 根据编号查询文章
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.ryanc.halo.service.impl;
|
|||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.Tag;
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.repository.PostRepository;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.util.HaloUtil;
|
||||
|
@ -53,17 +54,6 @@ public class PostServiceImpl implements PostService {
|
|||
return post.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章
|
||||
*
|
||||
* @param post Post
|
||||
* @return post
|
||||
*/
|
||||
@Override
|
||||
public Post updateByPost(Post post) {
|
||||
return postRepository.save(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章状态
|
||||
*
|
||||
|
@ -85,7 +75,7 @@ public class PostServiceImpl implements PostService {
|
|||
*/
|
||||
@Override
|
||||
public void updateAllSummary(Integer postSummary) {
|
||||
List<Post> posts = this.findAllPosts();
|
||||
List<Post> posts = this.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||
for(Post post:posts){
|
||||
if(!(HaloUtil.htmlToText(post.getPostContent()).length()<postSummary)){
|
||||
post.setPostSummary(HaloUtil.getSummary(post.getPostContent(),postSummary));
|
||||
|
@ -95,24 +85,26 @@ public class PostServiceImpl implements PostService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 查询所有文章 分页
|
||||
* 获取文章列表 分页
|
||||
*
|
||||
* @param pageable Pageable
|
||||
* @return Page
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
@Override
|
||||
public Page<Post> findAllPosts(Pageable pageable) {
|
||||
return postRepository.findAll(pageable);
|
||||
public Page<Post> findAllPosts(String postType,Pageable pageable) {
|
||||
return postRepository.findPostsByPostType(postType,pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有文章 不分页
|
||||
* 获取文章列表 不分页
|
||||
*
|
||||
* @return List
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
@Override
|
||||
public List<Post> findAllPosts() {
|
||||
return postRepository.findAll();
|
||||
public List<Post> findAllPosts(String postType) {
|
||||
return postRepository.findPostsByPostType(postType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,26 +120,28 @@ public class PostServiceImpl implements PostService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 根据状态分页查询文章
|
||||
* 根据文章状态查询 分页
|
||||
*
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
* @return page
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
* @return Page<Post></>
|
||||
*/
|
||||
@Override
|
||||
public Page<Post> findPostByStatus(Integer status, Pageable pageable) {
|
||||
return postRepository.findPostsByPostStatus(status,pageable);
|
||||
public Page<Post> findPostByStatus(Integer status,String postType, Pageable pageable) {
|
||||
return postRepository.findPostsByPostStatusAndPostType(status,postType,pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态查询文章
|
||||
* 根据文章状态查询
|
||||
*
|
||||
* @param status status
|
||||
* @return list
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List<Post></>
|
||||
*/
|
||||
@Override
|
||||
public List<Post> findPostByStatus(Integer status) {
|
||||
return postRepository.findPostsByPostStatus(status);
|
||||
public List<Post> findPostByStatus(Integer status,String postType) {
|
||||
return postRepository.findPostsByPostStatusAndPostType(status,postType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +184,7 @@ public class PostServiceImpl implements PostService {
|
|||
*/
|
||||
@Override
|
||||
public List<Post> findByPostDateAfter(Date postDate) {
|
||||
return postRepository.findByPostDateAfterAndPostStatusOrderByPostDateDesc(postDate,0);
|
||||
return postRepository.findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(postDate,0,HaloConst.POST_TYPE_POST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,7 +195,7 @@ public class PostServiceImpl implements PostService {
|
|||
*/
|
||||
@Override
|
||||
public List<Post> findByPostDateBefore(Date postDate) {
|
||||
return postRepository.findByPostDateBeforeAndPostStatusOrderByPostDateAsc(postDate,0);
|
||||
return postRepository.findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(postDate,0,HaloConst.POST_TYPE_POST);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class AdminController extends BaseController{
|
|||
@GetMapping(value = {"","/index"})
|
||||
public String index(Model model,HttpSession session){
|
||||
//查询文章条数
|
||||
Integer postCount = postService.findAllPosts().size();
|
||||
Integer postCount = postService.findAllPosts(HaloConst.POST_TYPE_POST).size();
|
||||
model.addAttribute("postCount",postCount);
|
||||
|
||||
//查询评论的条数
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.web.controller.admin;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.util.HaloUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -73,7 +74,7 @@ public class BackupController {
|
|||
*/
|
||||
@GetMapping(value = "/backupPost")
|
||||
public String backupPosts(){
|
||||
List<Post> posts = postService.findAllPosts();
|
||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_POST);
|
||||
try {
|
||||
File path = new File(ResourceUtils.getURL("classpath:").getPath());
|
||||
String savePath = path.getAbsolutePath()+"/backup/posts/posts_backup_"+HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss");
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package cc.ryanc.halo.web.controller.admin;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Gallery;
|
||||
import cc.ryanc.halo.model.domain.Link;
|
||||
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.GalleryService;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.util.HaloUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
@ -16,6 +19,8 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.websocket.server.PathParam;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -37,6 +42,15 @@ public class PageController {
|
|||
@Autowired
|
||||
private GalleryService galleryService;
|
||||
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
@Autowired
|
||||
private LogsService logsService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* 页面管理页面
|
||||
*
|
||||
|
@ -44,7 +58,9 @@ public class PageController {
|
|||
* @return 模板路径admin/admin_page
|
||||
*/
|
||||
@GetMapping
|
||||
public String pages(){
|
||||
public String pages(Model model){
|
||||
List<Post> posts = postService.findAllPosts(HaloConst.POST_TYPE_PAGE);
|
||||
model.addAttribute("pages",posts);
|
||||
return "admin/admin_page";
|
||||
}
|
||||
|
||||
|
@ -182,4 +198,36 @@ public class PageController {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转到新建页面
|
||||
*
|
||||
* @return 模板路径
|
||||
*/
|
||||
@GetMapping(value = "/new")
|
||||
public String newPage(Model model){
|
||||
return "admin/admin_page_md_editor";
|
||||
}
|
||||
|
||||
/**
|
||||
* 发表页面
|
||||
* @param post post
|
||||
* @param session session
|
||||
*/
|
||||
@PostMapping(value = "/new/push")
|
||||
@ResponseBody
|
||||
public void pushPage(@ModelAttribute Post post, HttpSession session){
|
||||
try{
|
||||
post.setPostDate(HaloUtil.getDate());
|
||||
//发表用户
|
||||
User user = (User)session.getAttribute(HaloConst.USER_SESSION_KEY);
|
||||
post.setUser(user);
|
||||
post.setPostType(HaloConst.POST_TYPE_PAGE);
|
||||
postService.saveByPost(post);
|
||||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST,post.getPostTitle(),HaloUtil.getIpAddr(request),HaloUtil.getDate()));
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,11 +67,11 @@ public class PostController extends BaseController{
|
|||
@RequestParam(value = "size",defaultValue = "10") Integer size){
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
||||
Pageable pageable = new PageRequest(page,size,sort);
|
||||
Page<Post> posts = postService.findPostByStatus(status,pageable);
|
||||
Page<Post> posts = postService.findPostByStatus(status,HaloConst.POST_TYPE_POST,pageable);
|
||||
model.addAttribute("posts",posts);
|
||||
model.addAttribute("publishCount",postService.findPostByStatus(0,pageable).getTotalElements());
|
||||
model.addAttribute("draftCount",postService.findPostByStatus(1,pageable).getTotalElements());
|
||||
model.addAttribute("trashCount",postService.findPostByStatus(2,pageable).getTotalElements());
|
||||
model.addAttribute("publishCount",postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable).getTotalElements());
|
||||
model.addAttribute("draftCount",postService.findPostByStatus(1,HaloConst.POST_TYPE_POST,pageable).getTotalElements());
|
||||
model.addAttribute("trashCount",postService.findPostByStatus(2,HaloConst.POST_TYPE_POST,pageable).getTotalElements());
|
||||
model.addAttribute("status",status);
|
||||
return "admin/admin_post";
|
||||
}
|
||||
|
@ -127,8 +127,7 @@ public class PostController extends BaseController{
|
|||
List<Tag> tags = tagService.findAllTags();
|
||||
model.addAttribute("categories",categories);
|
||||
model.addAttribute("tags",tags);
|
||||
model.addAttribute("btnPush","发布");
|
||||
return "admin/admin_editor";
|
||||
return "admin/admin_post_md_editor";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,11 +236,10 @@ public class PostController extends BaseController{
|
|||
model.addAttribute("post",post.get());
|
||||
List<Category> categories = categoryService.findAllCategories();
|
||||
model.addAttribute("categories",categories);
|
||||
model.addAttribute("btnPush","更新");
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "admin/admin_editor";
|
||||
return "admin/admin_post_md_editor";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.web.controller.front;
|
||||
|
||||
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;
|
||||
|
@ -56,7 +57,7 @@ public class ArchivesController extends BaseController {
|
|||
//所有文章数据,分页,material主题适用
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
||||
Pageable pageable = new PageRequest(page-1,5,sort);
|
||||
Page<Post> posts = postService.findPostByStatus(0,pageable);
|
||||
Page<Post> posts = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
||||
model.addAttribute("posts",posts);
|
||||
return this.render("archives");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package cc.ryanc.halo.web.controller.front;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.web.controller.core.BaseController;
|
||||
|
@ -66,7 +65,7 @@ public class IndexController extends BaseController {
|
|||
}
|
||||
//所有文章数据,分页
|
||||
Pageable pageable = new PageRequest(page-1,size,sort);
|
||||
Page<Post> posts = postService.findPostByStatus(0,pageable);
|
||||
Page<Post> posts = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
||||
model.addAttribute("posts",posts);
|
||||
|
||||
return this.render("index");
|
||||
|
@ -91,7 +90,7 @@ public class IndexController extends BaseController {
|
|||
|
||||
//文章数据,只获取文章,没有分页
|
||||
Pageable pageable = new PageRequest(page-1,size,sort);
|
||||
List<Post> posts = postService.findPostByStatus(0,pageable).getContent();
|
||||
List<Post> posts = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable).getContent();
|
||||
return posts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.springframework.data.domain.Page;
|
|||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
@ -42,7 +41,7 @@ public class OthersController {
|
|||
//获取文章列表并根据时间排序
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
||||
Pageable pageable = new PageRequest(0,Integer.parseInt(rssPosts),sort);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0,pageable);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
||||
List<Post> posts = postsPage.getContent();
|
||||
return postService.buildRss(posts);
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ public class OthersController {
|
|||
//获取文章列表并根据时间排序
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"postDate");
|
||||
Pageable pageable = new PageRequest(0,999,sort);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0,pageable);
|
||||
Page<Post> postsPage = postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable);
|
||||
List<Post> posts = postsPage.getContent();
|
||||
return postService.buildSiteMap(posts);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package cc.ryanc.halo.web.controller.front;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Gallery;
|
||||
import cc.ryanc.halo.model.domain.Link;
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -69,4 +70,18 @@ public class PagesController extends BaseController {
|
|||
model.addAttribute("links",links);
|
||||
return this.render("links");
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染自定义页面
|
||||
*
|
||||
* @param postUrl 页面路径
|
||||
* @param model model
|
||||
* @return 模板路径/themes/{theme}/post
|
||||
*/
|
||||
@GetMapping(value = "/{postUrl}")
|
||||
public String getPage(@PathVariable String postUrl,Model model){
|
||||
Post post = postService.findByPostUrl(postUrl);
|
||||
model.addAttribute("post",post);
|
||||
return this.render("post");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package cc.ryanc.halo.web.controller.front;
|
|||
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.Tag;
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cc.ryanc.halo.service.TagService;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<td><a href="${comment.commentAuthorUrl}" target="_blank">${comment.commentAuthor}</a></td>
|
||||
<td>${comment.commentContent}</td>
|
||||
<td>
|
||||
<a target="_blank" href="/article/${comment.post.postUrl}">${comment.post.postTitle}</a>
|
||||
<a target="_blank" href="/archives/${comment.post.postUrl}">${comment.post.postTitle}</a>
|
||||
</td>
|
||||
<td>${comment.commentDate}</td>
|
||||
<td>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<#if (options.post_editor?default('editor.md'))=='editor.md'>
|
||||
<#include "admin_md-editor.ftl">
|
||||
<#else >
|
||||
<#include "admin_rt-editor.ftl">
|
||||
</#if>
|
|
@ -14,7 +14,7 @@
|
|||
</style>
|
||||
<section class="content-header">
|
||||
<h1 style="display: inline-block;">页面<small></small></h1>
|
||||
<a id="btnNewPage" href="/admin/posts/new">
|
||||
<a id="btnNewPage" href="/admin/page/new">
|
||||
新建页面
|
||||
</a>
|
||||
<ol class="breadcrumb">
|
||||
|
@ -79,37 +79,33 @@
|
|||
</div>
|
||||
<div class="tab-pane" id="pages">
|
||||
<div class="box-body table-responsive">
|
||||
开发中...
|
||||
<#--<table class="table table-bordered table-hover">-->
|
||||
<#--<thead>-->
|
||||
<#--<tr>-->
|
||||
<#--<th>标题</th>-->
|
||||
<#--<th>路径</th>-->
|
||||
<#--<th>日期</th>-->
|
||||
<#--<th>操作</th>-->
|
||||
<#--</tr>-->
|
||||
<#--</thead>-->
|
||||
<#--<tbody>-->
|
||||
<#--<tr>-->
|
||||
<#--<td>友情链接</td>-->
|
||||
<#--<td>/link</td>-->
|
||||
<#--<th>日期</th>-->
|
||||
<#--<td>-->
|
||||
<#--<a href="/links" class="btn btn-info btn-xs " target="_blank">预览</a>-->
|
||||
<#--<a href="/admin/page/links" class="btn btn-primary btn-xs ">配置</a>-->
|
||||
<#--</td>-->
|
||||
<#--</tr>-->
|
||||
<#--<tr>-->
|
||||
<#--<td>关于页面</td>-->
|
||||
<#--<td>/about</td>-->
|
||||
<#--<th>日期</th>-->
|
||||
<#--<td>-->
|
||||
<#--<a href="#" class="btn btn-info btn-xs " target="_blank">预览</a>-->
|
||||
<#--<a href="/admin/page/about" class="btn btn-primary btn-xs ">配置</a>-->
|
||||
<#--</td>-->
|
||||
<#--</tr>-->
|
||||
<#--</tbody>-->
|
||||
<#--</table>-->
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>标题</th>
|
||||
<th>路径</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#if pages?size gt 0>
|
||||
<#list pages as page>
|
||||
<tr>
|
||||
<td>${page.postTitle}</td>
|
||||
<td>${page.postUrl}</td>
|
||||
<td>
|
||||
<a href="/${page.postUrl}" class="btn btn-info btn-xs " target="_blank">预览</a>
|
||||
<a data-pjax="true" href="#" class="btn btn-primary btn-xs ">编辑</a>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#else>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center;">暂无页面</td>
|
||||
</tr>
|
||||
</#if>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,246 @@
|
|||
<#include "module/_macro.ftl">
|
||||
<@head title="${options.blog_title} | 后台管理:页面编辑"></@head>
|
||||
<div class="wrapper">
|
||||
<!-- 顶部栏模块 -->
|
||||
<#include "module/_header.ftl">
|
||||
<!-- 菜单栏模块 -->
|
||||
<#include "module/_sidebar.ftl">
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<link rel="stylesheet" href="/static/plugins/toast/css/jquery.toast.min.css">
|
||||
<link rel="stylesheet" href="/static/plugins/editor.md/css/editormd.min.css">
|
||||
<style type="text/css">
|
||||
#post_title{
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
新建页面
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a data-pjax="true" href="#"><i class="fa fa-dashboard"></i> 首页</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-pjax="true" href="/admin/page">页面</a>
|
||||
</li>
|
||||
<li class="active">新建页面</li>
|
||||
</ol>
|
||||
</section>
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<#if post??>
|
||||
<input type="hidden" id="postId" name="postId" value="${post.postId}">
|
||||
</#if>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<input type="text" class="form-control input-lg" id="post_title" name="post_title" placeholder="请输入页面标题" value="<#if post??>${post.postTitle}</#if>">
|
||||
</div>
|
||||
<div style="display: block;margin-bottom: 10px;">
|
||||
<span>
|
||||
永久链接:
|
||||
<a href="#">${options.blog_url}/<span id="postUrl"><#if post??>${post.postUrl}</#if></span>/</a>
|
||||
<button class="btn btn-default btn-sm " id="btn_input_postUrl">编辑</button>
|
||||
<button class="btn btn-default btn-sm " id="btn_change_postUrl" onclick="UrlOnBlurAuto()" style="display: none;">确定</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
<!-- Editor.md编辑器 -->
|
||||
<div class="box-body pad">
|
||||
<div id="markdown-editor">
|
||||
<textarea style="display:none;"><#if post??>${post.postContentMd?if_exists}</#if></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">发布</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button onclick="push(1)" class="btn btn-default btn-sm ">保存草稿</button>
|
||||
<button onclick="push(0)" class="btn btn-primary btn-sm pull-right " data-loading-text="发布中...">
|
||||
<#if post??>
|
||||
更新
|
||||
<#else>
|
||||
发布
|
||||
</#if>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">缩略图</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div>
|
||||
<#if post??>
|
||||
<img src="${post.postThumbnail?default("/static/images/thumbnail.png")}" class="img-responsive img-thumbnail" id="selectImg" onclick="openAttach('selectImg')" style="cursor: pointer;">
|
||||
<#else >
|
||||
<img src="/static/images/thumbnail.png" class="img-responsive img-thumbnail" id="selectImg" onclick="openAttach('selectImg')" style="cursor: pointer;">
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
||||
<script src="/static/plugins/layer/layer.js"></script>
|
||||
<script src="/static/plugins/editor.md/editormd.min.js"></script>
|
||||
<script>
|
||||
|
||||
/**
|
||||
* 打开附件
|
||||
*/
|
||||
function openAttach(e) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '所有附件',
|
||||
shadeClose: true,
|
||||
shade: 0.5,
|
||||
maxmin: true,
|
||||
area: ['90%', '90%'],
|
||||
content: '/admin/attachments/select?id='+e,
|
||||
scrollbar: false
|
||||
});
|
||||
}
|
||||
var editor;
|
||||
function loadEditor() {
|
||||
editor = editormd("markdown-editor", {
|
||||
width: "100%",
|
||||
height: 620,
|
||||
syncScrolling: "single",
|
||||
path: "/static/plugins/editor.md/lib/",
|
||||
saveHTMLToTextarea: true,
|
||||
imageUpload : true,
|
||||
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
|
||||
imageUploadURL : "/admin/attachments/upload/editor"
|
||||
// toolbarIcons : function () {
|
||||
// return editormd.toolbarModes["simple"];
|
||||
// }
|
||||
});
|
||||
}
|
||||
$(document).ready(function () {
|
||||
loadEditor();
|
||||
});
|
||||
|
||||
/**
|
||||
* 检测是否已经存在该链接
|
||||
* @constructor
|
||||
*/
|
||||
function UrlOnBlurAuto() {
|
||||
if($('#newPostUrl').val()===""){
|
||||
showMsg("固定链接不能为空!","info",2000);
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/admin/posts/checkUrl',
|
||||
async: false,
|
||||
data: {
|
||||
'postUrl': $('#newPostUrl').val()
|
||||
},
|
||||
success: function (data) {
|
||||
if(data==true){
|
||||
showMsg("该路径已经存在!","info",2000);
|
||||
return;
|
||||
}else{
|
||||
$('#postUrl').html($('#newPostUrl').val());
|
||||
$('#btn_change_postUrl').hide();
|
||||
$('#btn_input_postUrl').show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#btn_input_postUrl').click(function () {
|
||||
$('#postUrl').html("<input type='text' id='newPostUrl' onblur='UrlOnBlurAuto()' value=''>");
|
||||
$(this).hide();
|
||||
$('#btn_change_postUrl').show();
|
||||
});
|
||||
var postTitle = $("#post_title");
|
||||
|
||||
/**
|
||||
* 提交文章
|
||||
* @param status 文章状态
|
||||
*/
|
||||
function push(status) {
|
||||
var Title = "";
|
||||
if(postTitle.val()){
|
||||
Title = postTitle.val();
|
||||
}else{
|
||||
showMsg("标题不能为空!","info",2000);
|
||||
return;
|
||||
}
|
||||
$('input[name="categories"]:checked').each(function(){
|
||||
cateList.push($(this).val());
|
||||
});
|
||||
if($('#postUrl').html()===""){
|
||||
showMsg("固定链接不能为空!","info",2000);
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/admin/page/new/push',
|
||||
async: false,
|
||||
data: {
|
||||
<#if post??>
|
||||
'postId': $('#postId').val(),
|
||||
</#if>
|
||||
'postStatus': status,
|
||||
'postTitle': Title,
|
||||
'postUrl' : $('#postUrl').html().toString(),
|
||||
'postContentMd': editor.getMarkdown(),
|
||||
'postContent': editor.getTextareaSavedHTML(),
|
||||
'postThumbnail': $('#selectImg')[0].src
|
||||
},
|
||||
success: function (data) {
|
||||
$.toast({
|
||||
text: "发布成功!",
|
||||
heading: '提示',
|
||||
icon: 'success',
|
||||
showHideTransition: 'fade',
|
||||
allowToastClose: true,
|
||||
hideAfter: 1000,
|
||||
stack: 1,
|
||||
position: 'top-center',
|
||||
textAlign: 'left',
|
||||
loader: true,
|
||||
loaderBg: '#ffffff',
|
||||
afterHidden: function () {
|
||||
window.location.href="/admin/page";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ctrl+C保存
|
||||
*/
|
||||
$(document).keydown(function (event) {
|
||||
if(event.ctrlKey&&event.keyCode === 83){
|
||||
push(1);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<#include "module/_footer.ftl">
|
||||
</div>
|
||||
<@footer></@footer>
|
8
src/main/resources/templates/admin/admin_md-editor.ftl → src/main/resources/templates/admin/admin_post_md_editor.ftl
Normal file → Executable file
8
src/main/resources/templates/admin/admin_md-editor.ftl → src/main/resources/templates/admin/admin_post_md_editor.ftl
Normal file → Executable file
|
@ -71,7 +71,13 @@
|
|||
</div>
|
||||
<div class="box-footer">
|
||||
<button onclick="push(1)" class="btn btn-default btn-sm ">保存草稿</button>
|
||||
<button onclick="push(0)" class="btn btn-primary btn-sm pull-right " data-loading-text="发布中...">${btnPush}</button>
|
||||
<button onclick="push(0)" class="btn btn-primary btn-sm pull-right " data-loading-text="发布中...">
|
||||
<#if post??>
|
||||
更新
|
||||
<#else>
|
||||
发布
|
||||
</#if>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-primary">
|
|
@ -1,135 +0,0 @@
|
|||
<#compress >
|
||||
<#include "module/_macro.ftl">
|
||||
<@head title="${options.blog_title} | 后台管理:文章编辑">
|
||||
</@head>
|
||||
<div class="wrapper">
|
||||
<!-- 顶部栏模块 -->
|
||||
<#include "module/_header.ftl">
|
||||
<!-- 菜单栏模块 -->
|
||||
<#include "module/_sidebar.ftl">
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<link rel="stylesheet" href="/static/plugins/toast/css/jquery.toast.min.css">
|
||||
<style type="text/css">
|
||||
#post_title{
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
新建文章
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a data-pjax="true" href="#"><i class="fa fa-dashboard"></i> 首页</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-pjax="true" href="/admin/posts">文章</a>
|
||||
</li>
|
||||
<li class="active">新建文章</li>
|
||||
</ol>
|
||||
</section>
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<input type="text" class="form-control input-lg" id="post_title" name="post_title" placeholder="请输入文章标题" value="<#if post??>${post.postTitle}</#if>">
|
||||
</div>
|
||||
<div style="display: block;margin-bottom: 10px;">
|
||||
<span>
|
||||
永久链接:
|
||||
<a href="#">https://ryanc.cc/2017/12/11/study</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
<!-- Editor.md编辑器 -->
|
||||
<div class="box-body pad">
|
||||
<div id="ckeditor" style="z-index: 2;">
|
||||
<textarea id="editor" name="editor" rows="20" cols="80"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">发布</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button class="btn btn-default btn-sm">保存草稿</button>
|
||||
<button onclick="push()" class="btn btn-primary btn-sm pull-right" data-loading-text="发布中...">${btnPush}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">分类目录</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body" style="display: block">
|
||||
<div class="form-group">
|
||||
<ul style="list-style: none;padding: 0px;margin: 0px;">
|
||||
<#list categories as cate>
|
||||
<li style="padding: 0;margin: 0px;list-style: none">
|
||||
<label>
|
||||
<input name="categories" type="checkbox" class="minimal" value="${cate.cateId}"> ${cate.cateName}
|
||||
</label>
|
||||
</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">标签</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div>标签设置</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">缩略图</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div>缩略图</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
||||
<script src="/static/plugins/ckeditor/ckeditor.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
CKEDITOR.replace('editor');
|
||||
})
|
||||
</script>
|
||||
</div>
|
||||
<#include "module/_footer.ftl">
|
||||
</div>
|
||||
<@footer></@footer>
|
||||
</#compress>
|
|
@ -49,7 +49,7 @@
|
|||
</a>
|
||||
<ul class="treeview-menu">
|
||||
<li><a data-pjax="true" href="/admin/page"><i class="fa fa-circle-o"></i>所有页面</a></li>
|
||||
<li><a data-pjax="false" href="#"><i class="fa fa-circle-o"></i>新建页面</a></li>
|
||||
<li><a data-pjax="false" href="/admin/page/new"><i class="fa fa-circle-o"></i>新建页面</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -142,12 +142,12 @@
|
|||
<div class="native-wrap">
|
||||
<div class="comment-header">
|
||||
<input type="hidden" name="postId" value="${post.postId}">
|
||||
<input type="text" class="comment-input comment-input-who" name="commentAuthor" placeholder="昵称">
|
||||
<input type="text" class="comment-input comment-input-who" name="commentAuthor" id="commentAuthor" placeholder="昵称">
|
||||
<input type="text" class="comment-input comment-input-email" name="commentAuthorEmail" placeholder="邮箱">
|
||||
<input type="text" class="comment-input comment-input-website" name="commentAuthorUrl" placeholder="网址(https/http)">
|
||||
</div>
|
||||
<div class="comment-content">
|
||||
<textarea class="comment-input-content" name="commentContent" placeholder="come on"></textarea>
|
||||
<textarea class="comment-input comment-input-content" name="commentContent" id="commentContent" placeholder="come on"></textarea>
|
||||
</div>
|
||||
<div class="comment-footer">
|
||||
<button type="button" class="comment-submit" id="btn-push">提交</button>
|
||||
|
@ -165,7 +165,7 @@
|
|||
</div>
|
||||
<script src="//cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/UAParser.js/0.7.7/ua-parser.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/UAParser.js/0.7.17/ua-parser.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$.ajax({
|
||||
|
@ -177,13 +177,12 @@
|
|||
setTimeout(function(){
|
||||
$('.native-loading').hide();
|
||||
},1000);
|
||||
var parser = new UAParser();
|
||||
$.each(data,function(i,element){
|
||||
// $.ua.set(element.commentAgent);
|
||||
// var uua = $.ua;
|
||||
// var browser = uua.browser.name+' '+uua.browser.version;
|
||||
// var os = uua.os.name + ' ' + uua.os.version;
|
||||
var browser = "";
|
||||
var os = "";
|
||||
parser.setUA(element.commentAgent);
|
||||
var result = parser.getResult();
|
||||
var browser = result.browser.name+' '+result.browser.version;
|
||||
var os = result.os.name + ' ' + result.os.version;
|
||||
var author = element.commentAuthor;
|
||||
var authorEmail = element.commentAuthorEmail;
|
||||
var authorUrl = element.commentAuthorUrl;
|
||||
|
@ -197,6 +196,16 @@
|
|||
});
|
||||
});
|
||||
$('#btn-push').click(function () {
|
||||
var author = $("#commentAuthor");
|
||||
if(author.val()==''){
|
||||
$(author).css("border-bottom","1px dashed red");
|
||||
return;
|
||||
}
|
||||
var content = $("#commentContent");
|
||||
if(content.val()==''){
|
||||
$(content).css("border-bottom","1px dashed red");
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/newComment',
|
||||
|
|
Loading…
Reference in New Issue