rm runmode

This commit is contained in:
deepzz0
2016-10-02 19:53:21 +08:00
parent 13aefb3e21
commit c1f6611b5d
8 changed files with 27 additions and 33 deletions

2
api.go
View File

@@ -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]
}

View File

@@ -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)
}

View File

@@ -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
# 以下数据初始化用,可在后台修改

View File

@@ -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

View File

@@ -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,
}
}

View File

@@ -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)

View File

@@ -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
View File

@@ -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)