mirror of https://github.com/halo-dev/halo
👽 完善文章系统ing
parent
67279111f6
commit
fa41bbc491
|
@ -13,8 +13,17 @@ public interface TagRepository extends JpaRepository<Tag,Long>{
|
|||
|
||||
/**
|
||||
* 根据标签路径查询,用于验证是否已经存在该路径
|
||||
*
|
||||
* @param tagUrl tagUrl
|
||||
* @return tag
|
||||
*/
|
||||
Tag findTagByTagUrl(String tagUrl);
|
||||
|
||||
/**
|
||||
* 根据标签名称查询
|
||||
*
|
||||
* @param tagName 标签名
|
||||
* @return tag
|
||||
*/
|
||||
Tag findTagByTagName(String tagName);
|
||||
}
|
||||
|
|
|
@ -51,4 +51,20 @@ public interface TagService {
|
|||
* @return tag
|
||||
*/
|
||||
Tag findByTagUrl(String tagUrl);
|
||||
|
||||
/**
|
||||
* 根据标签名称查询
|
||||
*
|
||||
* @param tagName tagName
|
||||
* @return tag
|
||||
*/
|
||||
Tag findTagByTagName(String tagName);
|
||||
|
||||
/**
|
||||
* 转换标签字符串为实体集合
|
||||
*
|
||||
* @param tagList tagList
|
||||
* @return list
|
||||
*/
|
||||
List<Tag> strListToTagList(String tagList);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import cc.ryanc.halo.service.TagService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -80,4 +81,40 @@ public class TagServiceImpl implements TagService {
|
|||
public Tag findByTagUrl(String tagUrl) {
|
||||
return tagRepository.findTagByTagUrl(tagUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签名称查询
|
||||
*
|
||||
* @param tagName tagName
|
||||
* @return tag
|
||||
*/
|
||||
@Override
|
||||
public Tag findTagByTagName(String tagName) {
|
||||
return tagRepository.findTagByTagName(tagName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换标签字符串为实体集合
|
||||
*
|
||||
* @param tagList tagList
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<Tag> strListToTagList(String tagList) {
|
||||
String [] tags = tagList.split(",");
|
||||
List<Tag> tagsList = new ArrayList<>();
|
||||
for(String tag:tags){
|
||||
Tag t = findTagByTagName(tag);
|
||||
Tag nt = null;
|
||||
if(null!=t){
|
||||
tagsList.add(t);
|
||||
}else{
|
||||
nt = new Tag();
|
||||
nt.setTagName(tag);
|
||||
nt.setTagUrl(tag);
|
||||
tagsList.add(saveByTag(nt));
|
||||
}
|
||||
}
|
||||
return tagsList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class HaloUtil {
|
|||
in.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("解压失败:"+e.getMessage());
|
||||
log.error("解压失败:{0}",e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(zip!=null)
|
||||
|
@ -104,7 +104,7 @@ public class HaloUtil {
|
|||
if(out!=null)
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class HaloUtil {
|
|||
BufferedImage bi = reader.read(0,param);
|
||||
ImageIO.write(bi, suffix, new File(dest));
|
||||
}catch (Exception e){
|
||||
log.error("剪裁失败,图片本身尺寸小于需要修剪的尺寸:"+e.getMessage());
|
||||
log.error("剪裁失败,图片本身尺寸小于需要修剪的尺寸:{0}",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ public class HaloUtil {
|
|||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return FILE_LIST;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public class HaloUtil {
|
|||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("主题获取失败:"+e.getMessage());
|
||||
log.error("主题获取失败:{0}",e.getMessage());
|
||||
}
|
||||
return themes;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public class HaloUtil {
|
|||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return tpls;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public class HaloUtil {
|
|||
inputStream.close();
|
||||
return new String(fileContent,"UTF-8");
|
||||
}catch (Exception e){
|
||||
log.error("读取模板文件错误:"+e.getMessage());
|
||||
log.error("读取模板文件错误:{0}",e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public class IndexController extends BaseController{
|
|||
model.addAttribute("afterPost",afterPosts.get(afterPosts.size()-1));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
model.addAttribute("post",post);
|
||||
|
||||
|
@ -514,7 +514,7 @@ public class IndexController extends BaseController{
|
|||
map.put("commentContent",comment.getCommentContent());
|
||||
mailService.sendTemplateMail(userService.findUser().getUserEmail(),"有新的评论",map,"common/mail/mail_admin.ftl");
|
||||
}catch (Exception e){
|
||||
log.error("邮件服务器未配置:"+e.getMessage());
|
||||
log.error("邮件服务器未配置:{0}",e.getMessage());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -149,7 +149,7 @@ public class AdminController extends BaseController{
|
|||
}
|
||||
userService.updateUserLoginLast(new Date());
|
||||
logsService.saveByLogs(new Logs(LogsRecord.LOGIN,LogsRecord.LOGIN_ERROR,HaloUtil.getIpAddr(request),new Date()));
|
||||
log.error("登录失败!:"+e.getMessage());
|
||||
log.error("登录失败!:{0}",e.getMessage());
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class AttachmentController {
|
|||
result.put("message","上传成功!");
|
||||
result.put("url",attachment.getAttachPath());
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
result.put("success","0");
|
||||
result.put("message","上传失败!");
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public class AttachmentController {
|
|||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("删除附件["+delFileName+"]失败!"+e.getMessage());
|
||||
log.error("删除附件["+delFileName+"]失败!:",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BackupController {
|
|||
String savePath = path.getAbsolutePath()+"/backup/database";
|
||||
HaloUtil.exportDatabase("localhost","root","123456",savePath,fileName,"testdb");
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/backup";
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CategoryController {
|
|||
try{
|
||||
categoryService.saveByCategory(category);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/category";
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class CategoryController {
|
|||
Category category = categoryService.removeByCateId(cateId);
|
||||
log.info("删除的分类目录:"+category);
|
||||
} catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/category";
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class CommentController extends BaseController{
|
|||
commentService.updateCommentStatus(commentId,2);
|
||||
this.getNewComments(session);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/comments";
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class CommentController extends BaseController{
|
|||
"您在" + HaloConst.OPTIONS.get("site_title") + "的评论已审核通过!", map, "common/mail/mail_passed.ftl");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("邮件服务器未配置:" + e.getMessage());
|
||||
log.error("邮件服务器未配置:{0}",e.getMessage());
|
||||
}
|
||||
}
|
||||
this.getNewComments(session);
|
||||
|
@ -154,7 +154,7 @@ public class CommentController extends BaseController{
|
|||
commentService.removeByCommentId(commentId);
|
||||
this.getNewComments(session);
|
||||
}catch (Exception e){
|
||||
log.error("删除评论失败:"+e.getMessage());
|
||||
log.error("删除评论失败:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/comments?status="+status;
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ public class CommentController extends BaseController{
|
|||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("回复评论失败!"+e.getMessage());
|
||||
log.error("回复评论失败!{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/comments";
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class OptionController {
|
|||
log.info("所保存的设置选项列表:"+options);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:",e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class PageController {
|
|||
Link backLink = linkService.saveByLink(link);
|
||||
log.info("保存成功,数据为:"+backLink);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/page/links";
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class PageController {
|
|||
Link link = linkService.removeByLinkId(linkId);
|
||||
log.info("删除的友情链接:"+link);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/page/links";
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package cc.ryanc.halo.web.controller.admin;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Category;
|
||||
import cc.ryanc.halo.model.domain.Logs;
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.domain.User;
|
||||
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.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.BaseController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -44,6 +42,9 @@ public class PostController extends BaseController{
|
|||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
@Autowired
|
||||
private TagService tagService;
|
||||
|
||||
@Autowired
|
||||
private LogsService logsService;
|
||||
|
||||
|
@ -98,7 +99,7 @@ public class PostController extends BaseController{
|
|||
Pageable pageable = new PageRequest(page,size,sort);
|
||||
model.addAttribute("posts",postService.searchPosts(keyword,pageable));
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "admin/admin_post";
|
||||
}
|
||||
|
@ -133,7 +134,7 @@ public class PostController extends BaseController{
|
|||
//设置选项
|
||||
model.addAttribute("options",HaloConst.OPTIONS);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "admin/admin_editor";
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ public class PostController extends BaseController{
|
|||
*/
|
||||
@PostMapping(value = "/new/push")
|
||||
@ResponseBody
|
||||
public void pushPost(@ModelAttribute Post post,@RequestParam("cateList") List<String> cateList, HttpSession session){
|
||||
public void pushPost(@ModelAttribute Post post, @RequestParam("cateList") List<String> cateList, @RequestParam("tagList") String tagList, HttpSession session){
|
||||
try{
|
||||
//提取摘要
|
||||
int postSummary = 50;
|
||||
|
@ -162,11 +163,13 @@ public class PostController extends BaseController{
|
|||
post.setUser(user);
|
||||
List<Category> categories = categoryService.strListToCateList(cateList);
|
||||
post.setCategories(categories);
|
||||
List<Tag> tags = tagService.strListToTagList(tagList);
|
||||
post.setTags(tags);
|
||||
postService.saveByPost(post);
|
||||
log.info("已发表新文章:"+post.getPostTitle());
|
||||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST,post.getPostTitle(),HaloUtil.getIpAddr(request),HaloUtil.getDate()));
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +185,7 @@ public class PostController extends BaseController{
|
|||
postService.updatePostStatus(postId,2);
|
||||
log.info("编号为"+postId+"的文章已被移到回收站");
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts";
|
||||
}
|
||||
|
@ -200,7 +203,7 @@ public class PostController extends BaseController{
|
|||
postService.updatePostStatus(postId,0);
|
||||
log.info("编号为"+postId+"的文章已改变为发布状态");
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts?status="+status;
|
||||
}
|
||||
|
@ -218,7 +221,7 @@ public class PostController extends BaseController{
|
|||
postService.removeByPostId(postId);
|
||||
logsService.saveByLogs(new Logs(LogsRecord.REMOVE_POST,post.get().getPostTitle(),HaloUtil.getIpAddr(request),HaloUtil.getDate()));
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts?status=2";
|
||||
}
|
||||
|
@ -241,7 +244,7 @@ public class PostController extends BaseController{
|
|||
//设置选项
|
||||
model.addAttribute("options",HaloConst.OPTIONS);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "admin/admin_editor";
|
||||
}
|
||||
|
@ -259,7 +262,7 @@ public class PostController extends BaseController{
|
|||
postService.updateAllSummary(postSummary);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TagController {
|
|||
try{
|
||||
tagService.saveByTag(tag);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/tag";
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class TagController {
|
|||
Tag tag = tagService.removeByTagId(tagId);
|
||||
log.info("删除的标签:"+tag);
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/tag";
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class ThemeController extends BaseController{
|
|||
log.error("上传失败,没有选择文件");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("上传失败:"+e.getMessage());
|
||||
log.error("上传失败:{0}",e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class ThemeController extends BaseController{
|
|||
File themesPath = new File(basePath.getAbsolutePath(),new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString());
|
||||
tplContent = HaloUtil.getFileContent(themesPath.getAbsolutePath());
|
||||
}catch (Exception e){
|
||||
log.error("获取模板文件错误:"+e.getMessage());
|
||||
log.error("获取模板文件错误:{0}",e.getMessage());
|
||||
}
|
||||
return tplContent;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ public class ThemeController extends BaseController{
|
|||
byte[] tplContentByte = tplContent.getBytes("UTF-8");
|
||||
Files.write(Paths.get(tplPath.getAbsolutePath()),tplContentByte);
|
||||
}catch (Exception e){
|
||||
log.error("文件保存失败:"+e.getMessage());
|
||||
log.error("文件保存失败:{0}",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -53,11 +53,10 @@ public class UserController {
|
|||
userService.saveByUser(user);
|
||||
session.invalidate();
|
||||
}else{
|
||||
log.error("用户信息不能为空值");
|
||||
return false;
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("未知错误:"+e.getMessage());
|
||||
log.error("未知错误:{0}",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -81,14 +80,12 @@ public class UserController {
|
|||
if(null!=user){
|
||||
user.setUserPass(HaloUtil.getMD5(newPass));
|
||||
userService.saveByUser(user);
|
||||
log.info("修改密码:成功");
|
||||
session.invalidate();
|
||||
}else{
|
||||
log.error("修改密码:原密码错误!");
|
||||
return false;
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("修改密码:未知错误,"+e.getMessage());
|
||||
log.error("修改密码:未知错误,{0}",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 8090
|
||||
port: 8080
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// http://code.accursoft.com/caret - 1.3.3
|
||||
!function(e){e.fn.caret=function(e){var t=this[0],n="true"===t.contentEditable;if(0==arguments.length){if(window.getSelection){if(n){t.focus();var o=window.getSelection().getRangeAt(0),r=o.cloneRange();return r.selectNodeContents(t),r.setEnd(o.endContainer,o.endOffset),r.toString().length}return t.selectionStart}if(document.selection){if(t.focus(),n){var o=document.selection.createRange(),r=document.body.createTextRange();return r.moveToElementText(t),r.setEndPoint("EndToEnd",o),r.text.length}var e=0,c=t.createTextRange(),r=document.selection.createRange().duplicate(),a=r.getBookmark();for(c.moveToBookmark(a);0!==c.moveStart("character",-1);)e++;return e}return t.selectionStart?t.selectionStart:0}if(-1==e&&(e=this[n?"text":"val"]().length),window.getSelection)n?(t.focus(),window.getSelection().collapse(t.firstChild,e)):t.setSelectionRange(e,e);else if(document.body.createTextRange)if(n){var c=document.body.createTextRange();c.moveToElementText(t),c.moveStart("character",e),c.collapse(!0),c.select()}else{var c=t.createTextRange();c.move("character",e),c.select()}return n||t.focus(),e}}(jQuery);
|
|
@ -0,0 +1,45 @@
|
|||
/* surrounding tag container */
|
||||
.tag-editor {
|
||||
list-style-type: none; padding:5px; margin: 0; overflow: hidden; border: 1px solid #eee; cursor: text;
|
||||
font: normal 14px sans-serif; color: #555; background: #fff; line-height: 20px;
|
||||
}
|
||||
|
||||
/* core styles usually need no change */
|
||||
.tag-editor li { display: block; float: left; overflow: hidden; margin: 3px 0; }
|
||||
.tag-editor div { float: left; padding: 0 4px; }
|
||||
.tag-editor .placeholder { padding: 0 8px; color: #bbb; }
|
||||
.tag-editor .tag-editor-spacer { padding: 0; width: 8px; overflow: hidden; color: transparent; background: none; }
|
||||
.tag-editor input {
|
||||
vertical-align: inherit; border: 0; outline: none; padding: 0; margin: 0; cursor: text;
|
||||
font-family: inherit; font-weight: inherit; font-size: inherit; font-style: inherit;
|
||||
box-shadow: none; background: none; color: #444;
|
||||
}
|
||||
/* hide original input field or textarea visually to allow tab navigation */
|
||||
.tag-editor-hidden-src { position: absolute !important; left: -99999px; }
|
||||
/* hide IE10 "clear field" X */
|
||||
.tag-editor ::-ms-clear { display: none; }
|
||||
|
||||
/* tag style */
|
||||
.tag-editor .tag-editor-tag {
|
||||
padding-left: 5px; color: #46799b; background: #e0eaf1; white-space: nowrap;
|
||||
overflow: hidden; cursor: pointer; border-radius: 2px 0 0 2px;
|
||||
}
|
||||
|
||||
/* delete icon */
|
||||
.tag-editor .tag-editor-delete { background: #e0eaf1; cursor: pointer; border-radius: 0 2px 2px 0; padding-left: 3px; padding-right: 4px; }
|
||||
.tag-editor .tag-editor-delete i { line-height: 18px; display: inline-block; }
|
||||
.tag-editor .tag-editor-delete i:before { font-size: 16px; color: #8ba7ba; content: "×"; font-style: normal; }
|
||||
.tag-editor .tag-editor-delete:hover i:before { color: #d65454; }
|
||||
.tag-editor .tag-editor-tag.active+.tag-editor-delete, .tag-editor .tag-editor-tag.active+.tag-editor-delete i { visibility: hidden; cursor: text; }
|
||||
|
||||
.tag-editor .tag-editor-tag.active { background: none !important; }
|
||||
|
||||
/* jQuery UI autocomplete - code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css */
|
||||
.ui-autocomplete { position: absolute; top: 0; left: 0; cursor: default; font-size: 14px; }
|
||||
.ui-front { z-index: 9999; }
|
||||
.ui-menu { list-style: none; padding: 1px; margin: 0; display: block; outline: none; }
|
||||
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.4; min-height: 0; /* support: IE7 */ }
|
||||
.ui-widget-content { border: 1px solid #bbb; background: #fff; color: #555; }
|
||||
.ui-widget-content a { color: #46799b; }
|
||||
.ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { background: #e0eaf1; }
|
||||
.ui-helper-hidden-accessible { display: none; }
|
|
@ -0,0 +1,370 @@
|
|||
/*
|
||||
jQuery tagEditor v1.0.21
|
||||
Copyright (c) 2014 Simon Steinberger / Pixabay
|
||||
GitHub: https://github.com/Pixabay/jQuery-tagEditor
|
||||
License: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
(function($){
|
||||
// auto grow input (stackoverflow.com/questions/931207)
|
||||
$.fn.tagEditorInput=function(){var t=" ",e=$(this),n=parseInt(e.css("fontSize")),i=$("<span/>").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:e.css("fontSize"),fontFamily:e.css("fontFamily"),fontWeight:e.css("fontWeight"),letterSpacing:e.css("letterSpacing"),whiteSpace:"nowrap"}),s=function(){if(t!==(t=e.val())){i.text(t);var s=i.width()+n;20>s&&(s=20),s!=e.width()&&e.width(s)}};return i.insertAfter(e),e.bind("keyup keydown focus",s)};
|
||||
|
||||
// plugin with val as parameter for public methods
|
||||
$.fn.tagEditor = function(options, val, blur){
|
||||
|
||||
// helper
|
||||
function escape(tag) {
|
||||
return tag.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||
}
|
||||
|
||||
// build options dictionary with default values
|
||||
var blur_result, o = $.extend({}, $.fn.tagEditor.defaults, options), selector = this;
|
||||
|
||||
// store regex and default delimiter in options for later use
|
||||
o.dregex = new RegExp('['+o.delimiter.replace('-', '\-')+']', 'g');
|
||||
|
||||
// public methods
|
||||
if (typeof options == 'string') {
|
||||
// depending on selector, response may contain tag lists of multiple editor instances
|
||||
var response = [];
|
||||
selector.each(function(){
|
||||
// the editor is the next sibling to the hidden, original field
|
||||
var el = $(this), o = el.data('options'), ed = el.next('.tag-editor');
|
||||
if (options == 'getTags')
|
||||
response.push({field: el[0], editor: ed, tags: ed.data('tags')});
|
||||
else if (options == 'addTag') {
|
||||
if (o.maxTags && ed.data('tags').length >= o.maxTags) return false;
|
||||
// insert new tag
|
||||
$('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag"></div><div class="tag-editor-delete"><i></i></div></li>').appendTo(ed).find('.tag-editor-tag')
|
||||
.html('<input type="text" maxlength="'+o.maxLength+'">').addClass('active').find('input').val(val).blur();
|
||||
if (!blur) ed.click();
|
||||
else $('.placeholder', ed).remove();
|
||||
} else if (options == 'removeTag') {
|
||||
// trigger delete on matching tag, then click editor to create a new tag
|
||||
$('.tag-editor-tag', ed).filter(function(){return $(this).text()==val;}).closest('li').find('.tag-editor-delete').click();
|
||||
if (!blur) ed.click();
|
||||
} else if (options == 'destroy') {
|
||||
el.removeClass('tag-editor-hidden-src').removeData('options').off('focus.tag-editor').next('.tag-editor').remove();
|
||||
}
|
||||
});
|
||||
return options == 'getTags' ? response : this;
|
||||
}
|
||||
|
||||
// delete selected tags on backspace, delete, ctrl+x
|
||||
if (window.getSelection) $(document).off('keydown.tag-editor').on('keydown.tag-editor', function(e){
|
||||
if (e.which == 8 || e.which == 46 || e.ctrlKey && e.which == 88) {
|
||||
try {
|
||||
var sel = getSelection(), el = document.activeElement.tagName != 'INPUT' ? $(sel.getRangeAt(0).startContainer.parentNode).closest('.tag-editor') : 0;
|
||||
} catch(e){ el = 0; }
|
||||
if (sel.rangeCount > 0 && el && el.length) {
|
||||
var tags = [], splits = sel.toString().split(el.prev().data('options').dregex);
|
||||
for (i=0; i<splits.length; i++){ var tag = $.trim(splits[i]); if (tag) tags.push(tag); }
|
||||
$('.tag-editor-tag', el).each(function(){
|
||||
if (~$.inArray($(this).text(), tags)) $(this).closest('li').find('.tag-editor-delete').click();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return selector.each(function(){
|
||||
var el = $(this), tag_list = []; // cache current tags
|
||||
|
||||
// create editor (ed) instance
|
||||
var ed = $('<ul '+(o.clickDelete ? 'oncontextmenu="return false;" ' : '')+'class="tag-editor"></ul>').insertAfter(el);
|
||||
el.addClass('tag-editor-hidden-src') // hide original field
|
||||
.data('options', o) // set data on hidden field
|
||||
.on('focus.tag-editor', function(){ ed.click(); }); // simulate tabindex
|
||||
|
||||
// add dummy item for min-height on empty editor
|
||||
ed.append('<li style="width:1px"> </li>');
|
||||
|
||||
// markup for new tag
|
||||
var new_tag = '<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag"></div><div class="tag-editor-delete"><i></i></div></li>';
|
||||
|
||||
// helper: update global data
|
||||
function set_placeholder(){
|
||||
if (o.placeholder && !tag_list.length && !$('.deleted, .placeholder, input', ed).length)
|
||||
ed.append('<li class="placeholder"><div>'+o.placeholder+'</div></li>');
|
||||
}
|
||||
|
||||
// helper: update global data
|
||||
function update_globals(init){
|
||||
var old_tags = tag_list.toString();
|
||||
tag_list = $('.tag-editor-tag:not(.deleted)', ed).map(function(i, e) {
|
||||
var val = $.trim($(this).hasClass('active') ? $(this).find('input').val() : $(e).text());
|
||||
if (val) return val;
|
||||
}).get();
|
||||
ed.data('tags', tag_list);
|
||||
el.val(tag_list.join(o.delimiter[0]));
|
||||
// change callback except for plugin init
|
||||
if (!init) if (old_tags != tag_list.toString()) o.onChange(el, ed, tag_list);
|
||||
set_placeholder();
|
||||
}
|
||||
|
||||
ed.click(function(e, closest_tag){
|
||||
var d, dist = 99999, loc;
|
||||
|
||||
// do not create tag when user selects tags by text selection
|
||||
if (window.getSelection && getSelection() != '') return;
|
||||
|
||||
if (o.maxTags && ed.data('tags').length >= o.maxTags) { ed.find('input').blur(); return false; }
|
||||
|
||||
blur_result = true
|
||||
$('input:focus', ed).blur();
|
||||
if (!blur_result) return false;
|
||||
blur_result = true
|
||||
|
||||
// always remove placeholder on click
|
||||
$('.placeholder', ed).remove();
|
||||
if (closest_tag && closest_tag.length)
|
||||
loc = 'before';
|
||||
else {
|
||||
// calculate tag closest to click position
|
||||
$('.tag-editor-tag', ed).each(function(){
|
||||
var tag = $(this), to = tag.offset(), tag_x = to.left, tag_y = to.top;
|
||||
if (e.pageY >= tag_y && e.pageY <= tag_y+tag.height()) {
|
||||
if (e.pageX < tag_x) loc = 'before', d = tag_x - e.pageX;
|
||||
else loc = 'after', d = e.pageX - tag_x - tag.width();
|
||||
if (d < dist) dist = d, closest_tag = tag;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (loc == 'before') {
|
||||
$(new_tag).insertBefore(closest_tag.closest('li')).find('.tag-editor-tag').click();
|
||||
} else if (loc == 'after')
|
||||
$(new_tag).insertAfter(closest_tag.closest('li')).find('.tag-editor-tag').click();
|
||||
else // empty editor
|
||||
$(new_tag).appendTo(ed).find('.tag-editor-tag').click();
|
||||
return false;
|
||||
});
|
||||
|
||||
ed.on('click', '.tag-editor-delete', function(e){
|
||||
// delete icon is hidden when input is visible; place cursor near invisible delete icon on click
|
||||
if ($(this).prev().hasClass('active')) { $(this).closest('li').find('input').caret(-1); return false; }
|
||||
|
||||
var li = $(this).closest('li'), tag = li.find('.tag-editor-tag');
|
||||
if (o.beforeTagDelete(el, ed, tag_list, tag.text()) === false) return false;
|
||||
tag.addClass('deleted').animate({width: 0}, o.animateDelete, function(){ li.remove(); set_placeholder(); });
|
||||
update_globals();
|
||||
return false;
|
||||
});
|
||||
|
||||
// delete on right mouse click or ctrl+click
|
||||
if (o.clickDelete)
|
||||
ed.on('mousedown', '.tag-editor-tag', function(e){
|
||||
if (e.ctrlKey || e.which > 1) {
|
||||
var li = $(this).closest('li'), tag = li.find('.tag-editor-tag');
|
||||
if (o.beforeTagDelete(el, ed, tag_list, tag.text()) === false) return false;
|
||||
tag.addClass('deleted').animate({width: 0}, o.animateDelete, function(){ li.remove(); set_placeholder(); });
|
||||
update_globals();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
ed.on('click', '.tag-editor-tag', function(e){
|
||||
// delete on right click or ctrl+click -> exit
|
||||
if (o.clickDelete && (e.ctrlKey || e.which > 1)) return false;
|
||||
|
||||
if (!$(this).hasClass('active')) {
|
||||
var tag = $(this).text();
|
||||
// guess cursor position in text input
|
||||
var left_percent = Math.abs(($(this).offset().left - e.pageX)/$(this).width()), caret_pos = parseInt(tag.length*left_percent),
|
||||
input = $(this).html('<input type="text" maxlength="'+o.maxLength+'" value="'+escape(tag)+'">').addClass('active').find('input');
|
||||
input.data('old_tag', tag).tagEditorInput().focus().caret(caret_pos);
|
||||
if (o.autocomplete) {
|
||||
var aco = $.extend({}, o.autocomplete);
|
||||
// extend user provided autocomplete select method
|
||||
var ac_select = 'select' in aco ? o.autocomplete.select : '';
|
||||
aco.select = function(e, ui){ if (ac_select) ac_select(e, ui); setTimeout(function(){
|
||||
ed.trigger('click', [$('.active', ed).find('input').closest('li').next('li').find('.tag-editor-tag')]);
|
||||
}, 20); };
|
||||
input.autocomplete(aco);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// helper: split into multiple tags, e.g. after paste
|
||||
function split_cleanup(input){
|
||||
var li = input.closest('li'), sub_tags = input.val().replace(/ +/, ' ').split(o.dregex),
|
||||
old_tag = input.data('old_tag'), old_tags = tag_list.slice(0), exceeded = false, cb_val; // copy tag_list
|
||||
for (var i=0; i<sub_tags.length; i++) {
|
||||
tag = $.trim(sub_tags[i]).slice(0, o.maxLength);
|
||||
if (o.forceLowercase) tag = tag.toLowerCase();
|
||||
cb_val = o.beforeTagSave(el, ed, old_tags, old_tag, tag);
|
||||
tag = cb_val || tag;
|
||||
if (cb_val === false || !tag) continue;
|
||||
// remove duplicates
|
||||
if (o.removeDuplicates && ~$.inArray(tag, old_tags))
|
||||
$('.tag-editor-tag', ed).each(function(){ if ($(this).text() == tag) $(this).closest('li').remove(); });
|
||||
old_tags.push(tag);
|
||||
li.before('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag">'+escape(tag)+'</div><div class="tag-editor-delete"><i></i></div></li>');
|
||||
if (o.maxTags && old_tags.length >= o.maxTags) { exceeded = true; break; }
|
||||
}
|
||||
input.attr('maxlength', o.maxLength).removeData('old_tag').val('')
|
||||
if (exceeded) input.blur(); else input.focus();
|
||||
update_globals();
|
||||
}
|
||||
|
||||
ed.on('blur', 'input', function(e){
|
||||
e.stopPropagation();
|
||||
var input = $(this), old_tag = input.data('old_tag'), tag = $.trim(input.val().replace(/ +/, ' ').replace(o.dregex, o.delimiter[0]));
|
||||
if (!tag) {
|
||||
if (old_tag && o.beforeTagDelete(el, ed, tag_list, old_tag) === false) {
|
||||
input.val(old_tag).focus();
|
||||
blur_result = false;
|
||||
update_globals();
|
||||
return;
|
||||
}
|
||||
try { input.closest('li').remove(); } catch(e){}
|
||||
if (old_tag) update_globals();
|
||||
}
|
||||
else if (tag.indexOf(o.delimiter[0])>=0) { split_cleanup(input); return; }
|
||||
else if (tag != old_tag) {
|
||||
if (o.forceLowercase) tag = tag.toLowerCase();
|
||||
cb_val = o.beforeTagSave(el, ed, tag_list, old_tag, tag);
|
||||
tag = cb_val || tag;
|
||||
if (cb_val === false) {
|
||||
if (old_tag) {
|
||||
input.val(old_tag).focus();
|
||||
blur_result = false;
|
||||
update_globals();
|
||||
return;
|
||||
}
|
||||
try { input.closest('li').remove(); } catch(e){}
|
||||
if (old_tag) update_globals();
|
||||
}
|
||||
// remove duplicates
|
||||
else if (o.removeDuplicates)
|
||||
$('.tag-editor-tag:not(.active)', ed).each(function(){ if ($(this).text() == tag) $(this).closest('li').remove(); });
|
||||
}
|
||||
input.parent().html(escape(tag)).removeClass('active');
|
||||
if (tag != old_tag) update_globals();
|
||||
set_placeholder();
|
||||
});
|
||||
|
||||
var pasted_content;
|
||||
ed.on('paste', 'input', function(e){
|
||||
$(this).removeAttr('maxlength');
|
||||
pasted_content = $(this);
|
||||
setTimeout(function(){ split_cleanup(pasted_content); }, 30);
|
||||
});
|
||||
|
||||
// keypress delimiter
|
||||
var inp;
|
||||
ed.on('keypress', 'input', function(e){
|
||||
if (o.delimiter.indexOf(String.fromCharCode(e.which))>=0) {
|
||||
inp = $(this);
|
||||
setTimeout(function(){ split_cleanup(inp); }, 20);
|
||||
}
|
||||
});
|
||||
|
||||
ed.on('keydown', 'input', function(e){
|
||||
var $t = $(this);
|
||||
|
||||
// left/up key + backspace key on empty field
|
||||
if ((e.which == 37 || !o.autocomplete && e.which == 38) && !$t.caret() || e.which == 8 && !$t.val()) {
|
||||
var prev_tag = $t.closest('li').prev('li').find('.tag-editor-tag');
|
||||
if (prev_tag.length) prev_tag.click().find('input').caret(-1);
|
||||
else if ($t.val() && !(o.maxTags && ed.data('tags').length >= o.maxTags)) $(new_tag).insertBefore($t.closest('li')).find('.tag-editor-tag').click();
|
||||
return false;
|
||||
}
|
||||
// right/down key
|
||||
else if ((e.which == 39 || !o.autocomplete && e.which == 40) && ($t.caret() == $t.val().length)) {
|
||||
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
|
||||
if (next_tag.length) next_tag.click().find('input').caret(0);
|
||||
else if ($t.val()) ed.click();
|
||||
return false;
|
||||
}
|
||||
// tab key
|
||||
else if (e.which == 9) {
|
||||
// shift+tab
|
||||
if (e.shiftKey) {
|
||||
var prev_tag = $t.closest('li').prev('li').find('.tag-editor-tag');
|
||||
if (prev_tag.length) prev_tag.click().find('input').caret(0);
|
||||
else if ($t.val() && !(o.maxTags && ed.data('tags').length >= o.maxTags)) $(new_tag).insertBefore($t.closest('li')).find('.tag-editor-tag').click();
|
||||
// allow tabbing to previous element
|
||||
else {
|
||||
el.attr('disabled', 'disabled');
|
||||
setTimeout(function(){ el.removeAttr('disabled'); }, 30);
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
// tab
|
||||
} else {
|
||||
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
|
||||
if (next_tag.length) next_tag.click().find('input').caret(0);
|
||||
else if ($t.val()) ed.click();
|
||||
else return; // allow tabbing to next element
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// del key
|
||||
else if (e.which == 46 && (!$.trim($t.val()) || ($t.caret() == $t.val().length))) {
|
||||
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
|
||||
if (next_tag.length) next_tag.click().find('input').caret(0);
|
||||
else if ($t.val()) ed.click();
|
||||
return false;
|
||||
}
|
||||
// enter key
|
||||
else if (e.which == 13) {
|
||||
ed.trigger('click', [$t.closest('li').next('li').find('.tag-editor-tag')]);
|
||||
|
||||
// trigger blur if maxTags limit is reached
|
||||
if (o.maxTags && ed.data('tags').length >= o.maxTags) ed.find('input').blur();
|
||||
|
||||
return false;
|
||||
}
|
||||
// pos1
|
||||
else if (e.which == 36 && !$t.caret()) ed.find('.tag-editor-tag').first().click();
|
||||
// end
|
||||
else if (e.which == 35 && $t.caret() == $t.val().length) ed.find('.tag-editor-tag').last().click();
|
||||
// esc
|
||||
else if (e.which == 27) {
|
||||
$t.val($t.data('old_tag') ? $t.data('old_tag') : '').blur();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// create initial tags
|
||||
var tags = o.initialTags.length ? o.initialTags : el.val().split(o.dregex);
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
if (o.maxTags && i >= o.maxTags) break;
|
||||
var tag = $.trim(tags[i].replace(/ +/, ' '));
|
||||
if (tag) {
|
||||
if (o.forceLowercase) tag = tag.toLowerCase();
|
||||
tag_list.push(tag);
|
||||
ed.append('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag">'+escape(tag)+'</div><div class="tag-editor-delete"><i></i></div></li>');
|
||||
}
|
||||
}
|
||||
update_globals(true); // true -> no onChange callback
|
||||
|
||||
// init sortable
|
||||
if (o.sortable && $.fn.sortable) ed.sortable({
|
||||
distance: 5, cancel: '.tag-editor-spacer, input', helper: 'clone',
|
||||
update: function(){ update_globals(); }
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.tagEditor.defaults = {
|
||||
initialTags: [],
|
||||
maxTags: 0,
|
||||
maxLength: 50,
|
||||
delimiter: ',;',
|
||||
placeholder: '',
|
||||
forceLowercase: true,
|
||||
removeDuplicates: true,
|
||||
clickDelete: false,
|
||||
animateDelete: 175,
|
||||
sortable: true, // jQuery UI sortable
|
||||
autocomplete: null, // options dict for jQuery UI autocomplete
|
||||
|
||||
// callbacks
|
||||
onChange: function(){},
|
||||
beforeTagSave: function(){},
|
||||
beforeTagDelete: function(){}
|
||||
};
|
||||
}(jQuery));
|
File diff suppressed because one or more lines are too long
|
@ -9,6 +9,7 @@
|
|||
<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">
|
||||
<link rel="stylesheet" href="/static/plugins/jquery-tageditor/jquery.tag-editor.css">
|
||||
<style type="text/css">
|
||||
#post_title{
|
||||
font-weight: 400;
|
||||
|
@ -40,7 +41,7 @@
|
|||
<div style="display: block;margin-bottom: 10px;">
|
||||
<span>
|
||||
永久链接:
|
||||
<a href="#">${options.site_url}/article/<span id="postUrl"></span>/</a>
|
||||
<a href="#">${options.site_url}/article/<span id="postUrl"><#if post??>${post.postUrl}</#if></span>/</a>
|
||||
<button class="btn btn-default btn-sm btn-flat" id="btn_input_postUrl">编辑</button>
|
||||
<button class="btn btn-default btn-sm btn-flat" id="btn_change_postUrl" onclick="UrlOnBlurAuto()" style="display: none;">确定</button>
|
||||
</span>
|
||||
|
@ -77,7 +78,7 @@
|
|||
<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">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -100,13 +101,13 @@
|
|||
<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">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div>标签设置</div>
|
||||
<input type="text" class="form-control input-lg" id="tagList" name=""/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-primary">
|
||||
|
@ -131,7 +132,25 @@
|
|||
<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 src="/static/plugins/jquery-tageditor/jquery.tag-editor.min.js"></script>
|
||||
<script src="/static/plugins/jquery-tageditor/jquery.caret.min.js"></script>
|
||||
<script>
|
||||
$('#tagList').tagEditor({
|
||||
//initialTags: ['Hello', 'World', 'Example', 'Tags'],
|
||||
delimiter: ',',
|
||||
placeholder: '请输入标签'
|
||||
});
|
||||
|
||||
<#if post??>
|
||||
<#if post.tags?size gt 0>
|
||||
<#list post.tags as tag>
|
||||
$('#tagList').tagEditor('addTag','${tag.tagName}');
|
||||
</#list>
|
||||
</#if>
|
||||
</#if>
|
||||
/**
|
||||
* 打开附件
|
||||
*/
|
||||
function openAttach() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
|
@ -166,6 +185,11 @@
|
|||
function TitleOnBlurAuto() {
|
||||
$('#postUrl').html($('#post_title').val());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否已经存在该链接
|
||||
* @constructor
|
||||
*/
|
||||
function UrlOnBlurAuto() {
|
||||
if($('#newPostUrl').val()===""){
|
||||
showMsg("固定链接不能为空!","info",2000);
|
||||
|
@ -197,7 +221,13 @@
|
|||
});
|
||||
var postTitle = $("#post_title");
|
||||
var cateList = new Array();
|
||||
|
||||
/**
|
||||
* 提交文章
|
||||
* @param status 文章状态
|
||||
*/
|
||||
function push(status) {
|
||||
alert( $('#tagList').tagEditor('getTags')[0].tags );
|
||||
var Title = "";
|
||||
if(postTitle.val()){
|
||||
Title = postTitle.val();
|
||||
|
@ -225,7 +255,8 @@
|
|||
'postUrl' : $('#postUrl').html().toString(),
|
||||
'postContentMd': editor.getMarkdown(),
|
||||
'postContent': editor.getTextareaSavedHTML(),
|
||||
'cateList' : cateList.toString()
|
||||
'cateList' : cateList.toString(),
|
||||
'tagList' : $('#tagList').tagEditor('getTags')[0].tags.toString()
|
||||
},
|
||||
success: function (data) {
|
||||
$.toast({
|
||||
|
@ -247,6 +278,10 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ctrl+C保存
|
||||
*/
|
||||
$(document).keydown(function (event) {
|
||||
if(event.ctrlKey&&event.keyCode === 83){
|
||||
push(1);
|
||||
|
|
|
@ -69,7 +69,15 @@
|
|||
无分类
|
||||
</#if>
|
||||
</td>
|
||||
<td>无标签</td>
|
||||
<td>
|
||||
<#if post.tags?size gt 0>
|
||||
<#list post.tags as tag>
|
||||
${tag.tagName}
|
||||
</#list>
|
||||
<#else >
|
||||
无标签
|
||||
</#if>
|
||||
</td>
|
||||
<td>
|
||||
<#if post.getComments()??>
|
||||
${post.getComments()?size}
|
||||
|
|
Loading…
Reference in New Issue