diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-01-19 09:54:42 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-01-19 09:54:42 -1000 |
| commit | a38abc90ee4fe00bf0fbdf897c5ef93e80e0c256 (patch) | |
| tree | 0936c38580482f9de52e8b1e8c207e8d11f3457b /internal/handlers/tabs.go | |
| parent | 2215aaa458b318edb16337ab56cf658117023eb4 (diff) | |
Refactor: Add cache key constants and configurable template path
Code quality improvements:
- Define CacheKey* constants in store package for type safety
- Add TemplateDir to config (default: web/templates, env: TEMPLATE_DIR)
- Update handlers to use store.CacheKey* instead of hardcoded strings
- Update NewTabsHandler to accept templateDir parameter
- Use filepath.Join for cross-platform template path construction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers/tabs.go')
| -rw-r--r-- | internal/handlers/tabs.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/handlers/tabs.go b/internal/handlers/tabs.go index 74dfbe8..ffdabb0 100644 --- a/internal/handlers/tabs.go +++ b/internal/handlers/tabs.go @@ -4,6 +4,7 @@ import ( "html/template" "log" "net/http" + "path/filepath" "sort" "strings" "time" @@ -31,15 +32,15 @@ type TabsHandler struct { } // NewTabsHandler creates a new TabsHandler instance -func NewTabsHandler(store *store.Store) *TabsHandler { +func NewTabsHandler(store *store.Store, templateDir string) *TabsHandler { // Parse templates including partials - tmpl, err := template.ParseGlob("web/templates/*.html") + tmpl, err := template.ParseGlob(filepath.Join(templateDir, "*.html")) if err != nil { log.Printf("Warning: failed to parse templates: %v", err) } // Also parse partials - tmpl, err = tmpl.ParseGlob("web/templates/partials/*.html") + tmpl, err = tmpl.ParseGlob(filepath.Join(templateDir, "partials", "*.html")) if err != nil { log.Printf("Warning: failed to parse partial templates: %v", err) } |
