diff --git a/internal/admin/admin.go b/internal/admin/admin.go
index 045d980..822495a 100644
--- a/internal/admin/admin.go
+++ b/internal/admin/admin.go
@@ -46,6 +46,7 @@ type TemplateData struct {
Channels []*model.Channel
Channel *model.Channel
ChannelPlugin *model.ChannelPlugin
+ Version string
}
// Admin represents the admin interface
@@ -55,10 +56,11 @@ type Admin struct {
store *sessions.CookieStore
templates map[string]*template.Template
baseTemplate *template.Template
+ version string
}
// New creates a new Admin instance
-func New(cfg *config.Config, database *db.Database) *Admin {
+func New(cfg *config.Config, database *db.Database, version string) *Admin {
// Create session store with appropriate options
store := sessions.NewCookieStore([]byte(cfg.SecretKey))
store.Options = &sessions.Options{
@@ -126,6 +128,7 @@ func New(cfg *config.Config, database *db.Database) *Admin {
store: store,
templates: templates,
baseTemplate: baseTemplate,
+ version: version,
}
}
@@ -264,6 +267,7 @@ func (a *Admin) render(w http.ResponseWriter, r *http.Request, templateName stri
data.LoggedIn = a.isLoggedIn(r)
data.Path = r.URL.Path
data.Flash = a.getFlashes(w, r)
+ data.Version = a.version
// Get template
tmpl, ok := a.templates[templateName]
diff --git a/internal/admin/templates/_base.html b/internal/admin/templates/_base.html
index 4a414e3..3ebdf85 100644
--- a/internal/admin/templates/_base.html
+++ b/internal/admin/templates/_base.html
@@ -117,6 +117,19 @@
+
diff --git a/internal/app/app.go b/internal/app/app.go
index 2e15bf6..5126672 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -9,6 +9,7 @@ import (
"net/http"
"os"
"os/signal"
+ "runtime/debug"
"strings"
"syscall"
"time"
@@ -26,12 +27,13 @@ import (
// App represents the application
type App struct {
- config *config.Config
- logger *slog.Logger
- db *db.Database
- router *http.ServeMux
- queue *queue.Queue
- admin *admin.Admin
+ config *config.Config
+ logger *slog.Logger
+ db *db.Database
+ router *http.ServeMux
+ queue *queue.Queue
+ admin *admin.Admin
+ version string
}
// New creates a new App instance
@@ -48,16 +50,24 @@ func New(cfg *config.Config, logger *slog.Logger) (*App, error) {
// Initialize message queue
messageQueue := queue.New(logger)
+ // Get version information
+ version := ""
+ info, ok := debug.ReadBuildInfo()
+ if ok {
+ version = info.Main.Version
+ }
+
// Initialize admin interface
- adminInterface := admin.New(cfg, database)
+ adminInterface := admin.New(cfg, database, version)
return &App{
- config: cfg,
- logger: logger,
- db: database,
- router: router,
- queue: messageQueue,
- admin: adminInterface,
+ config: cfg,
+ logger: logger,
+ db: database,
+ router: router,
+ queue: messageQueue,
+ admin: adminInterface,
+ version: version,
}, nil
}