set LIEU_DEV='' env variable for quicker html dev

pull/4/head
cblgh 2021-05-12 13:52:51 +02:00
rodzic 6cd59b2f3d
commit e0f200bdba
1 zmienionych plików z 12 dodań i 3 usunięć

Wyświetl plik

@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"strings"
"html/template"
@ -47,12 +48,12 @@ type AboutData struct {
RingLink string
}
const useURLTitles = true
var templates = template.Must(template.ParseFiles(
"html/head.html", "html/nav.html", "html/footer.html",
"html/about.html", "html/index.html", "html/list.html", "html/search.html", "html/webring.html"))
const useURLTitles = true
func (h RequestHandler) searchRoute(res http.ResponseWriter, req *http.Request) {
var query string
view := &TemplateView{}
@ -138,7 +139,15 @@ func (h RequestHandler) webringRoute(res http.ResponseWriter, req *http.Request)
func (h RequestHandler) renderView(res http.ResponseWriter, tmpl string, view *TemplateView) {
view.SiteName = h.config.General.Name
errTemp := templates.ExecuteTemplate(res, tmpl+".html", view)
var errTemp error
if _, exists := os.LookupEnv("LIEU_DEV"); exists {
var templates = template.Must(template.ParseFiles(
"html/head.html", "html/nav.html", "html/footer.html",
"html/about.html", "html/index.html", "html/list.html", "html/search.html", "html/webring.html"))
errTemp = templates.ExecuteTemplate(res, tmpl+".html", view)
} else {
errTemp = templates.ExecuteTemplate(res, tmpl+".html", view)
}
util.Check(errTemp)
}