This commit is contained in:
parent
67c36e0089
commit
1857df995d
15
conf/wide.go
15
conf/wide.go
|
@ -17,6 +17,7 @@ package conf
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -24,7 +25,6 @@ import (
|
|||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/b3log/wide/event"
|
||||
|
@ -64,7 +64,7 @@ type conf struct {
|
|||
HTTPSessionMaxAge int // HTTP session max age (in seciond)
|
||||
StaticResourceVersion string // version of static resources
|
||||
Locale string // default locale
|
||||
Autocomplete bool // default autocomplete
|
||||
SiteStatCode template.HTML // site statistic code
|
||||
}
|
||||
|
||||
// Logger.
|
||||
|
@ -83,8 +83,8 @@ var Docker bool
|
|||
const DockerImageGo = "golang"
|
||||
|
||||
// Load loads the Wide configurations from wide.json and users' configurations from users/{userId}.json.
|
||||
func Load(confPath, confData, confServer, confLogLevel string) {
|
||||
initWide(confPath, confData, confServer, confLogLevel)
|
||||
func Load(confPath, confData, confServer, confLogLevel string, confSiteStatCode template.HTML) {
|
||||
initWide(confPath, confData, confServer, confLogLevel, confSiteStatCode)
|
||||
initUsers()
|
||||
|
||||
cmd := exec.Command("docker", "version")
|
||||
|
@ -158,7 +158,7 @@ func initUsers() {
|
|||
initCustomizedConfs()
|
||||
}
|
||||
|
||||
func initWide(confPath, confData, confServer, confLogLevel string) {
|
||||
func initWide(confPath, confData, confServer, confLogLevel string, confSiteStatCode template.HTML) {
|
||||
bytes, err := ioutil.ReadFile(confPath)
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
|
@ -220,6 +220,11 @@ func initWide(confPath, confData, confServer, confLogLevel string) {
|
|||
Wide.Server = confServer
|
||||
}
|
||||
|
||||
// SiteStatCode
|
||||
if "" != confSiteStatCode {
|
||||
Wide.SiteStatCode = confSiteStatCode
|
||||
}
|
||||
|
||||
time := strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||
logger.Debugf("${time} [%s]", time)
|
||||
Wide.StaticResourceVersion = strings.Replace(Wide.StaticResourceVersion, "${time}", time, 1)
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"HTTPSessionMaxAge": 86400,
|
||||
"StaticResourceVersion": "${time}",
|
||||
"Locale": "zh_CN",
|
||||
"Autocomplete": true
|
||||
"SiteStatCode": ""
|
||||
}
|
3
main.go
3
main.go
|
@ -51,6 +51,7 @@ func init() {
|
|||
confData := flag.String("data", "", "path of data dir")
|
||||
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
|
||||
confLogLevel := flag.String("log_level", "", "this will overwrite Wide.LogLevel if specified")
|
||||
confSiteStatCode := flag.String("site_stat_code", "", "this will overrite Wide.SiteStatCode if specified")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -66,7 +67,7 @@ func init() {
|
|||
|
||||
i18n.Load()
|
||||
event.Load()
|
||||
conf.Load(*confPath, *confData, *confServer, *confLogLevel)
|
||||
conf.Load(*confPath, *confData, *confServer, *confLogLevel, template.HTML(*confSiteStatCode))
|
||||
|
||||
conf.FixedTimeCheckEnv()
|
||||
session.FixedTimeSave()
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
<link rel="stylesheet" href="/static/css/themes/{{.user.Theme}}.css?{{.conf.StaticResourceVersion}}" id="themesLink">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
{{if ne "" .conf.SiteStatCode}}
|
||||
{{.conf.SiteStatCode}}
|
||||
{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<!-- menu bar -->
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<meta name="author" content="B3log">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
{{if ne "" .conf.SiteStatCode}}
|
||||
{{.conf.SiteStatCode}}
|
||||
{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<h2>{{.i18n.editor}}</h2>
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
<link rel="stylesheet" href="/static/css/base.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="stylesheet" href="/static/css/sign.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico"/>
|
||||
{{if ne "" .conf.SiteStatCode}}
|
||||
{{.conf.SiteStatCode}}
|
||||
{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
<link rel="stylesheet" href="/static/css/playground.css?{{.conf.StaticResourceVersion}}">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
{{if ne "" .conf.SiteStatCode}}
|
||||
{{.conf.SiteStatCode}}
|
||||
{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<div class="header menu fn-clear">
|
||||
|
|
Loading…
Reference in New Issue