diff --git a/pkg/app/public.go b/pkg/app/public.go index fe65eee..0f688f5 100644 --- a/pkg/app/public.go +++ b/pkg/app/public.go @@ -38,14 +38,16 @@ func (h *publicHandler) Handler(user *auth.User, company *auth.Company, conn *da switch head { case "": h.home.Handler(user, company, conn).ServeHTTP(w, r) + case "campground": + campgroundHandler(user, company, conn).ServeHTTP(w, r) case "campsites": h.campsite.Handler(user, company, conn).ServeHTTP(w, r) + case "contact": + contactHandler(user, company, conn).ServeHTTP(w, r) case "services": h.services.Handler(user, company, conn).ServeHTTP(w, r) case "surroundings": surroundingsHandler(user, company, conn).ServeHTTP(w, r) - case "contact": - contactHandler(user, company, conn).ServeHTTP(w, r) default: http.NotFound(w, r) } @@ -72,6 +74,26 @@ func surroundingsHandler(user *auth.User, company *auth.Company, conn *database. }) } +func campgroundHandler(user *auth.User, company *auth.Company, conn *database.Conn) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + var head string + head, r.URL.Path = httplib.ShiftPath(r.URL.Path) + switch head { + case "": + switch r.Method { + case http.MethodGet: + page := template.NewPublicPage() + page.Setup(r, user, company, conn) + template.MustRenderPublicFiles(w, r, user, company, page, "campground.gohtml", "web/templates/campground_map.svg") + default: + httplib.MethodNotAllowed(w, r, http.MethodGet) + } + default: + http.NotFound(w, r) + } + }) +} + func contactHandler(user *auth.User, company *auth.Company, conn *database.Conn) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var head string diff --git a/pkg/template/render.go b/pkg/template/render.go index 83b6877..41937e9 100644 --- a/pkg/template/render.go +++ b/pkg/template/render.go @@ -52,6 +52,12 @@ func MustRenderPublic(w io.Writer, r *http.Request, user *auth.User, company *au mustRenderLayout(w, user, company, publicTemplateFile, data, layout, filename) } +func MustRenderPublicFiles(w io.Writer, r *http.Request, user *auth.User, company *auth.Company, data interface{}, filenames ...string) { + layout := "layout.gohtml" + filenames = append([]string{layout}, filenames...) + mustRenderLayout(w, user, company, publicTemplateFile, data, filenames...) +} + func mustRenderLayout(w io.Writer, user *auth.User, company *auth.Company, templateFile func(string) string, data interface{}, templates ...string) { t := template.New(templates[len(templates)-1]) t.Funcs(template.FuncMap{ diff --git a/po/ca.po b/po/ca.po index 29ec247..cbe1aeb 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2023-10-06 21:58+0200\n" +"POT-Creation-Date: 2023-10-06 22:10+0200\n" "PO-Revision-Date: 2023-07-22 23:45+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Catalan \n" @@ -20,7 +20,7 @@ msgstr "" #: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:15 -#: web/templates/public/layout.gohtml:43 web/templates/public/layout.gohtml:69 +#: web/templates/public/layout.gohtml:43 web/templates/public/layout.gohtml:70 #: web/templates/admin/services/index.gohtml:53 msgctxt "title" msgid "Services" @@ -30,7 +30,7 @@ msgstr "Serveis" msgid "The campsite offers many different services." msgstr "El càmping disposa de diversos serveis." -#: web/templates/public/home.gohtml:6 web/templates/public/layout.gohtml:30 +#: web/templates/public/home.gohtml:6 web/templates/public/layout.gohtml:29 #: web/templates/public/layout.gohtml:68 msgctxt "title" msgid "Home" @@ -52,7 +52,7 @@ msgstr "Els nostres serveis" #: web/templates/public/home.gohtml:34 #: web/templates/public/surroundings.gohtml:6 #: web/templates/public/surroundings.gohtml:10 -#: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:70 +#: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:71 msgctxt "title" msgid "Surroundings" msgstr "L’entorn" @@ -154,14 +154,21 @@ msgstr "Caiac" msgid "There are several points where you can go by kayak, from sections of the Ter river as well as on the coast…." msgstr "Hi ha diversos punts on poder anar amb caiac, des de trams del riu Ter com també a la costa…." +#: web/templates/public/campground.gohtml:6 +#: web/templates/public/campground.gohtml:11 +#: web/templates/public/layout.gohtml:30 web/templates/public/layout.gohtml:69 +msgctxt "title" +msgid "Campground" +msgstr "El càmping" + #: web/templates/public/contact.gohtml:6 web/templates/public/contact.gohtml:15 -#: web/templates/public/layout.gohtml:45 web/templates/public/layout.gohtml:71 +#: web/templates/public/layout.gohtml:45 web/templates/public/layout.gohtml:72 msgctxt "title" msgid "Contact" msgstr "Contacte" -#: web/templates/public/layout.gohtml:11 web/templates/public/layout.gohtml:25 -#: web/templates/public/layout.gohtml:93 +#: web/templates/public/layout.gohtml:11 web/templates/public/layout.gohtml:24 +#: web/templates/public/layout.gohtml:94 msgid "Campsite Montagut" msgstr "Càmping Montagut" @@ -169,7 +176,7 @@ msgstr "Càmping Montagut" msgid "Skip to main content" msgstr "Salta al contingut principal" -#: web/templates/public/layout.gohtml:34 web/templates/public/layout.gohtml:78 +#: web/templates/public/layout.gohtml:34 web/templates/public/layout.gohtml:79 #: web/templates/admin/campsite/index.gohtml:6 #: web/templates/admin/campsite/index.gohtml:12 #: web/templates/admin/layout.gohtml:40 web/templates/admin/layout.gohtml:71 diff --git a/po/es.po b/po/es.po index a9154bc..fcad996 100644 --- a/po/es.po +++ b/po/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2023-10-06 21:58+0200\n" +"POT-Creation-Date: 2023-10-06 22:10+0200\n" "PO-Revision-Date: 2023-07-22 23:46+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Spanish \n" @@ -20,7 +20,7 @@ msgstr "" #: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:15 -#: web/templates/public/layout.gohtml:43 web/templates/public/layout.gohtml:69 +#: web/templates/public/layout.gohtml:43 web/templates/public/layout.gohtml:70 #: web/templates/admin/services/index.gohtml:53 msgctxt "title" msgid "Services" @@ -30,7 +30,7 @@ msgstr "Servicios" msgid "The campsite offers many different services." msgstr "El camping dispone de varios servicios." -#: web/templates/public/home.gohtml:6 web/templates/public/layout.gohtml:30 +#: web/templates/public/home.gohtml:6 web/templates/public/layout.gohtml:29 #: web/templates/public/layout.gohtml:68 msgctxt "title" msgid "Home" @@ -52,7 +52,7 @@ msgstr "Nuestros servicios" #: web/templates/public/home.gohtml:34 #: web/templates/public/surroundings.gohtml:6 #: web/templates/public/surroundings.gohtml:10 -#: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:70 +#: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:71 msgctxt "title" msgid "Surroundings" msgstr "El entorno" @@ -154,14 +154,21 @@ msgstr "Kayak" msgid "There are several points where you can go by kayak, from sections of the Ter river as well as on the coast…." msgstr "Hay diversos puntos dónde podéis ir en kayak, desde tramos del río Ter como también en la costa…." +#: web/templates/public/campground.gohtml:6 +#: web/templates/public/campground.gohtml:11 +#: web/templates/public/layout.gohtml:30 web/templates/public/layout.gohtml:69 +msgctxt "title" +msgid "Campground" +msgstr "El camping" + #: web/templates/public/contact.gohtml:6 web/templates/public/contact.gohtml:15 -#: web/templates/public/layout.gohtml:45 web/templates/public/layout.gohtml:71 +#: web/templates/public/layout.gohtml:45 web/templates/public/layout.gohtml:72 msgctxt "title" msgid "Contact" msgstr "Contacto" -#: web/templates/public/layout.gohtml:11 web/templates/public/layout.gohtml:25 -#: web/templates/public/layout.gohtml:93 +#: web/templates/public/layout.gohtml:11 web/templates/public/layout.gohtml:24 +#: web/templates/public/layout.gohtml:94 msgid "Campsite Montagut" msgstr "Camping Montagut" @@ -169,7 +176,7 @@ msgstr "Camping Montagut" msgid "Skip to main content" msgstr "Saltar al contenido principal" -#: web/templates/public/layout.gohtml:34 web/templates/public/layout.gohtml:78 +#: web/templates/public/layout.gohtml:34 web/templates/public/layout.gohtml:79 #: web/templates/admin/campsite/index.gohtml:6 #: web/templates/admin/campsite/index.gohtml:12 #: web/templates/admin/layout.gohtml:40 web/templates/admin/layout.gohtml:71 diff --git a/web/templates/public/campground.gohtml b/web/templates/public/campground.gohtml new file mode 100644 index 0000000..e7b0a3d --- /dev/null +++ b/web/templates/public/campground.gohtml @@ -0,0 +1,13 @@ + +{{ define "title" -}} + {{( pgettext "Campground" "title" )}} +{{- end }} + +{{ define "content" -}} + {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/app.campgroundPage*/ -}} +

{{( pgettext "Campground" "title" )}}

+ {{ template "campground_map.svg" }} +{{- end }} diff --git a/web/templates/public/layout.gohtml b/web/templates/public/layout.gohtml index 19ad0e0..4137392 100644 --- a/web/templates/public/layout.gohtml +++ b/web/templates/public/layout.gohtml @@ -27,6 +27,7 @@