svg run ok

This commit is contained in:
Help-14 2022-04-16 20:01:54 +07:00
parent 9d350399ca
commit 17a57bbcd4
2 changed files with 17 additions and 13 deletions

3
.gitignore vendored
View file

@ -105,4 +105,5 @@ dist
src/temp
src/build
src/data
src/data
data

View file

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