-
Notifications
You must be signed in to change notification settings - Fork 745
/
Copy pathdefine.go
125 lines (103 loc) · 3.07 KB
/
define.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//定义一些常量和变量
package helper
import (
"net/url"
"sync"
"github.com/astaxie/beego"
"github.com/huichen/sego"
)
const (
//DocHub Version
VERSION = "v2.4"
//Cache Config
CACHE_CONF = `{"CachePath":"./cache/runtime","FileSuffix":".cache","DirectoryLevel":2,"EmbedExpiry":120}`
DEFAULT_STATIC_EXT = ".txt,.html,.ico,.jpeg,.png,.gif,.xml"
DEFAULT_COOKIE_SECRET = "dochub"
// 扩展名
EXT_CATE_WORD = "word"
EXT_NUM_WORD = 1
EXT_CATE_PPT = "ppt"
EXT_NUM_PPT = 2
EXT_CATE_EXCEL = "excel"
EXT_NUM_EXCEL = 3
EXT_CATE_PDF = "pdf"
EXT_NUM_PDF = 4
EXT_CATE_TEXT = "text"
EXT_NUM_TEXT = 5
EXT_CATE_OTHER = "other"
EXT_NUM_OTHER = 6
EXT_CATE_OTHER_MOBI = "mobi"
EXT_CATE_OTHER_EPUB = "epub"
EXT_CATE_OTHER_CHM = "chm"
EXT_CATE_OTHER_UMD = "umd"
RootPath = "./virtualroot" // 虚拟根目录
)
type ConfigCate string
const (
//word
ExtDOC = ".doc"
ExtDOCX = ".docx"
ExtRTF = ".rtf"
ExtWPS = ".wps"
ExtODT = ".odt"
// power point
ExtPPT = ".ppt"
ExtPPTX = ".pptx"
ExtPPS = ".pps"
ExtPPSX = ".ppsx"
ExtDPS = ".dps"
ExtODP = ".odp"
ExtPOT = ".pot"
// excel
ExtXLS = ".xls"
ExtXLSX = ".xlsx"
ExtET = ".et"
ExtODS = ".ods"
// PDF
ExtPDF = ".pdf"
// text
ExtTXT = ".txt"
// other
ExtEPUB = ".epub"
ExtUMD = ".umd"
ExtMOBI = ".mobi"
ExtCHM = ".chm"
)
var (
//develop mode
Debug = beego.AppConfig.String("runmode") == "dev"
//允许直接访问的文件扩展名
StaticExt = make(map[string]bool)
//分词器
Segmenter sego.Segmenter
//配置文件的全局map
ConfigMap sync.Map
//程序是否已经安装
IsInstalled = false
//允许上传的文档扩展名
//AllowedUploadExt = ",doc,docx,rtf,wps,odt,ppt,pptx,pps,ppsx,dps,odp,pot,xls,xlsx,et,ods,txt,pdf,chm,epub,umd,mobi,"
AllowedUploadDocsExt = map[string]bool{
".doc": true, ".docx": true, ".rtf": true, ".wps": true, ".odt": true, //word
".ppt": true, ".pptx": true, ".pps": true, ".ppsx": true, ".dps": true, ".odp": true, ".pot": true, // power point
".xls": true, ".xlsx": true, ".et": true, ".ods": true, // excel
".pdf": true, //pdf
".epub": true, ".mobi": true, ".txt": true, //other
".umd": true, ".chm": true, //不能转化的电子书
}
// 图片尺寸
CoverWidth = beego.AppConfig.DefaultInt("cover_width", 140)
CoverHeight = beego.AppConfig.DefaultInt("cover_height", 200)
BannerWidth = beego.AppConfig.DefaultInt("banner_width", 825)
BannerHeight = beego.AppConfig.DefaultInt("banner_height", 316)
AvatarWidth = beego.AppConfig.DefaultInt("avatar_width", 120)
AvatarHeight = beego.AppConfig.DefaultInt("avatar_height", 120)
)
var (
HeaderGzip = map[string]string{"Content-Encoding": "gzip"}
HeaderSVG = map[string]string{"Content-Type": "image/svg+xml"}
HeaderPNG = map[string]string{"Content-type": "image/png"}
HeaderJPEG = map[string]string{"Content-type": "image/jpeg"}
)
func HeaderDisposition(name string) map[string]string {
return map[string]string{"Content-Disposition": "attachment; filename=" + url.PathEscape(name)}
}