mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-09 08:02:26 +08:00
rm runmode
This commit is contained in:
2
api.go
2
api.go
@@ -375,7 +375,7 @@ func apiTrashRecover(c *gin.Context) {
|
||||
}
|
||||
|
||||
func responseNotice(c *gin.Context, typ, content, hl string) {
|
||||
domain := runmode.Domain
|
||||
domain := setting.Conf.Mode.Domain
|
||||
if i := strings.Index(domain, ":"); i > -1 {
|
||||
domain = domain[0:i]
|
||||
}
|
||||
|
||||
2
back.go
2
back.go
@@ -119,7 +119,7 @@ func HandlePost(c *gin.Context) {
|
||||
h["Post"] = true
|
||||
h["Path"] = c.Request.URL.Path
|
||||
h["Title"] = "撰写文章 | " + Ei.BTitle
|
||||
h["Domain"] = runmode.Domain
|
||||
h["Domain"] = setting.Conf.Mode.Domain
|
||||
h["Series"] = Ei.Series
|
||||
c.HTML(http.StatusOK, "backLayout.html", h)
|
||||
}
|
||||
|
||||
28
conf/app.yml
28
conf/app.yml
@@ -1,7 +1,7 @@
|
||||
# 静态文件版本
|
||||
staticversion: 2
|
||||
# 运行模式 dev or prod
|
||||
runmode: prod
|
||||
# 静态文件版本
|
||||
staticversion: 2
|
||||
# 回收箱保留48小时
|
||||
trash: -48
|
||||
# 定时清理回收箱,%d小时
|
||||
@@ -29,21 +29,15 @@ disqus:
|
||||
url: https://disqus.com/api/3.0/threads/set.json
|
||||
interval: 5
|
||||
# 运行模式
|
||||
modes:
|
||||
dev:
|
||||
# don't modify
|
||||
enablehttp: true
|
||||
httpport: 9000
|
||||
domain: deepzz.com
|
||||
prod:
|
||||
# you can fix certfile, keyfile, domain
|
||||
enablehttp: true
|
||||
httpport: 9000
|
||||
enablehttps: false
|
||||
httpsport: 443
|
||||
certfile: conf/certs/domain.pem
|
||||
keyfile: conf/certs/domain.key
|
||||
domain: deepzz.com
|
||||
mode:
|
||||
# you can fix certfile, keyfile, domain
|
||||
enablehttp: true
|
||||
httpport: 9000
|
||||
enablehttps: false
|
||||
httpsport: 443
|
||||
certfile: conf/certs/domain.pem
|
||||
keyfile: conf/certs/domain.key
|
||||
domain: deepzz.com
|
||||
# twitter地址: //twitter.com/chenqijing2
|
||||
twitter: //twitter.com/chenqijing2
|
||||
# 以下数据初始化用,可在后台修改
|
||||
|
||||
@@ -33,7 +33,7 @@ func CommentsCount() {
|
||||
var threads []string
|
||||
for ; index < len(Ei.Articles) && count < 20; index++ {
|
||||
artc := Ei.Articles[index]
|
||||
threads = append(threads, fmt.Sprintf("thread=link:https://%s/post/%s.html", runmode.Domain, artc.Slug))
|
||||
threads = append(threads, fmt.Sprintf("thread=link:https://%s/post/%s.html", setting.Conf.Mode.Domain, artc.Slug))
|
||||
count++
|
||||
}
|
||||
count = 0
|
||||
|
||||
2
front.go
2
front.go
@@ -69,7 +69,7 @@ func GetBase() gin.H {
|
||||
"CopyYear": time.Now().Year(),
|
||||
"BTitle": Ei.BTitle,
|
||||
"BeiAn": Ei.BeiAn,
|
||||
"Domain": runmode.Domain,
|
||||
"Domain": setting.Conf.Mode.Domain,
|
||||
"Static": setting.Conf.Static,
|
||||
}
|
||||
}
|
||||
|
||||
13
router.go
13
router.go
@@ -14,7 +14,6 @@ import (
|
||||
)
|
||||
|
||||
var router *gin.Engine
|
||||
var runmode = setting.Conf.Modes[setting.Conf.RunMode]
|
||||
|
||||
func init() {
|
||||
if setting.Conf.RunMode == setting.PROD {
|
||||
@@ -90,10 +89,10 @@ func Run() {
|
||||
endRunning = make(chan bool, 1)
|
||||
err error
|
||||
)
|
||||
if runmode.EnableHttp {
|
||||
if setting.Conf.Mode.EnableHttp {
|
||||
go func() {
|
||||
logd.Info(fmt.Sprintf("http server Running on %d", runmode.HttpPort))
|
||||
err = router.Run(fmt.Sprintf(":%d", runmode.HttpPort))
|
||||
logd.Info(fmt.Sprintf("http server Running on %d", setting.Conf.Mode.HttpPort))
|
||||
err = router.Run(fmt.Sprintf(":%d", setting.Conf.Mode.HttpPort))
|
||||
if err != nil {
|
||||
logd.Info("ListenAndServe: ", err)
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
@@ -101,10 +100,10 @@ func Run() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
if runmode.EnableHttps {
|
||||
if setting.Conf.Mode.EnableHttps {
|
||||
go func() {
|
||||
logd.Info(fmt.Sprintf("https server Running on %d", runmode.HttpsPort))
|
||||
err = router.RunTLS(fmt.Sprintf(":%d", runmode.HttpsPort), runmode.CertFile, runmode.KeyFile)
|
||||
logd.Info(fmt.Sprintf("https server Running on %d", setting.Conf.Mode.HttpsPort))
|
||||
err = router.RunTLS(fmt.Sprintf(":%d", setting.Conf.Mode.HttpsPort), setting.Conf.Mode.CertFile, setting.Conf.Mode.KeyFile)
|
||||
if err != nil {
|
||||
logd.Info("ListenAndServe: ", err)
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
|
||||
@@ -40,9 +40,9 @@ type Config struct {
|
||||
URL string
|
||||
Interval int
|
||||
}
|
||||
Modes map[string]RunMode // 运行模式
|
||||
Twitter string // twitter地址
|
||||
Blogger struct { // 初始化数据
|
||||
Mode RunMode // 运行模式
|
||||
Twitter string // twitter地址
|
||||
Blogger struct { // 初始化数据
|
||||
BlogName string
|
||||
SubTitle string
|
||||
BeiAn string
|
||||
|
||||
5
xml.go
5
xml.go
@@ -7,6 +7,7 @@ import (
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/eiblog/eiblog/setting"
|
||||
"github.com/eiblog/utils/logd"
|
||||
"github.com/eiblog/utils/tmpl"
|
||||
)
|
||||
@@ -40,7 +41,7 @@ func doFeed() {
|
||||
params := map[string]interface{}{
|
||||
"Title": Ei.BTitle,
|
||||
"SubTitle": Ei.SubTitle,
|
||||
"Domain": runmode.Domain,
|
||||
"Domain": setting.Conf.Mode.Domain,
|
||||
"BuildDate": buildDate.Format(time.RFC1123Z),
|
||||
"Artcs": artcs,
|
||||
}
|
||||
@@ -65,7 +66,7 @@ func doSitemap() {
|
||||
logd.Error("not found sitemapTpl.")
|
||||
return
|
||||
}
|
||||
params := map[string]interface{}{"Artcs": Ei.Articles, "Domain": runmode.Domain}
|
||||
params := map[string]interface{}{"Artcs": Ei.Articles, "Domain": setting.Conf.Mode.Domain}
|
||||
f, err := os.OpenFile("static/sitemap.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
|
||||
if err != nil {
|
||||
logd.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user