- 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>
2.0 KiB
2.0 KiB
贡献指南 — Gitea 邮件模板
参与方式
添加新风格
- 使用工具脚手架:
cd tools && go run . create <风格名称>— 这会创建完整的目录结构和全部 11 种邮件类型的占位.tmpl文件 - 在
themes/<风格名称>/中编写每个.tmpl文件,应用独特的视觉设计 - 重新生成预览:
cd tools && go run . preview all(构建脚本会自动发现themes/下的所有主题目录并动态生成主题选择器) - 提交包含截图渲染效果的 PR
风格指南
- 每个风格必须包含全部 11 种模板类型
- 只使用 Gitea 内置模板函数
- 翻译键必须来自 Gitea 官方语言文件(
mail.*命名空间) - 不要在以下模板中使用
.DisplayName:collaborator、transfer、release、workflow_run、assigned、default - 面向 600px 宽度的邮件客户端设计
- 尽可能在 Gmail、Outlook、Apple Mail 中测试
报告 Bug
- 检查引用的 Go 模板变量是否存在
- 验证翻译键是否与 Gitea 语言文件匹配
- 确认
.DisplayName未在不支持的模板中使用 - 重新生成预览:
cd tools && go run . preview all - 提交 issue,注明风格名称、邮件类型及错误描述
改进文档
文档改进、预览截图、安装指南和翻译始终欢迎。
开发环境
无需构建工具或依赖。
本地预览
- 先生成预览数据:
cd tools && go run . preview all - 在浏览器中打开
preview/index.html - 在 Modern、Gmail、Outlook、Raw source 模式间切换验证效果
集成测试
将模板部署到 Gitea 实例,使用管理后台的测试邮件功能: Site Administration > Configuration > Mailer > Send Test Email
提交规范
style(<名称>):— 特定风格的模板变更preview:— 预览工具变更tools:— Go 构建脚本变更docs:— 文档和翻译fix:— Bug 修复project:— README、LICENSE、元文件
许可协议
参与贡献即表示您同意将您的贡献以 MIT 许可证授权。