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
@@ -4,12 +4,10 @@
|
||||
|
||||
### 添加新风格
|
||||
|
||||
1. 创建风格目录:`themes/<风格名称>/`
|
||||
2. 从现有风格复制目录结构
|
||||
3. 用独特的视觉设计实现全部 11 个 `.tmpl` 文件
|
||||
4. 重新生成预览:`go run ./tools/build-preview.go`(构建脚本会自动发现 `themes/` 下的所有主题目录)
|
||||
5. 在 `preview/index.html` 的 `<select id="sel-theme">` 中添加选项
|
||||
6. 提交包含截图渲染效果的 PR
|
||||
1. 使用工具脚手架:`cd tools && go run . create <风格名称>` — 这会创建完整的目录结构和全部 11 种邮件类型的占位 `.tmpl` 文件
|
||||
2. 在 `themes/<风格名称>/` 中编写每个 `.tmpl` 文件,应用独特的视觉设计
|
||||
3. 重新生成预览:`cd tools && go run . preview all`(构建脚本会自动发现 `themes/` 下的所有主题目录并动态生成主题选择器)
|
||||
4. 提交包含截图渲染效果的 PR
|
||||
|
||||
### 风格指南
|
||||
|
||||
@@ -25,7 +23,7 @@
|
||||
1. 检查引用的 Go 模板变量是否存在
|
||||
2. 验证翻译键是否与 Gitea 语言文件匹配
|
||||
3. 确认 `.DisplayName` 未在不支持的模板中使用
|
||||
4. 重新生成预览:`go run ./tools/build-preview.go`
|
||||
4. 重新生成预览:`cd tools && go run . preview all`
|
||||
5. 提交 issue,注明风格名称、邮件类型及错误描述
|
||||
|
||||
### 改进文档
|
||||
@@ -40,7 +38,7 @@
|
||||
|
||||
### 本地预览
|
||||
|
||||
1. 先生成预览数据:`go run ./tools/build-preview.go`
|
||||
1. 先生成预览数据:`cd tools && go run . preview all`
|
||||
2. 在浏览器中打开 `preview/index.html`
|
||||
3. 在 Modern、Gmail、Outlook、Raw source 模式间切换验证效果
|
||||
|
||||
|
||||
Reference in new issue
Block a user