实现文档编辑

This commit is contained in:
Minho
2017-04-27 18:19:37 +08:00
parent 8c85227c30
commit ca1b1a4b83
18 changed files with 1095 additions and 173 deletions

View File

@@ -22,4 +22,7 @@ db_password=123456
cover=/static/images/book.jpg
#默认编辑器
editor=markdown
editor=markdown
#上传文件的后缀
upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif

View File

@@ -27,4 +27,7 @@ cover=/static/images/book.jpg
avatar=/static/images/headimgurl.jpg
#默认阅读令牌长度
token_size=12
token_size=12
#上传文件的后缀
upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif

View File

@@ -1,7 +1,10 @@
// package conf 为配置相关.
package conf
import "github.com/astaxie/beego"
import (
"github.com/astaxie/beego"
"strings"
)
// 登录用户的Session名
const LoginSessionName = "LoginSessionName"
@@ -53,4 +56,36 @@ func GetTokenSize() int {
func GetDefaultCover() string {
return beego.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")
temp := strings.Split(ext,"|")
exts := make([]string,len(temp))
i := 0
for _,item := range temp {
if item != "" {
exts[i] = item
i++
}
}
return exts
}
func IsAllowUploadFileExt(ext string) bool {
if strings.HasPrefix(ext,".") {
ext = string(ext[1:])
}
exts := GetUploadFileExt()
for _,item := range exts {
if strings.EqualFold(item,ext) {
return true
}
}
return false
}