mirror of
https://github.com/Kugelschieber/schnittfest.git
synced 2026-01-18 10:20:27 +00:00
Finished for now.
This commit is contained in:
@@ -21,11 +21,9 @@ func LandingPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
langCode := util.GetLangCode(r)
|
||||
data := struct {
|
||||
Vars map[string]string
|
||||
NavbarVars map[string]string
|
||||
FooterVars map[string]string
|
||||
}{
|
||||
landingPageI18n[langCode],
|
||||
navbarComponentI18n[langCode],
|
||||
footerComponentI18n[langCode],
|
||||
}
|
||||
|
||||
|
||||
34
pages/legal_page.go
Normal file
34
pages/legal_page.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/Kugelschieber/schnittfest/util"
|
||||
"github.com/emvi/logbuch"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var legalPageI18n = map[string]map[string]string{
|
||||
"de": {},
|
||||
}
|
||||
|
||||
func LegalPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
tpl := tplCache.GetTemplate(legalPageTemplate)
|
||||
|
||||
if tpl == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
langCode := util.GetLangCode(r)
|
||||
data := struct {
|
||||
Vars map[string]string
|
||||
FooterVars map[string]string
|
||||
}{
|
||||
legalPageI18n[langCode],
|
||||
footerComponentI18n[langCode],
|
||||
}
|
||||
|
||||
if err := tpl.Execute(w, &data); err != nil {
|
||||
logbuch.Error("Error rendering legal page", logbuch.Fields{"err": err})
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pages
|
||||
|
||||
var navbarComponentI18n = map[string]map[string]string{
|
||||
"de": {},
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
const (
|
||||
defaultTemplateBase = "template"
|
||||
landingPageTemplate = "landing_page"
|
||||
termsPageTemplate = "terms_page"
|
||||
legalPageTemplate = "legal_page"
|
||||
notfoundPageTemplate = "notfound_page"
|
||||
)
|
||||
|
||||
@@ -27,17 +29,21 @@ func LoadTemplates() {
|
||||
}
|
||||
|
||||
if _, err := tplCache.ParseFiles(landingPageTemplate, filepath.Join(templateBase, "landing_page.html"),
|
||||
filepath.Join(templateBase, "head.html"),
|
||||
filepath.Join(templateBase, "end.html"),
|
||||
filepath.Join(templateBase, "navbar.html"),
|
||||
filepath.Join(templateBase, "footer.html")); err != nil {
|
||||
logbuch.Fatal("Error loading landing page template", logbuch.Fields{"err": err})
|
||||
}
|
||||
|
||||
if _, err := tplCache.ParseFiles(termsPageTemplate, filepath.Join(templateBase, "terms_page.html"),
|
||||
filepath.Join(templateBase, "footer.html")); err != nil {
|
||||
logbuch.Fatal("Error loading terms page template", logbuch.Fields{"err": err})
|
||||
}
|
||||
|
||||
if _, err := tplCache.ParseFiles(legalPageTemplate, filepath.Join(templateBase, "legal_page.html"),
|
||||
filepath.Join(templateBase, "footer.html")); err != nil {
|
||||
logbuch.Fatal("Error loading legal page template", logbuch.Fields{"err": err})
|
||||
}
|
||||
|
||||
if _, err := tplCache.ParseFiles(notfoundPageTemplate, filepath.Join(templateBase, "404_page.html"),
|
||||
filepath.Join(templateBase, "head.html"),
|
||||
filepath.Join(templateBase, "end.html"),
|
||||
filepath.Join(templateBase, "navbar.html"),
|
||||
filepath.Join(templateBase, "footer.html")); err != nil {
|
||||
logbuch.Fatal("Error loading 404 page template", logbuch.Fields{"err": err})
|
||||
}
|
||||
|
||||
34
pages/terms_page.go
Normal file
34
pages/terms_page.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/Kugelschieber/schnittfest/util"
|
||||
"github.com/emvi/logbuch"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var termsPageI18n = map[string]map[string]string{
|
||||
"de": {},
|
||||
}
|
||||
|
||||
func TermsPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
tpl := tplCache.GetTemplate(termsPageTemplate)
|
||||
|
||||
if tpl == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
langCode := util.GetLangCode(r)
|
||||
data := struct {
|
||||
Vars map[string]string
|
||||
FooterVars map[string]string
|
||||
}{
|
||||
termsPageI18n[langCode],
|
||||
footerComponentI18n[langCode],
|
||||
}
|
||||
|
||||
if err := tpl.Execute(w, &data); err != nil {
|
||||
logbuch.Error("Error rendering terms page", logbuch.Fields{"err": err})
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user