hub v0.3.2: Show Hub version in page footers

Add hubVersion template function via closure in web.New(). Version is
passed from main.go (set via ldflags at build time) and displayed in
the footer of all 6 page templates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.6 committed 2026-02-20 19:39:52 +01:00
1 parent 11428659d1
commit 6bcbaa1574
10 files changed
+20 -10

No files matched your search

+5 -2
View File
@@ -21,6 +21,7 @@ type Server struct {
store *store.Store
passwordHash string
apiKey string // report API key — used for controller callbacks
version string
logger *log.Logger
templates *template.Template
staleThreshold time.Duration
@@ -29,7 +30,7 @@ type Server struct {
}
// New creates a new web server.
func New(store *store.Store, passwordHash, apiKey string, staleThreshold time.Duration, logger *log.Logger) *Server {
func New(store *store.Store, passwordHash, apiKey, version string, staleThreshold time.Duration, logger *log.Logger) *Server {
funcMap := template.FuncMap{
"timeAgo": timeAgo,
"statusColor": statusColor,
@@ -40,7 +41,8 @@ func New(store *store.Store, passwordHash, apiKey string, staleThreshold time.Du
b, _ := json.Marshal(v)
return template.JS(b)
},
"add": func(a, b int) int { return a + b },
"hubVersion": func() string { return version },
"add": func(a, b int) int { return a + b },
"mapGet": func(m map[string]int, key string) int {
if m == nil {
return 0
@@ -55,6 +57,7 @@ func New(store *store.Store, passwordHash, apiKey string, staleThreshold time.Du
store: store,
passwordHash: passwordHash,
apiKey: apiKey,
version: version,
logger: logger,
templates: tmpl,
staleThreshold: staleThreshold,