Add the campground page

For now, this page only shows the map, that i had to create a new
“files” template function to include it as an extra template file.
This commit is contained in:
jordi fita mas 2023-10-06 22:14:11 +02:00
parent ae29726fa2
commit caab52a274
6 changed files with 75 additions and 18 deletions

View File

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

View File

@ -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{

View File

@ -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 <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\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 "Lentorn"
@ -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

View File

@ -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 <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\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

View File

@ -0,0 +1,13 @@
<!--
SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
SPDX-License-Identifier: AGPL-3.0-only
-->
{{ define "title" -}}
{{( pgettext "Campground" "title" )}}
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/app.campgroundPage*/ -}}
<h2>{{( pgettext "Campground" "title" )}}</h2>
{{ template "campground_map.svg" }}
{{- end }}

View File

@ -27,6 +27,7 @@
<nav>
<ul>
<li><a href="/{{ currentLocale }}/">{{( pgettext "Home" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/campground">{{( pgettext "Campground" "title" )}}</a></li>
{{ with .Menu -}}
{{ if .CampsiteTypes -}}
<li class="has-submenu">
@ -65,6 +66,7 @@
<h2>{{( pgettext "Sections" "title" )}}</h2>
<ul>
<li><a href="/{{ currentLocale }}/">{{( pgettext "Home" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/campground">{{( pgettext "Campground" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/services">{{( pgettext "Services" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/surroundings">{{( pgettext "Surroundings" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/contact">{{( pgettext "Contact" "title" )}}</a></li>