refactor, fix bug and update i18n(blog), to be continue

pull/680/head
shiqstone 2021-04-19 11:24:12 +08:00
parent 25e06a767b
commit 93d377f3b9
9 changed files with 260 additions and 168 deletions

View File

@ -31,7 +31,7 @@ setting = Setting
save = Save
cancel = Cancel
create = Create
confirm_delete = Confirm Delete
confirm_delete = Confirm
upload_lang = en
js_lang = en
remove = Remove
@ -41,6 +41,7 @@ creator = Creator
administrator = Administrator
editor = Editor
observer = Observer
back = Back
[message]
tips = Tips
@ -167,9 +168,26 @@ user_exist_in_proj = The user already exists in the project
cannot_change_own_priv = Cannot change own permissions
cannot_delete_self = Cannot delete myself
cannot_handover_myself = Cannot handover to myself
confirm_delete_blog = Confirm delete blog?
delete_blog_tips = Deleted blog cannot be retrieved.
input_proj_id_pls = input project ID please
input_doc_id_pls = input document ID please
blog_digest_tips = blog digest cannot exceed 500 characters
blog_title_empty = blog title cannot be empty
blog_not_exist = Blog does not exist or has been deleted
blog_pwd_incorrect = Access password incorrect
set_pwd_pls = please set password for encrypt blog
unknown_blog_type = unknown blog type
blog_title_tips = blog title cannot exceed 200 characters
ref_doc_prj_not_existed = The Project of reference document not existed
query_ref_doc_error = query reference document failed
ref_doc_not_exist_or_no_permit = reference document does not exist or has insufficient permissions
blog_id_existed = blog id already existed
query_failed = query failed
blog_has_modified = The article has been modified
[blog]
author = author
author = Author
project_list = Project List
add_project = Add Project
import_project = Import Project
@ -232,6 +250,29 @@ preview = Preview
choose = Choose
upload = Upload
recipient_account = Recipient
blog_list = Blog List
add_blog = Add Blog
encryption = encryption
encrypt = encrypt
edit_blog = Edit blog
delete_blog = Delete blog
setting_blog = Setting Blog
no_blog = No Blog
blog_setting = Blog Setting
title = Blog Title
type = Blog Type
normal_blog = Normal Blog
link_blog = Link Blog
ref_doc = Reference Document
blog_status = Blog Status
blog_pwd = Blog Password
blog_digest = Blog Digest
posted_on = Posted on
modified_on = Modified on
prev = prev
next = next
no = no
edit_title = Edit Blog
[doc]
modify_doc = Modify Document

View File

@ -41,6 +41,7 @@ creator = 创始人
administrator = 管理员
editor = 编辑者
observer = 观察者
back = 返回
[message]
tips = 友情提示
@ -167,6 +168,23 @@ user_exist_in_proj = 用户已存在该项目中
cannot_change_own_priv = 不能变更自己的权限
cannot_delete_self = 不能删除自己
cannot_handover_myself = 不能转让给自己
confirm_delete_blog = 确定删除文章吗?
delete_blog_tips = 删除文章后将无法找回。
input_proj_id_pls = 请输入项目标识
input_doc_id_pls = 请输入文档标识
blog_digest_tips = 文章摘要不超过500个字符
blog_title_empty = 文章标题不能为空
blog_not_exist = 文章不存在或已删除
blog_pwd_incorrect = 文章密码不正确
set_pwd_pls = 加密文章请设置密码
unknown_blog_type = 未知的文章类型
blog_title_tips = 文章标题不能大于200个字符
ref_doc_prj_not_existed = 关联文档的项目不存在
query_ref_doc_error = 查询关联项目文档时出错
ref_doc_not_exist_or_no_permit = 关联文档不存在或权限不足
blog_id_existed = 文章标识已存在
query_failed = 查询失败
blog_has_modified = 文章已被修改
[blog]
author = 作者
@ -232,6 +250,29 @@ preview = 预览
choose = 选择
upload = 上传
recipient_account = 接收者账号
blog_list = 文章列表
add_blog = 添加文章
encryption = 加密
encrypt =
edit_blog = 文章编辑
delete_blog = 删除文章
setting_blog = 文章设置
no_blog = 暂无文章
blog_setting = 文章设置
title = 文章标题
type = 文章类型
normal_blog = 普通文章
link_blog = 链接文章
ref_doc = 关联文档
blog_status = 文章状态
blog_pwd = 文章密码
blog_digest = 文章摘要
posted_on = 发布于
modified_on = 修改于
prev = 上一篇
next = 下一篇
no =
edit_title = 编辑文章
[doc]
modify_doc = 修改文档

View File

