From 7662ae52c08c659f5aaf69f446822f48c3d0a831 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 16 Apr 2026 22:56:16 +0300 Subject: refactor(generator): load themes & shared HTML from embedded template files (task s4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the 12 theme HTML templates out of theme_*.go (~185KB of raw-string literals) and the shared navDefs/faviconHeadHTML fragments out of shared.go/favicon.go into separate .tmpl files under internal/generator/templates/{themes,shared}/. A new templates subpackage owns a //go:embed FS and exposes Theme(), Shared() and ThemeNames() helpers so the binary still ships fully self-contained. The hand-maintained themeRegistry map is replaced by on-startup enumeration of the embedded FS; getTheme/ListThemes now derive theme names from the template files themselves, and navDefs/faviconHeadHTML are loaded once at package init. Rendered output is byte-equivalent — all unit tests and integration tests pass, go vet is clean. Made-with: Cursor --- internal/generator/shared.go | 422 ++----------------------------------------- 1 file changed, 18 insertions(+), 404 deletions(-) (limited to 'internal/generator/shared.go') diff --git a/internal/generator/shared.go b/internal/generator/shared.go index 11dbeed..d0badb8 100644 --- a/internal/generator/shared.go +++ b/internal/generator/shared.go @@ -1,416 +1,30 @@ package generator -// navDefs is appended to every theme template when parsing. +import ( + "log" + + "codeberg.org/snonux/snonux/internal/generator/templates" +) + +// navDefs is the content of templates/shared/nav.tmpl loaded once at startup. // It defines named sub-templates shared across all themes: // - "splashGate" — synchronous script: first child of ; sets html.sno-splash-skip when // splash should not run (?splash=0, not index path, or Referer from same-site index/pageN). // - "navhints" — keyboard shortcut hint bar HTML -// - "navSharedCSSInner" — shared CSS (injected inside each theme’s