Frontend: put version number in static URL to cache-bust on updates
All checks were successful
/ build-container (push) Successful in 8m40s

This commit is contained in:
Finn 2025-02-23 14:48:35 -08:00
parent 426ab872dd
commit f90a7cd66d
4 changed files with 7 additions and 4 deletions

View file

@ -26,5 +26,9 @@ func init() {
break
}
}
if Version == "" {
Version = "development"
}
}
}

View file

@ -2,7 +2,6 @@ package frontend
import (
"embed"
"fmt"
"html/template"
"io/fs"
"time"
@ -20,7 +19,7 @@ var (
Templates *template.Template
funcs = template.FuncMap{
"version": func() string { return fmt.Sprintf("better-zwave-locks %s", config.Version) },
"version": func() string { return config.Version },
"time_since": func(t time.Time) string { return time.Since(t).Round(time.Second).String() },
}
)

View file

@ -5,7 +5,7 @@
<title>Better Z-Wave Locks for Home Assistant</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="{{ .BaseURL }}/static/main.css" />
<link rel="stylesheet" href="{{ .BaseURL }}/static-{{ version }}/main.css" />
</head>
<body>

View file

@ -28,7 +28,7 @@ func ListenAndServe(zwaveClient *zwavejs.Client) {
server.Use(accessLogMiddleware)
server.RouteNotFound("/*", tmpl("404.html"))
server.StaticFS("/static", frontend.Static)
server.StaticFS("/static-"+config.Version, frontend.Static)
server.GET("/", indexHandler)
server.GET("/locks/:lock", lockHandler)
server.GET("/locks/:lock/edit", lockEditHandler)