diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-09 20:44:58 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-09 20:44:58 +0300 |
| commit | 3e61d09873065f5342efc414ee3ea0d5fdc4c767 (patch) | |
| tree | 7d0ac51cfb41b4774db6292deeb0cc3dce93cf07 /internal/generator/themes.go | |
| parent | 51f95f88ca78471a50b3fc62dbcea8edb609dc80 (diff) | |
add snonux static microblog generator
Full Go implementation with:
- txt/md/image/audio input processing, URL auto-linking in .txt files
- Paginated HTML output with Atom feed
- 11 visual themes: neon, terminal, synthwave, minimal, brutalist, paper,
aurora, matrix, ocean, retro, glass (selectable via --theme flag)
- Keyboard navigation (j/k/arrows, Enter modal, h/l page nav)
- Shared nav templates (navhints, navmodal, navscript) across all themes
- Magefile build automation; integration test suite covering all themes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/generator/themes.go')
| -rw-r--r-- | internal/generator/themes.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/generator/themes.go b/internal/generator/themes.go new file mode 100644 index 0000000..8de6193 --- /dev/null +++ b/internal/generator/themes.go @@ -0,0 +1,44 @@ +package generator + +// themeRegistry maps theme names to their HTML template strings. +// Each template must use {{template "navhints" .}}, {{template "navmodal" .}}, +// and {{template "navscript" .}} — these are defined in shared.go (navDefs). +var themeRegistry = map[string]string{ + "neon": neonTemplate, + "terminal": terminalTemplate, + "synthwave": synthwaveTemplate, + "minimal": minimalTemplate, + "brutalist": brutalistTemplate, + "paper": paperTemplate, + "aurora": auroraTemplate, + "matrix": matrixTemplate, + "ocean": oceanTemplate, + "retro": retroTemplate, + "glass": glassTemplate, +} + +// getTheme returns the HTML template string for the given theme name. +// Falls back to the neon theme if the name is unknown. +func getTheme(name string) string { + if t, ok := themeRegistry[name]; ok { + return t + } + return neonTemplate +} + +// ListThemes returns a sorted list of all available theme names. +func ListThemes() []string { + names := make([]string, 0, len(themeRegistry)) + for k := range themeRegistry { + names = append(names, k) + } + // Sort for deterministic output in --help text. + for i := 0; i < len(names); i++ { + for j := i + 1; j < len(names); j++ { + if names[i] > names[j] { + names[i], names[j] = names[j], names[i] + } + } + } + return names +} |
