Frontend: put version number in static URL to cache-bust on updates
All checks were successful
/ build-container (push) Successful in 8m40s
All checks were successful
/ build-container (push) Successful in 8m40s
This commit is contained in:
parent
426ab872dd
commit
f90a7cd66d
4 changed files with 7 additions and 4 deletions
|
@ -26,5 +26,9 @@ func init() {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
if Version == "" {
|
||||
Version = "development"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() },
|
||||
}
|
||||
)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue