|
@@ -30,14 +30,7 @@ func main() {
|
|
|
os.MkdirAll(dataPath, os.ModePerm)
|
|
|
modules.CopyDir(filepath.Join(pwd, "common"), dataPath)
|
|
|
}
|
|
|
-
|
|
|
- appConfig = modules.LoadConfig()
|
|
|
- websiteData.Config = appConfig.Website
|
|
|
- websiteData.Language = modules.LoadLanguage(appConfig.Website.Language)
|
|
|
- websiteData.Contents = modules.LoadContent().Data
|
|
|
-
|
|
|
- tmpl, _ := template.ParseFiles(filepath.Join(pwd, "themes", appConfig.Website.Theme, "index.html"))
|
|
|
- webTemplate = tmpl
|
|
|
+ loadData()
|
|
|
|
|
|
commonfs := http.FileServer(http.Dir(dataPath))
|
|
|
http.Handle("/common/", http.StripPrefix("/common/", commonfs))
|
|
@@ -58,6 +51,20 @@ func main() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func loadData() {
|
|
|
+ appConfig = modules.LoadConfig()
|
|
|
+ websiteData.Config = appConfig.Website
|
|
|
+ websiteData.Language = modules.LoadLanguage(appConfig.Website.Language)
|
|
|
+ websiteData.Contents = modules.LoadContent().Data
|
|
|
+
|
|
|
+ tmpl, _ := template.ParseFiles(filepath.Join(pwd, "themes", appConfig.Website.Theme, "index.html"))
|
|
|
+ webTemplate = tmpl
|
|
|
+}
|
|
|
+
|
|
|
+func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
|
|
+ webTemplate.Execute(w, websiteData)
|
|
|
+}
|
|
|
+
|
|
|
var weatherTimeOut int64
|
|
|
var weatherCache []byte
|
|
|
|
|
@@ -79,7 +86,3 @@ func serveWeather(w http.ResponseWriter, r *http.Request) {
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
w.Write(weatherCache)
|
|
|
}
|
|
|
-
|
|
|
-func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
|
|
- webTemplate.Execute(w, websiteData)
|
|
|
-}
|