71 Commits
Author SHA1 Message Date
KenanZhu d8a714b2b5 feat(preview): cross-browser scrollbar, keyboard nav, dev-mode client simulation, docs overhaul
preview/index.html:
- Fix scrollbar CSS: scoped webkit pseudo-elements + standards-track fallback, removed deprecated overflow:overlay
- Keyboard navigation: arrows cycle focus between Theme/Template/Client selects, up/down select within focused dropdown, d/m toggle viewport
- Dev/static mode detection: delayed static warning only when WebSocket absent, WebSocket errors only on disconnect (not on initial fail)
- iframe sandbox: removed static sandbox attr, applied dynamically only in dev mode (file: protocol rejects sandboxed srcdoc)
- Loading fix: removed double-toggle between init and render(); added 5s safety timeout
- Transform clean: returns HTML as-is; CSS stripping moved to server-side
- Dev disclaimer: blue info banner shown on WebSocket connect

tools/server/inliner.mjs:
- Added stripGmail() / stripOutlook() — server-side CSS property stripping for email client simulation

tools/server/server.mjs:
- Fixed WebSocket upgrade: use app.listen() instead of createServer(app).listen()
- Juice post-processing now generates three rendered.js variants (modern/gmail/outlook)
- Initial startup runs juice-only pass (avoids duplicate Go compilation)

docs/ (all 6 languages — en, zh-CN, zh-TW, ja, ko, ru):
- Image size limits: max 50KiB, recommended 10-20KiB
- Dev disclaimer: simulation cannot 100% reproduce every client
- Changed 'accurate' to 'relatively accurate' across all static-mode warnings
- Converted all plain blockquotes to GitHub admonitions ([!WARNING] / [!NOTE])
2026-06-04 16:01:42 +08:00
KenanZhu 4bc9a0667f change(*): update preview index.html and relevant docs files 2026-06-04 15:35:35 +08:00
KenanZhuandClaude Opus 4.8 b09e2f4ef0 style(preview): theme-matching scrollbar colour
Replaced neutral-gray scrollbar with muted-steel-blue
rgba(107,125,153,...) — the page's --muted colour at varying
opacities. Thumb blends with the navy-blue background palette
(#0b1120 / #151d2e / #1e2d45) rather than standing out as
an unrelated grey element.

Page-level + iframe-injected scrollbar: unified palette.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:52:14 +08:00
KenanZhuandClaude Opus 4.8 69f2bbdda1 style(preview): double panel width, fix Chrome/Edge white scrollbar
- Panel width: 270px → 540px (2x) for better parameter display
- Scrollbar fix for Chrome/Edge:
  - Replaced backdrop-filter (not supported on scrollbar pseudo-
    elements) with solid background-color
  - Added !important to override Windows Fluent overlay scrollbar
  - Used standards-track scrollbar-color on :root (Chrome 121+)
  - Neutral gray rgba(128,128,128,.30) — visible on any background
  - Hover: rgba(128,128,128,.45)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:47:43 +08:00
KenanZhuandClaude Opus 4.8 87d1603187 style(preview): cross-browser immersive scrollbar support
Page-level scrollbar:
- WebKit: ::-webkit-scrollbar with 3px width, transparent track,
  6% white thumb → 18% on hover
- Firefox: scrollbar-width:thin + scrollbar-color on #preview-area, #panel
- Legacy Edge/IE: -ms-overflow-style: -ms-autohiding-scrollbar
- Chrome 108+: overflow:overlay via @supports (scrollbar floats,
  no layout shift)

Iframe content (email preview):
- Same cross-browser treatment injected into every rendered template
- Dark email themes get dark scrollbar (rgba(0,0,0,.08))
- Light email themes also covered (6% black is subtle on any bg)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:38:55 +08:00
KenanZhuandClaude Opus 4.8 dc602a7dde fix(preview): stop loader re-appearing when rendered.js is missing
When rendered is null, render() was setting loading.style.display='flex'
before returning — overriding the hide already done in the init error
branch. Now render() silently returns, leaving init to handle the error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:36:42 +08:00
KenanZhuandClaude Opus 4.8 dc2d9de2a4 style(preview): ultra-thin immersive scrollbars
- Global scrollbar: 3px wide, transparent track, 6% white thumb
  that brightens to 15% on hover. Firefox thin scrollbar via
  scrollbar-width:thin. Practically invisible unless needed.
- Iframe content: inject matching scrollbar CSS into every
  rendered email template so the email preview itself has
  the same subtle scrollbar treatment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:34:08 +08:00
KenanZhuandClaude Opus 4.8 39af7f7729 fix(preview): restore truncated HTML closing tags
The _patch.cjs script accidentally stripped </script></body></html>
when replacing the WebSocket section, causing the inline JavaScript
to never terminate — the browser parsed everything as script content
and all functions were undefined.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:29:00 +08:00
KenanZhuandClaude Opus 4.8 fa6c7032dd fix(preview): ship rendered.js, hide loader on missing file
- Remove preview/rendered.js from .gitignore so the project works
  out-of-the-box after clone (no Go required for static preview).
- Hide loading spinner when rendered.js is not found; previously
  the spinner stayed visible forever because render() returned
  early when 'rendered' was null.
- Regenerate rendered.js with all current template fixes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:21:46 +08:00
KenanZhuandClaude Opus 4.8 fe77d52b5b refactor(preview): unified message notification component
Replace ad-hoc #static-notice with reusable .message system:
- .message — base notification bar, spans full width below navbar
- .message-warn — amber/yellow warning (static mode notice)
- .message-error — red error (missing rendered.js, dev disconnect)
- showMessage(html, type) / clearMessages() helpers
- Messages stack vertically in #messages container
- Static notice auto-shown on page load; cleared on dev ws connect
- Dev reconnect/disconnect events shown as error messages

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:17:16 +08:00
KenanZhuandClaude Opus 4.8 dc07b54625 fix(preview): simplify transform, fix static-notice display
- transform(): only Raw mode does HTML escaping. Modern, Gmail, Outlook
  all show the same rendered HTML — in dev mode Juice handles CSS
  inlining server-side; in static mode the notice bar warns.
- static-notice: change display from '' to 'block' to properly
  override CSS rule #static-notice{display:none}. The empty string
  did not override the stylesheet rule in static file:// mode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 14:09:27 +08:00
KenanZhuandClaude Opus 4.8 7724b4806c docs: update all docs with dev server, live reload, Juice inlining
- README.md: restructure Preview section into Static + Dev modes
  with feature comparison table; mention juice inlining and live reload
- CONTRIBUTING.md: update Development Setup with Go/Node.js
  requirements, static vs dev preview workflows, Juice reference
- AGENTS.md: add dev command to subcommand list, document
  tools/server/ directory, update Build Tool section
- docs/CONTRIBUTING.*.md (5 languages): add dev server section,
  Node.js requirement, live reload description
- docs/README.*.md (5 languages): add dev mode to Preview section
- docs/images/README.md: update capture instructions for dev server

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 13:58:15 +08:00
KenanZhuandClaude Opus 4.8 13c49d2087 fix(preview): static-notice, simplify transform, HTML-safe rendering
- Add static-notice banner: 'Gmail/Outlook simulation is approximate.
  Use dev mode for accurate rendering.' Hidden in dev mode via
  WebSocket try/catch, auto-shown in file:// mode on WS failure.
- Simplify transform(): Gmail/Outlook modes now return same HTML as
  Modern — the dev server with Juice provides actual client sim.
- Add markSafeHTML(): converts RenderedNote/Body/RenderedContent
  from plain string to template.HTML so markdown-rendered HTML
  content is not escaped by Go's html/template engine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 13:51:43 +08:00
KenanZhuandClaude Opus 4.8 a0cd5e32f4 fix(templates): add inline colors for dark-background themes, set CanReply=false
- aurora, neon, terminal: add explicit inline color styles to bare
  text elements (locale.Tr calls, h4 headings, download labels)
  that were invisible in clients stripping <style> blocks (Gmail).
  33 files across 3 dark-background themes.
- CanReply: changed from true to false in mock data — matches
  typical Gitea deployment where IncomingEmail is disabled by
  default. Template syntax kept identical to official Gitea.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 13:51:10 +08:00
KenanZhuandClaude Opus 4.8 05d76a90af feat(dev): add live-reload dev server with Juice CSS inlining
- tools/server/: Node.js dev server (Express + WebSocket + fs.watch)
  Watches themes/ for .tmpl changes, rebuilds via Go preview command,
  applies Juice CSS inlining for email client compatibility, pushes
  live reload to browser via WebSocket.
- tools/cli/dev.go: 'go run . dev' subcommand — starts Node.js server
  with automatic npm install, initial preview generation, and
  Ctrl+C graceful shutdown.
- tools/tools.go: register dev command in CLI app.
- .gitignore: add node_modules exclusion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 13:50:57 +08:00
KenanZhuandClaude Opus 4.8 0bf982ffb9 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>
2026-06-04 12:26:44 +08:00
KenanZhuandClaude Opus 4.8 77854ee0ed docs(contributing): remove outdated step — themes are auto-discovered by build script
The build-preview.go now uses discoverThemes() to find all theme directories
under themes/ automatically. The manual step of adding themes to a slice is
no longer needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:36:50 +08:00
KenanZhuandClaude Opus 4.8 d9e6873f49 fix(aurora): add card-body CSS to prevent dark text/links on dark background
Aurora is a dark theme (bg #0a0815, card rgba(25,20,50,0.8)) but raw HTML
elements like h2/h4/li/a inside the card had no inline color — rendering
as browser-default black text and blue links, unreadable on dark backgrounds.

Fix: add .card-body CSS rules to all 11 Aurora templates covering h1-h6,
links, and li elements. Also add .aurora-content wrapper for user-generated
HTML (Release.RenderedNote, .Body, .RenderedContent) with full color
coverage for code, pre, blockquote, hr, img.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:34:32 +08:00
KenanZhuandClaude Opus 4.8 86bb2538bb fix(templates): cross-validate against official Gitea mail templates
- Fix INK theme: replace .ActiveCodeLives with correct field, remove from non-auth contexts (8 files)
- Fix hardcoded button text: use locale key mail.view_it_on in ember, heritage, ink, mono, terminal, terra (30+ files)
- Add missing {{if .CanReply}}mail.reply{{end}} block to all 10 themes default.tmpl
- Add missing mail.release.note locale label to all 10 themes release.tmpl
- Add missing mail.team_invite.text_3 to ink and terra team_invite.tmpl
- Add missing blockquote CSS to aurora, ink, mono, neon, terra default.tmpl

Verified: all 110 templates compile successfully with Go build-preview.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:18:40 +08:00
KenanZhuandClaude Opus 4.8 493def1ab8 chore(docs): update directory tree to reflect 10 visual styles
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 18:34:12 +08:00
KenanZhuandClaude Opus 4.8 a2742887e8 chore(init): scaffold Gitea mail templates — 110 templates, 10 visual styles, drop-in deployment
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 18:10:22 +08:00