@ -3,7 +3,6 @@ package controllers
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego/logs"
"html/template"
"net/http"
"net/url"
@ -13,6 +12,9 @@ import (
"strings"
"time"
"github.com/astaxie/beego/logs"
"github.com/beego/i18n"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"github.com/mindoc-org/mindoc/conf"
@ -39,20 +41,20 @@ func (c *BlogController) Index() {
blogId, _ := strconv.Atoi(c.Ctx.Input.Param(":id"))
if blogId <= 0 {
c.ShowErrorPage(404, "页面不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.page_not_existed"))
}
blogReadSession := fmt.Sprintf("blog:read:%d", blogId)
blog, err := models.NewBlog().FindFromCache(blogId)
if err != nil {
c.ShowErrorPage(404, "文章不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.blog_not_existed"))
}
if c.Ctx.Input.IsPost() {
password := c.GetString("password")
if blog.BlogStatus == "password" && password != blog.Password {
c.JsonResult(6001, "文章密码不正确")
c.JsonResult(6001, i18n.Tr(c.Lang, "message.blog_pwd_incorrect"))
} else if blog.BlogStatus == "password" && password == blog.Password {
//如果密码输入正确则存入session中
_ = c.CruSession.Set(blogReadSession, blogId)
@ -159,33 +161,33 @@ func (c *BlogController) ManageSetting() {
documentId := 0
if blogTitle == "" {
c.JsonResult(6001, "文章标题不能为空")
c.JsonResult(6001, i18n.Tr(c.Lang, "message.blog_title_empty"))
}
if strings.Count(blogExcerpt, "") > 500 {
c.JsonResult(6008, "文章摘要必须小于500字符")
c.JsonResult(6008, i18n.Tr(c.Lang, "message.blog_digest_tips"))
}
if blogStatus != "public" && blogStatus != "password" && blogStatus != "draft" {
blogStatus = "public"
}
if blogStatus == "password" && blogPassword == "" {
c.JsonResult(6010, "加密文章请设置密码")
c.JsonResult(6010, i18n.Tr(c.Lang, "message.set_pwd_pls"))
}
if blogType != 0 && blogType != 1 {
c.JsonResult(6005, "未知的文章类型")
c.JsonResult(6005, i18n.Tr(c.Lang, "message.unknown_blog_type"))
}
if strings.Count(blogTitle, "") > 200 {
c.JsonResult(6002, "文章标题不能大于200个字符")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.blog_title_tips"))
}
//如果是关联文章,需要同步关联的文档
if blogType == 1 {
book, err := models.NewBook().FindByIdentify(bookIdentify)
if err != nil {
c.JsonResult(6011, "关联文档的项目不存在")
c.JsonResult(6011, i18n.Tr(c.Lang, "message.ref_doc_not_exist_or_no_permit"))
}
doc, err := models.NewDocument().FindByIdentityFirst(documentIdentify, book.BookId)
if err != nil {
c.JsonResult(6003, "查询关联项目文档时出错")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.query_failed"))
}
documentId = doc.DocumentId
@ -194,7 +196,7 @@ func (c *BlogController) ManageSetting() {
bookResult, err := models.NewBookResult().FindByIdentify(book.Identify, c.Member.MemberId)
if err != nil || bookResult.RoleId == conf.BookObserver {
c.JsonResult(6002, "关联文档不存在或权限不足")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.ref_doc_not_exist_or_no_permit"))
}
}
}
@ -210,13 +212,13 @@ func (c *BlogController) ManageSetting() {
}
if err != nil {
c.JsonResult(6003, "文章不存在")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.blog_not_exist"))
}
//如果设置了文章标识
if blogIdentify != "" {
//如果查询到的文章标识存在并且不是当前文章的id
if b, err := models.NewBlog().FindByIdentify(blogIdentify); err == nil && b.BlogId != blogId {
c.JsonResult(6004, "文章标识已存在")
c.JsonResult(6004, i18n.Tr(c.Lang, "message.blog_id_existed"))
}
}
blog.Modified = time.Now()
@ -225,7 +227,7 @@ func (c *BlogController) ManageSetting() {
//如果设置了文章标识
if blogIdentify != "" {
if models.NewBlog().IsExist(blogIdentify) {
c.JsonResult(6004, "文章标识已存在")
c.JsonResult(6004, i18n.Tr(c.Lang, "message.blog_id_existed"))
}
}
@ -252,7 +254,7 @@ func (c *BlogController) ManageSetting() {
if err := blog.Save(); err != nil {
logs.Error("保存文章失败 -> ", err)
c.JsonResult(6011, "保存文章失败")
c.JsonResult(6011, i18n.Tr(c.Lang, "message.failed"))
} else {
c.JsonResult(0, "ok", blog)
}
@ -286,7 +288,7 @@ func (c *BlogController) ManageEdit() {
blogId, _ := c.GetInt("blogId", 0)
if blogId <= 0 {
c.JsonResult(6001, "文章参数错误")
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
}
blogContent := c.GetString("content", "")
blogHtml := c.GetString("htmlContent", "")
@ -303,21 +305,21 @@ func (c *BlogController) ManageEdit() {
}
if err != nil {
logs.Error("查询文章失败 ->", err)
c.JsonResult(6002, "查询文章失败")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.query_failed"))
}
if version > 0 && blog.Version != version && cover != "yes" {
c.JsonResult(6005, "文章已被修改")
c.JsonResult(6005, i18n.Tr(c.Lang, "message.blog_has_modified"))
}
//如果是关联文章,需要同步关联的文档
if blog.BlogType == 1 {
doc, err := models.NewDocument().Find(blog.DocumentId)
if err != nil {
logs.Error("查询关联项目文档时出错 ->", err)
c.JsonResult(6003, "查询关联项目文档时出错")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.query_failed"))
}
book, err := models.NewBook().Find(doc.BookId)
if err != nil {
c.JsonResult(6002, "项目不存在或权限不足")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit"))
}
// 如果不是超级管理员,则校验权限
@ -326,7 +328,7 @@ func (c *BlogController) ManageEdit() {
if err != nil || bookResult.RoleId == conf.BookObserver {
logs.Error("FindByIdentify => ", err)
c.JsonResult(6002, "关联文档不存在或权限不足")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.ref_doc_not_exist_or_no_permit"))
}
}
@ -337,7 +339,7 @@ func (c *BlogController) ManageEdit() {
doc.ModifyAt = c.Member.MemberId
if err := doc.InsertOrUpdate("markdown", "release", "content", "modify_time", "modify_at"); err != nil {
logs.Error("保存关联文档时出错 ->", err)
c.JsonResult(6004, "保存关联文档时出错")
c.JsonResult(6004, i18n.Tr(c.Lang, "message.failed"))
}
}
@ -348,7 +350,7 @@ func (c *BlogController) ManageEdit() {
if err := blog.Save("blog_content", "blog_release", "modify_at", "modify_time", "version"); err != nil {
logs.Error("保存文章失败 -> ", err)
c.JsonResult(6011, "保存文章失败")
c.JsonResult(6011, i18n.Tr(c.Lang, "message.failed"))
} else {
c.JsonResult(0, "ok", blog)
}
@ -357,7 +359,7 @@ func (c *BlogController) ManageEdit() {
blogId, _ := strconv.Atoi(c.Ctx.Input.Param(":id"))
if blogId <= 0 {
c.ShowErrorPage(500, "参数错误")
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.param_error"))
}
var blog *models.Blog
var err error
@ -368,7 +370,7 @@ func (c *BlogController) ManageEdit() {
blog, err = models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId)
}
if err != nil {
c.ShowErrorPage(404, "文章不存在或已删除")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.blog_not_exist"))
}
blog.LinkAttach()
@ -396,7 +398,7 @@ func (c *BlogController) ManageDelete() {
blogId, _ := c.GetInt("blog_id", 0)
if blogId <= 0 {
c.JsonResult(6001, "参数错误")
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
}
var blog *models.Blog
var err error
@ -407,13 +409,13 @@ func (c *BlogController) ManageDelete() {
blog, err = models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId)
}
if err != nil {
c.JsonResult(6002, "文章不存在或已删除")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.blog_not_exist"))
}
if err := blog.Delete(blogId); err != nil {
c.JsonResult(6003, "删除失败")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.failed"))
} else {
c.JsonResult(0, "删除成功")
c.JsonResult(0, i18n.Tr(c.Lang, "message.success"))
}
}
@ -424,16 +426,16 @@ func (c *BlogController) Upload() {
blogId, _ := c.GetInt("blogId")
if blogId <= 0 {
c.JsonResult(6001, "参数错误")
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
}
blog, err := models.NewBlog().Find(blogId)
if err != nil {
c.JsonResult(6010, "文章不存在")
c.JsonResult(6010, i18n.Tr(c.Lang, "message.blog_not_exist"))
}
if !c.Member.IsAdministrator() && blog.MemberId != c.Member.MemberId {
c.JsonResult(6011, "没有文章的访问权限")
c.JsonResult(6011, i18n.Tr(c.Lang, "message.no_permission"))
}
name := "editormd-file-file"
@ -443,7 +445,7 @@ func (c *BlogController) Upload() {
name = "editormd-image-file"
file, moreFile, err = c.GetFile(name)
if err == http.ErrMissingFile {
c.JsonResult(6003, "没有发现需要上传的图片")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty"))
}
}
@ -458,18 +460,18 @@ func (c *BlogController) Upload() {
}
if conf.GetUploadFileSize() > 0 && moreFile.Size > conf.GetUploadFileSize() {
c.JsonResult(6009, "查过文件允许的上传最大值")
c.JsonResult(6009, i18n.Tr(c.Lang, "message.upload_file_size_limit"))
}
ext := filepath.Ext(moreFile.Filename)
if ext == "" {
c.JsonResult(6003, "无法解析文件的格式")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_type_error"))
}
//如果文件类型设置为 * 标识不限制文件类型
if beego.AppConfig.DefaultString("upload_file_ext", "") != "*" {
if !conf.IsAllowUploadFileExt(ext) {
c.JsonResult(6004, "不允许的文件类型")
c.JsonResult(6004, i18n.Tr(c.Lang, "message.upload_file_type_error"))
}
}
@ -478,7 +480,7 @@ func (c *BlogController) Upload() {
_, err := models.NewBlog().Find(blogId)
if err != nil {
c.JsonResult(6006, "文档不存在或权限不足")
c.JsonResult(6006, i18n.Tr(c.Lang, "message.doc_not_exist_or_no_permit"))
}
} else {
@ -487,7 +489,7 @@ func (c *BlogController) Upload() {
if err != nil {
logs.Error("查询文章时出错 -> ", err)
if err == orm.ErrNoRows {
c.JsonResult(6006, "权限不足")
c.JsonResult(6006, i18n.Tr(c.Lang, "message.no_permission"))
}
c.JsonResult(6001, err.Error())
@ -506,7 +508,7 @@ func (c *BlogController) Upload() {
if err != nil {
logs.Error("SaveToFile => ", err)
c.JsonResult(6005, "保存文件失败")
c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed"))
}
var httpPath string
@ -539,14 +541,14 @@ func (c *BlogController) Upload() {
if err := attachment.Insert(); err != nil {
os.Remove(filePath)
logs.Error("保存文件附件失败 -> ", err)
c.JsonResult(6006, "文件保存失败")
c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed"))
}
if attachment.HttpPath == "" {
attachment.HttpPath = conf.URLForNotHost("BlogController.Download", ":id", blogId, ":attach_id", attachment.AttachmentId)
if err := attachment.Update(); err != nil {
logs.Error("保存文件失败 -> ", attachment.FilePath, err)
c.JsonResult(6005, "保存文件失败")
c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed"))
}
}
result["attach"] = attachment
@ -569,21 +571,21 @@ func (c *BlogController) RemoveAttachment() {
blogId, _ := strconv.Atoi(c.Ctx.Input.Param(":id"))
if attachId <= 0 {
c.JsonResult(6001, "参数错误")
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
}
blog, err := models.NewBlog().Find(blogId)
if err != nil {
if err == orm.ErrNoRows {
c.ShowErrorPage(500, "文档不存在")
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.doc_not_exist"))
} else {
c.ShowErrorPage(500, "查询文章时异常")
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.query_failed"))
}
}
attach, err := models.NewAttachment().Find(attachId)
if err != nil {
logs.Error(err)
c.JsonResult(6002, "附件不存在")
c.JsonResult(6002, i18n.Tr(c.Lang, "message.attachment_not_exist"))
}
if !c.Member.IsAdministrator() {
@ -591,19 +593,19 @@ func (c *BlogController) RemoveAttachment() {
if err != nil {
logs.Error(err)
c.JsonResult(6003, "文档不存在")
c.JsonResult(6003, i18n.Tr(c.Lang, "message.doc_not_exist"))
}
}
if blog.BlogType == 1 && attach.BookId != blog.BookId && attach.DocumentId != blog.DocumentId {
c.ShowErrorPage(404, "附件不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist"))
} else if attach.BookId != 0 || attach.DocumentId != blogId {
c.ShowErrorPage(404, "附件不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist"))
}
if err := attach.Delete(); err != nil {
logs.Error(err)
c.JsonResult(6005, "删除失败")
c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed"))
}
os.Remove(filepath.Join(conf.WorkingDirectory, attach.FilePath))
@ -622,15 +624,15 @@ func (c *BlogController) Download() {
blog, err := models.NewBlog().Find(blogId)
if err != nil {
if err == orm.ErrNoRows {
c.ShowErrorPage(500, "文档不存在")
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.doc_not_exist"))
} else {
c.ShowErrorPage(500, "查询文章时异常")
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.query_failed"))
}
}
blogReadSession := fmt.Sprintf("blog:read:%d", blogId)
//如果没有启动匿名访问,或者设置了访问密码
if (c.Member == nil && !c.EnableAnonymous) || (blog.BlogStatus == "password" && password != blog.Password && c.CruSession.Get(blogReadSession) == nil) {
c.ShowErrorPage(403, "没有下载权限")
c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission"))
}
// 查找附件
@ -638,18 +640,18 @@ func (c *BlogController) Download() {
if err != nil {
if err == orm.ErrNoRows {
c.ShowErrorPage(404, "附件不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist"))
} else {
logs.Error("查询附件时出现异常 -> ", err)
c.ShowErrorPage(500, "查询附件时出现异常")
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.query_failed"))
}
}
//如果是链接的文章需要校验文档ID是否一致如果不是需要保证附件的项目ID为0且文档的ID等于博文ID
if blog.BlogType == 1 && attachment.DocumentId != blog.DocumentId {
c.ShowErrorPage(404, "附件不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist"))
} else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId) {
c.ShowErrorPage(404, "附件不存在")
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist"))
}
c.Ctx.Output.Download(filepath.Join(conf.WorkingDirectory, attachment.FilePath), attachment.FileName)

View File

@ -82,13 +82,13 @@
<div class="blog-meta">
<div class="item user_img"><img src="{{cdnimg .Model.MemberAvatar}}" align="{{.Model.CreateName}}"> </div>
<div class="item">&nbsp;{{.Model.CreateName}}</div>
<div class="item">发布于</div>
<div class="item">{{i18n .Lang "blog.posted_on"}}</div>
<div class="item">{{date .Model.Created "Y-m-d H:i:s"}}</div>
<div class="item">{{.Model.ModifyRealName}}</div>
<div class="item">修改于</div>
<div class="item">{{i18n .Lang "blog.modified_on"}}</div>
<div class="item">{{date .Model.Modified "Y-m-d H:i:s"}}</div>
{{if eq .Member.MemberId .Model.MemberId}}
<div class="item"><a href='{{urlfor "BlogController.ManageEdit" ":id" .Model.BlogId}}' title="文章编辑"><i class="fa fa-edit"></i> 编辑</a></div>
<div class="item"><a href='{{urlfor "BlogController.ManageEdit" ":id" .Model.BlogId}}' title="{{i18n .Lang "blog.edit_blog"}}"><i class="fa fa-edit"></i> {{i18n .Lang "common.edit"}}</a></div>
{{end}}
</div>
</div>
@ -96,7 +96,7 @@
<div class="article-body markdown-body editormd-preview-container content">
{{.Content}}
{{if .Model.AttachList}}
<div class="attach-list"><strong>附件</strong><ul>
<div class="attach-list"><strong>{{i18n .Lang "blog.attachment"}}</strong><ul>
{{range $index,$item := .Model.AttachList}}
<li><a href="{{$item.HttpPath}}" title="{{$item.FileName}}">{{$item.FileName}}</a> </li>
{{end}}
@ -106,20 +106,20 @@
</div>
<div class="row blog-footer">
<p>
<span>上一篇</span>
<span>{{i18n .Lang "blog.prev"}}</span>
{{if .Previous}}
<a href="{{urlfor "BlogController.Index" ":id" .Previous.BlogId}}" title="{{.Previous.BlogTitle}}">{{.Previous.BlogTitle}}
</a>
{{else}}
{{i18n .Lang "blog.no"}}
{{end}}
</p>
<p>
<span>下一篇</span>
<span>{{i18n .Lang "blog.next"}}</span>
{{if .Next}}
<a href="{{urlfor "BlogController.Index" ":id" .Next.BlogId}}" title="{{.Next.BlogTitle}}">{{.Next.BlogTitle}}</a>
{{else}}
{{i18n .Lang "blog.no"}}
{{end}}
</p>
</div>

View File

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>请输入文章密码 - Powered by MinDoc</title>
<title>{{i18n .Lang "doc.input_pwd"}} - Powered by MinDoc</title>
<script src="{{cdnjs "static/jquery/1.12.4/jquery.min.js"}}"></script>
<script src="{{cdnjs "static/js/jquery.form.js"}}"></script>
<style type="text/css">
@ -99,14 +99,14 @@
<form action="{{urlfor "BlogController.Index" ":id" .Model.BlogId}}" method="post" id="auth_form">
<input type="hidden" value="{{.Model.BlogId}}" name="blogId" />
<div class="tit">
请输入浏览密码
{{i18n .Lang "doc.input_pwd"}}
</div>
<div style="margin-top: 10px;">
<input type="password" name="password" placeholder="浏览密码" class="inp"/>
<input type="password" name="password" placeholder="{{i18n .Lang "blog.access_pass"}}" class="inp"/>
</div>
<div class="btn">
<span id="error" style="color: #919191; font-size: 13px;"></span>
<input type="submit" value="提交" class="button"/>
<input type="submit" value="{{i18n .Lang "doc.commit"}}" class="button"/>
</div>
<div class="clear"></div>
</form>
@ -117,7 +117,7 @@ $("#auth_form").ajaxForm({
beforeSerialize: function () {
var pwd = $("#auth_form input[name='password']").val();
if (pwd === "") {
$("#error").html("请输入密码");
$("#error").html("{{i18n .Lang "doc.input_pwd"}}");
return false;
}
},

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>文章列表 - Powered by MinDoc</title>
<title>{{i18n .Lang "blog.blog_list"}} - Powered by MinDoc</title>
<meta name="keywords" content="MinDoc,文档在线管理系统,WIKI,wiki,wiki在线,文档在线管理,接口文档在线管理,接口文档管理">
<meta name="description" content="MinDoc文档在线管理系统 {{.site_description}}">
<!-- Bootstrap -->
@ -30,20 +30,20 @@
<div class="manual-list">
{{range $index,$item := .Lists}}
<div class="search-item">
<div class="title">{{if eq $item.BlogStatus "password"}}<span class="label"></span>{{end}} <a href="{{urlfor "BlogController.Index" ":id" $item.BlogId}}" title="{{$item.BlogTitle}}">{{$item.BlogTitle}}</a> </div>
<div class="title">{{if eq $item.BlogStatus "password"}}<span class="label">{{i18n $.Lang "blog.encrypt"}}</span>{{end}} <a href="{{urlfor "BlogController.Index" ":id" $item.BlogId}}" title="{{$item.BlogTitle}}">{{$item.BlogTitle}}</a> </div>
<div class="description">
{{$item.BlogExcerpt}}
</div>
{{/*<div class="site">{{urlfor "BlogController.Index" ":id" $item.BlogId}}</div>*/}}
<div class="source">
<span class="item">作者{{$item.CreateName}}</span>
<span class="item">更新时间{{date_format $item.Modified "2006-01-02 15:04:05"}}</span>
<span class="item">{{i18n $.Lang "blog.author"}}{{$item.CreateName}}</span>
<span class="item">{{i18n $.Lang "blog.update_time"}}{{date_format $item.Modified "2006-01-02 15:04:05"}}</span>
</div>
</div>
{{else}}
<div class="search-empty">
<img src="{{cdnimg "/static/images/search_empty.png"}}" class="empty-image">
<span class="empty-text">暂无文章</span>
<span class="empty-text">{{i18n $.Lang "blog.no_blog"}}</span>
</div>
{{end}}
<nav class="pagination-container">

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>编辑文章 - Powered by MinDoc</title>
<title>{{i18n .Lang "blog.edit_title"}} - Powered by MinDoc</title>
<script type="text/javascript">
window.baseUrl = "{{.BaseUrl}}";
window.katex = { js: "{{cdnjs "/static/katex/katex"}}",css: "{{cdncss "/static/katex/katex"}}"};
@ -18,12 +18,13 @@
window.blogVersion = {{.Model.Version}};
window.removeAttachURL = "{{urlfor "BlogController.RemoveAttachment" ":id" .Model.BlogId}}";
window.highlightStyle = "{{.HighlightStyle}}";
window.lang = {{i18n $.Lang "common.js_lang"}};
</script>
<!-- Bootstrap -->
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/jstree/3.3.4/themes/default/style.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/editor.md/css/editormd.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/editor.md/css/editormd.css" "version"}}" rel="stylesheet">
<link href="{{cdncss "/static/css/jstree.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/webuploader/webuploader.css"}}" rel="stylesheet">
@ -35,50 +36,50 @@
<div class="m-manual manual-editor">
<div class="manual-head" id="editormd-tools" style="min-width: 1200px; position:absolute;">
<div class="editormd-group">
<a href="{{urlfor "BlogController.ManageList"}}" data-toggle="tooltip" data-title="返回"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>
<a href="{{urlfor "BlogController.ManageList"}}" data-toggle="tooltip" data-title="{{i18n .Lang "doc.backward"}}"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>
</div>
<div class="editormd-group">
<a href="javascript:;" id="markdown-save" data-toggle="tooltip" data-title="保存" class="disabled save"><i class="fa fa-save" aria-hidden="true" name="save"></i></a>
<a href="javascript:;" id="markdown-save" data-toggle="tooltip" data-title="{{i18n .Lang "doc.save"}}" class="disabled save"><i class="fa fa-save" aria-hidden="true" name="save"></i></a>
</div>
<div class="editormd-group">
<a href="javascript:;" data-toggle="tooltip" data-title="撤销 (Ctrl-Z)"><i class="fa fa-undo first" name="undo" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="重做 (Ctrl-Y)"><i class="fa fa-repeat last" name="redo" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.undo"}} (Ctrl-Z)"><i class="fa fa-undo first" name="undo" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.redo"}} (Ctrl-Y)"><i class="fa fa-repeat last" name="redo" unselectable="on"></i></a>
</div>
<div class="editormd-group">
<a href="javascript:;" data-toggle="tooltip" data-title="粗体"><i class="fa fa-bold first" name="bold" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="斜体"><i class="fa fa-italic item" name="italic" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="删除线"><i class="fa fa-strikethrough last" name="del" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.bold"}}"><i class="fa fa-bold first" name="bold" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.italic"}}"><i class="fa fa-italic item" name="italic" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.strikethrough"}}"><i class="fa fa-strikethrough last" name="del" unselectable="on"></i></a>
</div>
<div class="editormd-group">
<a href="javascript:;" data-toggle="tooltip" data-title="标题一"><i class="fa editormd-bold first" name="h1" unselectable="on">H1</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="标题二"><i class="fa editormd-bold item" name="h2" unselectable="on">H2</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="标题三"><i class="fa editormd-bold item" name="h3" unselectable="on">H3</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="标题四"><i class="fa editormd-bold item" name="h4" unselectable="on">H4</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="标题五"><i class="fa editormd-bold item" name="h5" unselectable="on">H5</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="标题六"><i class="fa editormd-bold last" name="h6" unselectable="on">H6</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.h1"}}"><i class="fa editormd-bold first" name="h1" unselectable="on">H1</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.h2"}}"><i class="fa editormd-bold item" name="h2" unselectable="on">H2</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.h3"}}"><i class="fa editormd-bold item" name="h3" unselectable="on">H3</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.h4"}}"><i class="fa editormd-bold item" name="h4" unselectable="on">H4</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.h5"}}"><i class="fa editormd-bold item" name="h5" unselectable="on">H5</i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.h6"}}"><i class="fa editormd-bold last" name="h6" unselectable="on">H6</i></a>
</div>
<div class="editormd-group">
<a href="javascript:;" data-toggle="tooltip" data-title="无序列表"><i class="fa fa-list-ul first" name="list-ul" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="有序列表"><i class="fa fa-list-ol item" name="list-ol" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="横线"><i class="fa fa-minus last" name="hr" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.unorder_list"}}"><i class="fa fa-list-ul first" name="list-ul" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.order_list"}}"><i class="fa fa-list-ol item" name="list-ol" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.hline"}}"><i class="fa fa-minus last" name="hr" unselectable="on"></i></a>
</div>
<div class="editormd-group">
<a href="javascript:;" data-toggle="tooltip" data-title="链接"><i class="fa fa-link first" name="link" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="引用链接"><i class="fa fa-anchor item" name="reference-link" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="添加图片"><i class="fa fa-picture-o item" name="image" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="行内代码"><i class="fa fa-code item" name="code" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="代码块" unselectable="on"><i class="fa fa-file-code-o item" name="code-block" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="添加表格"><i class="fa fa-table item" name="table" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="引用"><i class="fa fa-quote-right item" name="quote" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="GFM 任务列表"><i class="fa fa-tasks item" name="tasks" aria-hidden="true"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="附件"><i class="fa fa-paperclip item" aria-hidden="true" name="attachment"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="模板"><i class="fa fa-tachometer last" name="template"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.link"}}"><i class="fa fa-link first" name="link" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.ref_link"}}"><i class="fa fa-anchor item" name="reference-link" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.add_pic"}}"><i class="fa fa-picture-o item" name="image" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.code"}}"><i class="fa fa-code item" name="code" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.code_block"}}" unselectable="on"><i class="fa fa-file-code-o item" name="code-block" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.table"}}"><i class="fa fa-table item" name="table" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.quote"}}"><i class="fa fa-quote-right item" name="quote" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.gfm_task"}}"><i class="fa fa-tasks item" name="tasks" aria-hidden="true"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.attachment"}}"><i class="fa fa-paperclip item" aria-hidden="true" name="attachment"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.template"}}"><i class="fa fa-tachometer last" name="template"></i></a>
</div>
<div class="editormd-group pull-right">
<a href="javascript:;" data-toggle="tooltip" data-title="关闭实时预览"><i class="fa fa-eye-slash first" name="watch" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="使用帮助"><i class="fa fa-question-circle-o last" aria-hidden="true" name="help"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.close_preview"}}"><i class="fa fa-eye-slash first" name="watch" unselectable="on"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-title="{{i18n .Lang "doc.help"}}"><i class="fa fa-question-circle-o last" aria-hidden="true" name="help"></i></a>
</div>
<div class="editormd-group">
@ -94,7 +95,7 @@
<div id="docEditor" class="manual-editormd-active"><textarea style="display: none">{{str2html .Model.BlogContent}}</textarea> </div>
</div>
<div class="manual-editor-status">
<div id="attachInfo" class="item">0 个附件</div>
<div id="attachInfo" class="item">0 {{i18n .Lang "doc.attachments"}}</div>
</div>
</div>
@ -109,7 +110,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">上传附件</h4>
<h4 class="modal-title" id="myModalLabel">{{i18n .Lang "doc.upload_attachment"}}</h4>
</div>
<div class="modal-body">
<div class="attach-drop-panel">
@ -146,8 +147,8 @@
</div>
<div class="modal-footer">
<span id="add-error-message" class="error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" id="btnUploadAttachFile" data-dismiss="modal">确定</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{{i18n .Lang "common.cancel"}}</button>
<button type="button" class="btn btn-primary" id="btnUploadAttachFile" data-dismiss="modal">{{i18n .Lang "common.confirm"}}</button>
</div>
</div>
</form>
@ -156,44 +157,44 @@
<!-- Modal -->
<div class="modal fade" id="documentTemplateModal" tabindex="-1" role="dialog" aria-labelledby="请选择模板类型" aria-hidden="true">
<div class="modal fade" id="documentTemplateModal" tabindex="-1" role="dialog" aria-labelledby="{{i18n .Lang "doc.choose_template_type"}}" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modal-title">请选择模板类型</h4>
<h4 class="modal-title" id="modal-title">{{i18n .Lang "doc.choose_template_type"}}</h4>
</div>
<div class="modal-body template-list">
<div class="container">
<div class="section">
<a data-type="normal" href="javascript:;"><i class="fa fa-file-o"></i></a>
<h3><a data-type="normal" href="javascript:;">普通文档</a></h3>
<h3><a data-type="normal" href="javascript:;">{{i18n .Lang "doc.normal_tpl"}}</a></h3>
<ul>
<li>默认类型</li>
<li>简单的文本文档</li>
<li>{{i18n .Lang "doc.tpl_default_type"}}</li>
<li>{{i18n .Lang "doc.tpl_plain_text"}}</li>
</ul>
</div>
<div class="section">
<a data-type="api" href="javascript:;"><i class="fa fa-file-code-o"></i></a>
<h3><a data-type="api" href="javascript:;">API文档</a></h3>
<h3><a data-type="api" href="javascript:;">{{i18n .Lang "doc.api_tpl"}}</a></h3>
<ul>
<li>用于API文档速写</li>
<li>支持代码高亮</li>
<li>{{i18n .Lang "doc.for_api_doc"}}</li>
<li>{{i18n .Lang "doc.code_highlight"}}</li>
</ul>
</div>
<div class="section">
<a data-type="code" href="javascript:;"><i class="fa fa-book"></i></a>
<h3><a data-type="code" href="javascript:;">数据字典</a></h3>
<h3><a data-type="code" href="javascript:;">{{i18n .Lang "doc.data_dict"}}</a></h3>
<ul>
<li>用于数据字典显示</li>
<li>表格支持</li>
<li>{{i18n .Lang "doc.for_data_dict"}}</li>
<li>{{i18n .Lang "doc.form_support"}}</li>
</ul>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{{i18n .Lang "common.cancel"}}</button>
</div>
</div>
</div>
@ -220,7 +221,13 @@
<script src="{{cdnjs "/static/js/blog.js" "version"}}" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
lang = {{i18n $.Lang "common.js_lang"}};
editLangPath = {{cdnjs "/static/editor.md/languages/"}} + lang
if(lang != 'zh-CN') {
editormd.loadScript(editLangPath, function(){
window.editor.lang = editormd.defaults.lang;
window.editor.recreate()
});
}
window.vueApp.lists = {{.AttachList}};
$("#attachInfo").on("click",function () {
$("#uploadAttachModal").modal("show");
@ -246,7 +253,7 @@
attachment_id : file.id,
file_size : file.size,
file_name : file.name,
message : "正在上传"
message : "{{i18n .Lang "doc.uploading"}}"
};
window.vueApp.lists.push(item);
@ -255,7 +262,8 @@
var item = window.vueApp.lists[i];
if(item.attachment_id == file.id){
item.state = "error";
item.message = "上传失败:" + reason;
item.message = "{{i18n .Lang "message.upload_failed"}}:" + reason;
break;
}
}
@ -265,7 +273,7 @@
var item = window.vueApp.lists[index];
if(item.attachment_id === file.id){
if(res.errcode === 0) {
window.vueApp.lists.splice(index, 1, res.attach?res.attach:res.data);
window.vueApp.lists.splice(index, 1, res.attach ? res.attach : res.data);
}else{
item.message = res.message;
item.state = "error";
@ -279,7 +287,7 @@
$percent.css( 'width', percentage * 100 + '%' );
}).on("error", function (type) {
if(type === "F_EXCEED_SIZE"){
layer.msg("文件超过了限定大小");
layer.msg("{{i18n .Lang "message.upload_file_size_limit"}}");
}
console.log(type);
});

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>我的文章 - Powered by MinDoc</title>
<title>{{i18n .Lang "common.my_blog"}} - Powered by MinDoc</title>
<!-- Bootstrap -->
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet" type="text/css">
@ -27,16 +27,16 @@
<div class="row">
<div class="page-left">
<ul class="menu">
<li {{if eq .ControllerName "BookController"}}class="active"{{end}}><a href="{{urlfor "BookController.Index"}}" class="item"><i class="fa fa-sitemap" aria-hidden="true"></i> 我的项目</a> </li>
<li {{if eq .ControllerName "BlogController"}}class="active"{{end}}><a href="{{urlfor "BlogController.ManageList"}}" class="item"><i class="fa fa-file" aria-hidden="true"></i> 我的文章</a> </li>
<li {{if eq .ControllerName "BookController"}}class="active"{{end}}><a href="{{urlfor "BookController.Index"}}" class="item"><i class="fa fa-sitemap" aria-hidden="true"></i> {{i18n .Lang "common.my_project"}}</a> </li>
<li {{if eq .ControllerName "BlogController"}}class="active"{{end}}><a href="{{urlfor "BlogController.ManageList"}}" class="item"><i class="fa fa-file" aria-hidden="true"></i> {{i18n .Lang "common.my_blog"}}</a> </li>
</ul>
</div>
<div class="page-right">
<div class="m-box">
<div class="box-head">
<strong class="box-title">文章列表</strong>
<strong class="box-title">{{i18n .Lang "blog.blog_list"}}</strong>
&nbsp;
<a href="{{urlfor "BlogController.ManageSetting"}}" class="btn btn-success btn-sm pull-right">添加文章</a>
<a href="{{urlfor "BlogController.ManageSetting"}}" class="btn btn-success btn-sm pull-right">{{i18n .Lang "blog.add_blog"}}</a>
</div>
</div>
<div class="box-body" id="blogList">
@ -46,7 +46,7 @@
<div class="content">
<a class="header" href="{{urlfor "BlogController.Index" ":id" $item.BlogId}}" target="_blank">
{{if eq $item.BlogStatus "password"}}
<div class="ui teal label horizontal" data-tooltip="加密">密</div>
<div class="ui teal label horizontal" data-tooltip="{{i18n $.Lang "blog.encryption"}}">{{i18n $.Lang "blog.encrypt"}}</div>
{{end}}
{{$item.BlogTitle}}
</a>
@ -57,16 +57,16 @@
<div>
<div class="ui horizontal small list">
<div class="item"><i class="fa fa-clock-o"></i> {{date $item.Modified "Y-m-d H:i:s"}}</div>
<div class="item"><a href="{{urlfor "BlogController.ManageEdit" ":id" $item.BlogId}}" title="文章编辑" target="_blank"><i class="fa fa-edit"></i> 编辑</a></div>
<div class="item"><a class="delete-btn" title="删除文章" data-id="{{$item.BlogId}}"><i class="fa fa-trash"></i> 删除</a></div>
<div class="item"><a href="{{urlfor "BlogController.ManageSetting" ":id" $item.BlogId}}" title="文章设置" class="setting-btn"><i class="fa fa-gear"></i> 设置</a></div>
<div class="item"><a href="{{urlfor "BlogController.ManageEdit" ":id" $item.BlogId}}" title="{{i18n $.Lang "blog.edit_blog"}}" target="_blank"><i class="fa fa-edit"></i> {{i18n $.Lang "blog.edit"}}</a></div>
<div class="item"><a class="delete-btn" title="{{i18n $.Lang "blog.delete_blog"}}" data-id="{{$item.BlogId}}"><i class="fa fa-trash"></i> {{i18n $.Lang "blog.delete"}}</a></div>
<div class="item"><a href="{{urlfor "BlogController.ManageSetting" ":id" $item.BlogId}}" title="{{i18n $.Lang "blog.setting_blog"}}" class="setting-btn"><i class="fa fa-gear"></i> {{i18n $.Lang "common.setting"}}</a></div>
</div>
</div>
</div>
</div>
</div>
{{else}}
<div class="text-center">暂无文章</div>
<div class="text-center">{{i18n .Lang "blog.no_blog"}}</div>
{{end}}
</div>
<nav class="pagination-container">
@ -88,17 +88,17 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">删除文章</h4>
<h4 class="modal-title">{{i18n .Lang "blog.delete_blog"}}</h4>
</div>
<div class="modal-body">
<span style="font-size: 14px;font-weight: 400;">确定删除文章吗?</span>
<span style="font-size: 14px;font-weight: 400;">{{i18n .Lang "message.confirm_delete_blog"}}</span>
<p></p>
<p class="text error-message">删除文章后将无法找回。</p>
<p class="text error-message">{{i18n .Lang "message.delete_blog_tips"}}</p>
</div>
<div class="modal-footer">
<span id="form-error-message2" class="error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" id="btnDeleteBlog" class="btn btn-primary" data-loading-text="删除中...">确定删除</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{{i18n .Lang "common.cancel"}}</button>
<button type="submit" id="btnDeleteBlog" class="btn btn-primary" data-loading-text="{{i18n .Lang "message.process"}}">{{i18n .Lang "common.confirm_delete"}}</button>
</div>
</div>
</form>
@ -140,7 +140,7 @@
},
error : function () {
layer.close(index);
layer.msg('服务器异常');
layer.msg({{i18n .Lang "message.system_error"}});
}
});
}
@ -166,7 +166,7 @@
$("#btnDeleteBlog").button("reset");
},
error : function () {
showError("服务器异常","#form-error-message2");
showError({{i18n .Lang "message.system_error"}},"#form-error-message2");
$("#btnDeleteBlog").button("reset");
}
});

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>文章设置 - Powered by MinDoc</title>
<title>{{i18n .Lang "blog.blog_setting"}} - Powered by MinDoc</title>
<!-- Bootstrap -->
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
@ -32,7 +32,7 @@
<div class="page-right">
<div class="m-box">
<div class="box-head">
<strong class="box-title"> 文章设置</strong>
<strong class="box-title"> {{i18n .Lang "blog.blog_setting"}}</strong>
</div>
</div>
<div class="box-body">
@ -42,58 +42,58 @@
<input type="hidden" name="document_id" value="{{.Model.DocumentId}}">
<input type="hidden" name="order_index" value="{{.Model.OrderIndex}}">
<div class="form-group">
<label>文章标题</label>
<input type="text" class="form-control" name="title" id="title" placeholder="文章标题" value="{{.Model.BlogTitle}}">
<label>{{i18n .Lang "blog.title"}}</label>
<input type="text" class="form-control" name="title" id="title" placeholder="{{i18n .Lang "blog.title"}}" value="{{.Model.BlogTitle}}">
</div>
<div class="form-group">
<label>文章类型</label>
<label>{{i18n .Lang "blog.type"}}</label>
<div class="radio">
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogType 0}}checked{{end}} name="blog_type" value="0">普通文章<span class="text"></span>
<input type="radio" {{if eq .Model.BlogType 0}}checked{{end}} name="blog_type" value="0">{{i18n .Lang "blog.normal_blog"}}<span class="text"></span>
</label>
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogType 1}}checked{{end}} name="blog_type" value="1">链接文章<span class="text"></span>
<input type="radio" {{if eq .Model.BlogType 1}}checked{{end}} name="blog_type" value="1">{{i18n .Lang "blog.link_blog"}}<span class="text"></span>
</label>
</div>
</div>
<div class="form-group" id="blogLinkDocument"{{if ne .Model.BlogType 1}} style="display: none;" {{end}}>
<label>关联文档</label>
<label>{{i18n .Lang "blog.ref_doc"}}</label>
<div class="row">
<div class="col-sm-6">
<input type="text" class="form-control" placeholder="请输入项目标识" name="bookIdentify" value="{{.Model.BookIdentify}}">
<input type="text" class="form-control" placeholder="{{i18n .Lang "message.input_proj_id_pls"}}" name="bookIdentify" value="{{.Model.BookIdentify}}">
</div>
<div class="col-sm-6">
<input type="text" class="form-control" placeholder="请输入文档标识" name="documentIdentify" value="{{.Model.DocumentIdentify}}">
<input type="text" class="form-control" placeholder="{{i18n .Lang "message.input_doc_id_pls"}}" name="documentIdentify" value="{{.Model.DocumentIdentify}}">
</div>
</div>
</div>
<div class="form-group">
<label>文章状态</label>
<label>{{i18n .Lang "blog.blog_status"}}</label>
<div class="radio">
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogStatus "public"}}checked{{end}} name="status" value="public">公开<span class="text"></span>
<input type="radio" {{if eq .Model.BlogStatus "public"}}checked{{end}} name="status" value="public">{{i18n .Lang "blog.public"}}<span class="text"></span>
</label>
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogStatus "password"}}checked{{end}} name="status" value="password">加密<span class="text"></span>
<input type="radio" {{if eq .Model.BlogStatus "password"}}checked{{end}} name="status" value="password">{{i18n .Lang "blog.encryption"}}<span class="text"></span>
</label>
</div>
</div>
<div class="form-group"{{if eq .Model.BlogStatus "public"}} style="display: none;"{{end}} id="blogPassword">
<label>文章密码</label>
<input type="password" class="form-control" name="password" id="password" placeholder="文章密码" value="{{.Model.Password}}" maxlength="20">
<label>{{i18n .Lang "blog.blog_pwd"}}</label>
<input type="password" class="form-control" name="password" id="password" placeholder="{{i18n .Lang "blog.blog_pwd"}}" value="{{.Model.Password}}" maxlength="20">
</div>
<div class="form-group">
<label>文章摘要</label>
<textarea rows="3" class="form-control" name="excerpt" style="height: 90px" placeholder="项目描述">{{.Model.BlogExcerpt}}</textarea>
<p class="text">文章摘要不超过500个字符</p>
<label>{{i18n .Lang "blog.blog_digest"}}</label>
<textarea rows="3" class="form-control" name="excerpt" style="height: 90px" placeholder="{{i18n .Lang "blog.blog_digest"}}">{{.Model.BlogExcerpt}}</textarea>
<p class="text">{{i18n .Lang "message.blog_digest_tips"}}</p>
</div>
<div class="form-group">
<button type="submit" id="btnSaveBlogInfo" class="btn btn-success" data-loading-text="保存中...">保存</button>
<a href="{{.Referer}}" title="返回" class="btn btn-info">返回</a>
<button type="submit" id="btnSaveBlogInfo" class="btn btn-success" data-loading-text="{{i18n .Lang "message.processing"}}">{{i18n .Lang "common.save"}}</button>
<a href="{{.Referer}}" title="{{i18n .Lang "doc.backward"}}" class="btn btn-info">{{i18n .Lang "doc.backward"}}</a>
<span id="form-error-message" class="error-message"></span>
</div>
</form>
@ -119,19 +119,19 @@
var title = $.trim($("#title").val());
if (title === ""){
return showError("文章标题不能为空");
return showError("{{i18n .Lang "message.blog_title_empty"}}");
}
$("#btnSaveBlogInfo").button("loading");
},success : function ($res) {
if($res.errcode === 0) {
showSuccess("保存成功");
showSuccess("{{i18n .Lang "message.success"}}");
$("#blogId").val($res.data.blog_id);
}else{
showError($res.message);
}
$("#btnSaveBlogInfo").button("reset");
}, error : function () {
showError("服务器异常.");
showError("{{i18n .Lang "message.system_error"}}");
$("#btnSaveBlogInfo").button("reset");
}
}).find("input[name='status']").change(function () {