Add the application’s version to the footer

This is mostly because it is required for the “Digital Kit”, but it also
works in our favor because now i can version the URL to the static
resources.

Go 1.18 adds the info from git if the package is build from a git
repository, but this is not the case in OBS, so i instead relay on a
constant for the version number.  This constant is “updated” by Debian’s
rules, mostly due to the discussion in [0].

[0]: https://github.com/golang/go/issues/22706
This commit is contained in:
jordi fita mas 2024-01-21 20:50:04 +01:00
parent d945f55096
commit cf527ce070
15 changed files with 88 additions and 53 deletions

4
debian/rules vendored
View File

@ -1,9 +1,13 @@
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
%:
dh $@ --builddirectory=_build --buildsystem=golang --with=golang
execute_before_dh_auto_build:
printf 'package build\n\nconst Version = "%s"\n' "$(DEB_VERSION_UPSTREAM)" > pkg/build/version.go
cp pkg/build/version.go _build/src/dev.tandem.ws/tandem/camper/pkg/build/version.go
make
execute_after_dh_auto_test:

3
pkg/build/version.go Normal file
View File

@ -0,0 +1,3 @@
package build
const Version = "1.0~git"

View File

@ -22,6 +22,7 @@ import (
"golang.org/x/text/number"
"dev.tandem.ws/tandem/camper/pkg/auth"
"dev.tandem.ws/tandem/camper/pkg/build"
httplib "dev.tandem.ws/tandem/camper/pkg/http"
)
@ -72,6 +73,9 @@ func MustRenderPublicFiles(w io.Writer, r *http.Request, user *auth.User, compan
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{
"camperVersion": func() string {
return build.Version
},
"gettext": user.Locale.Get,
"pgettext": user.Locale.GetC,
"currentLocale": func() string {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-01-18 20:54+0100\n"
"POT-Creation-Date: 2024-01-21 20:47+0100\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"
@ -1238,6 +1238,10 @@ msgctxt "title"
msgid "Bookings"
msgstr "Reserves"
#: web/templates/admin/layout.gohtml:101
msgid "Camper Version: %s"
msgstr "Camper versió: %s"
#: web/templates/admin/home/index.gohtml:11
msgctxt "title"
msgid "Cover"
@ -1753,60 +1757,60 @@ msgstr "No podeu deixar el fitxer del mèdia en blanc."
msgid "Filename can not be empty."
msgstr "No podeu deixar el nom del fitxer en blanc."
#: pkg/booking/admin.go:148
#: pkg/booking/admin.go:149
msgctxt "filename"
msgid "bookings.ods"
msgstr "reserves.ods"
#: pkg/booking/admin.go:176
#: pkg/booking/admin.go:177
msgctxt "redsys environment"
msgid "Test"
msgstr "Proves"
#: pkg/booking/admin.go:180
#: pkg/booking/admin.go:181
msgctxt "redsys environment"
msgid "Live"
msgstr "Real"
#: pkg/booking/admin.go:189
#: pkg/booking/admin.go:190
msgctxt "redsys integration"
msgid "InSite"
msgstr "InSite"
#: pkg/booking/admin.go:193
#: pkg/booking/admin.go:194
msgctxt "redsys integration"
msgid "Redirect"
msgstr "Redirecció"
#: pkg/booking/admin.go:237
#: pkg/booking/admin.go:238
msgid "Merchant code can not be empty."
msgstr "No podeu deixar el codi del comerç en blanc."
#: pkg/booking/admin.go:238
#: pkg/booking/admin.go:239
msgid "Merchant code must be exactly nine digits long."
msgstr "El codi del comerç ha de ser de nou dígits."
#: pkg/booking/admin.go:239
#: pkg/booking/admin.go:240
msgid "Merchant code must be a number."
msgstr "El codi del comerç."
#: pkg/booking/admin.go:243
#: pkg/booking/admin.go:244
msgid "Terminal number can not be empty."
msgstr "No podeu deixar el número del terminal en blanc."
#: pkg/booking/admin.go:244
#: pkg/booking/admin.go:245
msgid "Terminal number must be a number between 1 and 999."
msgstr "El número del terminal ha de ser entre 1 i 999"
#: pkg/booking/admin.go:252
#: pkg/booking/admin.go:253
msgid "Selected environment is not valid."
msgstr "Lentorn escollit no és vàlid."
#: pkg/booking/admin.go:253
#: pkg/booking/admin.go:254
msgid "Selected integration is not valid."
msgstr "La integració escollida no és vàlida."
#: pkg/booking/admin.go:256
#: pkg/booking/admin.go:257
msgid "The merchant key is not valid."
msgstr "Aquesta clau del comerç no és vàlid."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-01-18 20:54+0100\n"
"POT-Creation-Date: 2024-01-21 20:47+0100\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"
@ -1238,6 +1238,10 @@ msgctxt "title"
msgid "Bookings"
msgstr "Reservas"
#: web/templates/admin/layout.gohtml:101
msgid "Camper Version: %s"
msgstr "Camper versión: %s"
#: web/templates/admin/home/index.gohtml:11
msgctxt "title"
msgid "Cover"
@ -1753,60 +1757,60 @@ msgstr "No podéis dejar el archivo del medio en blanco."
msgid "Filename can not be empty."
msgstr "No podéis dejar el nombre del archivo en blanco."
#: pkg/booking/admin.go:148
#: pkg/booking/admin.go:149
msgctxt "filename"
msgid "bookings.ods"
msgstr "reservas.ods"
#: pkg/booking/admin.go:176
#: pkg/booking/admin.go:177
msgctxt "redsys environment"
msgid "Test"
msgstr "Pruebas"
#: pkg/booking/admin.go:180
#: pkg/booking/admin.go:181
msgctxt "redsys environment"
msgid "Live"
msgstr "Real"
#: pkg/booking/admin.go:189
#: pkg/booking/admin.go:190
msgctxt "redsys integration"
msgid "InSite"
msgstr "InSite"
#: pkg/booking/admin.go:193
#: pkg/booking/admin.go:194
msgctxt "redsys integration"
msgid "Redirect"
msgstr "Redirección"
#: pkg/booking/admin.go:237
#: pkg/booking/admin.go:238
msgid "Merchant code can not be empty."
msgstr "No podéis dejar el código del comercio en blanco."
#: pkg/booking/admin.go:238
#: pkg/booking/admin.go:239
msgid "Merchant code must be exactly nine digits long."
msgstr "El código del comercio tiene que ser de nueve dígitos."
#: pkg/booking/admin.go:239
#: pkg/booking/admin.go:240
msgid "Merchant code must be a number."
msgstr "El código del comercio tiene que ser un número."
#: pkg/booking/admin.go:243
#: pkg/booking/admin.go:244
msgid "Terminal number can not be empty."
msgstr "No podéis dejar el número de terminal en blanco."
#: pkg/booking/admin.go:244
#: pkg/booking/admin.go:245
msgid "Terminal number must be a number between 1 and 999."
msgstr "El número de terminal tiene que ser entre 1 y 999."
#: pkg/booking/admin.go:252
#: pkg/booking/admin.go:253
msgid "Selected environment is not valid."
msgstr "El entorno escogido no es válido."
#: pkg/booking/admin.go:253
#: pkg/booking/admin.go:254
msgid "Selected integration is not valid."
msgstr "La integración escogida no es válida."
#: pkg/booking/admin.go:256
#: pkg/booking/admin.go:257
msgid "The merchant key is not valid."
msgstr "Esta clave del comercio no es válida."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-01-18 20:54+0100\n"
"POT-Creation-Date: 2024-01-21 20:47+0100\n"
"PO-Revision-Date: 2023-12-20 10:13+0100\n"
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
"Language-Team: French <traduc@traduc.org>\n"
@ -1239,6 +1239,10 @@ msgctxt "title"
msgid "Bookings"
msgstr "Réservations"
#: web/templates/admin/layout.gohtml:101
msgid "Camper Version: %s"
msgstr "Camper version: %s"
#: web/templates/admin/home/index.gohtml:11
msgctxt "title"
msgid "Cover"
@ -1754,60 +1758,60 @@ msgstr "Le fichier téléchargé ne peut pas être vide."
msgid "Filename can not be empty."
msgstr "Le nom de fichier ne peut pas être vide."
#: pkg/booking/admin.go:148
#: pkg/booking/admin.go:149
msgctxt "filename"
msgid "bookings.ods"
msgstr "reservations.ods"
#: pkg/booking/admin.go:176
#: pkg/booking/admin.go:177
msgctxt "redsys environment"
msgid "Test"
msgstr "Test"
#: pkg/booking/admin.go:180
#: pkg/booking/admin.go:181
msgctxt "redsys environment"
msgid "Live"
msgstr "Live"
#: pkg/booking/admin.go:189
#: pkg/booking/admin.go:190
msgctxt "redsys integration"
msgid "InSite"
msgstr "Insite"
#: pkg/booking/admin.go:193
#: pkg/booking/admin.go:194
msgctxt "redsys integration"
msgid "Redirect"
msgstr "Redirection"
#: pkg/booking/admin.go:237
#: pkg/booking/admin.go:238
msgid "Merchant code can not be empty."
msgstr "Le code marchand ne peut pas être vide."
#: pkg/booking/admin.go:238
#: pkg/booking/admin.go:239
msgid "Merchant code must be exactly nine digits long."
msgstr "Le code marchand doit comporter exactement neuf chiffres."
#: pkg/booking/admin.go:239
#: pkg/booking/admin.go:240
msgid "Merchant code must be a number."
msgstr "Le code du commerçant doit être un chiffre."
#: pkg/booking/admin.go:243
#: pkg/booking/admin.go:244
msgid "Terminal number can not be empty."
msgstr "Le numéro de terminal ne peut pas être vide."
#: pkg/booking/admin.go:244
#: pkg/booking/admin.go:245
msgid "Terminal number must be a number between 1 and 999."
msgstr "Le numéro de terminal doit être compris entre 1 et 999."
#: pkg/booking/admin.go:252
#: pkg/booking/admin.go:253
msgid "Selected environment is not valid."
msgstr "Lenvironnement sélectionné nest pas valide."
#: pkg/booking/admin.go:253
#: pkg/booking/admin.go:254
msgid "Selected integration is not valid."
msgstr "Lintégration sélectionnée nest pas valide."
#: pkg/booking/admin.go:256
#: pkg/booking/admin.go:257
msgid "The merchant key is not valid."
msgstr "La clé marchand nest pas valide."

View File

@ -263,6 +263,15 @@ body > nav a {
align-items: center;
}
body > footer {
border-top: 1px solid var(--camper--color--light-gray);
padding: .25em 3rem;
}
body > footer p {
margin: 0;
}
main {
padding: 2rem 3rem;
}

View File

@ -73,7 +73,7 @@
</form>
<script type="module">
import {setupIconInput} from "/static/camper.js";
import {setupIconInput} from "/static/camper.js?v={{ camperVersion }}";
setupIconInput(document.querySelector('.icon-input'));
</script>

View File

@ -35,7 +35,7 @@
{{- end }}
<script type="module">
import {setupCampgroundMap} from "/static/camper.js";
import {setupCampgroundMap} from "/static/camper.js?v={{ camperVersion }}";
setupCampgroundMap(document.getElementById('campground-map'));
</script>
{{- end }}

View File

@ -9,12 +9,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-header" content="{ {{ CSRFHeader }} }">
<title>{{ template "title" . }} — Camper</title>
<link rel="stylesheet" media="screen" href="/static/camper.css">
<link rel="stylesheet" media="screen" href="/static/icons.css">
<link rel="stylesheet" media="screen" href="/static/camper.css?v={{ camperVersion }}">
<link rel="stylesheet" media="screen" href="/static/icons.css?v={{ camperVersion }}">
<script src="/static/sortable@1.15.1.min.js"></script>
<script src="/static/alpinejs@3.13.3.min.js" defer></script>
<script src="/static/htmx@1.9.3.min.js"></script>
<script type="module" src="/static/camper.js"></script>
<script type="module" src="/static/camper.js?v={{ camperVersion }}"></script>
{{ block "head" . }}{{ end }}
</head>
<body>
@ -97,5 +97,8 @@
<main id="content">
{{- template "content" . }}
</main>
<footer>
<p><small>{{printf (gettext "Camper Version: %s") camperVersion }}</small></p>
</footer>
</body>
</html>

View File

@ -33,7 +33,7 @@
</footer>
</form>
<script type="module">
import {camperUploadForm} from "/static/camper.js";
import {camperUploadForm} from "/static/camper.js?v={{ camperVersion }}";
camperUploadForm(document.getElementById('mediaPickerUpload'));
</script>
<form action="/admin/media/field" method="get" data-hx-boost="true" data-hx-push-url="false">

View File

@ -28,7 +28,7 @@
</footer>
</form>
<script type="module">
import {camperUploadForm} from "/static/camper.js";
import {camperUploadForm} from "/static/camper.js?v={{ camperVersion }}";
camperUploadForm(document.getElementById('mediaUpload'));
</script>
{{- end }}

View File

@ -62,7 +62,7 @@
{{ end }}
</div>
<script type="module">
import {setupCalendar} from "/static/camper.js";
import {setupCalendar} from "/static/camper.js?v={{ camperVersion }}";
setupCalendar(document.querySelector('.season-calendar'))
</script>

View File

@ -86,7 +86,7 @@
</form>
<script type="module">
import {setupIconInput} from "/static/camper.js";
import {setupIconInput} from "/static/camper.js?v={{ camperVersion }}";
setupIconInput(document.querySelector('.icon-input'));
</script>

View File

@ -12,8 +12,8 @@
<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">
<link rel="stylesheet" media="screen" href="/static/icons.css">
<link rel="stylesheet" media="screen" href="/static/public.css?v={{ camperVersion }}">
<link rel="stylesheet" media="screen" href="/static/icons.css?v={{ camperVersion }}">
{{ range .LocalizedAlternates -}}
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .HRef }}"/>
{{ end }}