added store handler
All checks were successful
release-tag / release-image (push) Successful in 2m25s
All checks were successful
release-tag / release-image (push) Successful in 2m25s
This commit is contained in:
@@ -117,6 +117,7 @@ func main() {
|
|||||||
staticDir := getenv("BLOG_STATIC_DIR", "/app/internal/web/static")
|
staticDir := getenv("BLOG_STATIC_DIR", "/app/internal/web/static")
|
||||||
pagesDir := getenv("BLOG_PAGES_DIR", "/pages")
|
pagesDir := getenv("BLOG_PAGES_DIR", "/pages")
|
||||||
templatesDir := getenv("BLOG_TEMPLATES_DIR", "/templates")
|
templatesDir := getenv("BLOG_TEMPLATES_DIR", "/templates")
|
||||||
|
storeEnabled := enabled("STORE_ENABLE", false)
|
||||||
ticksDir := getenv("BLOG_TICKS_DIR", "/ticks")
|
ticksDir := getenv("BLOG_TICKS_DIR", "/ticks")
|
||||||
gitEnable := enabled("GIT_ENABLE", false)
|
gitEnable := enabled("GIT_ENABLE", false)
|
||||||
gitRepo := getenv("GIT_REPO", "null")
|
gitRepo := getenv("GIT_REPO", "null")
|
||||||
@@ -138,6 +139,11 @@ func main() {
|
|||||||
// Basislayout zuerst parsen
|
// Basislayout zuerst parsen
|
||||||
layout := template.Must(template.New("base").Funcs(funcs).ParseFiles(templatesDir + "/base.html"))
|
layout := template.Must(template.New("base").Funcs(funcs).ParseFiles(templatesDir + "/base.html"))
|
||||||
|
|
||||||
|
var tplStore *template.Template
|
||||||
|
if storeEnabled {
|
||||||
|
tplStore = template.Must(template.New("store").Funcs(funcs).ParseFiles(templatesDir + "/store.html"))
|
||||||
|
}
|
||||||
|
|
||||||
// LIST‑Seite: base + list.html
|
// LIST‑Seite: base + list.html
|
||||||
tplList = template.Must(layout.Clone())
|
tplList = template.Must(layout.Clone())
|
||||||
template.Must(tplList.Funcs(funcs).ParseFiles(templatesDir + "/list.html"))
|
template.Must(tplList.Funcs(funcs).ParseFiles(templatesDir + "/list.html"))
|
||||||
@@ -220,6 +226,17 @@ func main() {
|
|||||||
|
|
||||||
mux.Handle("/static/", cacheControl(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir)))))
|
mux.Handle("/static/", cacheControl(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir)))))
|
||||||
|
|
||||||
|
mux.HandleFunc("/store", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if storeEnabled {
|
||||||
|
if err := tplStore.ExecuteTemplate(w, "store", nil); err != nil {
|
||||||
|
http.Error(w, err.Error(), 500)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
if gitEnable {
|
if gitEnable {
|
||||||
xMinute, _ := strconv.Atoi(gitInterval)
|
xMinute, _ := strconv.Atoi(gitInterval)
|
||||||
xDuration := time.Duration(xMinute) * time.Minute
|
xDuration := time.Duration(xMinute) * time.Minute
|
||||||
|
Reference in New Issue
Block a user