Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues: 功能优化和体验优化 #972

Merged
merged 5 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions controllers/BlogController.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *BlogController) ManageList() {

pageIndex, _ := c.GetInt("page", 1)

blogList, totalCount, err := models.NewBlog().FindToPager(pageIndex, conf.PageSize, c.Member.MemberId, "")
blogList, totalCount, err := models.NewBlog().FindToPager(pageIndex, conf.PageSize, c.Member.MemberId, "all")

if err != nil {
c.ShowErrorPage(500, err.Error())
Expand Down Expand Up @@ -168,7 +168,7 @@ func (c *BlogController) ManageSetting() {
if strings.Count(blogExcerpt, "") > 500 {
c.JsonResult(6008, i18n.Tr(c.Lang, "message.blog_digest_tips"))
}
if blogStatus != "public" && blogStatus != "password" && blogStatus != "draft" {
if blogStatus != "private" && blogStatus != "public" && blogStatus != "password" && blogStatus != "draft" {
blogStatus = "public"
}
if blogStatus == "password" && blogPassword == "" {
Expand Down
39 changes: 23 additions & 16 deletions models/Blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/mindoc-org/mindoc/utils"
)

//博文表
// 博文表
type Blog struct {
BlogId int `orm:"pk;auto;unique;column(blog_id)" json:"blog_id"`
//文章标题
Expand Down Expand Up @@ -89,7 +89,7 @@ func NewBlog() *Blog {
}
}

//根据文章ID查询文章
// 根据文章ID查询文章
func (b *Blog) Find(blogId int) (*Blog, error) {
o := orm.NewOrm()

Expand All @@ -102,7 +102,7 @@ func (b *Blog) Find(blogId int) (*Blog, error) {
return b.Link()
}

//从缓存中读取文章
// 从缓存中读取文章
func (b *Blog) FindFromCache(blogId int) (blog *Blog, err error) {
key := fmt.Sprintf("blog-id-%d", blogId)
var temp Blog
Expand All @@ -126,7 +126,7 @@ func (b *Blog) FindFromCache(blogId int) (blog *Blog, err error) {
return
}

//查找指定用户的指定文章
// 查找指定用户的指定文章
func (b *Blog) FindByIdAndMemberId(blogId, memberId int) (*Blog, error) {
o := orm.NewOrm()

Expand All @@ -139,7 +139,7 @@ func (b *Blog) FindByIdAndMemberId(blogId, memberId int) (*Blog, error) {
return b.Link()
}

//根据文章标识查询文章
// 根据文章标识查询文章
func (b *Blog) FindByIdentify(identify string) (*Blog, error) {
o := orm.NewOrm()

Expand All @@ -151,7 +151,7 @@ func (b *Blog) FindByIdentify(identify string) (*Blog, error) {
return b, nil
}

//获取指定文章的链接内容
// 获取指定文章的链接内容
func (b *Blog) Link() (*Blog, error) {
o := orm.NewOrm()
//如果是链接文章,则需要从链接的项目中查找文章内容
Expand Down Expand Up @@ -211,14 +211,14 @@ func (b *Blog) Link() (*Blog, error) {
return b, nil
}

//判断指定的文章标识是否存在
// 判断指定的文章标识是否存在
func (b *Blog) IsExist(identify string) bool {
o := orm.NewOrm()

return o.QueryTable(b.TableNameWithPrefix()).Filter("blog_identify", identify).Exist()
}

//保存文章
// 保存文章
func (b *Blog) Save(cols ...string) error {
o := orm.NewOrm()

Expand All @@ -239,7 +239,7 @@ func (b *Blog) Save(cols ...string) error {
b.Modified = time.Now()
_, err = o.Update(b, cols...)
key := fmt.Sprintf("blog-id-%d", b.BlogId)
cache.Delete(key)
_ = cache.Delete(key)

} else {

Expand All @@ -250,7 +250,7 @@ func (b *Blog) Save(cols ...string) error {
return err
}

//过滤文章的危险标签,处理文章外链以及图片.
// 过滤文章的危险标签,处理文章外链以及图片.
func (b *Blog) Processor() *Blog {

b.BlogRelease = utils.SafetyProcessor(b.BlogRelease)
Expand Down Expand Up @@ -285,7 +285,7 @@ func (b *Blog) Processor() *Blog {
return b
}

//分页查询文章列表
// 分页查询文章列表
func (b *Blog) FindToPager(pageIndex, pageSize int, memberId int, status string) (blogList []*Blog, totalCount int, err error) {

o := orm.NewOrm()
Expand All @@ -297,10 +297,14 @@ func (b *Blog) FindToPager(pageIndex, pageSize int, memberId int, status string)
if memberId > 0 {
query = query.Filter("member_id", memberId)
}
if status != "" {
if status != "" && status != "all" {
query = query.Filter("blog_status", status)
}

if status == "" {
query = query.Filter("blog_status__ne", "private")
}

_, err = query.OrderBy("-order_index", "-blog_id").Offset(offset).Limit(pageSize).All(&blogList)

if err != nil {
Expand All @@ -326,8 +330,11 @@ func (b *Blog) FindToPager(pageIndex, pageSize int, memberId int, status string)
return
}

//删除文章
// 删除文章
func (b *Blog) Delete(blogId int) error {
// 删除文章缓存
key := fmt.Sprintf("blog-id-%d", blogId)
_ = cache.Delete(key)
o := orm.NewOrm()

_, err := o.QueryTable(b.TableNameWithPrefix()).Filter("blog_id", blogId).Delete()
Expand All @@ -337,7 +344,7 @@ func (b *Blog) Delete(blogId int) error {
return err
}

//查询下一篇文章
// 查询下一篇文章
func (b *Blog) QueryNext(blogId int) (*Blog, error) {
o := orm.NewOrm()
blog := NewBlog()
Expand All @@ -355,7 +362,7 @@ func (b *Blog) QueryNext(blogId int) (*Blog, error) {
return blog, err
}

//查询下一篇文章
// 查询下一篇文章
func (b *Blog) QueryPrevious(blogId int) (*Blog, error) {
o := orm.NewOrm()
blog := NewBlog()
Expand All @@ -373,7 +380,7 @@ func (b *Blog) QueryPrevious(blogId int) (*Blog, error) {
return blog, err
}

//关联文章附件
// 关联文章附件
func (b *Blog) LinkAttach() (err error) {

o := orm.NewOrm()
Expand Down
12 changes: 12 additions & 0 deletions static/cherry/cherry-markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -6078,3 +6078,15 @@ span.change {
border-radius: 10px !important;
background-color: #b3d4fc !important;
}


@media screen and (max-width: 1400px) {
.cherry-toolbar-button {
padding: 0;
}

.cherry-toolbar .toolbar-left {
justify-content: space-between;
width: 95%;
}
}
28 changes: 11 additions & 17 deletions static/editor.md/plugins/image-dialog/image-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"<label>" + imageLang.url + "</label>" +
"<input type=\"text\" data-url />" + (function() {
return (settings.imageUpload) ? "<div class=\"" + classPrefix + "file-input\">" +
// 3xxx ÏÂÐÐÌí¼Ómultiple=\"multiple\"
// 3xxx �������multiple=\"multiple\"
"<input type=\"file\" name=\"" + classPrefix + "image-file\" accept=\"image/jpeg,image/png,image/gif,image/jpg\" multiple=\"multiple\" />" +
"<input type=\"submit\" value=\"" + imageLang.uploadButton + "\" />" +
"</div>" : "";
Expand All @@ -78,7 +78,7 @@
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
// ÕâÀォ¶àͼƬµØÖ·¸ÄÔìºó²åÈëÎĵµÖÐ
// ���ォ��ͼƬ��ַ���������ĵ���
buttons: {
enter: [lang.buttons.enter, function() {
var url = this.find("[data-url]").val();
Expand All @@ -88,7 +88,7 @@
alert(imageLang.imageURLEmpty);
return false;
}
// ÕâÀïÔö¼ÓÑ­»·
// ��������ѭ��
let arr = url.split(";");
var altAttr = (alt !== "") ? " \"" + alt + "\"" : "";
for (let i = 0; i < arr.length; i++) {
Expand Down Expand Up @@ -121,19 +121,19 @@
fileInput.bind("change", function() {
// 3xxx 20240602
// let formData = new FormData();
// »ñÈ¡Îı¾¿òdom
// ��ȡ�ı���dom
// var doc = document.getElementById('doc');
// »ñÈ¡ÉÏ´«¿Ø¼þdom
// ��ȡ�ϴ��ؼ�dom
// var upload = document.getElementById('upload');
// let files = upload.files;
//±éÀúÎļþÐÅÏ¢appendµ½formData´æ´¢
//�����ļ���Ϣappend��formData�洢
// for (let i = 0; i < files.length; i++) {
// let file = files[i]
// formData.append('files', file)
// }
// »ñÈ¡ÎļþÃû
// ��ȡ�ļ���
// var fileName = upload.files[0].name;
// »ñÈ¡Îļþ·¾¶
// ��ȡ�ļ�·��
// var filePath = upload.value;
// doc.value = fileName;
// 3xxx
Expand Down Expand Up @@ -161,17 +161,11 @@
var json = (body.innerText) ? body.innerText : ((body.textContent) ? body.textContent : null);
json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
var url="";
for (let i = 0; i < json.length; i++) {
if (json[i].success === 1) {
if (i==0){
url=json[i].url;
}else{
url=url+";"+json[i].url;
}
if (json.success === 1) {
url=json.url;
} else {
alert(json[i].message);
alert(json.message);
}
}
dialog.find("[data-url]").val(url)
return false;
};
Expand Down
5 changes: 4 additions & 1 deletion views/blog/manage_setting.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogStatus "password"}}checked{{end}} name="status" value="password">{{i18n .Lang "blog.encryption"}}<span class="text"></span>
</label>
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogStatus "private"}}checked{{end}} name="status" value="private">{{i18n .Lang "blog.private"}}<span class="text"></span>
</label>
</div>
</div>
<div class="form-group"{{if eq .Model.BlogStatus "public"}} style="display: none;"{{end}} id="blogPassword">
<div class="form-group"{{if ne .Model.BlogStatus "password"}} style="display: none;"{{end}} id="blogPassword">
<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>
Expand Down
Loading