-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconst.go
64 lines (53 loc) · 1.41 KB
/
const.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
package solitudes
import (
"github.com/blevesearch/bleve/v2"
"github.com/jinzhu/gorm"
"github.com/panjf2000/ants"
"github.com/patrickmn/go-cache"
"go.uber.org/dig"
"golang.org/x/sync/singleflight"
"github.com/naiba/solitudes/internal/model"
)
const (
// CtxAuthorized 用户已认证
CtxAuthorized = "cazed"
// CtxTranslator 翻译
CtxTranslator = "ct"
// AuthCookie 用户认证使用的Cookie名
AuthCookie = "i_like_solitude"
// CacheKeyPrefixRelatedChapters 缓存键前缀:章节
CacheKeyPrefixRelatedChapters = "ckprc"
// CacheKeyPrefixRelatedArticle 缓存键前缀:文章
CacheKeyPrefixRelatedArticle = "ckpra"
// CacheKeyPrefixRelatedSiblingArticle 缓存键前缀:相邻文章
CacheKeyPrefixRelatedSiblingArticle = "ckprsa"
)
// SysVeriable 全局变量
type SysVeriable struct {
Config *model.Config
DB *gorm.DB
Cache *cache.Cache
Search bleve.Index
SafeCache *singleflight.Group
Pool *ants.Pool
}
const fullTextSearchIndexPath = "data/bleve"
// Injector 运行时依赖注入
var Injector *dig.Container
// System 全局变量
var System *SysVeriable
// BuildVersion 构建版本
var BuildVersion = "_BuildVersion_"
// Templates 文章模板
var Templates = map[byte]string{
1: "Article template",
2: "Page template",
}
// TemplateIndex 模板索引
var TemplateIndex = map[byte]string{
1: "article",
2: "page",
}
func init() {
BuildVersion = BuildVersion[:8]
}