mirror of https://github.com/mindoc-org/mindoc.git
merge from mindoc-org/mindoc and resolved conflict
commit
4ad0fe74d0
|
@ -21,9 +21,11 @@ _testmain.go
|
|||
|
||||
*.exe
|
||||
mindoc
|
||||
database
|
||||
*.test
|
||||
*.prof
|
||||
.idea
|
||||
.vscode
|
||||
/conf/app.conf
|
||||
/vendor
|
||||
/runtime
|
||||
|
|
42
.travis.yml
42
.travis.yml
|
@ -1,32 +1,46 @@
|
|||
os: linux
|
||||
dist: focal
|
||||
|
||||
language: go
|
||||
|
||||
go:
|
||||
- "1.12"
|
||||
- "1.13"
|
||||
|
||||
arch:
|
||||
- amd64
|
||||
|
||||
env:
|
||||
- GO111MODULE=on CGO_ENABLED=1
|
||||
|
||||
sudo: true
|
||||
install:
|
||||
- dep ensure
|
||||
- go mod tidy -v
|
||||
|
||||
before_install:
|
||||
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
- whereis gcc
|
||||
- go env
|
||||
|
||||
script:
|
||||
- dep ensure && GO_ENABLED=1 go build -v -x -tags "pam" && go install
|
||||
- go build -o mindoc_linux_amd64 -ldflags "-w"
|
||||
- cp conf/app.conf.example conf/app.conf
|
||||
- ./mindoc_linux_amd64 version
|
||||
- rm conf/app.conf
|
||||
|
||||
before_deploy:
|
||||
- dep ensure -v && CGO_ENABLED=1 GOARCH=amd64 GOOS=linux go build -o mindoc_linux_amd64 -ldflags="-w -X github.com/mindoc-org/mindoc/conf.VERSION=$TRAVIS_TAG -X 'github.com/mindoc-org/mindoc/conf.BUILD_TIME=`date`' -X 'conf.GO_VERSION=`github.com/mindoc-org/mindoc/go version`'"
|
||||
- rm -rf simsun.ttc start.sh commands controllers models modules data routers tasks vendor docs search utils graphics .git Godeps uploads/* .gitignore .travis.yml Dockerfile Gopkg.toml LICENSE main.go README.md conf/enumerate.go conf/mail.go install.lock *.md
|
||||
- go mod tidy -v && GOARCH=amd64 GOOS=linux go build -o mindoc_linux_amd64 -ldflags="-w -X 'github.com/mindoc-org/mindoc/conf.VERSION=$TRAVIS_TAG' -X 'github.com/mindoc-org/mindoc/conf.BUILD_TIME=`date`' -X 'conf.GO_VERSION=`go version`'"
|
||||
# remove files
|
||||
- rm appveyor.yml docker-compose.yml Dockerfile .travis.yml .gitattributes .gitignore go.mod go.sum main.go README.md simsun.ttc start.sh
|
||||
# remove dirs
|
||||
- rm -rf cache commands controllers converter .git .github graphics mail models routers utils
|
||||
- ls -alh
|
||||
- cp conf/app.conf.example conf/app.conf
|
||||
- zip -r mindoc_linux_amd64.zip conf static uploads views lib mindoc_linux_amd64
|
||||
- zip -r mindoc_linux_amd64.zip conf static uploads views lib mindoc_linux_amd64 favicon.ico LICENSE.md
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key: $CI_USER_TOKEN
|
||||
skip_cleanup: true
|
||||
token: $CI_USER_TOKEN
|
||||
cleanup: true
|
||||
overwrite: true
|
||||
file:
|
||||
- mindoc_linux_amd64.zip
|
||||
on:
|
||||
overwrite: true
|
||||
tags: true
|
||||
all_branches: true
|
||||
go: "1.12"
|
||||
branch: master
|
||||
|
|
68
README.md
68
README.md
|
@ -1,29 +1,25 @@
|
|||
# MinDoc 简介
|
||||
|
||||
[![Build Status](https://travis-ci.org/lifei6671/mindoc.svg?branch=master)](https://travis-ci.org/lifei6671/mindoc)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/ik70whjrioyvfy18/branch/master?svg=true)](https://ci.appveyor.com/project/lifei6671/godoc/branch/master)
|
||||
[![Build Status](https://travis-ci.com/mindoc-org/mindoc.svg?branch=master)](https://travis-ci.com/mindoc-org/mindoc)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/o3lcfmf5iy2cp9m6?svg=true)](https://ci.appveyor.com/project/gsw945/mindoc)
|
||||
|
||||
MinDoc 是一款针对IT团队开发的简单好用的文档管理系统。
|
||||
|
||||
MinDoc 的前身是 SmartWiki 文档系统。SmartWiki 是基于 PHP 框架 laravel 开发的一款文档管理系统。因 PHP 的部署对普通用户来说太复杂,所以改用 Golang 开发。可以方便用户部署和实用。
|
||||
MinDoc 的前身是 [SmartWiki](https://github.com/lifei6671/SmartWiki) 文档系统。SmartWiki 是基于 PHP 框架 laravel 开发的一款文档管理系统。因 PHP 的部署对普通用户来说太复杂,所以改用 Golang 开发。可以方便用户部署和实用。
|
||||
|
||||
开发缘起是公司IT部门需要一款简单实用的项目接口文档管理和分享的系统。其功能和界面源于 kancloud 。
|
||||
|
||||
可以用来储存日常接口文档,数据库字典,手册说明等文档。内置项目管理,用户管理,权限管理等功能,能够满足大部分中小团队的文档管理需求。
|
||||
|
||||
演示站点: [http://doc.iminho.me](http://doc.iminho.me)
|
||||
演示站点: [https://www.iminho.me/wiki/](https://www.iminho.me/wiki/)
|
||||
|
||||
---
|
||||
|
||||
<details>
|
||||
<summary>开发维护召集令</summary>
|
||||
### 开发&维护&使用 悉知
|
||||
|
||||
感谢作者 [lifei6671](https://github.com/lifei6671) 创造了MinDoc,并持续维护了很久。
|
||||
|
||||
本人向公司推广了MinDoc,反向很好。受益于开源,便想回馈于开源。但看到MinDoc似乎停更了一年,尝试和作者沟通后,得知作者因工作等原因,精力有限,无法持续维护,请求得到了GitHub仓库的部分维护权限。
|
||||
本人技术能力有限,且业余时间并不充裕,处理 Issues 和 Pull Requests 的进度缓慢,希望能和热心开发者一起持续维护MinDoc。
|
||||
维护权限需要作者添加,有意向者请添加下方QQ群,或通过发送邮件(`gsw945#foxmail.com`, 请替换`#`为`@`),私聊我加入作者所在的微信群。
|
||||
</details>
|
||||
作者因工作等原因,精力有限,无法花费足够的时间来持续维护mindoc,已于北京时间2021年3月23日将mindoc交给社区(github组织[mindoc-org](https://github.com/mindoc-org))维护,期待热心开发者加入[mindoc-org](https://github.com/mindoc-org)一起来维护MinDoc。
|
||||
|
||||
遇到问题请提 [Issues](https://github.com/mindoc-org/mindoc/issues ),欢迎使用者和贡献者加入QQ群 `1051164153`
|
||||
<a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=bHFR7P3Qp1nsSPbsTw4KN_ZpFLUAblIU&jump_from=webapi"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="MinDoc使用&开发交流群" title="MinDoc使用&开发交流群"></a>
|
||||
|
@ -38,17 +34,18 @@ MinDoc 的前身是 SmartWiki 文档系统。SmartWiki 是基于 PHP 框架 lara
|
|||
|
||||
对于没有Golang使用经验的用户,可以从 [https://github.com/mindoc-org/mindoc/releases](https://github.com/mindoc-org/mindoc/releases) 这里下载编译完的程序。
|
||||
|
||||
如果有Golang开发经验,建议通过编译安装,在此之前,您需要先安装Golang官方包管理工具,详见[Install dep](https://golang.github.io/dep/docs/installation.html)。
|
||||
如果有Golang开发经验,建议通过编译安装,要求golang版本不小于1.13(需支持`CGO`和`go mod`)。
|
||||
|
||||
```bash
|
||||
# 克隆源码
|
||||
git clone https://github.com/mindoc-org/mindoc.git
|
||||
|
||||
# go包安装
|
||||
go mod tidy
|
||||
|
||||
# 编译(sqlite需要CGO支持)
|
||||
go build -ldflags "-w"
|
||||
|
||||
# 数据库初始化(此步骤执行之前,需配置`conf/app.conf`)
|
||||
./mindoc install
|
||||
|
||||
# 执行
|
||||
./mindoc
|
||||
|
||||
```
|
||||
|
@ -64,7 +61,7 @@ MinDoc 如果使用MySQL储存数据,则编码必须是`utf8mb4_general_ci`。
|
|||
|
||||
```bash
|
||||
|
||||
#邮件配置
|
||||
#邮件配置-示例
|
||||
#是否启用邮件
|
||||
enable_mail=true
|
||||
#smtp服务器的账号
|
||||
|
@ -100,6 +97,7 @@ HTTP_PORT 程序监听的端口号
|
|||
举个栗子
|
||||
|
||||
```bash
|
||||
# TODO: 新版docker镜像将使用阿里云,配置中
|
||||
docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP_ADDR=10.xxx.xxx.xxx -e MYSQL_PORT_3306_TCP_PORT=3306 -e MYSQL_INSTANCE_NAME=mindoc -e MYSQL_USERNAME=root -e MYSQL_PASSWORD=123456 -e httpport=8181 -d daocloud.io/lifei6671/mindoc:latest
|
||||
```
|
||||
### docker-compose 一键安装
|
||||
|
@ -130,7 +128,8 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP
|
|||
> docker-compose down
|
||||
- 删除并重新创建
|
||||
> docker-compose -f docker-compose.yml down && docker-compose up -d
|
||||
更多 docker-compose 的使用相关的内容 请查看官网文档或百度
|
||||
>
|
||||
> 更多 docker-compose 的使用相关的内容 请查看官网文档或百度
|
||||
|
||||
# 项目截图
|
||||
|
||||
|
@ -171,23 +170,24 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP
|
|||
![超级管理员后台](https://raw.githubusercontent.com/lifei6671/mindoc/master/uploads/20170501204710.png)
|
||||
|
||||
|
||||
# 使用的技术
|
||||
# 使用的技术(TODO: 最新技术栈整理中,使用的第三方库升级中)
|
||||
|
||||
- beego 1.10.0
|
||||
- mysql 5.6
|
||||
- editor.md Markdown 编辑器
|
||||
- bootstrap 3.2
|
||||
- jquery 库
|
||||
- webuploader 文件上传框架
|
||||
- Nprogress 库
|
||||
- jstree 树状结构库
|
||||
- font awesome 字体库
|
||||
- cropper 图片剪裁库
|
||||
- layer 弹出层框架
|
||||
- highlight 代码高亮库
|
||||
- to-markdown HTML转Markdown库
|
||||
- quill 富文本编辑器
|
||||
- vue 框架
|
||||
- [Beego](https://github.com/beego/beego) ~~1.10.0~~
|
||||
- MySQL 5.6
|
||||
- [editor.md](https://github.com/pandao/editor.md) Markdown 编辑器
|
||||
- [Bootstrap](https://github.com/twbs/bootstrap) 3.2
|
||||
- jQuery(https://github.com/jquery/jquery) 库
|
||||
- [WebUploader](https://github.com/fex-team/webuploader) 文件上传框架
|
||||
- [NProgress](https://github.com/rstacruz/nprogress) 库
|
||||
- [jsTree](https://github.com/vakata/jstree) 树状结构库
|
||||
- [Font Awesome](https://github.com/FortAwesome/Font-Awesome) 字体库
|
||||
- [Cropper](https://github.com/fengyuanchen/cropper) 图片剪裁库
|
||||
- [layer](https://github.com/sentsin/layer) 弹出层框架
|
||||
- [highlight.js](https://github.com/highlightjs/highlight.js) 代码高亮库
|
||||
- ~~to-markdown~~[Turndown](https://github.com/domchristie/turndown) HTML转Markdown库
|
||||
- ~~quill 富文本编辑器~~
|
||||
- [wangEditor](https://github.com/wangeditor-team/wangEditor) 富文本编辑器
|
||||
- [Vue.js](https://github.com/vuejs/vue) 框架
|
||||
|
||||
|
||||
# 主要功能
|
||||
|
@ -206,7 +206,7 @@ docker run -p 8181:8181 --name mindoc -e DB_ADAPTER=mysql -e MYSQL_PORT_3306_TCP
|
|||
|
||||
如果您还不熟悉GitHub的Fork and Pull开发模式,您可以阅读GitHub的文档(https://help.github.com/articles/using-pull-requests) 获得更多的信息。
|
||||
|
||||
# 关于作者
|
||||
# 关于作者[lifei6671](https://github.com/lifei6671)
|
||||
|
||||
一个不纯粹的PHPer,一个不自由的 gopher 。
|
||||
|
||||
|
|
13
appveyor.yml
13
appveyor.yml
|
@ -7,11 +7,8 @@ clone_folder: c:\gopath\src\github.com\mindoc-org\mindoc
|
|||
init:
|
||||
- cmd: >-
|
||||
if [%tbs_arch%]==[x86] SET PATH=C:\MinGW\bin;%PATH%
|
||||
|
||||
if [%tbs_arch%]==[x64] SET PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64;C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
|
||||
|
||||
SET PATH=%GOPATH%\bin;%GOBIN%;%PATH%
|
||||
|
||||
FOR /f "delims=" %%i IN ('go version') DO (SET GO_VERSION=%%i)
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
|
@ -26,28 +23,20 @@ environment:
|
|||
install:
|
||||
- cmd: >-
|
||||
echo %PATH%
|
||||
|
||||
echo %GO_VERSION%
|
||||
|
||||
go env
|
||||
|
||||
where gcc
|
||||
|
||||
where g++
|
||||
build_script:
|
||||
- cmd: >-
|
||||
cd c:\gopath\src\github.com\mindoc-org\mindoc
|
||||
|
||||
go mod tidy
|
||||
|
||||
go build -ldflags "-w"
|
||||
|
||||
go build -v -o "mindoc_windows_%GOARCH%.exe" -ldflags="-w -X github.com/mindoc-org/mindoc/conf.VERSION=%APPVEYOR_REPO_TAG_NAME% -X 'github.com/mindoc-org/mindoc/conf.BUILD_TIME=%date% %time%' -X 'conf.GO_VERSION=%GO_VERSION%'"
|
||||
|
||||
7z a -t7z -r mindoc_windows_%GOARCH%.7z conf/*.conf* static/* mindoc_windows_%GOARCH%.exe views/* uploads/*
|
||||
test_script:
|
||||
- cmd: >-
|
||||
cd c:\gopath\src\github.com\mindoc-org\mindoc
|
||||
|
||||
xcopy conf\app.conf.example conf\app.conf /F /Y
|
||||
mindoc_windows_%GOARCH%.exe version
|
||||
deploy: off
|
|
@ -2,18 +2,26 @@ package cache
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"errors"
|
||||
"github.com/astaxie/beego/cache"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
var bm cache.Cache
|
||||
|
||||
var nilctx = context.TODO()
|
||||
|
||||
func Get(key string, e interface{}) error {
|
||||
|
||||
val := bm.Get(key)
|
||||
val, err := bm.Get(nilctx, key)
|
||||
|
||||
if err != nil {
|
||||
return errors.New("get cache error:" + err.Error())
|
||||
}
|
||||
|
||||
if val == nil {
|
||||
return errors.New("cache does not exist")
|
||||
|
@ -57,30 +65,30 @@ func Put(key string, val interface{}, timeout time.Duration) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return bm.Put(key, buf.String(), timeout)
|
||||
return bm.Put(nilctx, key, buf.String(), timeout)
|
||||
}
|
||||
|
||||
func Delete(key string) error {
|
||||
return bm.Delete(key)
|
||||
return bm.Delete(nilctx, key)
|
||||
}
|
||||
func Incr(key string) error {
|
||||
return bm.Incr(key)
|
||||
return bm.Incr(nilctx, key)
|
||||
}
|
||||
func Decr(key string) error {
|
||||
return bm.Decr(key)
|
||||
return bm.Decr(nilctx, key)
|
||||
}
|
||||
func IsExist(key string) bool {
|
||||
return bm.IsExist(key)
|
||||
func IsExist(key string) (bool, error) {
|
||||
return bm.IsExist(nilctx, key)
|
||||
}
|
||||
func ClearAll() error {
|
||||
return bm.ClearAll()
|
||||
return bm.ClearAll(nilctx)
|
||||
}
|
||||
|
||||
func StartAndGC(config string) error {
|
||||
return bm.StartAndGC(config)
|
||||
}
|
||||
|
||||
//初始化缓存
|
||||
//Init will initialize cache
|
||||
func Init(c cache.Cache) {
|
||||
bm = c
|
||||
}
|
||||
|
|
|
@ -1,36 +1,39 @@
|
|||
package cache
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type NullCache struct {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (bm *NullCache) Get(key string) interface{} {
|
||||
return nil
|
||||
func (bm *NullCache) Get(ctx context.Context, key string) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (bm *NullCache)GetMulti(keys []string) []interface{} {
|
||||
return nil
|
||||
func (bm *NullCache)GetMulti(ctx context.Context, keys []string) ([]interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (bm *NullCache)Put(key string, val interface{}, timeout time.Duration) error {
|
||||
func (bm *NullCache)Put(ctx context.Context,key string, val interface{}, timeout time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)Delete(key string) error {
|
||||
func (bm *NullCache)Delete(ctx context.Context,key string) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)Incr(key string) error {
|
||||
func (bm *NullCache)Incr(ctx context.Context,key string) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)Decr(key string) error {
|
||||
func (bm *NullCache)Decr(ctx context.Context,key string) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)IsExist(key string) bool {
|
||||
return false
|
||||
func (bm *NullCache)IsExist(ctx context.Context,key string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (bm *NullCache)ClearAll() error{
|
||||
func (bm *NullCache)ClearAll(ctx context.Context) error{
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,13 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
beegoCache "github.com/astaxie/beego/cache"
|
||||
_ "github.com/astaxie/beego/cache/memcache"
|
||||
|
||||
"github.com/astaxie/beego/cache/redis"
|
||||
_ "github.com/astaxie/beego/cache/redis"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
beegoCache "github.com/beego/beego/v2/client/cache"
|
||||
_ "github.com/beego/beego/v2/client/cache/memcache"
|
||||
"github.com/beego/beego/v2/client/cache/redis"
|
||||
_ "github.com/beego/beego/v2/client/cache/redis"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/howeyc/fsnotify"
|
||||
"github.com/lifei6671/gocaptcha"
|
||||
|
@ -35,17 +34,17 @@ import (
|
|||
// RegisterDataBase 注册数据库
|
||||
func RegisterDataBase() {
|
||||
logs.Info("正在初始化数据库配置.")
|
||||
adapter := beego.AppConfig.String("db_adapter")
|
||||
dbadapter, _ := web.AppConfig.String("db_adapter")
|
||||
orm.DefaultTimeLoc = time.Local
|
||||
orm.DefaultRowsLimit = -1
|
||||
|
||||
if strings.EqualFold(adapter, "mysql") {
|
||||
host := beego.AppConfig.String("db_host")
|
||||
database := beego.AppConfig.String("db_database")
|
||||
username := beego.AppConfig.String("db_username")
|
||||
password := beego.AppConfig.String("db_password")
|
||||
if strings.EqualFold(dbadapter, "mysql") {
|
||||
host, _ := web.AppConfig.String("db_host")
|
||||
database, _ := web.AppConfig.String("db_database")
|
||||
username, _ := web.AppConfig.String("db_username")
|
||||
password, _ := web.AppConfig.String("db_password")
|
||||
|
||||
timezone := beego.AppConfig.String("timezone")
|
||||
timezone, _ := web.AppConfig.String("timezone")
|
||||
location, err := time.LoadLocation(timezone)
|
||||
if err == nil {
|
||||
orm.DefaultTimeLoc = location
|
||||
|
@ -53,7 +52,7 @@ func RegisterDataBase() {
|
|||
logs.Error("加载时区配置信息失败,请检查是否存在 ZONEINFO 环境变量->", err)
|
||||
}
|
||||
|
||||
port := beego.AppConfig.String("db_port")
|
||||
port, _ := web.AppConfig.String("db_port")
|
||||
|
||||
dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true&loc=%s", username, password, host, port, database, url.QueryEscape(timezone))
|
||||
|
||||
|
@ -62,9 +61,9 @@ func RegisterDataBase() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
} else if strings.EqualFold(adapter, "sqlite3") {
|
||||
} else if strings.EqualFold(dbadapter, "sqlite3") {
|
||||
|
||||
database := beego.AppConfig.String("db_database")
|
||||
database, _ := web.AppConfig.String("db_database")
|
||||
if strings.HasPrefix(database, "./") {
|
||||
database = filepath.Join(conf.WorkingDirectory, string(database[1:]))
|
||||
}
|
||||
|
@ -124,11 +123,11 @@ func RegisterLogger(log string) {
|
|||
_ = logs.SetLogger("console")
|
||||
logs.EnableFuncCallDepth(true)
|
||||
|
||||
if beego.AppConfig.DefaultBool("log_is_async", true) {
|
||||
if web.AppConfig.DefaultBool("log_is_async", true) {
|
||||
logs.Async(1e3)
|
||||
}
|
||||
if log == "" {
|
||||
logPath, err := filepath.Abs(beego.AppConfig.DefaultString("log_path", conf.WorkingDir("runtime", "logs")))
|
||||
logPath, err := filepath.Abs(web.AppConfig.DefaultString("log_path", conf.WorkingDir("runtime", "logs")))
|
||||
if err == nil {
|
||||
log = logPath
|
||||
} else {
|
||||
|
@ -148,44 +147,36 @@ func RegisterLogger(log string) {
|
|||
config["perm"] = "0755"
|
||||
config["rotate"] = true
|
||||
|
||||
if maxLines := beego.AppConfig.DefaultInt("log_maxlines", 1000000); maxLines > 0 {
|
||||
if maxLines := web.AppConfig.DefaultInt("log_maxlines", 1000000); maxLines > 0 {
|
||||
config["maxLines"] = maxLines
|
||||
}
|
||||
if maxSize := beego.AppConfig.DefaultInt("log_maxsize", 1<<28); maxSize > 0 {
|
||||
if maxSize := web.AppConfig.DefaultInt("log_maxsize", 1<<28); maxSize > 0 {
|
||||
config["maxsize"] = maxSize
|
||||
}
|
||||
if !beego.AppConfig.DefaultBool("log_daily", true) {
|
||||
if !web.AppConfig.DefaultBool("log_daily", true) {
|
||||
config["daily"] = false
|
||||
}
|
||||
if maxDays := beego.AppConfig.DefaultInt("log_maxdays", 7); maxDays > 0 {
|
||||
if maxDays := web.AppConfig.DefaultInt("log_maxdays", 7); maxDays > 0 {
|
||||
config["maxdays"] = maxDays
|
||||
}
|
||||
if level := beego.AppConfig.DefaultString("log_level", "Trace"); level != "" {
|
||||
if level := web.AppConfig.DefaultString("log_level", "Trace"); level != "" {
|
||||
switch level {
|
||||
case "Emergency":
|
||||
config["level"] = logs.LevelEmergency
|
||||
break
|
||||
case "Alert":
|
||||
config["level"] = logs.LevelAlert
|
||||
break
|
||||
case "Critical":
|
||||
config["level"] = logs.LevelCritical
|
||||
break
|
||||
case "Error":
|
||||
config["level"] = logs.LevelError
|
||||
break
|
||||
case "Warning":
|
||||
config["level"] = logs.LevelWarning
|
||||
break
|
||||
case "Notice":
|
||||
config["level"] = logs.LevelNotice
|
||||
break
|
||||
case "Informational":
|
||||
config["level"] = logs.LevelInformational
|
||||
break
|
||||
case "Debug":
|
||||
config["level"] = logs.LevelDebug
|
||||
break
|
||||
}
|
||||
}
|
||||
b, err := json.Marshal(config)
|
||||
|
@ -214,20 +205,20 @@ func RegisterCommand() {
|
|||
|
||||
//注册模板函数
|
||||
func RegisterFunction() {
|
||||
err := beego.AddFuncMap("config", models.GetOptionValue)
|
||||
err := web.AddFuncMap("config", models.GetOptionValue)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("注册函数 config 出错 ->", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
err = beego.AddFuncMap("cdn", func(p string) string {
|
||||
cdn := beego.AppConfig.DefaultString("cdn", "")
|
||||
err = web.AddFuncMap("cdn", func(p string) string {
|
||||
cdn := web.AppConfig.DefaultString("cdn", "")
|
||||
if strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://") {
|
||||
return p
|
||||
}
|
||||
//如果没有设置cdn,则使用baseURL拼接
|
||||
if cdn == "" {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "")
|
||||
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(baseUrl, "/") {
|
||||
return baseUrl + p[1:]
|
||||
|
@ -250,28 +241,28 @@ func RegisterFunction() {
|
|||
os.Exit(-1)
|
||||
}
|
||||
|
||||
err = beego.AddFuncMap("cdnjs", conf.URLForWithCdnJs)
|
||||
err = web.AddFuncMap("cdnjs", conf.URLForWithCdnJs)
|
||||
if err != nil {
|
||||
logs.Error("注册函数 cdnjs 出错 ->", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
err = beego.AddFuncMap("cdncss", conf.URLForWithCdnCss)
|
||||
err = web.AddFuncMap("cdncss", conf.URLForWithCdnCss)
|
||||
if err != nil {
|
||||
logs.Error("注册函数 cdncss 出错 ->", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
err = beego.AddFuncMap("cdnimg", conf.URLForWithCdnImage)
|
||||
err = web.AddFuncMap("cdnimg", conf.URLForWithCdnImage)
|
||||
if err != nil {
|
||||
logs.Error("注册函数 cdnimg 出错 ->", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
//重写url生成,支持配置域名以及域名前缀
|
||||
err = beego.AddFuncMap("urlfor", conf.URLFor)
|
||||
err = web.AddFuncMap("urlfor", conf.URLFor)
|
||||
if err != nil {
|
||||
logs.Error("注册函数 urlfor 出错 ->", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
err = beego.AddFuncMap("date_format", func(t time.Time, format string) string {
|
||||
err = web.AddFuncMap("date_format", func(t time.Time, format string) string {
|
||||
return t.Local().Format(format)
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -279,7 +270,7 @@ func RegisterFunction() {
|
|||
os.Exit(-1)
|
||||
}
|
||||
|
||||
err = beego.AddFuncMap("i18n", i18n.Tr)
|
||||
err = web.AddFuncMap("i18n", i18n.Tr)
|
||||
if err != nil {
|
||||
logs.Error("注册函数 i18n 出错 ->", err)
|
||||
os.Exit(-1)
|
||||
|
@ -321,11 +312,11 @@ func ResolveCommand(args []string) {
|
|||
log.Fatal("读取字体文件时出错 -> ", err)
|
||||
}
|
||||
|
||||
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
|
||||
if err := web.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
|
||||
log.Fatal("An error occurred:", err)
|
||||
}
|
||||
if conf.LogFile == "" {
|
||||
logPath, err := filepath.Abs(beego.AppConfig.DefaultString("log_path", conf.WorkingDir("runtime", "logs")))
|
||||
logPath, err := filepath.Abs(web.AppConfig.DefaultString("log_path", conf.WorkingDir("runtime", "logs")))
|
||||
if err == nil {
|
||||
conf.LogFile = logPath
|
||||
} else {
|
||||
|
@ -333,15 +324,15 @@ func ResolveCommand(args []string) {
|
|||
}
|
||||
}
|
||||
|
||||
conf.AutoLoadDelay = beego.AppConfig.DefaultInt("config_auto_delay", 0)
|
||||
conf.AutoLoadDelay = web.AppConfig.DefaultInt("config_auto_delay", 0)
|
||||
uploads := conf.WorkingDir("uploads")
|
||||
|
||||
_ = os.MkdirAll(uploads, 0666)
|
||||
|
||||
beego.BConfig.WebConfig.StaticDir["/static"] = filepath.Join(conf.WorkingDirectory, "static")
|
||||
beego.BConfig.WebConfig.StaticDir["/uploads"] = uploads
|
||||
beego.BConfig.WebConfig.ViewsPath = conf.WorkingDir("views")
|
||||
beego.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteDefaultMode
|
||||
web.BConfig.WebConfig.StaticDir["/static"] = filepath.Join(conf.WorkingDirectory, "static")
|
||||
web.BConfig.WebConfig.StaticDir["/uploads"] = uploads
|
||||
web.BConfig.WebConfig.ViewsPath = conf.WorkingDir("views")
|
||||
web.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteDefaultMode
|
||||
|
||||
fonts := conf.WorkingDir("static", "fonts")
|
||||
|
||||
|
@ -363,15 +354,15 @@ func ResolveCommand(args []string) {
|
|||
|
||||
//注册缓存管道
|
||||
func RegisterCache() {
|
||||
isOpenCache := beego.AppConfig.DefaultBool("cache", false)
|
||||
isOpenCache := web.AppConfig.DefaultBool("cache", false)
|
||||
if !isOpenCache {
|
||||
cache.Init(&cache.NullCache{})
|
||||
return
|
||||
}
|
||||
logs.Info("正常初始化缓存配置.")
|
||||
cacheProvider := beego.AppConfig.String("cache_provider")
|
||||
cacheProvider, _ := web.AppConfig.String("cache_provider")
|
||||
if cacheProvider == "file" {
|
||||
cacheFilePath := beego.AppConfig.DefaultString("cache_file_path", "./runtime/cache/")
|
||||
cacheFilePath := web.AppConfig.DefaultString("cache_file_path", "./runtime/cache/")
|
||||
if strings.HasPrefix(cacheFilePath, "./") {
|
||||
cacheFilePath = filepath.Join(conf.WorkingDirectory, string(cacheFilePath[1:]))
|
||||
}
|
||||
|
@ -380,9 +371,9 @@ func RegisterCache() {
|
|||
fileConfig := make(map[string]string, 0)
|
||||
|
||||
fileConfig["CachePath"] = cacheFilePath
|
||||
fileConfig["DirectoryLevel"] = beego.AppConfig.DefaultString("cache_file_dir_level", "2")
|
||||
fileConfig["EmbedExpiry"] = beego.AppConfig.DefaultString("cache_file_expiry", "120")
|
||||
fileConfig["FileSuffix"] = beego.AppConfig.DefaultString("cache_file_suffix", ".bin")
|
||||
fileConfig["DirectoryLevel"] = web.AppConfig.DefaultString("cache_file_dir_level", "2")
|
||||
fileConfig["EmbedExpiry"] = web.AppConfig.DefaultString("cache_file_expiry", "120")
|
||||
fileConfig["FileSuffix"] = web.AppConfig.DefaultString("cache_file_suffix", ".bin")
|
||||
|
||||
bc, err := json.Marshal(&fileConfig)
|
||||
if err != nil {
|
||||
|
@ -395,13 +386,13 @@ func RegisterCache() {
|
|||
cache.Init(fileCache)
|
||||
|
||||
} else if cacheProvider == "memory" {
|
||||
cacheInterval := beego.AppConfig.DefaultInt("cache_memory_interval", 60)
|
||||
cacheInterval := web.AppConfig.DefaultInt("cache_memory_interval", 60)
|
||||
memory := beegoCache.NewMemoryCache()
|
||||
beegoCache.DefaultEvery = cacheInterval
|
||||
cache.Init(memory)
|
||||
} else if cacheProvider == "redis" {
|
||||
//设置Redis前缀
|
||||
if key := beego.AppConfig.DefaultString("cache_redis_prefix", ""); key != "" {
|
||||
if key := web.AppConfig.DefaultString("cache_redis_prefix", ""); key != "" {
|
||||
redis.DefaultKey = key
|
||||
}
|
||||
var redisConfig struct {
|
||||
|
@ -410,11 +401,11 @@ func RegisterCache() {
|
|||
DbNum int `json:"dbNum"`
|
||||
}
|
||||
redisConfig.DbNum = 0
|
||||
redisConfig.Conn = beego.AppConfig.DefaultString("cache_redis_host", "")
|
||||
if pwd := beego.AppConfig.DefaultString("cache_redis_password", ""); pwd != "" {
|
||||
redisConfig.Conn = web.AppConfig.DefaultString("cache_redis_host", "")
|
||||
if pwd := web.AppConfig.DefaultString("cache_redis_password", ""); pwd != "" {
|
||||
redisConfig.Password = pwd
|
||||
}
|
||||
if dbNum := beego.AppConfig.DefaultInt("cache_redis_db", 0); dbNum > 0 {
|
||||
if dbNum := web.AppConfig.DefaultInt("cache_redis_db", 0); dbNum > 0 {
|
||||
redisConfig.DbNum = dbNum
|
||||
}
|
||||
|
||||
|
@ -436,7 +427,7 @@ func RegisterCache() {
|
|||
var memcacheConfig struct {
|
||||
Conn string `json:"conn"`
|
||||
}
|
||||
memcacheConfig.Conn = beego.AppConfig.DefaultString("cache_memcache_host", "")
|
||||
memcacheConfig.Conn = web.AppConfig.DefaultString("cache_memcache_host", "")
|
||||
|
||||
bc, err := json.Marshal(&memcacheConfig)
|
||||
if err != nil {
|
||||
|
@ -475,7 +466,7 @@ func RegisterAutoLoadConfig() {
|
|||
case ev := <-watcher.Event:
|
||||
//如果是修改了配置文件
|
||||
if ev.IsModify() {
|
||||
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
|
||||
if err := web.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
|
||||
logs.Error("An error occurred ->", err)
|
||||
continue
|
||||
}
|
||||
|
@ -503,27 +494,27 @@ func RegisterAutoLoadConfig() {
|
|||
|
||||
//注册错误处理方法.
|
||||
func RegisterError() {
|
||||
beego.ErrorHandler("404", func(writer http.ResponseWriter, request *http.Request) {
|
||||
web.ErrorHandler("404", func(writer http.ResponseWriter, request *http.Request) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data["ErrorCode"] = 404
|
||||
data["ErrorMessage"] = "页面未找到或已删除"
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf, "errors/error.tpl", beego.BConfig.WebConfig.ViewsPath, data); err == nil {
|
||||
if err := web.ExecuteViewPathTemplate(&buf, "errors/error.tpl", web.BConfig.WebConfig.ViewsPath, data); err == nil {
|
||||
_, _ = fmt.Fprint(writer, buf.String())
|
||||
} else {
|
||||
_, _ = fmt.Fprint(writer, data["ErrorMessage"])
|
||||
}
|
||||
})
|
||||
beego.ErrorHandler("401", func(writer http.ResponseWriter, request *http.Request) {
|
||||
web.ErrorHandler("401", func(writer http.ResponseWriter, request *http.Request) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data["ErrorCode"] = 401
|
||||
data["ErrorMessage"] = "请与 Web 服务器的管理员联系,以确认您是否具有访问所请求资源的权限。"
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf, "errors/error.tpl", beego.BConfig.WebConfig.ViewsPath, data); err == nil {
|
||||
if err := web.ExecuteViewPathTemplate(&buf, "errors/error.tpl", web.BConfig.WebConfig.ViewsPath, data); err == nil {
|
||||
_, _ = fmt.Fprint(writer, buf.String())
|
||||
} else {
|
||||
_, _ = fmt.Fprint(writer, data["ErrorMessage"])
|
||||
|
|
|
@ -7,7 +7,8 @@ import (
|
|||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/kardianos/service"
|
||||
"github.com/mindoc-org/mindoc/commands"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
|
@ -54,7 +55,7 @@ func (d *Daemon) Run() {
|
|||
|
||||
commands.RegisterError()
|
||||
|
||||
beego.ErrorController(&controllers.ErrorController{})
|
||||
web.ErrorController(&controllers.ErrorController{})
|
||||
|
||||
f, err := filepath.Abs(os.Args[0])
|
||||
|
||||
|
@ -64,7 +65,7 @@ func (d *Daemon) Run() {
|
|||
|
||||
fmt.Printf("MinDoc version => %s\nbuild time => %s\nstart directory => %s\n%s\n", conf.VERSION, conf.BUILD_TIME, f, conf.GO_VERSION)
|
||||
|
||||
beego.Run()
|
||||
web.Run()
|
||||
}
|
||||
|
||||
func (d *Daemon) Stop(s service.Service) error {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"flag"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
@ -24,7 +25,6 @@ func Install() {
|
|||
initialization()
|
||||
} else {
|
||||
panic(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Install Successfully!")
|
||||
os.Exit(0)
|
||||
|
@ -99,24 +99,26 @@ func initialization() {
|
|||
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
member, err := models.NewMember().FindByFieldFirst("account", "admin")
|
||||
if err == orm.ErrNoRows {
|
||||
if errors.Is(err, orm.ErrNoRows) {
|
||||
|
||||
// create admin user
|
||||
logs.Info("creating admin user")
|
||||
member.Account = "admin"
|
||||
member.Avatar = conf.URLForWithCdnImage("/static/images/headimgurl.jpg")
|
||||
member.Password = "123456"
|
||||
member.AuthMethod = "local"
|
||||
member.Role = 0
|
||||
member.Role = conf.MemberSuperRole
|
||||
member.Email = "admin@iminho.me"
|
||||
|
||||
if err := member.Add(); err != nil {
|
||||
panic("Member.Add => " + err.Error())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// create demo book
|
||||
logs.Info("creating demo book")
|
||||
book := models.NewBook()
|
||||
|
||||
book.MemberId = member.MemberId
|
||||
|
@ -137,8 +139,9 @@ func initialization() {
|
|||
|
||||
if err := book.Insert(); err != nil {
|
||||
panic("初始化项目失败 -> " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
} else if err != nil {
|
||||
panic(fmt.Errorf("occur errors when initialize: %s", err))
|
||||
}
|
||||
|
||||
if !models.NewItemsets().Exist(1) {
|
||||
|
@ -147,7 +150,6 @@ func initialization() {
|
|||
item.MemberId = 1
|
||||
if err := item.Save(); err != nil {
|
||||
panic("初始化项目空间失败 -> " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
// License for the specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
|
@ -20,8 +21,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
)
|
||||
|
||||
|
@ -113,17 +114,17 @@ func RunMigration() {
|
|||
|
||||
//导出数据库的表结构
|
||||
func ExportDatabaseTable() ([]string, error) {
|
||||
db_adapter := beego.AppConfig.String("db_adapter")
|
||||
db_database := beego.AppConfig.String("db_database")
|
||||
dbadapter, _ := web.AppConfig.String("db_adapter")
|
||||
dbdatabase, _ := web.AppConfig.String("db_database")
|
||||
tables := make([]string, 0)
|
||||
|
||||
o := orm.NewOrm()
|
||||
switch db_adapter {
|
||||
switch dbadapter {
|
||||
case "mysql":
|
||||
{
|
||||
var lists []orm.Params
|
||||
|
||||
_, err := o.Raw(fmt.Sprintf("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '%s'", db_database)).Values(&lists)
|
||||
_, err := o.Raw(fmt.Sprintf("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '%s'", dbdatabase)).Values(&lists)
|
||||
if err != nil {
|
||||
return tables, err
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ package commands
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ runmode = "${MINDOC_RUN_MODE||dev}"
|
|||
sessionon = true
|
||||
sessionname = mindoc_id
|
||||
copyrequestbody = true
|
||||
enablexsrf = "${MINDOC_ENABLE_XSRF||true}"
|
||||
enablexsrf = "${MINDOC_ENABLE_XSRF||false}"
|
||||
|
||||
#系统完整URL(http://doc.iminho.me),如果该项不设置,会从请求头中获取地址。
|
||||
baseurl="${MINDOC_BASE_URL}"
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// 登录用户的Session名
|
||||
|
@ -81,32 +81,32 @@ var (
|
|||
|
||||
// app_key
|
||||
func GetAppKey() string {
|
||||
return beego.AppConfig.DefaultString("app_key", "mindoc")
|
||||
return web.AppConfig.DefaultString("app_key", "mindoc")
|
||||
}
|
||||
|
||||
func GetDatabasePrefix() string {
|
||||
return beego.AppConfig.DefaultString("db_prefix", "md_")
|
||||
return web.AppConfig.DefaultString("db_prefix", "md_")
|
||||
}
|
||||
|
||||
//获取默认头像
|
||||
func GetDefaultAvatar() string {
|
||||
return URLForWithCdnImage(beego.AppConfig.DefaultString("avatar", "/static/images/headimgurl.jpg"))
|
||||
return URLForWithCdnImage(web.AppConfig.DefaultString("avatar", "/static/images/headimgurl.jpg"))
|
||||
}
|
||||
|
||||
//获取阅读令牌长度.
|
||||
func GetTokenSize() int {
|
||||
return beego.AppConfig.DefaultInt("token_size", 12)
|
||||
return web.AppConfig.DefaultInt("token_size", 12)
|
||||
}
|
||||
|
||||
//获取默认文档封面.
|
||||
func GetDefaultCover() string {
|
||||
|
||||
return URLForWithCdnImage(beego.AppConfig.DefaultString("cover", "/static/images/book.jpg"))
|
||||
return URLForWithCdnImage(web.AppConfig.DefaultString("cover", "/static/images/book.jpg"))
|
||||
}
|
||||
|
||||
//获取允许的商城文件的类型.
|
||||
func GetUploadFileExt() []string {
|
||||
ext := beego.AppConfig.DefaultString("upload_file_ext", "png|jpg|jpeg|gif|txt|doc|docx|pdf")
|
||||
ext := web.AppConfig.DefaultString("upload_file_ext", "png|jpg|jpeg|gif|txt|doc|docx|pdf")
|
||||
|
||||
temp := strings.Split(ext, "|")
|
||||
|
||||
|
@ -124,7 +124,7 @@ func GetUploadFileExt() []string {
|
|||
|
||||
// 获取上传文件允许的最大值
|
||||
func GetUploadFileSize() int64 {
|
||||
size := beego.AppConfig.DefaultString("upload_file_size", "0")
|
||||
size := web.AppConfig.DefaultString("upload_file_size", "0")
|
||||
|
||||
if strings.HasSuffix(size, "MB") {
|
||||
if s, e := strconv.ParseInt(size[0:len(size)-2], 10, 64); e == nil {
|
||||
|
@ -149,12 +149,12 @@ func GetUploadFileSize() int64 {
|
|||
|
||||
//是否启用导出
|
||||
func GetEnableExport() bool {
|
||||
return beego.AppConfig.DefaultBool("enable_export", true)
|
||||
return web.AppConfig.DefaultBool("enable_export", true)
|
||||
}
|
||||
|
||||
//同一项目导出线程的并发数
|
||||
func GetExportProcessNum() int {
|
||||
exportProcessNum := beego.AppConfig.DefaultInt("export_process_num", 1)
|
||||
exportProcessNum := web.AppConfig.DefaultInt("export_process_num", 1)
|
||||
|
||||
if exportProcessNum <= 0 || exportProcessNum > 4 {
|
||||
exportProcessNum = 1
|
||||
|
@ -164,7 +164,7 @@ func GetExportProcessNum() int {
|
|||
|
||||
//导出项目队列的并发数量
|
||||
func GetExportLimitNum() int {
|
||||
exportLimitNum := beego.AppConfig.DefaultInt("export_limit_num", 1)
|
||||
exportLimitNum := web.AppConfig.DefaultInt("export_limit_num", 1)
|
||||
|
||||
if exportLimitNum < 0 {
|
||||
exportLimitNum = 1
|
||||
|
@ -174,7 +174,7 @@ func GetExportLimitNum() int {
|
|||
|
||||
//等待导出队列的长度
|
||||
func GetExportQueueLimitNum() int {
|
||||
exportQueueLimitNum := beego.AppConfig.DefaultInt("export_queue_limit_num", 10)
|
||||
exportQueueLimitNum := web.AppConfig.DefaultInt("export_queue_limit_num", 10)
|
||||
|
||||
if exportQueueLimitNum <= 0 {
|
||||
exportQueueLimitNum = 100
|
||||
|
@ -184,7 +184,7 @@ func GetExportQueueLimitNum() int {
|
|||
|
||||
//默认导出项目的缓存目录
|
||||
func GetExportOutputPath() string {
|
||||
exportOutputPath := filepath.Join(beego.AppConfig.DefaultString("export_output_path", filepath.Join(WorkingDirectory, "cache")), "books")
|
||||
exportOutputPath := filepath.Join(web.AppConfig.DefaultString("export_output_path", filepath.Join(WorkingDirectory, "cache")), "books")
|
||||
|
||||
return exportOutputPath
|
||||
}
|
||||
|
@ -210,8 +210,8 @@ func IsAllowUploadFileExt(ext string) bool {
|
|||
|
||||
//重写生成URL的方法,加上完整的域名
|
||||
func URLFor(endpoint string, values ...interface{}) string {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
|
||||
pathUrl := beego.URLFor(endpoint, values...)
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "")
|
||||
pathUrl := web.URLFor(endpoint, values...)
|
||||
|
||||
if baseUrl == "" {
|
||||
baseUrl = BaseUrl
|
||||
|
@ -225,12 +225,12 @@ func URLFor(endpoint string, values ...interface{}) string {
|
|||
if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") {
|
||||
return baseUrl + "/" + pathUrl
|
||||
}
|
||||
return baseUrl + beego.URLFor(endpoint, values...)
|
||||
return baseUrl + web.URLFor(endpoint, values...)
|
||||
}
|
||||
|
||||
func URLForNotHost(endpoint string, values ...interface{}) string {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
|
||||
pathUrl := beego.URLFor(endpoint, values...)
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "")
|
||||
pathUrl := web.URLFor(endpoint, values...)
|
||||
|
||||
if baseUrl == "" {
|
||||
baseUrl = "/"
|
||||
|
@ -244,17 +244,17 @@ func URLForNotHost(endpoint string, values ...interface{}) string {
|
|||
if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") {
|
||||
return baseUrl + "/" + pathUrl
|
||||
}
|
||||
return baseUrl + beego.URLFor(endpoint, values...)
|
||||
return baseUrl + web.URLFor(endpoint, values...)
|
||||
}
|
||||
|
||||
func URLForWithCdnImage(p string) string {
|
||||
if strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://") {
|
||||
return p
|
||||
}
|
||||
cdn := beego.AppConfig.DefaultString("cdnimg", "")
|
||||
cdn := web.AppConfig.DefaultString("cdnimg", "")
|
||||
//如果没有设置cdn,则使用baseURL拼接
|
||||
if cdn == "" {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "/")
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "/")
|
||||
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(baseUrl, "/") {
|
||||
return baseUrl + p[1:]
|
||||
|
@ -274,7 +274,7 @@ func URLForWithCdnImage(p string) string {
|
|||
}
|
||||
|
||||
func URLForWithCdnCss(p string, v ...string) string {
|
||||
cdn := beego.AppConfig.DefaultString("cdncss", "")
|
||||
cdn := web.AppConfig.DefaultString("cdncss", "")
|
||||
if strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://") {
|
||||
return p
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ func URLForWithCdnCss(p string, v ...string) string {
|
|||
}
|
||||
//如果没有设置cdn,则使用baseURL拼接
|
||||
if cdn == "" {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "/")
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "/")
|
||||
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(baseUrl, "/") {
|
||||
return baseUrl + p[1:]
|
||||
|
@ -305,7 +305,7 @@ func URLForWithCdnCss(p string, v ...string) string {
|
|||
}
|
||||
|
||||
func URLForWithCdnJs(p string, v ...string) string {
|
||||
cdn := beego.AppConfig.DefaultString("cdnjs", "")
|
||||
cdn := web.AppConfig.DefaultString("cdnjs", "")
|
||||
if strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://") {
|
||||
return p
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ func URLForWithCdnJs(p string, v ...string) string {
|
|||
|
||||
//如果没有设置cdn,则使用baseURL拼接
|
||||
if cdn == "" {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "/")
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "/")
|
||||
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(baseUrl, "/") {
|
||||
return baseUrl + p[1:]
|
||||
|
|
21
conf/mail.go
21
conf/mail.go
|
@ -1,8 +1,9 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type SmtpConf struct {
|
||||
|
@ -18,14 +19,14 @@ type SmtpConf struct {
|
|||
}
|
||||
|
||||
func GetMailConfig() *SmtpConf {
|
||||
user_name := beego.AppConfig.String("smtp_user_name")
|
||||
password := beego.AppConfig.String("smtp_password")
|
||||
smtp_host := beego.AppConfig.String("smtp_host")
|
||||
smtp_port := beego.AppConfig.DefaultInt("smtp_port", 25)
|
||||
form_user_name := beego.AppConfig.String("form_user_name")
|
||||
enable_mail := beego.AppConfig.String("enable_mail")
|
||||
mail_number := beego.AppConfig.DefaultInt("mail_number", 5)
|
||||
secure := beego.AppConfig.DefaultString("secure","NONE")
|
||||
user_name, _ := web.AppConfig.String("smtp_user_name")
|
||||
password, _ := web.AppConfig.String("smtp_password")
|
||||
smtp_host, _ := web.AppConfig.String("smtp_host")
|
||||
smtp_port := web.AppConfig.DefaultInt("smtp_port", 25)
|
||||
form_user_name, _ := web.AppConfig.String("form_user_name")
|
||||
enable_mail, _ := web.AppConfig.String("enable_mail")
|
||||
mail_number := web.AppConfig.DefaultInt("mail_number", 5)
|
||||
secure := web.AppConfig.DefaultString("secure", "NONE")
|
||||
|
||||
if secure != "NONE" && secure != "LOGIN" && secure != "SSL" {
|
||||
secure = "NONE"
|
||||
|
@ -38,7 +39,7 @@ func GetMailConfig() *SmtpConf {
|
|||
SmtpPassword: password,
|
||||
FormUserName: form_user_name,
|
||||
SmtpPort: smtp_port,
|
||||
Secure:secure,
|
||||
Secure: secure,
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/i18n"
|
||||
"net/url"
|
||||
"regexp"
|
||||
|
@ -10,7 +9,8 @@ import (
|
|||
|
||||
"html/template"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/lifei6671/gocaptcha"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/mail"
|
||||
|
@ -34,12 +34,14 @@ func (c *AccountController) referer() string {
|
|||
|
||||
func (c *AccountController) Prepare() {
|
||||
c.BaseController.Prepare()
|
||||
c.EnableXSRF = beego.AppConfig.DefaultBool("enablexsrf", true)
|
||||
c.EnableXSRF = web.AppConfig.DefaultBool("enablexsrf", true)
|
||||
|
||||
c.Data["xsrfdata"] = template.HTML(c.XSRFFormHTML())
|
||||
c.Data["corpID"] = beego.AppConfig.String("dingtalk_corpid")
|
||||
c.Data["ENABLE_QR_DINGTALK"] = (beego.AppConfig.String("dingtalk_corpid") != "")
|
||||
c.Data["dingtalk_qr_key"] = beego.AppConfig.String("dingtalk_qr_key")
|
||||
c.Data["corpID"], _ = web.AppConfig.String("dingtalk_corpid")
|
||||
if dtcorpid, _ := web.AppConfig.String("dingtalk_corpid"); dtcorpid != "" {
|
||||
c.Data["ENABLE_QR_DINGTALK"] = true
|
||||
}
|
||||
c.Data["dingtalk_qr_key"], _ = web.AppConfig.String("dingtalk_qr_key")
|
||||
|
||||
if !c.EnableXSRF {
|
||||
return
|
||||
|
@ -152,9 +154,9 @@ func (c *AccountController) DingTalkLogin() {
|
|||
c.JsonResult(500, i18n.Tr(c.Lang, "message.failed_obtain_user_info"), nil)
|
||||
}
|
||||
|
||||
appKey := beego.AppConfig.String("dingtalk_app_key")
|
||||
appSecret := beego.AppConfig.String("dingtalk_app_secret")
|
||||
tmpReader := beego.AppConfig.String("dingtalk_tmp_reader")
|
||||
appKey, _ := web.AppConfig.String("dingtalk_app_key")
|
||||
appSecret, _ := web.AppConfig.String("dingtalk_app_secret")
|
||||
tmpReader, _ := web.AppConfig.String("dingtalk_tmp_reader")
|
||||
|
||||
if appKey == "" || appSecret == "" || tmpReader == "" {
|
||||
c.JsonResult(500, i18n.Tr(c.Lang, "message.dingtalk_auto_login_not_enable"), nil)
|
||||
|
@ -212,8 +214,8 @@ func (c *AccountController) QRLogin() {
|
|||
c.Redirect(conf.URLFor("AccountController.Login"), 302)
|
||||
c.StopRun()
|
||||
}
|
||||
appKey := beego.AppConfig.String("dingtalk_qr_key")
|
||||
appSecret := beego.AppConfig.String("dingtalk_qr_secret")
|
||||
appKey, _ := web.AppConfig.String("dingtalk_qr_key")
|
||||
appSecret, _ := web.AppConfig.String("dingtalk_qr_secret")
|
||||
|
||||
qrDingtalk := dingtalk.NewDingtalkQRLogin(appSecret, appKey)
|
||||
unionID, err := qrDingtalk.GetUnionIDByCode(code)
|
||||
|
@ -223,9 +225,9 @@ func (c *AccountController) QRLogin() {
|
|||
c.StopRun()
|
||||
}
|
||||
|
||||
appKey = beego.AppConfig.String("dingtalk_app_key")
|
||||
appSecret = beego.AppConfig.String("dingtalk_app_secret")
|
||||
tmpReader := beego.AppConfig.String("dingtalk_tmp_reader")
|
||||
appKey, _ = web.AppConfig.String("dingtalk_app_key")
|
||||
appSecret, _ = web.AppConfig.String("dingtalk_app_secret")
|
||||
tmpReader, _ := web.AppConfig.String("dingtalk_tmp_reader")
|
||||
|
||||
dingtalkAgent := dingtalk.NewDingTalkAgent(appSecret, appKey)
|
||||
err = dingtalkAgent.GetAccesstoken()
|
||||
|
@ -478,7 +480,7 @@ func (c *AccountController) FindPassword() {
|
|||
c.TplName = "errors/error.tpl"
|
||||
return
|
||||
}
|
||||
subTime := memberToken.SendTime.Sub(time.Now())
|
||||
subTime := time.Until(memberToken.SendTime)
|
||||
|
||||
if !strings.EqualFold(memberToken.Email, email) || subTime.Minutes() > float64(mailConf.MailExpired) || !memberToken.ValidTime.IsZero() {
|
||||
c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.captcha_expired")
|
||||
|
@ -527,7 +529,7 @@ func (c *AccountController) ValidEmail() {
|
|||
logs.Error(err)
|
||||
c.JsonResult(6007, i18n.Tr(c.Lang, "message.mail_expired"))
|
||||
}
|
||||
subTime := memberToken.SendTime.Sub(time.Now())
|
||||
subTime := time.Until(memberToken.SendTime)
|
||||
|
||||
if !strings.EqualFold(memberToken.Email, email) || subTime.Minutes() > float64(mailConf.MailExpired) || !memberToken.ValidTime.IsZero() {
|
||||
|
||||
|
|
|
@ -14,14 +14,15 @@ import (
|
|||
"io/ioutil"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
)
|
||||
|
||||
type BaseController struct {
|
||||
beego.Controller
|
||||
web.Controller
|
||||
Member *models.Member
|
||||
Option map[string]string
|
||||
EnableAnonymous bool
|
||||
|
@ -75,9 +76,9 @@ func (c *BaseController) Prepare() {
|
|||
c.EnableAnonymous = strings.EqualFold(c.Option["ENABLE_ANONYMOUS"], "true")
|
||||
c.EnableDocumentHistory = strings.EqualFold(c.Option["ENABLE_DOCUMENT_HISTORY"], "true")
|
||||
}
|
||||
c.Data["HighlightStyle"] = beego.AppConfig.DefaultString("highlight_style", "github")
|
||||
c.Data["HighlightStyle"] = web.AppConfig.DefaultString("highlight_style", "github")
|
||||
|
||||
if b, err := ioutil.ReadFile(filepath.Join(beego.BConfig.WebConfig.ViewsPath, "widgets", "scripts.tpl")); err == nil {
|
||||
if b, err := ioutil.ReadFile(filepath.Join(web.BConfig.WebConfig.ViewsPath, "widgets", "scripts.tpl")); err == nil {
|
||||
c.Data["Scripts"] = template.HTML(string(b))
|
||||
}
|
||||
|
||||
|
@ -161,18 +162,18 @@ func (c *BaseController) ExecuteViewPathTemplate(tplName string, data interface{
|
|||
viewPath := c.ViewPath
|
||||
|
||||
if c.ViewPath == "" {
|
||||
viewPath = beego.BConfig.WebConfig.ViewsPath
|
||||
viewPath = web.BConfig.WebConfig.ViewsPath
|
||||
|
||||
}
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf, tplName, viewPath, data); err != nil {
|
||||
if err := web.ExecuteViewPathTemplate(&buf, tplName, viewPath, data); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
func (c *BaseController) BaseUrl() string {
|
||||
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
|
||||
baseUrl := web.AppConfig.DefaultString("baseurl", "")
|
||||
if baseUrl != "" {
|
||||
if strings.HasSuffix(baseUrl, "/") {
|
||||
baseUrl = strings.TrimSuffix(baseUrl, "/")
|
||||
|
@ -192,7 +193,7 @@ func (c *BaseController) ShowErrorPage(errCode int, errMsg string) {
|
|||
|
||||
var buf bytes.Buffer
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf, "errors/error.tpl", beego.BConfig.WebConfig.ViewsPath, map[string]interface{}{"ErrorMessage": errMsg, "ErrorCode": errCode, "BaseUrl": conf.BaseUrl}); err != nil {
|
||||
if err := web.ExecuteViewPathTemplate(&buf, "errors/error.tpl", web.BConfig.WebConfig.ViewsPath, map[string]interface{}{"ErrorMessage": errMsg, "ErrorCode": errCode, "BaseUrl": conf.BaseUrl}); err != nil {
|
||||
c.Abort("500")
|
||||
}
|
||||
if errCode >= 200 && errCode <= 510 {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
@ -12,11 +13,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
@ -57,11 +57,11 @@ func (c *BlogController) Index() {
|
|||
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)
|
||||
_ = c.CruSession.Set(context.TODO(), blogReadSession, blogId)
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
c.JsonResult(0, "OK")
|
||||
} else if blog.BlogStatus == "password" && (c.CruSession.Get(blogReadSession) == nil || (c.Member != nil && blog.MemberId != c.Member.MemberId && !c.Member.IsAdministrator())) {
|
||||
} else if blog.BlogStatus == "password" && (c.CruSession.Get(context.TODO(), blogReadSession) == nil || (c.Member != nil && blog.MemberId != c.Member.MemberId && !c.Member.IsAdministrator())) {
|
||||
//如果不存在已输入密码的标记
|
||||
c.TplName = "blog/index_password.tpl"
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ func (c *BlogController) Upload() {
|
|||
c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_type_error"))
|
||||
}
|
||||
//如果文件类型设置为 * 标识不限制文件类型
|
||||
if beego.AppConfig.DefaultString("upload_file_ext", "") != "*" {
|
||||
if web.AppConfig.DefaultString("upload_file_ext", "") != "*" {
|
||||
if !conf.IsAllowUploadFileExt(ext) {
|
||||
c.JsonResult(6004, i18n.Tr(c.Lang, "message.upload_file_type_error"))
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ func (c *BlogController) Download() {
|
|||
}
|
||||
blogReadSession := fmt.Sprintf("blog:read:%d", blogId)
|
||||
//如果没有启动匿名访问,或者设置了访问密码
|
||||
if (c.Member == nil && !c.EnableAnonymous) || (blog.BlogStatus == "password" && password != blog.Password && c.CruSession.Get(blogReadSession) == nil) {
|
||||
if (c.Member == nil && !c.EnableAnonymous) || (blog.BlogStatus == "password" && password != blog.Password && c.CruSession.Get(context.TODO(), blogReadSession) == nil) {
|
||||
c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -17,14 +18,14 @@ import (
|
|||
|
||||
"net/http"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/graphics"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
"github.com/mindoc-org/mindoc/utils/pagination"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
)
|
||||
|
||||
type BookController struct {
|
||||
|
@ -614,7 +615,7 @@ func (c *BookController) Import() {
|
|||
c.JsonResult(6006, i18n.Tr(c.Lang, "message.project_id_existed"))
|
||||
}
|
||||
|
||||
tempPath := filepath.Join(os.TempDir(), c.CruSession.SessionID())
|
||||
tempPath := filepath.Join(os.TempDir(), c.CruSession.SessionID(context.TODO()))
|
||||
|
||||
os.MkdirAll(tempPath, 0766)
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package controllers
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
@ -14,9 +15,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/qr"
|
||||
|
@ -27,7 +28,7 @@ import (
|
|||
"github.com/mindoc-org/mindoc/utils/filetil"
|
||||
"github.com/mindoc-org/mindoc/utils/gopool"
|
||||
"github.com/mindoc-org/mindoc/utils/pagination"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
)
|
||||
|
||||
// DocumentController struct
|
||||
|
@ -143,17 +144,22 @@ func (c *DocumentController) Read() {
|
|||
doc.AttachList = attach
|
||||
}
|
||||
|
||||
doc.IncrViewCount(doc.DocumentId)
|
||||
c.Data["ViewCount"] = doc.ViewCount + 1
|
||||
|
||||
if c.IsAjax() {
|
||||
var data struct {
|
||||
DocTitle string `json:"doc_title"`
|
||||
Body string `json:"body"`
|
||||
Title string `json:"title"`
|
||||
Version int64 `json:"version"`
|
||||
ViewCount int `json:"view_count"`
|
||||
}
|
||||
data.DocTitle = doc.DocumentName
|
||||
data.Body = doc.Release
|
||||
data.Title = doc.DocumentName + " - Powered by MinDoc"
|
||||
data.Version = doc.Version
|
||||
data.ViewCount = doc.ViewCount + 1
|
||||
|
||||
c.JsonResult(0, "ok", data)
|
||||
}
|
||||
|
@ -242,7 +248,7 @@ func (c *DocumentController) Edit() {
|
|||
}
|
||||
}
|
||||
|
||||
c.Data["BaiDuMapKey"] = beego.AppConfig.DefaultString("baidumapkey", "")
|
||||
c.Data["BaiDuMapKey"] = web.AppConfig.DefaultString("baidumapkey", "")
|
||||
|
||||
if conf.GetUploadFileSize() > 0 {
|
||||
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
|
||||
|
@ -839,7 +845,7 @@ func (c *DocumentController) Export() {
|
|||
if bookResult.Editor != "markdown" {
|
||||
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.cur_project_not_support_md"))
|
||||
}
|
||||
p, err := bookResult.ExportMarkdown(c.CruSession.SessionID())
|
||||
p, err := bookResult.ExportMarkdown(c.CruSession.SessionID(context.TODO()))
|
||||
|
||||
if err != nil {
|
||||
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.failed"))
|
||||
|
@ -874,7 +880,7 @@ func (c *DocumentController) Export() {
|
|||
c.Abort("200")
|
||||
|
||||
} else if output == "pdf" || output == "epub" || output == "docx" || output == "mobi" {
|
||||
if err := models.BackgroundConvert(c.CruSession.SessionID(), bookResult); err != nil && err != gopool.ErrHandlerIsExist {
|
||||
if err := models.BackgroundConvert(c.CruSession.SessionID(context.TODO()), bookResult); err != nil && err != gopool.ErrHandlerIsExist {
|
||||
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.export_failed"))
|
||||
}
|
||||
|
||||
|
@ -1277,7 +1283,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|||
|
||||
func promptUserToLogIn(c *DocumentController) {
|
||||
logs.Info("Access " + c.Ctx.Request.URL.RequestURI() + " not permitted.")
|
||||
logs.Info(" Access will be redirected to login page(SessionId: " + c.CruSession.SessionID() + ").")
|
||||
logs.Info(" Access will be redirected to login page(SessionId: " + c.CruSession.SessionID(context.TODO()) + ").")
|
||||
|
||||
if c.IsAjax() {
|
||||
c.JsonResult(6000, i18n.Tr(c.Lang, "message.need_relogin"))
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"math"
|
||||
"net/url"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils/pagination"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils/pagination"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"math"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils/pagination"
|
||||
|
|
|
@ -13,16 +13,16 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
"github.com/mindoc-org/mindoc/utils/filetil"
|
||||
"github.com/mindoc-org/mindoc/utils/pagination"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
)
|
||||
|
||||
type ManagerController struct {
|
||||
|
@ -748,7 +748,7 @@ func (c *ManagerController) Config() {
|
|||
|
||||
tf.WriteString(content)
|
||||
|
||||
err = beego.LoadAppConfig("ini", tf.Name())
|
||||
err = web.LoadAppConfig("ini", tf.Name())
|
||||
|
||||
if err != nil {
|
||||
logs.Error("加载配置文件失败 ->", err)
|
||||
|
|
|
@ -4,9 +4,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/i18n"
|
||||
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/graphics"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
|
|
13
go.mod
13
go.mod
|
@ -1,13 +1,13 @@
|
|||
module github.com/mindoc-org/mindoc
|
||||
|
||||
go 1.12
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.4.1
|
||||
github.com/Unknwon/goconfig v0.0.0-20200908083735-df7de6a44db8 // indirect
|
||||
github.com/andybalholm/cascadia v1.2.0 // indirect
|
||||
github.com/astaxie/beego v1.12.3
|
||||
github.com/beego/i18n v0.0.0-20161101132742-e9308947f407 // indirect
|
||||
github.com/beego/beego/v2 v2.0.2-0.20210322114547-10ea897525a5
|
||||
github.com/beego/i18n v0.0.0-20161101132742-e9308947f407
|
||||
github.com/boombuler/barcode v1.0.0
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
|
||||
github.com/howeyc/fsnotify v0.9.0
|
||||
|
@ -16,13 +16,10 @@ require (
|
|||
github.com/lifei6671/gocaptcha v0.1.1
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 // indirect
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0
|
||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-00010101000000-000000000000 // indirect
|
||||
gopkg.in/ldap.v2 v2.5.1
|
||||
gopkg.in/russross/blackfriday.v2 v2.0.0
|
||||
gopkg.in/yaml.v2 v2.3.0 // indirect
|
||||
|
||||
)
|
||||
|
|
126
go.sum
126
go.sum
|
@ -1,3 +1,4 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/PuerkitoBio/goquery v1.4.1 h1:smcIRGdYm/w7JSbcdeLHEMzxmsBQvl8lhf0dSw2nzMI=
|
||||
|
@ -12,8 +13,8 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn
|
|||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
||||
github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE=
|
||||
github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY=
|
||||
github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
|
||||
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
|
||||
github.com/beego/beego/v2 v2.0.2-0.20210322114547-10ea897525a5 h1:i0swsv6hmoF6pkeG2S/dvOWwOKFPGDKhrmTlWH6I1nM=
|
||||
github.com/beego/beego/v2 v2.0.2-0.20210322114547-10ea897525a5/go.mod h1:JlRUJ/NVNygorqjyt7/lQ8R++KSE0qXvxeIfbnIUd7Q=
|
||||
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
|
||||
github.com/beego/i18n v0.0.0-20161101132742-e9308947f407 h1:WtJfx5HqASTQp7HfiZldnin8KQV2futplF3duGp5PGc=
|
||||
github.com/beego/i18n v0.0.0-20161101132742-e9308947f407/go.mod h1:KLeFCpAMq2+50NkXC8iiJxLLiiTfTqrGtKEVm+2fk7s=
|
||||
|
@ -28,12 +29,18 @@ github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6
|
|||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pOvUGt1D1lA5KjYhPBAN/3iWdP7xeFS9F0=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
|
||||
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
|
||||
github.com/couchbase/goutils v0.0.0-20201030094643-5e82bb967e67/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
|
@ -42,6 +49,9 @@ github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt
|
|||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.0 h1:/S4hO/AO6tLMlPX0oftGSOcdGJJN/MuYzfgWRMn199E=
|
||||
|
@ -50,13 +60,19 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2
|
|||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-redis/redis v6.14.2+incompatible h1:UE9pLhzmWf+xHNmZsoccjXosPicuiNaInPgym8nzfg0=
|
||||
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v7 v7.4.0 h1:7obg6wUoj05T0EpY0o8B59S9w5yeMWql7sw2kwNW1x4=
|
||||
github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
@ -71,21 +87,29 @@ github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8l
|
|||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY=
|
||||
github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA=
|
||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kardianos/service v1.1.0 h1:QV2SiEeWK42P0aEmGcsAgjApw/lRxkwopvT+Gu6t1/0=
|
||||
github.com/kardianos/service v1.1.0/go.mod h1:RrJI2xn5vve/r32U5suTbeaSGoMU6GbNPoj36CVYcHc=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
|
@ -102,6 +126,8 @@ github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJK
|
|||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
|
@ -112,10 +138,15 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S
|
|||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
|
||||
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
@ -129,6 +160,7 @@ github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R
|
|||
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
|
@ -138,10 +170,11 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
|
|||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
|
||||
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
|
||||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
|
||||
|
@ -158,26 +191,51 @@ github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2K
|
|||
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
|
||||
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
|
||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067 h1:KYGJGHOQy8oSi1fDlSpcZF0+juKwk/hEMv5SiwHogR0=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
@ -185,17 +243,41 @@ golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
|
@ -205,15 +287,17 @@ google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyz
|
|||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/ldap.v2 v2.5.1 h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU=
|
||||
gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/russross/blackfriday.v2 v2.0.0 h1:+FlnIV8DSQnT7NZ43hcVKcdJdzZoeCmJj4Ql8gq5keA=
|
||||
gopkg.in/russross/blackfriday.v2 v2.0.0/go.mod h1:6sSBNz/GtOm/pJTuh5UmBK2ZHfmnxGbl2NZg1UliSOI=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
@ -222,3 +306,7 @@ gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/mail"
|
||||
|
@ -18,6 +17,8 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
7
main.go
7
main.go
|
@ -5,10 +5,9 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
|
||||
_ "github.com/astaxie/beego/session/memcache"
|
||||
_ "github.com/astaxie/beego/session/mysql"
|
||||
|
||||
_ "github.com/astaxie/beego/session/redis"
|
||||
_ "github.com/beego/beego/v2/server/web/session/memcache"
|
||||
_ "github.com/beego/beego/v2/server/web/session/mysql"
|
||||
_ "github.com/beego/beego/v2/server/web/session/redis"
|
||||
"github.com/kardianos/service"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/mindoc-org/mindoc/commands"
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"os"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils/filetil"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package models
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/utils/filetil"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/mindoc-org/mindoc/cache"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
@ -110,7 +111,7 @@ func (b *Blog) FindFromCache(blogId int) (blog *Blog, err error) {
|
|||
if err == nil {
|
||||
b = &temp
|
||||
b.Link()
|
||||
beego.Debug("从缓存读取文章成功 ->", key)
|
||||
logs.Debug("从缓存读取文章成功 ->", key)
|
||||
return b, nil
|
||||
} else {
|
||||
logs.Error("读取缓存失败 ->", err)
|
||||
|
@ -273,7 +274,7 @@ func (b *Blog) Processor() *Blog {
|
|||
}
|
||||
})
|
||||
//设置图片为CDN地址
|
||||
if cdnimg := beego.AppConfig.String("cdnimg"); cdnimg != "" {
|
||||
if cdnimg, _ := web.AppConfig.String("cdnimg"); cdnimg != "" {
|
||||
content.Find("img").Each(func(i int, contentSelection *goquery.Selection) {
|
||||
if src, ok := contentSelection.Attr("src"); ok && strings.HasPrefix(src, "/uploads/") {
|
||||
contentSelection.SetAttr("src", utils.JoinURI(cdnimg, src))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -16,8 +17,8 @@ import (
|
|||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
@ -25,7 +26,7 @@ import (
|
|||
"github.com/mindoc-org/mindoc/utils/filetil"
|
||||
"github.com/mindoc-org/mindoc/utils/requests"
|
||||
"github.com/mindoc-org/mindoc/utils/ziptil"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
)
|
||||
|
||||
var releaseQueue = make(chan int, 500)
|
||||
|
@ -197,7 +198,7 @@ func (book *Book) Copy(identify string) error {
|
|||
logs.Error("查询项目时出错 -> ", err)
|
||||
return err
|
||||
}
|
||||
if err := o.Begin(); err != nil {
|
||||
if _, err := o.Begin(); err != nil {
|
||||
logs.Error("开启事物时出错 -> ", err)
|
||||
return err
|
||||
}
|
||||
|
@ -210,49 +211,87 @@ func (book *Book) Copy(identify string) error {
|
|||
book.CommentCount = 0
|
||||
book.HistoryCount = 0
|
||||
|
||||
if _, err := o.Insert(book); err != nil {
|
||||
logs.Error("复制项目时出错 -> ", err)
|
||||
o.Rollback()
|
||||
/* v2 version of beego remove the o.Rollback api for transaction operation.
|
||||
* typically, in v1, you can write code like this:
|
||||
*
|
||||
* o := orm.NewOrm()
|
||||
* if err := o.Operateion(); err != nil {
|
||||
* o.Rollback()
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* however, in v2, this is not available. beego will handles the transaction in new way using
|
||||
* cluster. the new code is like below:
|
||||
*
|
||||
* o := orm.NewOrm()
|
||||
* if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error{
|
||||
* err := o.Operations()
|
||||
* if err != nil {
|
||||
* return err
|
||||
* }
|
||||
* ...
|
||||
* }); err != nil {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* when operation failed, it will automatically calls o.Rollback() for TxOrmer.
|
||||
* more details see https://beego.me/docs/mvc/model/transaction.md
|
||||
*/
|
||||
if err := o.DoTx(func(ctx context.Context, txo orm.TxOrmer) error {
|
||||
_, err := txo.Insert(book)
|
||||
return err
|
||||
|
||||
}); err != nil {
|
||||
logs.Error("复制项目时出错: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
var rels []*Relationship
|
||||
|
||||
if _, err := o.QueryTable(NewRelationship().TableNameWithPrefix()).Filter("book_id", bookId).All(&rels); err != nil {
|
||||
if err := o.DoTx(func(ctx context.Context, txo orm.TxOrmer) error {
|
||||
_, err := txo.QueryTable(NewRelationship().TableNameWithPrefix()).Filter("book_id", bookId).All(&rels)
|
||||
return err
|
||||
}); err != nil {
|
||||
logs.Error("复制项目关系时出错 -> ", err)
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range rels {
|
||||
rel.BookId = book.BookId
|
||||
rel.RelationshipId = 0
|
||||
if _, err := o.Insert(rel); err != nil {
|
||||
if err := o.DoTx(func(ctx context.Context, txo orm.TxOrmer) error {
|
||||
_, err := txo.Insert(rel)
|
||||
return err
|
||||
}); err != nil {
|
||||
logs.Error("复制项目关系时出错 -> ", err)
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var docs []*Document
|
||||
|
||||
if _, err := o.QueryTable(NewDocument().TableNameWithPrefix()).Filter("book_id", bookId).Filter("parent_id", 0).All(&docs); err != nil && err != orm.ErrNoRows {
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err := txOrm.QueryTable(NewDocument().TableNameWithPrefix()).Filter("book_id", bookId).Filter("parent_id", 0).All(&docs)
|
||||
return err
|
||||
}); err != nil && err != orm.ErrNoRows {
|
||||
logs.Error("读取项目文档时出错 -> ", err)
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
if len(docs) > 0 {
|
||||
if err := recursiveInsertDocument(docs, o, book.BookId, 0); err != nil {
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
return recursiveInsertDocument(docs, txOrm, book.BookId, 0)
|
||||
}); err != nil {
|
||||
logs.Error("复制项目时出错 -> ", err)
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return o.Commit()
|
||||
return nil
|
||||
}
|
||||
|
||||
//递归的复制文档
|
||||
func recursiveInsertDocument(docs []*Document, o orm.Ormer, bookId int, parentId int) error {
|
||||
func recursiveInsertDocument(docs []*Document, o orm.TxOrmer, bookId int, parentId int) error {
|
||||
for _, doc := range docs {
|
||||
|
||||
docId := doc.DocumentId
|
||||
|
@ -419,42 +458,49 @@ func (book *Book) ThoroughDeleteBook(id int) error {
|
|||
o.Begin()
|
||||
|
||||
//删除附件,这里没有删除实际物理文件
|
||||
_, err = o.Raw("DELETE FROM "+NewAttachment().TableNameWithPrefix()+" WHERE book_id=?", book.BookId).Exec()
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err = txOrm.Raw("DELETE FROM "+NewAttachment().TableNameWithPrefix()+" WHERE book_id=?", book.BookId).Exec()
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//删除文档
|
||||
_, err = o.Raw("DELETE FROM "+NewDocument().TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err = txOrm.Raw("DELETE FROM "+NewDocument().TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
//删除项目
|
||||
_, err = o.Raw("DELETE FROM "+book.TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err = txOrm.Raw("DELETE FROM "+book.TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//删除关系
|
||||
_, err = o.Raw("DELETE FROM "+NewRelationship().TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err = txOrm.Raw("DELETE FROM "+NewRelationship().TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = o.Raw(fmt.Sprintf("DELETE FROM %s WHERE book_id=?", NewTeamRelationship().TableNameWithPrefix()), book.BookId).Exec()
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err = txOrm.Raw(fmt.Sprintf("DELETE FROM %s WHERE book_id=?", NewTeamRelationship().TableNameWithPrefix()), book.BookId).Exec()
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
//删除模板
|
||||
_, err = o.Raw("DELETE FROM "+NewTemplate().TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
_, err = txOrm.Raw("DELETE FROM "+NewTemplate().TableNameWithPrefix()+" WHERE book_id = ?", book.BookId).Exec()
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -471,7 +517,7 @@ func (book *Book) ThoroughDeleteBook(id int) error {
|
|||
logs.Error("删除项目附件和图片失败 ->", err)
|
||||
}
|
||||
|
||||
return o.Commit()
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ import (
|
|||
"regexp"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/converter"
|
||||
|
@ -25,7 +25,7 @@ import (
|
|||
"github.com/mindoc-org/mindoc/utils/gopool"
|
||||
"github.com/mindoc-org/mindoc/utils/requests"
|
||||
"github.com/mindoc-org/mindoc/utils/ziptil"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -269,7 +269,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
|||
convertBookResult := ConvertBookResult{}
|
||||
|
||||
outputPath := filepath.Join(conf.GetExportOutputPath(), strconv.Itoa(m.BookId))
|
||||
viewPath := beego.BConfig.WebConfig.ViewsPath
|
||||
viewPath := web.BConfig.WebConfig.ViewsPath
|
||||
|
||||
pdfpath := filepath.Join(outputPath, "book.pdf")
|
||||
epubpath := filepath.Join(outputPath, "book.epub")
|
||||
|
@ -380,7 +380,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
|||
}
|
||||
var buf bytes.Buffer
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf, "document/export.tpl", viewPath, map[string]interface{}{"Model": m, "Lists": item, "BaseUrl": conf.BaseUrl}); err != nil {
|
||||
if err := web.ExecuteViewPathTemplate(&buf, "document/export.tpl", viewPath, map[string]interface{}{"Model": m, "Lists": item, "BaseUrl": conf.BaseUrl}); err != nil {
|
||||
return convertBookResult, err
|
||||
}
|
||||
html := buf.String()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package models
|
||||
|
||||
import "github.com/astaxie/beego/orm"
|
||||
import "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
type Dashboard struct {
|
||||
BookNumber int64 `json:"book_number"`
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/mindoc-org/mindoc/cache"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
@ -44,6 +45,7 @@ type Document struct {
|
|||
Version int64 `orm:"column(version);type(bigint);" json:"version"`
|
||||
//是否展开子目录:0 否/1 是 /2 空间节点,单击时展开下一级
|
||||
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
|
||||
ViewCount int `orm:"column(view_count);type(int)" json:"view_count"`
|
||||
AttachList []*Attachment `orm:"-" json:"attach"`
|
||||
//i18n
|
||||
Lang string `orm:"-"`
|
||||
|
@ -338,7 +340,7 @@ func (item *Document) Processor() *Document {
|
|||
selector.First().AppendHtml(release)
|
||||
}
|
||||
}
|
||||
cdnimg := beego.AppConfig.String("cdnimg")
|
||||
cdnimg,_ := web.AppConfig.String("cdnimg")
|
||||
|
||||
docQuery.Find("img").Each(func(i int, selection *goquery.Selection) {
|
||||
|
||||
|
@ -389,3 +391,11 @@ func (item *Document) Processor() *Document {
|
|||
}
|
||||
return item
|
||||
}
|
||||
|
||||
// 增加阅读次数
|
||||
func (item *Document) IncrViewCount(id int) {
|
||||
o := orm.NewOrm()
|
||||
o.QueryTable(item.TableNameWithPrefix()).Filter("document_id", id).Update(orm.Params{
|
||||
"view_count": orm.ColValue(orm.ColAdd, 1),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type DocumentSearchResult struct {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"html/template"
|
||||
"math"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package models
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
"github.com/mindoc-org/mindoc/utils/cryptil"
|
||||
|
@ -112,8 +112,9 @@ func (item *Itemsets) Delete(itemId int) (err error) {
|
|||
if !item.Exist(itemId) {
|
||||
return errors.New("项目空间不存在")
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
if err := o.Begin(); err != nil {
|
||||
ormer := orm.NewOrm()
|
||||
o, err := ormer.Begin()
|
||||
if err != nil {
|
||||
logs.Error("开启事物失败 ->", err)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import (
|
|||
|
||||
"math"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
|
@ -77,14 +77,14 @@ func (m *Member) Login(account string, password string) (*Member, error) {
|
|||
err := o.Raw("select * from md_members where (account = ? or email = ?) and status = 0 limit 1;", account, account).QueryRow(member)
|
||||
|
||||
if err != nil {
|
||||
if beego.AppConfig.DefaultBool("ldap_enable", false) == true {
|
||||
if web.AppConfig.DefaultBool("ldap_enable", false) {
|
||||
logs.Info("转入LDAP登陆 ->", account)
|
||||
return member.ldapLogin(account, password)
|
||||
} else if beego.AppConfig.String("http_login_url") != "" {
|
||||
} else if url, err := web.AppConfig.String("http_login_url"); url != "" {
|
||||
logs.Info("转入 HTTP 接口登陆 ->", account)
|
||||
return member.httpLogin(account, password)
|
||||
} else {
|
||||
logs.Error("用户登录 ->", err)
|
||||
logs.Error("user login for `%s`: %s", account, err)
|
||||
return member, ErrMemberNoExist
|
||||
}
|
||||
}
|
||||
|
@ -121,26 +121,32 @@ func (m *Member) TmpLogin(account string) (*Member, error) {
|
|||
|
||||
//ldapLogin 通过LDAP登陆
|
||||
func (m *Member) ldapLogin(account string, password string) (*Member, error) {
|
||||
if beego.AppConfig.DefaultBool("ldap_enable", false) == false {
|
||||
if !web.AppConfig.DefaultBool("ldap_enable", false) {
|
||||
return m, ErrMemberAuthMethodInvalid
|
||||
}
|
||||
var err error
|
||||
lc, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", beego.AppConfig.String("ldap_host"), beego.AppConfig.DefaultInt("ldap_port", 3268)))
|
||||
ldaphost, _ := web.AppConfig.String("ldap_host")
|
||||
lc, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", ldaphost, web.AppConfig.DefaultInt("ldap_port", 3268)))
|
||||
if err != nil {
|
||||
logs.Error("绑定 LDAP 用户失败 ->", err)
|
||||
return m, ErrLDAPConnect
|
||||
}
|
||||
defer lc.Close()
|
||||
err = lc.Bind(beego.AppConfig.String("ldap_user"), beego.AppConfig.String("ldap_password"))
|
||||
ldapuser, _ := web.AppConfig.String("ldap_user")
|
||||
ldappass, _ := web.AppConfig.String("ldap_password")
|
||||
err = lc.Bind(ldapuser, ldappass)
|
||||
if err != nil {
|
||||
logs.Error("绑定 LDAP 用户失败 ->", err)
|
||||
return m, ErrLDAPFirstBind
|
||||
}
|
||||
ldapbase, _ := web.AppConfig.String("ldap_base")
|
||||
ldapfilter, _ := web.AppConfig.String("ldap_filter")
|
||||
ldapattr, _ := web.AppConfig.String("ldap_attribute")
|
||||
searchRequest := ldap.NewSearchRequest(
|
||||
beego.AppConfig.String("ldap_base"),
|
||||
ldapbase,
|
||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
//修改objectClass通过配置文件获取值
|
||||
fmt.Sprintf("(&(%s)(%s=%s))", beego.AppConfig.String("ldap_filter"), beego.AppConfig.String("ldap_attribute"), account),
|
||||
fmt.Sprintf("(&(%s)(%s=%s))", ldapfilter, ldapattr, account),
|
||||
[]string{"dn", "mail"},
|
||||
nil,
|
||||
)
|
||||
|
@ -163,7 +169,7 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) {
|
|||
m.Email = searchResult.Entries[0].GetAttributeValue("mail")
|
||||
m.AuthMethod = "ldap"
|
||||
m.Avatar = "/static/images/headimgurl.jpg"
|
||||
m.Role = conf.SystemRole(beego.AppConfig.DefaultInt("ldap_user_role", 2))
|
||||
m.Role = conf.SystemRole(web.AppConfig.DefaultInt("ldap_user_role", 2))
|
||||
m.CreateTime = time.Now()
|
||||
|
||||
err = m.Add()
|
||||
|
@ -177,7 +183,7 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) {
|
|||
}
|
||||
|
||||
func (m *Member) httpLogin(account, password string) (*Member, error) {
|
||||
urlStr := beego.AppConfig.String("http_login_url")
|
||||
urlStr, _ := web.AppConfig.String("http_login_url")
|
||||
if urlStr == "" {
|
||||
return nil, ErrMemberAuthMethodInvalid
|
||||
}
|
||||
|
@ -188,7 +194,7 @@ func (m *Member) httpLogin(account, password string) (*Member, error) {
|
|||
"time": []string{strconv.FormatInt(time.Now().Unix(), 10)},
|
||||
}
|
||||
h := md5.New()
|
||||
h.Write([]byte(val.Encode() + beego.AppConfig.DefaultString("http_login_secret", "")))
|
||||
h.Write([]byte(val.Encode() + web.AppConfig.DefaultString("http_login_secret", "")))
|
||||
|
||||
val.Add("sn", hex.EncodeToString(h.Sum(nil)))
|
||||
|
||||
|
@ -240,7 +246,7 @@ func (m *Member) httpLogin(account, password string) (*Member, error) {
|
|||
member.Account = account
|
||||
member.Password = password
|
||||
member.AuthMethod = "http"
|
||||
member.Role = conf.SystemRole(beego.AppConfig.DefaultInt("ldap_user_role", 2))
|
||||
member.Role = conf.SystemRole(web.AppConfig.DefaultInt("ldap_user_role", 2))
|
||||
member.CreateTime = time.Now()
|
||||
if err := member.Add(); err != nil {
|
||||
logs.Error("自动注册用户错误", err)
|
||||
|
@ -459,9 +465,9 @@ func (m *Member) Valid(is_hash_password bool) error {
|
|||
|
||||
//删除一个用户.
|
||||
func (m *Member) Delete(oldId int, newId int) error {
|
||||
o := orm.NewOrm()
|
||||
ormer := orm.NewOrm()
|
||||
|
||||
err := o.Begin()
|
||||
o, err := ormer.Begin()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -3,7 +3,7 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package models
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
@ -122,11 +122,11 @@ func (m *Relationship) Insert() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (m *Relationship) Update() error {
|
||||
o := orm.NewOrm()
|
||||
|
||||
_, err := o.Update(m)
|
||||
|
||||
func (m *Relationship) Update(txOrm orm.TxOrmer) error {
|
||||
_, err := txOrm.Update(m)
|
||||
if err != nil {
|
||||
txOrm.Rollback()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -152,11 +152,11 @@ func (m *Relationship) DeleteByBookIdAndMemberId(book_id, member_id int) error {
|
|||
}
|
||||
|
||||
func (m *Relationship) Transfer(book_id, founder_id, receive_id int) error {
|
||||
o := orm.NewOrm()
|
||||
ormer := orm.NewOrm()
|
||||
|
||||
founder := NewRelationship()
|
||||
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("book_id", book_id).Filter("member_id", founder_id).One(founder)
|
||||
err := ormer.QueryTable(m.TableNameWithPrefix()).Filter("book_id", book_id).Filter("member_id", founder_id).One(founder)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -166,12 +166,12 @@ func (m *Relationship) Transfer(book_id, founder_id, receive_id int) error {
|
|||
}
|
||||
receive := NewRelationship()
|
||||
|
||||
err = o.QueryTable(m.TableNameWithPrefix()).Filter("book_id", book_id).Filter("member_id", receive_id).One(receive)
|
||||
err = ormer.QueryTable(m.TableNameWithPrefix()).Filter("book_id", book_id).Filter("member_id", receive_id).One(receive)
|
||||
|
||||
if err != orm.ErrNoRows && err != nil {
|
||||
return err
|
||||
}
|
||||
o.Begin()
|
||||
o, _ := ormer.Begin()
|
||||
|
||||
founder.RoleId = conf.BookAdmin
|
||||
|
||||
|
@ -179,8 +179,7 @@ func (m *Relationship) Transfer(book_id, founder_id, receive_id int) error {
|
|||
receive.RoleId = conf.BookFounder
|
||||
receive.BookId = book_id
|
||||
|
||||
if err := founder.Update(); err != nil {
|
||||
o.Rollback()
|
||||
if err := founder.Update(o); err != nil {
|
||||
return err
|
||||
}
|
||||
if receive.RelationshipId > 0 {
|
||||
|
|
|
@ -2,10 +2,10 @@ package models
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
@ -59,9 +59,9 @@ func (t *Team) Delete(id int) (err error) {
|
|||
if id <= 0 {
|
||||
return ErrInvalidParameter
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
ormer := orm.NewOrm()
|
||||
|
||||
err = o.Begin()
|
||||
o, err := ormer.Begin()
|
||||
|
||||
if err != nil {
|
||||
logs.Error("开启事物时出错 ->", err)
|
||||
|
|
|
@ -3,10 +3,9 @@ package models
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/i18n"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ package models
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package models
|
||||
|
||||
import "github.com/astaxie/beego/orm"
|
||||
import "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
type CommentResult struct {
|
||||
Comment
|
||||
|
|
|
@ -3,7 +3,7 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"net/url"
|
||||
"regexp"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/context"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
)
|
||||
|
@ -30,14 +30,14 @@ func init() {
|
|||
}
|
||||
}
|
||||
}
|
||||
beego.InsertFilter("/manager", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/manager/*", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/setting", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/setting/*", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/book", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/book/*", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/api/*", beego.BeforeRouter, FilterUser)
|
||||
beego.InsertFilter("/manage/*", beego.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/manager", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/manager/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/setting", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/setting/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/book", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/book/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/api/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/manage/*", web.BeforeRouter, FilterUser)
|
||||
|
||||
var FinishRouter = func(ctx *context.Context) {
|
||||
ctx.ResponseWriter.Header().Add("MinDoc-Version", conf.VERSION)
|
||||
|
@ -46,7 +46,8 @@ func init() {
|
|||
}
|
||||
|
||||
var StartRouter = func(ctx *context.Context) {
|
||||
sessionId := ctx.Input.Cookie(beego.AppConfig.String("sessionname"))
|
||||
sessname, _ := web.AppConfig.String("sessionname")
|
||||
sessionId := ctx.Input.Cookie(sessname)
|
||||
if sessionId != "" {
|
||||
//sessionId必须是数字字母组成,且最小32个字符,最大1024字符
|
||||
if ok, err := regexp.MatchString(`^[a-zA-Z0-9]{32,512}$`, sessionId); !ok || err != nil {
|
||||
|
@ -54,6 +55,6 @@ func init() {
|
|||
}
|
||||
}
|
||||
}
|
||||
beego.InsertFilter("/*", beego.BeforeStatic, StartRouter, false)
|
||||
beego.InsertFilter("/*", beego.BeforeRouter, FinishRouter, false)
|
||||
web.InsertFilter("/*", web.BeforeStatic, StartRouter, web.WithReturnOnOutput(false))
|
||||
web.InsertFilter("/*", web.BeforeRouter, FinishRouter, web.WithReturnOnOutput(false))
|
||||
}
|
||||
|
|
|
@ -1,148 +1,148 @@
|
|||
package routers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/mindoc-org/mindoc/controllers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
beego.Router("/", &controllers.HomeController{}, "*:Index")
|
||||
web.Router("/", &controllers.HomeController{}, "*:Index")
|
||||
|
||||
beego.Router("/login", &controllers.AccountController{}, "*:Login")
|
||||
beego.Router("/dingtalk_login", &controllers.AccountController{}, "*:DingTalkLogin")
|
||||
beego.Router("/qrlogin/:app", &controllers.AccountController{}, "*:QRLogin")
|
||||
beego.Router("/logout", &controllers.AccountController{}, "*:Logout")
|
||||
beego.Router("/register", &controllers.AccountController{}, "*:Register")
|
||||
beego.Router("/find_password", &controllers.AccountController{}, "*:FindPassword")
|
||||
beego.Router("/valid_email", &controllers.AccountController{}, "post:ValidEmail")
|
||||
beego.Router("/captcha", &controllers.AccountController{}, "*:Captcha")
|
||||
web.Router("/login", &controllers.AccountController{}, "*:Login")
|
||||
web.Router("/dingtalk_login", &controllers.AccountController{}, "*:DingTalkLogin")
|
||||
web.Router("/qrlogin/:app", &controllers.AccountController{}, "*:QRLogin")
|
||||
web.Router("/logout", &controllers.AccountController{}, "*:Logout")
|
||||
web.Router("/register", &controllers.AccountController{}, "*:Register")
|
||||
web.Router("/find_password", &controllers.AccountController{}, "*:FindPassword")
|
||||
web.Router("/valid_email", &controllers.AccountController{}, "post:ValidEmail")
|
||||
web.Router("/captcha", &controllers.AccountController{}, "*:Captcha")
|
||||
|
||||
beego.Router("/manager", &controllers.ManagerController{}, "*:Index")
|
||||
beego.Router("/manager/users", &controllers.ManagerController{}, "*:Users")
|
||||
beego.Router("/manager/users/edit/:id", &controllers.ManagerController{}, "*:EditMember")
|
||||
beego.Router("/manager/member/create", &controllers.ManagerController{}, "post:CreateMember")
|
||||
beego.Router("/manager/member/delete", &controllers.ManagerController{}, "post:DeleteMember")
|
||||
beego.Router("/manager/member/update-member-status", &controllers.ManagerController{}, "post:UpdateMemberStatus")
|
||||
beego.Router("/manager/member/change-member-role", &controllers.ManagerController{}, "post:ChangeMemberRole")
|
||||
beego.Router("/manager/books", &controllers.ManagerController{}, "*:Books")
|
||||
beego.Router("/manager/books/edit/:key", &controllers.ManagerController{}, "*:EditBook")
|
||||
beego.Router("/manager/books/delete", &controllers.ManagerController{}, "*:DeleteBook")
|
||||
web.Router("/manager", &controllers.ManagerController{}, "*:Index")
|
||||
web.Router("/manager/users", &controllers.ManagerController{}, "*:Users")
|
||||
web.Router("/manager/users/edit/:id", &controllers.ManagerController{}, "*:EditMember")
|
||||
web.Router("/manager/member/create", &controllers.ManagerController{}, "post:CreateMember")
|
||||
web.Router("/manager/member/delete", &controllers.ManagerController{}, "post:DeleteMember")
|
||||
web.Router("/manager/member/update-member-status", &controllers.ManagerController{}, "post:UpdateMemberStatus")
|
||||
web.Router("/manager/member/change-member-role", &controllers.ManagerController{}, "post:ChangeMemberRole")
|
||||
web.Router("/manager/books", &controllers.ManagerController{}, "*:Books")
|
||||
web.Router("/manager/books/edit/:key", &controllers.ManagerController{}, "*:EditBook")
|
||||
web.Router("/manager/books/delete", &controllers.ManagerController{}, "*:DeleteBook")
|
||||
|
||||
beego.Router("/manager/comments", &controllers.ManagerController{}, "*:Comments")
|
||||
beego.Router("/manager/setting", &controllers.ManagerController{}, "*:Setting")
|
||||
beego.Router("/manager/books/token", &controllers.ManagerController{}, "post:CreateToken")
|
||||
beego.Router("/manager/books/transfer", &controllers.ManagerController{}, "post:Transfer")
|
||||
beego.Router("/manager/books/open", &controllers.ManagerController{}, "post:PrivatelyOwned")
|
||||
web.Router("/manager/comments", &controllers.ManagerController{}, "*:Comments")
|
||||
web.Router("/manager/setting", &controllers.ManagerController{}, "*:Setting")
|
||||
web.Router("/manager/books/token", &controllers.ManagerController{}, "post:CreateToken")
|
||||
web.Router("/manager/books/transfer", &controllers.ManagerController{}, "post:Transfer")
|
||||
web.Router("/manager/books/open", &controllers.ManagerController{}, "post:PrivatelyOwned")
|
||||
|
||||
beego.Router("/manager/attach/list", &controllers.ManagerController{}, "*:AttachList")
|
||||
beego.Router("/manager/attach/detailed/:id", &controllers.ManagerController{}, "*:AttachDetailed")
|
||||
beego.Router("/manager/attach/delete", &controllers.ManagerController{}, "post:AttachDelete")
|
||||
beego.Router("/manager/label/list", &controllers.ManagerController{}, "get:LabelList")
|
||||
beego.Router("/manager/label/delete/:id", &controllers.ManagerController{}, "post:LabelDelete")
|
||||
web.Router("/manager/attach/list", &controllers.ManagerController{}, "*:AttachList")
|
||||
web.Router("/manager/attach/detailed/:id", &controllers.ManagerController{}, "*:AttachDetailed")
|
||||
web.Router("/manager/attach/delete", &controllers.ManagerController{}, "post:AttachDelete")
|
||||
web.Router("/manager/label/list", &controllers.ManagerController{}, "get:LabelList")
|
||||
web.Router("/manager/label/delete/:id", &controllers.ManagerController{}, "post:LabelDelete")
|
||||
|
||||
//beego.Router("/manager/config", &controllers.ManagerController{}, "*:Config")
|
||||
//web.Router("/manager/config", &controllers.ManagerController{}, "*:Config")
|
||||
|
||||
beego.Router("/manager/team", &controllers.ManagerController{}, "*:Team")
|
||||
beego.Router("/manager/team/create", &controllers.ManagerController{}, "POST:TeamCreate")
|
||||
beego.Router("/manager/team/edit", &controllers.ManagerController{}, "POST:TeamEdit")
|
||||
beego.Router("/manager/team/delete", &controllers.ManagerController{}, "POST:TeamDelete")
|
||||
web.Router("/manager/team", &controllers.ManagerController{}, "*:Team")
|
||||
web.Router("/manager/team/create", &controllers.ManagerController{}, "POST:TeamCreate")
|
||||
web.Router("/manager/team/edit", &controllers.ManagerController{}, "POST:TeamEdit")
|
||||
web.Router("/manager/team/delete", &controllers.ManagerController{}, "POST:TeamDelete")
|
||||
|
||||
beego.Router("/manager/team/member/list/:id", &controllers.ManagerController{}, "*:TeamMemberList")
|
||||
beego.Router("/manager/team/member/add", &controllers.ManagerController{}, "POST:TeamMemberAdd")
|
||||
beego.Router("/manager/team/member/delete", &controllers.ManagerController{}, "POST:TeamMemberDelete")
|
||||
beego.Router("/manager/team/member/change_role", &controllers.ManagerController{}, "POST:TeamChangeMemberRole")
|
||||
beego.Router("/manager/team/member/search", &controllers.ManagerController{}, "*:TeamSearchMember")
|
||||
web.Router("/manager/team/member/list/:id", &controllers.ManagerController{}, "*:TeamMemberList")
|
||||
web.Router("/manager/team/member/add", &controllers.ManagerController{}, "POST:TeamMemberAdd")
|
||||
web.Router("/manager/team/member/delete", &controllers.ManagerController{}, "POST:TeamMemberDelete")
|
||||
web.Router("/manager/team/member/change_role", &controllers.ManagerController{}, "POST:TeamChangeMemberRole")
|
||||
web.Router("/manager/team/member/search", &controllers.ManagerController{}, "*:TeamSearchMember")
|
||||
|
||||
beego.Router("/manager/team/book/list/:id", &controllers.ManagerController{}, "*:TeamBookList")
|
||||
beego.Router("/manager/team/book/add", &controllers.ManagerController{}, "POST:TeamBookAdd")
|
||||
beego.Router("/manager/team/book/delete", &controllers.ManagerController{}, "POST:TeamBookDelete")
|
||||
beego.Router("/manager/team/book/search", &controllers.ManagerController{}, "*:TeamSearchBook")
|
||||
web.Router("/manager/team/book/list/:id", &controllers.ManagerController{}, "*:TeamBookList")
|
||||
web.Router("/manager/team/book/add", &controllers.ManagerController{}, "POST:TeamBookAdd")
|
||||
web.Router("/manager/team/book/delete", &controllers.ManagerController{}, "POST:TeamBookDelete")
|
||||
web.Router("/manager/team/book/search", &controllers.ManagerController{}, "*:TeamSearchBook")
|
||||
|
||||
beego.Router("/manager/itemsets", &controllers.ManagerController{}, "*:Itemsets")
|
||||
beego.Router("/manager/itemsets/edit", &controllers.ManagerController{}, "post:ItemsetsEdit")
|
||||
beego.Router("/manager/itemsets/delete", &controllers.ManagerController{}, "post:ItemsetsDelete")
|
||||
web.Router("/manager/itemsets", &controllers.ManagerController{}, "*:Itemsets")
|
||||
web.Router("/manager/itemsets/edit", &controllers.ManagerController{}, "post:ItemsetsEdit")
|
||||
web.Router("/manager/itemsets/delete", &controllers.ManagerController{}, "post:ItemsetsDelete")
|
||||
|
||||
beego.Router("/setting", &controllers.SettingController{}, "*:Index")
|
||||
beego.Router("/setting/password", &controllers.SettingController{}, "*:Password")
|
||||
beego.Router("/setting/upload", &controllers.SettingController{}, "*:Upload")
|
||||
web.Router("/setting", &controllers.SettingController{}, "*:Index")
|
||||
web.Router("/setting/password", &controllers.SettingController{}, "*:Password")
|
||||
web.Router("/setting/upload", &controllers.SettingController{}, "*:Upload")
|
||||
|
||||
beego.Router("/book", &controllers.BookController{}, "*:Index")
|
||||
beego.Router("/book/:key/dashboard", &controllers.BookController{}, "*:Dashboard")
|
||||
beego.Router("/book/:key/setting", &controllers.BookController{}, "*:Setting")
|
||||
beego.Router("/book/:key/users", &controllers.BookController{}, "*:Users")
|
||||
beego.Router("/book/:key/release", &controllers.BookController{}, "post:Release")
|
||||
beego.Router("/book/:key/sort", &controllers.BookController{}, "post:SaveSort")
|
||||
beego.Router("/book/:key/teams", &controllers.BookController{}, "*:Team")
|
||||
web.Router("/book", &controllers.BookController{}, "*:Index")
|
||||
web.Router("/book/:key/dashboard", &controllers.BookController{}, "*:Dashboard")
|
||||
web.Router("/book/:key/setting", &controllers.BookController{}, "*:Setting")
|
||||
web.Router("/book/:key/users", &controllers.BookController{}, "*:Users")
|
||||
web.Router("/book/:key/release", &controllers.BookController{}, "post:Release")
|
||||
web.Router("/book/:key/sort", &controllers.BookController{}, "post:SaveSort")
|
||||
web.Router("/book/:key/teams", &controllers.BookController{}, "*:Team")
|
||||
|
||||
beego.Router("/book/create", &controllers.BookController{}, "*:Create")
|
||||
beego.Router("/book/itemsets/search", &controllers.BookController{}, "*:ItemsetsSearch")
|
||||
web.Router("/book/create", &controllers.BookController{}, "*:Create")
|
||||
web.Router("/book/itemsets/search", &controllers.BookController{}, "*:ItemsetsSearch")
|
||||
|
||||
beego.Router("/book/users/create", &controllers.BookMemberController{}, "post:AddMember")
|
||||
beego.Router("/book/users/change", &controllers.BookMemberController{}, "post:ChangeRole")
|
||||
beego.Router("/book/users/delete", &controllers.BookMemberController{}, "post:RemoveMember")
|
||||
beego.Router("/book/users/import", &controllers.BookController{}, "post:Import")
|
||||
beego.Router("/book/users/copy", &controllers.BookController{}, "post:Copy")
|
||||
web.Router("/book/users/create", &controllers.BookMemberController{}, "post:AddMember")
|
||||
web.Router("/book/users/change", &controllers.BookMemberController{}, "post:ChangeRole")
|
||||
web.Router("/book/users/delete", &controllers.BookMemberController{}, "post:RemoveMember")
|
||||
web.Router("/book/users/import", &controllers.BookController{}, "post:Import")
|
||||
web.Router("/book/users/copy", &controllers.BookController{}, "post:Copy")
|
||||
|
||||
beego.Router("/book/setting/save", &controllers.BookController{}, "post:SaveBook")
|
||||
beego.Router("/book/setting/open", &controllers.BookController{}, "post:PrivatelyOwned")
|
||||
beego.Router("/book/setting/transfer", &controllers.BookController{}, "post:Transfer")
|
||||
beego.Router("/book/setting/upload", &controllers.BookController{}, "post:UploadCover")
|
||||
beego.Router("/book/setting/delete", &controllers.BookController{}, "post:Delete")
|
||||
web.Router("/book/setting/save", &controllers.BookController{}, "post:SaveBook")
|
||||
web.Router("/book/setting/open", &controllers.BookController{}, "post:PrivatelyOwned")
|
||||
web.Router("/book/setting/transfer", &controllers.BookController{}, "post:Transfer")
|
||||
web.Router("/book/setting/upload", &controllers.BookController{}, "post:UploadCover")
|
||||
web.Router("/book/setting/delete", &controllers.BookController{}, "post:Delete")
|
||||
|
||||
beego.Router("/book/team/add", &controllers.BookController{}, "POST:TeamAdd")
|
||||
beego.Router("/book/team/delete", &controllers.BookController{}, "POST:TeamDelete")
|
||||
beego.Router("/book/team/search", &controllers.BookController{}, "*:TeamSearch")
|
||||
web.Router("/book/team/add", &controllers.BookController{}, "POST:TeamAdd")
|
||||
web.Router("/book/team/delete", &controllers.BookController{}, "POST:TeamDelete")
|
||||
web.Router("/book/team/search", &controllers.BookController{}, "*:TeamSearch")
|
||||
|
||||
//管理文章的路由
|
||||
beego.Router("/manage/blogs", &controllers.BlogController{}, "*:ManageList")
|
||||
beego.Router("/manage/blogs/setting/?:id", &controllers.BlogController{}, "*:ManageSetting")
|
||||
beego.Router("/manage/blogs/edit/?:id", &controllers.BlogController{}, "*:ManageEdit")
|
||||
beego.Router("/manage/blogs/delete", &controllers.BlogController{}, "post:ManageDelete")
|
||||
beego.Router("/manage/blogs/upload", &controllers.BlogController{}, "post:Upload")
|
||||
beego.Router("/manage/blogs/attach/:id", &controllers.BlogController{}, "post:RemoveAttachment")
|
||||
web.Router("/manage/blogs", &controllers.BlogController{}, "*:ManageList")
|
||||
web.Router("/manage/blogs/setting/?:id", &controllers.BlogController{}, "*:ManageSetting")
|
||||
web.Router("/manage/blogs/edit/?:id", &controllers.BlogController{}, "*:ManageEdit")
|
||||
web.Router("/manage/blogs/delete", &controllers.BlogController{}, "post:ManageDelete")
|
||||
web.Router("/manage/blogs/upload", &controllers.BlogController{}, "post:Upload")
|
||||
web.Router("/manage/blogs/attach/:id", &controllers.BlogController{}, "post:RemoveAttachment")
|
||||
|
||||
//读文章的路由
|
||||
beego.Router("/blogs", &controllers.BlogController{}, "*:List")
|
||||
beego.Router("/blog-attach/:id:int/:attach_id:int", &controllers.BlogController{}, "get:Download")
|
||||
beego.Router("/blog-:id([0-9]+).html", &controllers.BlogController{}, "*:Index")
|
||||
web.Router("/blogs", &controllers.BlogController{}, "*:List")
|
||||
web.Router("/blog-attach/:id:int/:attach_id:int", &controllers.BlogController{}, "get:Download")
|
||||
web.Router("/blog-:id([0-9]+).html", &controllers.BlogController{}, "*:Index")
|
||||
|
||||
//模板相关接口
|
||||
beego.Router("/api/template/get", &controllers.TemplateController{}, "get:Get")
|
||||
beego.Router("/api/template/list", &controllers.TemplateController{}, "post:List")
|
||||
beego.Router("/api/template/add", &controllers.TemplateController{}, "post:Add")
|
||||
beego.Router("/api/template/remove", &controllers.TemplateController{}, "post:Delete")
|
||||
web.Router("/api/template/get", &controllers.TemplateController{}, "get:Get")
|
||||
web.Router("/api/template/list", &controllers.TemplateController{}, "post:List")
|
||||
web.Router("/api/template/add", &controllers.TemplateController{}, "post:Add")
|
||||
web.Router("/api/template/remove", &controllers.TemplateController{}, "post:Delete")
|
||||
|
||||
beego.Router("/api/attach/remove/", &controllers.DocumentController{}, "post:RemoveAttachment")
|
||||
beego.Router("/api/:key/edit/?:id", &controllers.DocumentController{}, "*:Edit")
|
||||
beego.Router("/api/upload", &controllers.DocumentController{}, "post:Upload")
|
||||
beego.Router("/api/:key/create", &controllers.DocumentController{}, "post:Create")
|
||||
beego.Router("/api/:key/delete", &controllers.DocumentController{}, "post:Delete")
|
||||
beego.Router("/api/:key/content/?:id", &controllers.DocumentController{}, "*:Content")
|
||||
beego.Router("/api/:key/compare/:id", &controllers.DocumentController{}, "*:Compare")
|
||||
beego.Router("/api/search/user/:key", &controllers.SearchController{}, "*:User")
|
||||
web.Router("/api/attach/remove/", &controllers.DocumentController{}, "post:RemoveAttachment")
|
||||
web.Router("/api/:key/edit/?:id", &controllers.DocumentController{}, "*:Edit")
|
||||
web.Router("/api/upload", &controllers.DocumentController{}, "post:Upload")
|
||||
web.Router("/api/:key/create", &controllers.DocumentController{}, "post:Create")
|
||||
web.Router("/api/:key/delete", &controllers.DocumentController{}, "post:Delete")
|
||||
web.Router("/api/:key/content/?:id", &controllers.DocumentController{}, "*:Content")
|
||||
web.Router("/api/:key/compare/:id", &controllers.DocumentController{}, "*:Compare")
|
||||
web.Router("/api/search/user/:key", &controllers.SearchController{}, "*:User")
|
||||
|
||||
beego.Router("/history/get", &controllers.DocumentController{}, "get:History")
|
||||
beego.Router("/history/delete", &controllers.DocumentController{}, "*:DeleteHistory")
|
||||
beego.Router("/history/restore", &controllers.DocumentController{}, "*:RestoreHistory")
|
||||
web.Router("/history/get", &controllers.DocumentController{}, "get:History")
|
||||
web.Router("/history/delete", &controllers.DocumentController{}, "*:DeleteHistory")
|
||||
web.Router("/history/restore", &controllers.DocumentController{}, "*:RestoreHistory")
|
||||
|
||||
beego.Router("/docs/:key", &controllers.DocumentController{}, "*:Index")
|
||||
beego.Router("/docs/:key/:id", &controllers.DocumentController{}, "*:Read")
|
||||
beego.Router("/docs/:key/search", &controllers.DocumentController{}, "post:Search")
|
||||
beego.Router("/export/:key", &controllers.DocumentController{}, "*:Export")
|
||||
beego.Router("/qrcode/:key.png", &controllers.DocumentController{}, "get:QrCode")
|
||||
web.Router("/docs/:key", &controllers.DocumentController{}, "*:Index")
|
||||
web.Router("/docs/:key/:id", &controllers.DocumentController{}, "*:Read")
|
||||
web.Router("/docs/:key/search", &controllers.DocumentController{}, "post:Search")
|
||||
web.Router("/export/:key", &controllers.DocumentController{}, "*:Export")
|
||||
web.Router("/qrcode/:key.png", &controllers.DocumentController{}, "get:QrCode")
|
||||
|
||||
beego.Router("/attach_files/:key/:attach_id", &controllers.DocumentController{}, "get:DownloadAttachment")
|
||||
web.Router("/attach_files/:key/:attach_id", &controllers.DocumentController{}, "get:DownloadAttachment")
|
||||
|
||||
beego.Router("/comment/create", &controllers.CommentController{}, "post:Create")
|
||||
beego.Router("/comment/lists", &controllers.CommentController{}, "get:Lists")
|
||||
beego.Router("/comment/index", &controllers.CommentController{}, "*:Index")
|
||||
web.Router("/comment/create", &controllers.CommentController{}, "post:Create")
|
||||
web.Router("/comment/lists", &controllers.CommentController{}, "get:Lists")
|
||||
web.Router("/comment/index", &controllers.CommentController{}, "*:Index")
|
||||
|
||||
beego.Router("/search", &controllers.SearchController{}, "get:Index")
|
||||
web.Router("/search", &controllers.SearchController{}, "get:Index")
|
||||
|
||||
beego.Router("/tag/:key", &controllers.LabelController{}, "get:Index")
|
||||
beego.Router("/tags", &controllers.LabelController{}, "get:List")
|
||||
web.Router("/tag/:key", &controllers.LabelController{}, "get:Index")
|
||||
web.Router("/tags", &controllers.LabelController{}, "get:List")
|
||||
|
||||
beego.Router("/items", &controllers.ItemsetsController{}, "get:Index")
|
||||
beego.Router("/items/:key", &controllers.ItemsetsController{}, "get:List")
|
||||
web.Router("/items", &controllers.ItemsetsController{}, "get:Index")
|
||||
web.Router("/items/:key", &controllers.ItemsetsController{}, "get:List")
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ function loadDocument($url, $id, $callback) {
|
|||
$("title").text(data.title);
|
||||
$("#article-title").text(data.doc_title);
|
||||
$("#article-info").text(data.doc_info);
|
||||
$("#view_count").text("阅读次数:" + data.view_count);
|
||||
|
||||
events.trigger('article.open', {$url: $url, $id: $id});
|
||||
|
||||
|
@ -80,6 +81,7 @@ function loadDocument($url, $id, $callback) {
|
|||
var doc_title = res.data.doc_title;
|
||||
var title = res.data.title;
|
||||
var doc_info = res.data.doc_info;
|
||||
var view_count = res.data.view_count;
|
||||
|
||||
$body = body;
|
||||
if (typeof $callback === "function" ) {
|
||||
|
@ -90,6 +92,7 @@ function loadDocument($url, $id, $callback) {
|
|||
$("title").text(title);
|
||||
$("#article-title").text(doc_title);
|
||||
$("#article-info").text(doc_info);
|
||||
$("#view_count").text("阅读次数:" + view_count);
|
||||
|
||||
events.data($id, res.data);
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ package utils
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"gopkg.in/ldap.v2"
|
||||
)
|
||||
|
||||
|
|
|
@ -146,7 +146,8 @@
|
|||
</div>
|
||||
<div class="m-copyright">
|
||||
<p>
|
||||
{{i18n .Lang "doc.doc_publish_by"}} <a href="https://www.iminho.me" target="_blank">MinDoc</a> {{i18n .Lang "doc.doc_publish"}}
|
||||
<div id="view_count">{{i18n .Lang "doc.view_count"}}:{{.ViewCount}}</div>
|
||||
{{i18n $.Lang "doc.doc_publish_by"}} <a href="https://www.iminho.me" target="_blank">MinDoc</a> {{i18n $.Lang "doc.doc_publish"}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</div>
|
||||
{{if .site_beian}}
|
||||
<div class="row text-center">
|
||||
<a href="http://www.beian.miit.gov.cn" target="_blank">{{.site_beian}}</a>
|
||||
<a href="https://beian.miit.gov.cn/" target="_blank">{{.site_beian}}</a>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue