6.7 KiB
6.7 KiB
AGENTS.md — Gitea Mail Templates
Project Overview
A growing collection of email template themes for self-hosted Gitea instances. Each theme contains 11 Go html/template files covering all supported Gitea notification email types.
Repository Layout
themes/ # One directory per theme, with 11 .tmpl files each
aurora/ # Ethereal / Dreamlike
bloom/ # Creative / Startup (glassmorphism)
ember/ # Community / Open Source
heritage/ # Education / Research
horizon/ # Enterprise / Corporate
ink/ # Editorial / Publishing
mono/ # Minimal / Swiss design
neon/ # Cyberpunk / Gaming
terminal/ # Developers / Tech
terra/ # Nature / Sustainability
.../ # Additional themes can be added
tools/ # Go CLI tooling (modular; uses urfave/cli/v2)
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 for template metadata
preview/ # Template rendering engine (funcs, locale, engine)
go.mod # Go module (CLI dependency declared here)
preview/ # Browser-based live preview
index.html # SPA with style/template/client/viewport switching
rendered.js # Pre-rendered HTML (generated, ignored in source clones)
docs/ # Bilingual documentation (English + Simplified Chinese)
Working With Templates
Template Files
- All
.tmplfiles use Gohtml/templatesyntax - Must use only Gitea 28's built-in template functions:
AppUrl,DotEscape,QueryEscape,ShortSha,HTMLFormat,PathEscapeSegments,FormatByteSize - Must use only official Gitea translation keys (
mail.*namespace) - Never reference
.DisplayNamein templates where the data context lacks it (collaborator, transfer, release, workflow_run, assigned, default) - Each style must have all 11 template types
Adding a New Theme
- Scaffold the new theme:
cd tools && go run . create <name>— creates the full directory structure with placeholder.tmplfiles for all 11 email types - Write all 11
.tmplfiles with unique visual design - Run
cd tools && go run . preview allto regenerate preview data - Update README.md style gallery table
Preview System
preview/index.htmlloadspreview/rendered.js(pre-rendered by Go) and displays in iframes- Supports theme/template switching, view mode (Modern/Source), and viewport toggle (Desktop 1386x780 / Mobile 390x780)
- Keyboard navigation:
←→cycles focus between Theme/Template/View selects,↑↓selects within the focused dropdown,d/mtoggles viewport REGISTRYandPARAMSare auto-generated fromtemplates_config.json— no manual syncing needed- Static preview works via
file://after runninggo run . preview allin a source clone; the updated packaging workflow includes generated preview data and screenshots for future builds (v28.0.0 and older archives include neither) - Dev server (
go run . dev) — pure Go HTTP server with SSE live reload; watchesthemes/for.tmplchanges, re-renders in-process, and pushes reload events to the browser
Build Tool
tools/tools.gois the main entry point for the modular CLI- Subcommands:
list,create,delete,preview,dev - Template metadata lives in
tools/data/templates_config.json— the single source of truth tools/config/handles config loading and data flatteningtools/preview/implements the rendering engine (template funcs, locale, engine, markSafeHTML)tools/cli/implements CLI subcommands usinggithub.com/urfave/cli/v2tools/preview/server.gopure Go dev server with SSE live reload and in-process template re-rendering- Uses Go's native
html/templatepackage for template rendering
Versioning
- Release tags identify actual downloadable packages; the compatibility matrix distinguishes released tags from source-only fixes
- Current template release: v28.0.0.
- v28.0.0 was verified against Gitea 28.0.0. Gitea 28 replaces the mail-template
FileSizefunction withFormatByteSize; earlier template releases can fail on Gitea 28, and v28.0.0 is not a drop-in replacement for earlier mail contexts. Choose an archive from the per-version matrix inCOMPATIBILITY.md; v1.27.2 is a known partial fix for push notifications
- Latest upstream Gitea release: 28.1.0 [PENDING].
- When a new Gitea version appears, the tracker adds pending compatibility and history rows and updates marked version lines and the pending README badge. After verification, update that version's matrix row and README tested text/badge; keep unreleased fixes distinct from the published release
- Tag a new release (
vX.Y.Z) only when the template content itself changes. On the new Gitea host, do not assume tag pushes automatically build or upload archives; verify the Gitea workflow before relying on it - Before tagging, add
.github/release-notes/vX.Y.Z.md, rungo test ./...andgo run . preview allfromtools/. The release workflow packages the tag, publishes the reviewed notes, and then updatesRELEASEblocks onmainwhen the host supports those Actions and write permissions; otherwise build/upload and update the labels manually - Participating Markdown documents declare their blocks in a
DOC-TAGSJSON comment. Each block uses a paired opening<!-- SUBJECT:CONTENT -->and closing<!-- /SUBJECT:CONTENT -->comment; its body is the managed text.TRACKERhandles upstream-pending content,RELEASEhandles published-template labels, andTRACKER:LATEST-TESTED/TRACKER:LATEST-VERIFIEDare manual-only. Within a document, the first block for a subject/content pair wins
Commit Conventions
style(name):— template changes for a specific themepreview:— preview tooling changestools:— Go CLI/build tooling changesdocs:— documentation and translationsfix:— bug fixesproject:— README, LICENSE, AGENTS.md, metarefactor:— code restructuring (e.g. modularization)chore:— maintenance (config updates, build scripts)
Constraints
- No JavaScript framework dependencies — preview is vanilla JS
- The CLI uses
github.com/urfave/cli/v2; the preview server itself uses Go's standard HTTP library - Templates must remain compatible with Gitea's
html/templateexecution environment - Preview works with
file://protocol (no server needed)