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

feat: 新增文章toc显示在侧边栏, 支持语言切换, 部分功能优化 #963

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
34ce2b3
feat: 首页项目拖拽排序功能
Zzhenping Jul 2, 2024
38c15ae
feat: 增加首页项目拖拽排序增加只能管理员进行, 排序失败元素回到原本位置
Zzhenping Jul 3, 2024
97bcf03
perf: 新建文章以后直接进入到编辑文章页面
Zzhenping Jul 3, 2024
33e5f22
perf: 优化文档打开时或刷新时样式闪动问题
Zzhenping Jul 3, 2024
4377ce1
perf: 优化表格样式
Zzhenping Jul 4, 2024
a19e819
feat: 支持上传视频功能
Zzhenping Jul 4, 2024
f78b654
feat: 视频样式调整
Zzhenping Jul 4, 2024
a7eccd2
feat: 直接粘贴视频上传功能
Zzhenping Jul 5, 2024
5f468a4
Merge branch 'issuse'
Zzhenping Jul 5, 2024
0c0bb26
perf: 优化markdown目录显示
Zzhenping Jul 5, 2024
6792c82
Merge branch 'issuse'
Zzhenping Jul 5, 2024
f3846cc
feat: 项目配置新增是否开启打印功能
Zzhenping Jul 5, 2024
1dd82a6
perf: 优化模型自动更新表字段
Zzhenping Jul 5, 2024
2b1be9a
Merge branch 'mindoc-org:master' into master
Zzhenping Jul 5, 2024
58bac86
perf: 创建项目时增加选择编辑器功能
Zzhenping Jul 5, 2024
d217c7e
perf: 优化cherry-markdown 菜单栏
Zzhenping Jul 8, 2024
18875b9
perf: 优化项目阅读界面, 新增打开搜索面板快捷键(Ctrl + f), esc恢复到目录快捷键功能
Zzhenping Jul 8, 2024
7fb4c51
perf: 优化项目搜索
Zzhenping Jul 8, 2024
b023458
perf: 文章TOC样式调整
Zzhenping Jul 9, 2024
0e92e0e
feat: 配置管理中增加本地化切换
Zzhenping Jul 9, 2024
0715427
feat: 配置管理中增加本地化切换
Zzhenping Jul 9, 2024
34f7421
fix: 调整页面内copyright的链接为: https://mindoc.com.cn/域名下
Zzhenping Jul 9, 2024
d581811
fix: 创建README.md资源
Zzhenping Jul 9, 2024
ce7e4b6
fix: 创建README.md资源
Zzhenping Jul 9, 2024
ebe6501
fix: README更新
Zzhenping Jul 9, 2024
97ba7d0
fix: README更新
Zzhenping Jul 9, 2024
e8cd92e
fix: README 地址修改
Zzhenping Jul 10, 2024
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
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ go build -ldflags "-w" -o mindoc main.go
bee run
```

## 旧版本运行 可更新部分数据库配置
```base
./mindoc update
```

MinDoc 如果使用MySQL储存数据,则编码必须是`utf8mb4_general_ci`。请在安装前,把数据库配置填充到项目目录下的 `conf/app.conf` 中。

如果使用 `SQLite` 数据库,则直接在配置文件中配置数据库路径即可.
Expand Down Expand Up @@ -189,46 +194,52 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP

**创建项目**

![创建项目](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204438.png)
![创建项目](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/create.png?raw=true)

**项目列表**

![项目列表](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203542.png)
![项目列表](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/project_list.png?raw=true)

**项目概述**

![项目概述](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203619.png)
![项目概述](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/intro.png?raw=true)

**项目成员**

![项目成员](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203637.png)
![项目成员](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/member.png?raw=true)

**项目设置**

![项目设置](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203656.png)
![项目设置](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/project_setting.png?raw=true)

**基于Editor.md开发的Markdown编辑器**

![基于Editor.md开发的Markdown编辑器](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501203854.png)
![基于Editor.md开发的Markdown编辑器](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/editor_md.png?raw=true)

**基于wangEditor开发的富文本编辑器**

![基于wangEditor开发的富文本编辑器](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204651.png)
![基于wangEditor开发的富文本编辑器](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/wang_editor.png?raw=true)


**基于cherryMarkdown开发的编辑器**

![基于cherry-markdown开发的编辑器](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/cheery-markdown.png?raw=true)

**项目预览**

![项目预览](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204609.png)
![项目预览](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/preview.png?raw=true)

**超级管理员后台**

![超级管理员后台](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204710.png)
![超级管理员后台](https://github.com/mindoc-org/mindoc/blob/master/uploads/docs/admin.png?raw=true)


# 使用的技术(TODO: 最新技术栈整理中,使用的第三方库升级中)

- [Beego](https://github.com/beego/beego) ~~1.10.0~~
- MySQL 5.6
- [editor.md](https://github.com/pandao/editor.md) Markdown 编辑器
- [cherry-markdown](https://github.com/Tencent/cherry-markdown) Cherry Markdown Writer
- [Bootstrap](https://github.com/twbs/bootstrap) 3.2
- [jQuery](https://github.com/jquery/jquery) 库
- [WebUploader](https://github.com/fex-team/webuploader) 文件上传框架
Expand All @@ -250,13 +261,13 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP

# 主要功能

- 项目管理,可以对项目进行编辑更改,成员添加等
- 项目管理,可以对项目进行编辑更改,成员添加, 项目排序等
- 文档管理,添加和删除文档等。
- 评论管理,可以管理文档评论和自己发布的评论。
- 用户管理,添加和禁用用户,个人资料更改等。
- 用户权限管理 , 实现用户角色的变更。
- 项目加密,可以设置项目公开状态,私有项目需要通过Token访问。
- 站点配置,可开启匿名访问、验证码等。
- 站点配置,多语言切换, 可开启匿名访问、验证码等。

# 参与开发

Expand Down
8 changes: 8 additions & 0 deletions commands/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ func RegisterModel() {
gob.Register(models.Document{})
gob.Register(models.Template{})
//migrate.RegisterMigration()
err := orm.RunSyncdb("default", false, true)
if err != nil {
logs.Error("注册Model失败 ->", err)
os.Exit(1)
}
}

// RegisterLogger 注册日志
Expand Down Expand Up @@ -229,6 +234,9 @@ func RegisterCommand() {
} else if len(os.Args) >= 2 && os.Args[1] == "version" {
CheckUpdate()
os.Exit(0)
} else if len(os.Args) >= 2 && os.Args[1] == "update" {
Update()
os.Exit(0)
}

}
Expand Down
24 changes: 23 additions & 1 deletion commands/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package commands
import (
"encoding/json"
"fmt"
"github.com/mindoc-org/mindoc/models"
"io/ioutil"
"net/http"
"os"

"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"github.com/mindoc-org/mindoc/conf"
)

//检查最新版本.
// 检查最新版本.
func CheckUpdate() {

fmt.Println("MinDoc current version => ", conf.VERSION)
Expand Down Expand Up @@ -47,3 +49,23 @@ func CheckUpdate() {
os.Exit(0)

}

func Update() {
fmt.Println("Update...")
RegisterDataBase()
RegisterModel()
err := orm.RunSyncdb("default", false, true)
if err == nil {
UpdateInitialization()
} else {
panic(err.Error())
}
fmt.Println("Update Successfully!")
os.Exit(0)
}
func UpdateInitialization() {
err := models.NewOption().Update()
if err != nil {
panic(err.Error())
}
}
4 changes: 4 additions & 0 deletions conf/lang/en-us.ini
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ next = next
no = no
edit_title = Edit Blog
private_blog_tips = Private blog, please enter password to access
print_text = Enable Printing

[doc]
modify_doc = Modify Document
Expand Down Expand Up @@ -501,6 +502,9 @@ edit_user = Edit User
pwd_tips = Please leave it blank if you do not change the password, only local users can change the password

[mgr]
language = Default Language
zh_cn = 简体中文
en_us = English
dashboard_menu = Dashboard
user_menu = User
team_menu = Team
Expand Down
4 changes: 4 additions & 0 deletions conf/lang/zh-cn.ini
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ next = 下一篇
no = 无
edit_title = 编辑文章
private_blog_tips = 加密文章,请输入密码访问
print_text = 开启打印

[doc]
modify_doc = 修改文档
Expand Down Expand Up @@ -501,6 +502,9 @@ edit_user = 编辑用户
pwd_tips = 不修改密码请留空,只支持本地用户修改密码

[mgr]
language = 默认语言
zh_cn = 简体中文
en_us = English
dashboard_menu = 仪表盘
user_menu = 用户管理
team_menu = 团队管理
Expand Down
12 changes: 8 additions & 4 deletions controllers/BaseController.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *BaseController) Prepare() {
c.SetLang()
}

//判断用户是否登录.
// 判断用户是否登录.
func (c *BaseController) isUserLoggedIn() bool {
return c.Member != nil && c.Member.MemberId > 0
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func (c *BaseController) JsonResult(errCode int, errMsg string, data ...interfac
c.StopRun()
}

//如果错误不为空,则响应错误信息到浏览器.
// 如果错误不为空,则响应错误信息到浏览器.
func (c *BaseController) CheckJsonError(code int, err error) {

if err == nil {
Expand Down Expand Up @@ -182,7 +182,7 @@ func (c *BaseController) BaseUrl() string {
return baseUrl
}

//显示错误信息页面.
// 显示错误信息页面.
func (c *BaseController) ShowErrorPage(errCode int, errMsg string) {
c.TplName = "errors/error.tpl"

Expand Down Expand Up @@ -217,7 +217,11 @@ func (c *BaseController) SetLang() {
}
if len(lang) == 0 ||
!i18n.IsExist(lang) {
lang, _ = web.AppConfig.String("default_lang")
if c.Data["language"] != nil {
lang = c.Data["language"].(string)
} else {
lang, _ = web.AppConfig.String("default_lang")
}
}
if !hasCookie {
c.Ctx.SetCookie("lang", lang, 1<<31-1, "/")
Expand Down
12 changes: 10 additions & 2 deletions controllers/BookController.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (c *BookController) Setting() {
if book.PrivateToken != "" {
book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
}

c.Data["Model"] = book

}
Expand Down Expand Up @@ -153,6 +154,7 @@ func (c *BookController) SaveBook() {
isUseFirstDocument := strings.TrimSpace(c.GetString("is_use_first_document")) == "on"
autoSave := strings.TrimSpace(c.GetString("auto_save")) == "on"
itemId, _ := c.GetInt("itemId")
pringState := strings.TrimSpace(c.GetString("print_state")) == "on"

if strings.Count(description, "") > 500 {
c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_desc_tips"))
Expand Down Expand Up @@ -211,6 +213,11 @@ func (c *BookController) SaveBook() {
} else {
book.AutoSave = 0
}
if pringState {
book.PrintSate = 1
} else {
book.PrintSate = 0
}
if err := book.Update(); err != nil {
c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed"))
}
Expand Down Expand Up @@ -456,6 +463,7 @@ func (c *BookController) Create() {
description := strings.TrimSpace(c.GetString("description", ""))
privatelyOwned, _ := strconv.Atoi(c.GetString("privately_owned"))
commentStatus := c.GetString("comment_status")
editor := c.GetString("editor")
itemId, _ := c.GetInt("itemId")

if bookName == "" {
Expand Down Expand Up @@ -522,6 +530,7 @@ func (c *BookController) Create() {
book.CommentCount = 0
book.PrivatelyOwned = privatelyOwned
book.CommentStatus = commentStatus

book.Identify = identify
book.DocCount = 0
book.MemberId = c.Member.MemberId
Expand All @@ -531,8 +540,7 @@ func (c *BookController) Create() {
book.IsDownload = 1
book.AutoRelease = 0
book.ItemId = itemId

book.Editor = "markdown"
book.Editor = editor
book.Theme = "default"

if err := book.Insert(c.Lang); err != nil {
Expand Down
Loading
Loading