diff --git a/conf/wide.go b/conf/wide.go index 4bfe9b2..a6610f2 100644 --- a/conf/wide.go +++ b/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" @@ -57,14 +57,14 @@ func main() { // Configuration. type conf struct { - Server string // server - LogLevel string // logging level: trace/debug/info/warn/error - Data string // data directory - RuntimeMode string // runtime mode (dev/prod) - HTTPSessionMaxAge int // HTTP session max age (in seciond) - StaticResourceVersion string // version of static resources - Locale string // default locale - Autocomplete bool // default autocomplete + Server string // server + LogLevel string // logging level: trace/debug/info/warn/error + Data string // data directory + RuntimeMode string // runtime mode (dev/prod) + HTTPSessionMaxAge int // HTTP session max age (in seciond) + StaticResourceVersion string // version of static resources + Locale string // default locale + 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) diff --git a/conf/wide.json b/conf/wide.json index dd5eaa8..d19978f 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -6,5 +6,5 @@ "HTTPSessionMaxAge": 86400, "StaticResourceVersion": "${time}", "Locale": "zh_CN", - "Autocomplete": true + "SiteStatCode": "" } \ No newline at end of file diff --git a/main.go b/main.go index 4bdf695..3acf722 100644 --- a/main.go +++ b/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() diff --git a/views/index.html b/views/index.html index 10c4a0c..8fc68db 100644 --- a/views/index.html +++ b/views/index.html @@ -31,6 +31,9 @@ + {{if ne "" .conf.SiteStatCode}} + {{.conf.SiteStatCode}} + {{end}} diff --git a/views/keyboard_shortcuts.html b/views/keyboard_shortcuts.html index 3f398ab..de80b53 100644 --- a/views/keyboard_shortcuts.html +++ b/views/keyboard_shortcuts.html @@ -9,6 +9,9 @@ + {{if ne "" .conf.SiteStatCode}} + {{.conf.SiteStatCode}} + {{end}}

{{.i18n.editor}}

diff --git a/views/login.html b/views/login.html index ee6acf7..b87e3fe 100644 --- a/views/login.html +++ b/views/login.html @@ -11,6 +11,9 @@ + {{if ne "" .conf.SiteStatCode}} + {{.conf.SiteStatCode}} + {{end}}
diff --git a/views/playground/index.html b/views/playground/index.html index 608e7e8..401f1e1 100644 --- a/views/playground/index.html +++ b/views/playground/index.html @@ -24,6 +24,9 @@ + {{if ne "" .conf.SiteStatCode}} + {{.conf.SiteStatCode}} + {{end}}