refactor(tools): modularize CLI with urfave/cli/v2, externalise template metadata
- Split monolithic build-preview.go into modular packages: tools.go (entry), cli/ (list/create/delete/preview commands), config/ (JSON loading), preview/ (rendering engine, funcs, locale) - Extract all template metadata into data/templates_config.json as single source of truth — no hardcoded template data in Go - Replace hand-rolled CLI parsing with github.com/urfave/cli/v2 - Add sensible defaults for --folder (../themes) and --config (./data/templates_config.json) — most commands now run bare - Add type-coercing gt/lt/ge/le template funcs for JSON float64 - Fix AppUrl to gitea.com matching official template convention - rendered.js now exports __REGISTRY__ and __PARAMS__ alongside __RENDERED__ — preview/index.html reads all from single source - Cross-validate all 11 template data contexts against official Gitea source (services/mailer/*.go + templates/mail/*.tmpl) - Update all docs (README, AGENTS, CONTRIBUTING, 5 languages) to reflect new CLI workflow with create scaffolding command Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
77854ee0ed
commit
0bf982ffb9
30 files changed
+1274
-540
No files matched your search
@@ -85,16 +85,16 @@ A live preview tool is included to browse all styles and email types without dep
|
||||
First, generate the preview data (requires Go):
|
||||
|
||||
```bash
|
||||
go run ./tools/build-preview.go
|
||||
cd tools && go run . preview all
|
||||
```
|
||||
|
||||
Then open `preview/index.html` directly in a browser. No server required.
|
||||
|
||||
> `preview/rendered.js` is generated and git-ignored. Re-run the command after modifying templates.
|
||||
> `preview/rendered.js` is generated and git-ignored. Re-run `cd tools && go run . preview all` after modifying templates. Use `cd tools && go run .` to see all commands (list, create, delete, preview). Most flags have sensible defaults — just `go run . create <name>` or `go run . preview all` works out of the box.
|
||||
|
||||
### Features
|
||||
|
||||
- Theme switcher — toggle between all 5 visual styles
|
||||
- Theme switcher — toggle between all 10 visual styles
|
||||
- Template switcher — browse all 11 email types
|
||||
- Client simulation — Modern, Gmail (no `<style>`), Outlook Desktop, Raw source
|
||||
- Viewport toggle — Desktop (1386x780) / Mobile (390x780)
|
||||
@@ -112,8 +112,12 @@ gitea-mail-templates/
|
||||
├── preview/ # Live preview SPA
|
||||
│ ├── index.html # Style/template/client/viewport switcher
|
||||
│ └── rendered.js # Pre-rendered templates (generated by tools/)
|
||||
├── tools/ # Build tooling
|
||||
│ ├── build-preview.go # Go build script — renders all templates
|
||||
├── tools/ # Modular CLI tooling
|
||||
│ ├── tools.go # Main entry point
|
||||
│ ├── cli/ # CLI subcommands (list, create, delete, preview)
|
||||
│ ├── config/ # Config types and templates_config.json loading
|
||||
│ ├── data/ # templates_config.json — single source of truth
|
||||
│ ├── preview/ # Template rendering engine
|
||||
│ └── go.mod
|
||||
├── docs/ # Multi-language documentation
|
||||
├── AGENTS.md # AI agent guidance
|
||||
|
||||
Reference in new issue
Block a user