camper/web/templates/public/layout.gohtml

189 lines
7.8 KiB
Plaintext
Raw Normal View History

Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
<!--
SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
SPDX-FileCopyrightText: 2023 Oriol Carbonell <info@oriolcarbonell.cat>
Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
SPDX-License-Identifier: AGPL-3.0-only
-->
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/template.PublicPage*/ -}}
Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
<!doctype html>
<html lang="{{ currentLocale }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ template "title" . }} — {{( gettext "Campsite Montagut" )}}</title>
<link rel="preload" href="/static/fonts/MabryPro-Regular.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/static/fonts/MabryPro-Bold.woff2" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" media="screen" href="/static/public.css?v={{ camperVersion }}">
<link rel="stylesheet" media="screen" href="/static/icons.css?v={{ camperVersion }}">
Add the language switched to the public layout The language switcher needs the same information as languageLinks needed, namely the list of locales and the current Path, to construct the URI to all alternate versions. However, in this case i need access to this data in the template context, to build the list of links. At first i use request’s context to hold the list of available locales from application, and it worked, possibly without ill-effects, but i realized that i was doing it just to avoid a new parameter. Or, more precise, an _explicit_ parameter; the context was used to skip the inner functions between app and template.MustRenderPublic, but the parameter was there all the same. Finally, i thought that some handler might want to filter the list of locales to show only the ones that it has a translation of. In that case, i would need to extract the locales from the context, filter it, and create a new request with the updated context. That made little sense, and made me add the explicit locales parameter. Since now the template has the same data as languageLinks, there is little point of having the link in the HTTP response headers, and added the <link> elements to <head>. I thought that maybe i could avoid these <links> as they give the exact same data as the language switch, but Google says nothing of using regular anchors to gather information about localized versions of the document[0], thus i opted to be conservative. One can reason that the <head> has more weight for Google, as most sites with user-generated content, which could contain these anchors, rarely allow users to edit the <head>. [0]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-06 03:53:52 +00:00
{{ range .LocalizedAlternates -}}
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .HRef }}">
Add the language switched to the public layout The language switcher needs the same information as languageLinks needed, namely the list of locales and the current Path, to construct the URI to all alternate versions. However, in this case i need access to this data in the template context, to build the list of links. At first i use request’s context to hold the list of available locales from application, and it worked, possibly without ill-effects, but i realized that i was doing it just to avoid a new parameter. Or, more precise, an _explicit_ parameter; the context was used to skip the inner functions between app and template.MustRenderPublic, but the parameter was there all the same. Finally, i thought that some handler might want to filter the list of locales to show only the ones that it has a translation of. In that case, i would need to extract the locales from the context, filter it, and create a new request with the updated context. That made little sense, and made me add the explicit locales parameter. Since now the template has the same data as languageLinks, there is little point of having the link in the HTTP response headers, and added the <link> elements to <head>. I thought that maybe i could avoid these <links> as they give the exact same data as the language switch, but Google says nothing of using regular anchors to gather information about localized versions of the document[0], thus i opted to be conservative. One can reason that the <head> has more weight for Google, as most sites with user-generated content, which could contain these anchors, rarely allow users to edit the <head>. [0]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-06 03:53:52 +00:00
{{ end }}
<script src="/static/htmx@1.9.3.min.js"></script>
Add the language switched to the public layout The language switcher needs the same information as languageLinks needed, namely the list of locales and the current Path, to construct the URI to all alternate versions. However, in this case i need access to this data in the template context, to build the list of links. At first i use request’s context to hold the list of available locales from application, and it worked, possibly without ill-effects, but i realized that i was doing it just to avoid a new parameter. Or, more precise, an _explicit_ parameter; the context was used to skip the inner functions between app and template.MustRenderPublic, but the parameter was there all the same. Finally, i thought that some handler might want to filter the list of locales to show only the ones that it has a translation of. In that case, i would need to extract the locales from the context, filter it, and create a new request with the updated context. That made little sense, and made me add the explicit locales parameter. Since now the template has the same data as languageLinks, there is little point of having the link in the HTTP response headers, and added the <link> elements to <head>. I thought that maybe i could avoid these <links> as they give the exact same data as the language switch, but Google says nothing of using regular anchors to gather information about localized versions of the document[0], thus i opted to be conservative. One can reason that the <head> has more weight for Google, as most sites with user-generated content, which could contain these anchors, rarely allow users to edit the <head>. [0]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-06 03:53:52 +00:00
{{- block "head" . }}{{ end }}
Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
</head>
<body>
<a href="#content">{{( gettext "Skip to main content" )}}</a>
Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
<header>
{{ with .CompanyAddress -}}
<address>
<a href="tel:{{ replaceAll .Phone " " "" }}">{{ replaceAll .Phone "+" "00 " }}</a>
<a href="mailto:{{ .Email }}">{{ .Email }}</a>
</address>
{{- end }}
{{ if .LocalizedAlternates -}}
<nav>
<ul>
<li class="has-submenu">{{ range .LocalizedAlternates -}}
{{ if eq .Lang currentLocale }}{{ template "alternateAnchor" . }}{{ end }}
{{- end }}
<ul>
{{ range .LocalizedAlternates }}{{ if ne .Lang currentLocale -}}
<li>{{ template "alternateAnchor" . }}</li>
{{ end }}{{ end }}
</ul>
</li>
</ul>
</nav>
{{- end }}
<h1><a href="/{{ currentLocale }}/"><span class="logo">◭</span><span
class="name">{{( gettext "Campsite Montagut" )}}</span></a></h1>
<input type="checkbox" id="menuShowHide">
<label for="menuShowHide">{{( gettext "Menu" )}}</label>
<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">
<button type="button">{{( pgettext "Campsites" "title" )}}</button>
<ul>
{{ range .CampsiteTypes -}}
<li><a href="{{ .HRef }}">{{ .Label }}</a></li>
{{ end }}
</ul>
</li>
{{- end }}
{{- end }}
<li><a href="/{{ currentLocale }}/services">{{( pgettext "Services" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/surroundings">{{( pgettext "Surroundings" "title" )}}</a></li>
<li><a href="/{{ currentLocale }}/location">{{( pgettext "Location" "title" )}}</a></li>
<li class="boto-reserva"><a href="/{{ currentLocale }}/booking">{{( pgettext "Booking" "title" )}}</a></li>
{{ if .LocalizedAlternates -}}
<li class="has-submenu">{{ range .LocalizedAlternates -}}
{{ if eq .Lang currentLocale }}<button type="button">{{ .Endonym }}</button>{{ end }}
{{- end }}
<ul>
{{ range .LocalizedAlternates }}{{ if ne .Lang currentLocale -}}
<li>{{ template "alternateAnchor" . }}</li>
{{ end }}{{ end }}
</ul>
</li>
{{- end }}
</ul>
</nav>
Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
</header>
<main id="content">
{{- template "content" . }}
</main>
<footer>
<div>
<section>
<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 }}/location">{{( pgettext "Location" "title" )}}</a></li>
</ul>
</section>
{{ with .Menu -}}
{{ if .CampsiteTypes -}}
<section>
<h2>{{( pgettext "Campsites" "title" )}}</h2>
<ul>
{{ range .CampsiteTypes -}}
<li><a href="{{ .HRef }}">{{ .Label }}</a></li>
{{ end }}
</ul>
</section>
{{- end }}
{{- end }}
2023-12-20 12:02:56 +00:00
<section>
<h2>{{ (pgettext "Opening" "title" )}}</h2>
{{ .OpeningDates }}
2023-12-20 12:02:56 +00:00
</section>
<section>
<h2>{{ .CompanyAddress.TradeName }}</h2>
{{ template "companyAddress" .CompanyAddress }}
{{ printf ( gettext "<abbr title=\"Catalonia Tourism Registry\">RTC</abbr> <abbr title=\"Number\">#</abbr>%s") .CompanyAddress.RTCNumber | raw }}
<div class="camping-association">
<img src="/static/camping-association/Reconeixement.gif" alt="Alan Rogers">
<img src="/static/camping-association/acsi.jpg" alt="ACSI">
<img src="/static/camping-association/logofecc4.gif" alt="Federación Española de Clubes Capistas">
<img src="/static/camping-association/anwb.png" alt="anwb">
</div>
</section>
</div>
<span>© {{ .CompanyAddress.TradeName }} | 19942023</span>
</footer>
Split templates and handlers into admin and public I need to check that the user is an employee (or admin) in administration handlers, but i do not want to do it for each handler, because i am bound to forget it. Thus, i added the /admin sub-path for these resources. The public-facing web is the rest of the resources outside /admin, but for now there is only home, to test whether it works as expected or not. The public-facing web can not relay on the user’s language settings, as the guest user has no way to set that. I would be happy to just use the Accept-Language header for that, but apparently Google does not use that header[0], and they give four alternatives: a country-specific domain, a subdomain with a generic top-level domain (gTLD), subdirectories with a gTLD, or URL parameters (e.g., site.com?loc=de). Of the four, Google does not recommend URL parameters, and the customer is already using subdirectories with the current site, therefor that’s what i have chosen. Google also tells me that it is a very good idea to have links between localized version of the same resources, either with <link> elements, Link HTTP response headers, or a sitemap file[1]; they are all equivalent in the eyes of Google. I have choosen the Link response headers way, because for that i can simply “augment” ResponseHeader to automatically add these headers when the response status is 2xx, otherwise i would need to pass down the original URL path until it reaches the template. Even though Camper is supposed to be a “generic”, multi-company application, i think i will stick to the easiest route and write the templates for just the “first” customer. [0]: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites [1]: https://developers.google.com/search/docs/specialty/international/localized-versions
2023-08-05 01:42:37 +00:00
</body>
</html>
{{ define "alternateAnchor" -}}
<a rel="alternate" href="{{ .HRef }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .Endonym }}</a>
{{- end }}
{{ define "companyAddress" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/template.address*/ -}}
<address>
{{ .Address }}<br>
{{ .PostalCode}} · {{ .City }} · {{ .Province }}<br>
{{ .Country }}<br>
<abbr>T</abbr> <a href="tel:{{ replaceAll .Phone " " "" }}">{{ replaceAll .Phone "+" "00 " }}</a><br>
<a href="mailto:{{ .Email }}">{{ .Email }}</a>
</address>
{{- end }}
{{ define "carouselStyle" -}}
<link rel="stylesheet" media="screen" href="/static/slick@1.8.1.css">
{{- end }}
{{ define "alpineScript" -}}
<script src="/static/alpinejs@3.13.3.min.js" defer></script>
{{- end }}
{{ define "carouselInit" -}}
<script src="/static/jquery@3.7.1.min.js"></script>
<script src="/static/slick@1.8.1.min.js"></script>
<script>
jQuery(function () {
jQuery('.carousel').slick({
slidesToShow: {{ . }},
slidesToScroll: 1,
infinite: false,
arrows: true,
prevArrow: '<button type="button" class="slick-prev">←</button>',
nextArrow: '<button type="button" class="slick-next">→</button>',
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: {{ . | dec }},
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
}
},
]
});
});
</script>
{{- end }}