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