Compare commits
8
Commits
6733e81356
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16b3141e09 | ||
|
|
85ee9dbdbf | ||
|
|
d99c5d1dc5 | ||
|
|
b8089e8a7e | ||
|
|
cb9382ade4 | ||
|
|
8ccb5ac443 | ||
|
|
3d7cf17fb1 | ||
|
|
bcf1b87e82 |
No files matched your search
@@ -21,9 +21,6 @@ REQUIRED_FILES = (
|
|||||||
"docs/README.zh-CN.md",
|
"docs/README.zh-CN.md",
|
||||||
"docs/CONTRIBUTING.zh-CN.md",
|
"docs/CONTRIBUTING.zh-CN.md",
|
||||||
"preview/index.html",
|
"preview/index.html",
|
||||||
"preview/lib/html2canvas/html2canvas.min.js",
|
|
||||||
"preview/lib/html2canvas/LICENSE",
|
|
||||||
"preview/lib/html2canvas/README.md",
|
|
||||||
)
|
)
|
||||||
OPTIONAL_ROOT_DOCUMENTS = ("AGENTS.md", "THIRD_PARTY_NOTICES.md")
|
OPTIONAL_ROOT_DOCUMENTS = ("AGENTS.md", "THIRD_PARTY_NOTICES.md")
|
||||||
DOCUMENTATION_DIRECTORIES = ("docs", ".github/release-notes")
|
DOCUMENTATION_DIRECTORIES = ("docs", ".github/release-notes")
|
||||||
|
|||||||
@@ -30,9 +30,6 @@ class PackagingTests(unittest.TestCase):
|
|||||||
"docs/README.zh-CN.md",
|
"docs/README.zh-CN.md",
|
||||||
"docs/CONTRIBUTING.zh-CN.md",
|
"docs/CONTRIBUTING.zh-CN.md",
|
||||||
"preview/index.html",
|
"preview/index.html",
|
||||||
"preview/lib/html2canvas/html2canvas.min.js",
|
|
||||||
"preview/lib/html2canvas/LICENSE",
|
|
||||||
"preview/lib/html2canvas/README.md",
|
|
||||||
"docs/images/README.md",
|
"docs/images/README.md",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -133,15 +130,8 @@ class PackagingTests(unittest.TestCase):
|
|||||||
self.assertEqual(expected_members, zipped)
|
self.assertEqual(expected_members, zipped)
|
||||||
self.assertEqual(expected_members, tarred)
|
self.assertEqual(expected_members, tarred)
|
||||||
self.assertIn(prefix + "themes/demo/mail/base/head.tmpl", zipped)
|
self.assertIn(prefix + "themes/demo/mail/base/head.tmpl", zipped)
|
||||||
for name in ("html2canvas.min.js", "LICENSE", "README.md"):
|
|
||||||
self.assertIn(prefix + "preview/lib/html2canvas/" + name, zipped)
|
|
||||||
self.assertFalse(any("stale" in name or "/build/" in name for name in zipped))
|
self.assertFalse(any("stale" in name or "/build/" in name for name in zipped))
|
||||||
|
|
||||||
def test_missing_screenshot_library_is_rejected(self):
|
|
||||||
(self.root / "preview/lib/html2canvas/html2canvas.min.js").unlink()
|
|
||||||
with self.assertRaisesRegex(ValueError, "Expected regular file"):
|
|
||||||
PACKER.collect(self.root, self.VERSION)
|
|
||||||
|
|
||||||
def test_existing_archives_are_not_overwritten(self):
|
def test_existing_archives_are_not_overwritten(self):
|
||||||
PACKER.package(self.root, self.VERSION, self.output)
|
PACKER.package(self.root, self.VERSION, self.output)
|
||||||
original_archives = {
|
original_archives = {
|
||||||
|
|||||||
+20
-15
@@ -9,26 +9,27 @@ This document describes the compatibility of Gitea Mail Templates with different
|
|||||||
Select the recommended template release for the Gitea version you run. `[PASS]` identifies a combination recorded as compatible; `[PENDING]` means verification is incomplete.
|
Select the recommended template release for the Gitea version you run. `[PASS]` identifies a combination recorded as compatible; `[PENDING]` means verification is incomplete.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Historical entries reflect the project's existing compatibility assessments. They do not mean that every patch version is retested for each release.
|
> This project generally aligns template version numbers with Gitea version numbers. However, not every Gitea release introduces mail template changes, so the compatibility matrix recommends template versions based on compatibility assessments; their version numbers may differ from the Gitea version you run. Historical entries reflect existing assessments and do not imply that every listed Gitea version is retested for each template release.
|
||||||
|
|
||||||
| Gitea version | Recommended template release | Status | Notes |
|
| Gitea version | Recommended template release | Status | Notes |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| 28.1.0 | — | [PENDING] | Compatibility verification pending |
|
| 28.2.0 | [**v28.1.0**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.1.0) | [PASS] | Mail templates, template function registrations and mail translation keys are unchanged from 28.1.0 |
|
||||||
| 28.0.0 | **v28.0.0** | [PASS] | Gitea replaced the mail function `FileSize` with `FormatByteSize` |
|
| 28.1.0 | [**v28.1.0**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.1.0) | [PASS] | - |
|
||||||
| 1.27.3 | **v1.27.3** | [PASS] | Pull request push notification commit links fixed in every theme |
|
| 28.0.0 | [**v28.1.0**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.1.0) | [PASS] | Gitea replaced the mail function `FileSize` with `FormatByteSize` |
|
||||||
| 1.27.2 | **v1.27.3** | [PASS] | The matching v1.27.2 template release has push notification defects in Bloom, Ember and Heritage |
|
| 1.27.3 | [**v1.27.3**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) | [PASS] | Pull request push notification commit links fixed in every theme |
|
||||||
| 1.27.1 | **v1.27.3** | [PASS] | Older v1.0.x templates use obsolete push commit fields |
|
| 1.27.2 | [**v1.27.3**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) | [PASS] | The matching v1.27.2 template release has push notification defects in Bloom, Ember and Heritage |
|
||||||
|
| 1.27.1 | [**v1.27.3**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) | [PASS] | Older v1.0.x templates use obsolete push commit fields |
|
||||||
| 1.27.0 | — | [PENDING] | Gitea uses a new commit data structure; v1.27.3 may be compatible but has not been verified against this version |
|
| 1.27.0 | — | [PENDING] | Gitea uses a new commit data structure; v1.27.3 may be compatible but has not been verified against this version |
|
||||||
| 1.26.4 | **v1.0.1** | [PASS] | — |
|
| 1.26.4 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.3 | **v1.0.1** | [PASS] | — |
|
| 1.26.3 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.2 | **v1.0.1** | [PASS] | — |
|
| 1.26.2 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.1 | **v1.0.1** | [PASS] | — |
|
| 1.26.1 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.0 | **v1.0.1** | [PASS] | — |
|
| 1.26.0 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.25.5 | **v1.0.1** | [PASS] | — |
|
| 1.25.5 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.25.0 | **v1.0.1** | [PASS] | — |
|
| 1.25.0 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Gitea 1.24.x and earlier use a different mail template layout and are `[UNSUPPORTED]`; Gitea Mail Templates no longer provides separate support for them. The v1.0.0 template tag has been superseded by v1.0.1 and is no longer recommended separately.
|
> Gitea 1.24.x and earlier use a different mail template layout and are `[UNSUPPORTED]`; Gitea Mail Templates no longer provides separate support for them.
|
||||||
|
|
||||||
## Gitea Version History — Mail Template Impact
|
## Gitea Version History — Mail Template Impact
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ This table describes changes in **Gitea**, not fixes in this template repository
|
|||||||
|
|
||||||
| Gitea | Release date | Mail template changes | Impact |
|
| Gitea | Release date | Mail template changes | Impact |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| **28.1.0** | 2026-10-06 | [PENDING] | [PENDING] |
|
| **28.2.0** | 2026-10-18 | No template interface changes | Custom-watch notification recipient rules and incoming reply token validation changed; existing templates are unaffected |
|
||||||
|
| **28.1.0** | 2026-10-06 | None | None |
|
||||||
| **28.0.0** | 2026-09-29 | Mail function `FileSize` renamed to `FormatByteSize` ([PR](https://github.com/go-gitea/gitea/pull/39083)) | **Breaking change:** old release attachment templates fail |
|
| **28.0.0** | 2026-09-29 | Mail function `FileSize` renamed to `FormatByteSize` ([PR](https://github.com/go-gitea/gitea/pull/39083)) | **Breaking change:** old release attachment templates fail |
|
||||||
| | | Introduced `templates/mail/base/` ([PR](https://github.com/go-gitea/gitea/pull/38396)) | **Breaking change:** older Gitea versions cannot directly use the new mail templates |
|
| | | Introduced `templates/mail/base/` ([PR](https://github.com/go-gitea/gitea/pull/38396)) | **Breaking change:** older Gitea versions cannot directly use the new mail templates |
|
||||||
| **1.27.3** | 2026-08-29 | None | None |
|
| **1.27.3** | 2026-08-29 | None | None |
|
||||||
@@ -54,6 +56,9 @@ This table describes changes in **Gitea**, not fixes in this template repository
|
|||||||
|
|
||||||
## Template Variable Reference
|
## Template Variable Reference
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Mail templates, context construction, template functions and translation keys were checked against the [Gitea 28.1.0 to 28.2.0 source diff](https://github.com/go-gitea/gitea/compare/v28.1.0...v28.2.0). Version 28.2.0 changes [email notification rules for custom watches](https://github.com/go-gitea/gitea/pull/39837) and [incoming email token validation](https://github.com/go-gitea/gitea/pull/39841), without changing the variables, functions or translation keys required by existing mail templates. Source build inputs are locked to v28.2.0; the published v28.1.0 templates remain usable.
|
||||||
|
|
||||||
Official templates define the context for each mail type. For specific mail templates, functions and variables used during development, refer to the official mail template documentation [1](#notes).
|
Official templates define the context for each mail type. For specific mail templates, functions and variables used during development, refer to the official mail template documentation [1](#notes).
|
||||||
|
|
||||||
## Translation Keys
|
## Translation Keys
|
||||||
|
|||||||
+288
-123
@@ -1,12 +1,13 @@
|
|||||||
# Contributing to Gitea Mail Templates
|
# Contributing
|
||||||
|
---
|
||||||
|
|
||||||
[简体中文](docs/CONTRIBUTING.zh-CN.md)
|
[简体中文](docs/CONTRIBUTING.zh-CN.md)
|
||||||
|
|
||||||
Contributions to themes, tooling, tests, documentation and translations are welcome. This guide covers the current source architecture; installation and release selection are described in the [README](README.md#installation).
|
Contributions to themes, tools, documentation and translations are welcome. This guide covers the development environment, command-line tools and contribution workflow. For template installation and release selection, see the [README](README.md#installation) and [compatibility matrix](COMPATIBILITY.md#compatibility-matrix).
|
||||||
|
|
||||||
## Local Development
|
## Local Development
|
||||||
|
|
||||||
Use **Go 1.24 or later**. From the repository root, prepare the dependencies and locked official inputs, then run the checks and generate the preview:
|
Use **Go 1.24 or later**. From the repository root, prepare the dependencies and locked official files, run the tests and generate the preview:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd tools
|
cd tools
|
||||||
@@ -16,35 +17,123 @@ go test ./...
|
|||||||
go run . preview all
|
go run . preview all
|
||||||
```
|
```
|
||||||
|
|
||||||
Open `preview/index.html` in a browser, or run `go run . dev` from `tools/` and visit [http://127.0.0.1:3456](http://127.0.0.1:3456) for live reload. The development server watches themes, the framework, the lock/cache and preview fixtures.
|
Then open [preview/index.html](preview/index.html) in a browser, or run `go run . dev` for live preview. The validation and packaging workflows use Python 3.11.
|
||||||
|
|
||||||
The CLI uses urfave/cli and the x/net HTML parser. Python 3.11 or later is used by the documentation and packaging checks.
|
The project is organized into a shared framework, theme styles and build tools. Official templates provide notification content, conditions, subjects and links. The shared framework handles presentation, while theme metadata and CSS select layouts and define styles. See the [README](README.md#project-directory-structure) for the directory layout.
|
||||||
|
|
||||||
### Common Commands
|
> [!NOTE]
|
||||||
|
> Downloaded official files, generated templates and preview data are not tracked in version control. Submit the relevant source files, tests and documentation; do not include `build/`, `dist/` or generated preview data.
|
||||||
|
|
||||||
Run these commands from `tools/`. Place flags before positional arguments.
|
## Development Tools
|
||||||
|
|
||||||
| Command | Result |
|
The CLI prepares official files, manages themes, builds templates and generates previews.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> Run all commands below from `tools/`. Place options before positional arguments. In the examples, `my-theme` is a theme name; quote paths containing spaces.
|
||||||
|
|
||||||
|
| Command | Purpose |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `go run . list` | List available themes |
|
| `upstream` | Prepare, synchronize or verify locked official build inputs |
|
||||||
| `go run . create my-theme` | Create theme metadata and CSS |
|
| `build` | Generate installable themes from official inputs and shared controls |
|
||||||
| `go run . build my-theme` | Generate one theme's installable templates |
|
| `list` | List available themes and their metadata |
|
||||||
| `go run . build all` | Generate every theme |
|
| `create` | Create theme CSS and metadata for the shared framework |
|
||||||
| `go run . preview all` | Build every theme and render all official languages |
|
| `delete` | Delete one or more theme source directories |
|
||||||
| `go run . dev` | Start the development server on port 3456 |
|
| `preview` | Pre-render mail templates to generate preview and test data |
|
||||||
| `go run . dev --port 3457` | Use a different local port |
|
| `dev` | Start a live-reload development server with SSE browser refresh |
|
||||||
| `go run . delete my-theme` | Remove the named theme's source directory |
|
| `help`, `h` | Show the command list or help for a specific command |
|
||||||
|
|
||||||
`build` writes to `build/themes/<name>/mail/` and records file and source hashes in `build.json`. `preview` also builds the templates, then writes `preview/rendered.js` and `preview/rendered/<locale>.js`. These generated files and the downloaded inputs are ignored by Git. Keep them out of contributions.
|
### upstream
|
||||||
|
|
||||||
## Adding a Theme
|
`upstream` manages the official files pinned by `gitea.lock.json`, including mail templates, locale files, the icon, license and reviewed adapter reference sources. Downloaded files are stored in `build/upstream/`.
|
||||||
|
|
||||||
1. Run `go run . create my-theme` from `tools/`.
|
| Subcommand | Behavior |
|
||||||
2. Edit `themes/my-theme/theme.json` and `theme.css`.
|
|---|---|
|
||||||
3. Run `go test ./...` and `go run . preview all` from `tools/`.
|
| `prepare` | Read the root lock file. Download and verify inputs if the cache is absent, or verify an existing cache before use. Does not modify the root lock file. |
|
||||||
4. Check desktop and mobile layouts in English, Simplified Chinese and at least one other official language. Include screenshots with the pull request.
|
| `sync --tag <TAG>` | Download the specified stable version's official files, verify them, then replace the cache and update the root lock file. |
|
||||||
|
| `verify` | Verify the existing cache against the root lock file, offline and read-only. |
|
||||||
|
|
||||||
Theme names start with a lowercase letter and may contain lowercase letters, digits and hyphens. A theme directory contains only `theme.json` and `theme.css`.
|
To prepare inputs for the first time or check them independently, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . upstream prepare
|
||||||
|
go run . upstream verify
|
||||||
|
```
|
||||||
|
|
||||||
|
All three subcommands support `--root`, which defaults to `..` relative to the current working directory. For example:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
go run . upstream verify --root "C:\Projects\GiteaMailTemplates"
|
||||||
|
```
|
||||||
|
|
||||||
|
The root lock file records the Gitea tag, its commit and file SHA-256 hashes. `verify` checks file hashes, reviewed adapter reference sources and English translation keys referenced by official templates. Missing keys in other languages produce warnings and fall back to English in the preview. Building and rendering also check framework translation keys and action-link anchors; cache verification does not replace those checks.
|
||||||
|
|
||||||
|
#### Updating the Official Version
|
||||||
|
|
||||||
|
Use `sync` only when reviewing a new official version. For example, to explicitly synchronize to `v28.2.0`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . upstream sync --tag v28.2.0
|
||||||
|
go run . upstream verify
|
||||||
|
go test ./...
|
||||||
|
go run . preview all
|
||||||
|
```
|
||||||
|
|
||||||
|
Tags must use the `vX.Y.Z` format and identify a stable release of Gitea 28 or later. `latest`, prerelease tags and older version tags are not supported. `sync` resolves tags through `api.github.com` and downloads files from `raw.githubusercontent.com`; it does not accept a local Gitea clone or an authentication token option.
|
||||||
|
|
||||||
|
After synchronization, review the lock file diff, adjust adapter logic and preview data as needed, and update compatibility records after validation. Synchronization does not automatically update documentation, release tags or compatibility conclusions.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> When adapter reference sources change, review the affected behavior before updating their hashes. Do not change hashes simply to bypass the checks.
|
||||||
|
|
||||||
|
Network or validation errors before cache replacement leave existing files unchanged. Cache replacement and root lock file writing are separate operations; if a filesystem error interrupts the process, check that both agree before retrying. Stop `dev` before updating inputs to avoid concurrent processes writing to the cache.
|
||||||
|
|
||||||
|
### build
|
||||||
|
|
||||||
|
`build` generates installable mail templates from locked official files, the shared framework and theme sources. Specify one or more themes, or use `all` to build every theme:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . build aurora
|
||||||
|
go run . build aurora bloom
|
||||||
|
go run . build all
|
||||||
|
```
|
||||||
|
|
||||||
|
| Option | Default | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `--folder` | `../themes` | Theme source directory; its parent is used as the project root |
|
||||||
|
|
||||||
|
When using another project path, that project's root must also provide the lock file and shared framework:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
go run . build --folder "C:\Projects\GiteaMailTemplates\themes" aurora
|
||||||
|
```
|
||||||
|
|
||||||
|
Output is written to `build/themes/<name>/mail/`, with build provenance and generated file hashes recorded in the adjacent `build.json`. Rebuilding updates the selected themes and removes their obsolete templates; it does not clean unselected themes. Building does not deploy templates. See the [README](README.md#install-a-theme) for installation.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> To change templates, edit theme sources, the shared framework or build adapter logic. Direct edits to generated `.tmpl` files are overwritten by subsequent builds and cause packaging provenance checks to fail.
|
||||||
|
|
||||||
|
### list
|
||||||
|
|
||||||
|
`list` displays theme names, modes and short descriptions, sorted by name:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . list
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `--folder` to select a theme directory; the default is `../themes`. The command validates theme metadata and styles without downloading official files or generating templates. Fix any reported theme-format errors first.
|
||||||
|
|
||||||
|
### create
|
||||||
|
|
||||||
|
`create` creates `theme.json` and `theme.css` for a new theme and supports creating multiple themes at once:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . create my-theme
|
||||||
|
go run . create first-theme second-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `--folder` to select the theme source directory; the default is `../themes`. The command does not overwrite existing directories. Theme names start with a lowercase letter and contain only lowercase letters, digits and hyphens. Avoid `all`, because build and preview commands treat it as the selector for every theme.
|
||||||
|
|
||||||
|
Edit the generated metadata and CSS to describe and style the theme. For example:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -55,76 +144,131 @@ Theme names start with a lowercase letter and may contain lowercase letters, dig
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| Mode | Generated presentation |
|
`name` must match the directory name. Theme directories contain only these two source files, without copies of official mail templates or translations.
|
||||||
|
|
||||||
|
| Mode | Presentation structure |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `framed` | Shared controls and a framework layout, styled with the theme's CSS. New themes use this mode with the `standard` layout. |
|
| `framed` | Shared controls and a layout, styled with theme CSS. New themes default to this mode and the `standard` layout. |
|
||||||
| `shared` | CSS in the official head partial and the official footer partial; no additional framework controls or per-mail overrides. |
|
| `shared` | CSS is added to the official head partial, and the official footer partial is retained. No framework controls or per-mail template overrides are added. |
|
||||||
|
|
||||||
### Shared Framework
|
A `framed` theme can use `layout` to select a preset from `framework/layouts/`. Headers, action buttons, fallback links, sidebars and footers live in `framework/mail/base/`. Structural changes shared by multiple themes belong in the framework; adaptation between official content and controls is handled in `tools/builder/framework.go`.
|
||||||
|
|
||||||
Headers, action buttons, fallback links, sidebars and footers live in `framework/mail/base/`. Layout presets live in `framework/layouts/`; the optional `layout` field selects a preset for framed themes. Colors, fonts and spacing belong in theme CSS.
|
Theme CSS uses existing classes such as `email-heading`, `email-text` and `email-subtext` to distinguish headings, body text and supporting text. Preserve official notification wording, translation keys, variables and functional links. Do not generate wording or hide notification content through CSS. The style validator rejects template expressions, external resource references and unsupported hiding rules.
|
||||||
|
|
||||||
`tools/builder/framework.go` adapts official action values and translation keys for the shared controls. Official templates retain responsibility for notification conditions, subjects, attachments and contextual links. Changes to controls or layout structure belong in the framework so all themes use the same adaptation logic.
|
After completing the theme, run the tests and generate a preview:
|
||||||
|
|
||||||
Layout fragments must form balanced presentation markup. `__HEADER__` inserts the shared header, `__MAIL_TYPE__` expands to the discovered mail ID, and `__SIDEBAR__` inserts the shared sidebar in footer fragments. Deployment logos use `{{AppUrl}}assets/img/favicon.png`; generated preview data embeds the downloaded icon for offline display.
|
|
||||||
|
|
||||||
## Design Guidelines
|
|
||||||
|
|
||||||
- Use email-compatible CSS. Theme CSS must not load external resources, generate text or hide official content.
|
|
||||||
- Use presentation markup for layout fragments. The validator accepts `table`, `tbody`, `tr`, `td`, `div` and `span` with supported presentation attributes.
|
|
||||||
- When editing an existing theme, preserve its visual identity: palette, typography, borders, header, buttons and layout.
|
|
||||||
- Check desktop and 390px mobile previews, including long text and URLs. Test Gmail, Outlook and Apple Mail where available; the browser preview does not emulate mail clients.
|
|
||||||
- Keep gallery images in PNG format, at most 50 KiB each; 10–20 KiB is preferred. Follow the [capture guide](docs/images/README.md) for consistent images.
|
|
||||||
|
|
||||||
## Official Snapshot Updates
|
|
||||||
|
|
||||||
`gitea.lock.json` records a stable Gitea 28+ tag, its commit and per-file SHA-256 hashes. Official mail templates, locale catalogs, the favicon, license and reviewed adapter references are downloaded into `build/upstream/`. Only the generated root lock is committed; official files are not maintained in the source tree.
|
|
||||||
|
|
||||||
### Command Reference
|
|
||||||
|
|
||||||
Run from `tools/`. Each upstream subcommand accepts `--root <repository-root>`, defaulting to `..` relative to the working directory. Place the flag after the subcommand and quote paths containing spaces:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
go run . upstream verify --root "C:\Projects\GiteaMailTemplates"
|
|
||||||
```
|
|
||||||
|
|
||||||
| Command | Behavior |
|
|
||||||
|---|---|
|
|
||||||
| `go run . upstream prepare` | Read the root lock. Download and validate its exact inputs if the cache is absent; otherwise verify the existing cache offline. Leaves the root lock unchanged. |
|
|
||||||
| `go run . upstream verify` | Check the existing cache against the root lock, offline and read-only. Reports `[PASS]` and lists non-English missing keys as `[FALLBACK]`. |
|
|
||||||
| `go run . upstream sync --tag vX.Y.Z` | Resolve an explicit stable Gitea 28+ tag through the GitHub API, download and validate its files, then replace the cache and generate the root lock. |
|
|
||||||
|
|
||||||
`sync` uses `api.github.com`; file downloads use `raw.githubusercontent.com`. These commands do not accept a local Gitea checkout, authentication tokens or an implicit `latest` version. Network errors and API rate limits stop the operation. Go may separately need network access to download its toolchain or modules.
|
|
||||||
|
|
||||||
### Existing Clone and Offline Use
|
|
||||||
|
|
||||||
`build`, `preview` and `dev` prepare inputs automatically. They require the committed root lock and validate cached files before use. Once the cache, Go toolchain and dependencies are available, builds can run offline.
|
|
||||||
|
|
||||||
Use `upstream verify` to check the cache independently. It validates official file hashes, reviewed adapter references and official template keys in the English catalog. Build and rendering checks also cover framework translation keys and primary-action anchors, so cache verification is only one part of compatibility testing.
|
|
||||||
|
|
||||||
### Missing Lock and Explicit Version Updates
|
|
||||||
|
|
||||||
For an existing clone, restore the tracked `gitea.lock.json` if it is missing. The copy at `build/upstream/lock.json` cannot replace it. When intentionally initializing the lock, run:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd tools
|
|
||||||
go run . upstream sync --tag v28.0.0
|
|
||||||
go run . upstream verify
|
|
||||||
go test ./...
|
go test ./...
|
||||||
|
go run . preview my-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
### delete
|
||||||
|
|
||||||
|
`delete` removes the source directories of one or more named themes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . delete my-theme
|
||||||
|
go run . delete first-theme second-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `--folder` to select the theme directory; the default is `../themes`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> After validation, the command deletes directories directly, without a confirmation prompt or recovery through the recycle bin. Check the names and preserve any changes you need before running it.
|
||||||
|
|
||||||
|
Missing themes produce warnings; invalid themes and symlink directories are rejected. Themes are processed sequentially, so a later failure does not restore directories already deleted. `all` does not mean deleting every theme.
|
||||||
|
|
||||||
|
Deleting sources does not remove previously generated builds, preview data or deployed templates. Run `preview all` again to update the preview manifest. Remove deployed templates separately at their actual installation location.
|
||||||
|
|
||||||
|
### preview
|
||||||
|
|
||||||
|
`preview` builds the selected themes and renders all locked official languages using sample data. Specify one or more themes, or use `all`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . preview aurora
|
||||||
|
go run . preview aurora bloom
|
||||||
go run . preview all
|
go run . preview all
|
||||||
```
|
```
|
||||||
|
|
||||||
To review a different version, specify its tag explicitly. Review the lock diff, update the framework adapter and fixtures as needed, and complete the checks before updating compatibility records. `sync` changes the cache and lock only; documentation and release publication are separate steps. Use `prepare` for a missing cache.
|
| Option | Default | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `--folder` | `../themes` | Theme source directory; its parent is used as the project root |
|
||||||
|
| `--config` | `./data/templates_config.json` | Mail type descriptions and preview sample data |
|
||||||
|
| `--output` | `preview/rendered.js` under the project root | Preview manifest path |
|
||||||
|
|
||||||
Changes to the reviewed translation or mail-renderer sources require an adapter review before their reference hashes can be updated. Official English must contain all referenced keys; other languages use English fallback. New mail types require framework alignment and fixtures in `tools/data/templates_config.json`, which supplies preview metadata and example contexts. Keep integer values as integers in JSON fixtures for Go formatting.
|
Default output includes `preview/rendered.js` and `preview/rendered/<locale>.js`. Open [preview/index.html](preview/index.html) in a browser; no server is required. See the [README](README.md#controls-and-keyboard-shortcuts) for controls and shortcuts.
|
||||||
|
|
||||||
Network or validation failures before cache replacement leave existing inputs unchanged. Cache replacement and root-lock writing are separate operations; if a filesystem error interrupts them, inspect both before retrying.
|
> [!NOTE]
|
||||||
|
> Native language names are generated for the actual preview locales from CLDR data in `golang.org/x/text/language/display` and written to the manifest as `language_names`. The preview interface reads this data directly, without maintaining a language-name table.
|
||||||
|
|
||||||
### Cache Recovery
|
> [!IMPORTANT]
|
||||||
|
> Each run overwrites the preview manifest at the output location instead of merging with previously selected themes. For example, after `preview aurora`, the manifest contains only Aurora. Run `preview all` to restore every theme.
|
||||||
|
|
||||||
`prepare` reports corrupt, incomplete or lock-mismatched caches without repairing them. `sync` also refuses to replace a non-empty invalid snapshot. Inspect the error and move the generated cache aside before preparing it again from the reviewed root lock.
|
To use a custom output path:
|
||||||
|
|
||||||
For example, in PowerShell **from the repository root**, with an unused backup name:
|
```bash
|
||||||
|
go run . preview --config ./data/templates_config.json --output ../build/preview-review/rendered.js all
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Language data is written to a `rendered/` directory next to the output file. The command does not copy the preview interface or change its script references; the existing `preview/index.html` still reads data from the default location.
|
||||||
|
|
||||||
|
When adding mail types or rendering branches, extend the descriptions and sample contexts in `tools/data/templates_config.json`. Keep integer values, such as counts and sizes, as integers in JSON. Use controlled test content for HTML fields such as body text, release notes and review content; do not include personal information or real credentials.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The preview checks template structure and presentation using sample contexts. It does not replace parameter compatibility review for the target Gitea version. Browsers and mail clients also differ in their CSS support.
|
||||||
|
|
||||||
|
### dev
|
||||||
|
|
||||||
|
`dev` starts a local development server, building every theme and preparing preview data on startup:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open [http://127.0.0.1:3456](http://127.0.0.1:3456). The default port is `3456`; use `--port` to change it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . dev --port 3457
|
||||||
|
```
|
||||||
|
|
||||||
|
The server listens only on `127.0.0.1`. Press `Ctrl + C` in the terminal to stop it. The command locates the project relative to the current `tools/` working directory and does not provide `--folder`, `--config` or `--root` options.
|
||||||
|
|
||||||
|
The server watches theme sources, the shared framework, the root lock file, official cache and preview data in `tools/data/`. Changes trigger a rebuild and refresh the preview through server-sent events (SSE). If a build fails, resolve the terminal error and save the file again.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> Refresh the page manually after editing `preview/index.html`. Stop and restart the server after editing Go tool code. These files are outside the current automatic rebuild watch scope.
|
||||||
|
|
||||||
|
### help, h
|
||||||
|
|
||||||
|
View all commands or help for a specific command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . help
|
||||||
|
go run . h
|
||||||
|
go run . help build
|
||||||
|
go run . preview --help
|
||||||
|
```
|
||||||
|
|
||||||
|
For `upstream` subcommand options, place `--help` after the subcommand:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . upstream prepare --help
|
||||||
|
go run . upstream sync --help
|
||||||
|
go run . upstream verify --help
|
||||||
|
```
|
||||||
|
|
||||||
|
Tool diagnostics use the `[LEVEL] [NAME] Message` format. `[I]`, `[W]`, `[E]` and `[F]` mean information, warning, error and fatal error, respectively. Level markers use different colors in supported terminals; set `NO_COLOR` to disable colors. Failed commands return a nonzero exit code. Preserve the complete output when troubleshooting.
|
||||||
|
|
||||||
|
## Frequently Asked Questions
|
||||||
|
|
||||||
|
### What if the lock file or official cache is missing?
|
||||||
|
|
||||||
|
If an existing clone lacks `gitea.lock.json`, restore the tracked root lock file. The copy at `build/upstream/lock.json` cannot replace it. If only the cache is missing, run `upstream prepare` rather than synchronizing to another version to recover it. `build`, `preview` and `dev` prepare official inputs automatically. They can run offline once the cache, Go toolchain and dependencies are available; `upstream verify` always checks local files only. For network errors or GitHub API rate limits during the initial download, resolve the network issue and retry.
|
||||||
|
|
||||||
|
### What if the cache is corrupt or does not match the lock file?
|
||||||
|
|
||||||
|
`prepare` does not repair corrupt caches automatically, and `sync` refuses to replace a non-empty invalid snapshot. Stop the development server, preserve the root lock file and move the cache to a backup location before preparing it again. For example, in PowerShell **from the repository root**, use a backup name that does not already exist:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Move-Item -LiteralPath .\build\upstream -Destination .\build\upstream.backup
|
Move-Item -LiteralPath .\build\upstream -Destination .\build\upstream.backup
|
||||||
@@ -133,70 +277,91 @@ go run . upstream prepare
|
|||||||
go run . upstream verify
|
go run . upstream verify
|
||||||
```
|
```
|
||||||
|
|
||||||
Preserve the rest of `build/` and leave official cached files unedited. To return to a previous snapshot, restore its reviewed root lock and rebuild the cache in the same way. Stop `dev` before replacing inputs, and avoid concurrent processes writing to the same cache.
|
> [!WARNING]
|
||||||
|
> Do not edit official cached files directly or delete the rest of `build/`. To revert the official version, restore the previously reviewed root lock file and rebuild the cache in the same way.
|
||||||
|
|
||||||
### Known Upstream Formatting Issue
|
### Why does synchronizing a new version report changed adapter sources?
|
||||||
|
|
||||||
Gitea v28.0.0 contains a Polish `mail.team_invite.text_1` placeholder defect. Preview preserves the official output and reports `[UPSTREAM-WARN]`. The exception matches the exact reviewed source text; other formatting errors fail rendering. Report upstream defects without modifying the cached locale files.
|
The project pins reviewed mail-rendering and translation reference sources. When upstream changes these implementations, the tool requires another review to avoid using incompatible preview functions or variable structures. Examine the official changes, adjust adapter logic and relevant tests, then update the reference hashes. New mail types, translation keys, functions or variable paths may also require changes. Update [compatibility records](COMPATIBILITY.md) after validation; a successful download does not establish compatibility.
|
||||||
|
|
||||||
## Verification and Release
|
### Why do some languages use English or produce formatting warnings?
|
||||||
|
|
||||||
### Checks for a Pull Request
|
Official English must contain all referenced translation keys. Missing keys in other languages fall back to English and produce warnings. Preserve official locale files without adding translations to the cache.
|
||||||
|
|
||||||
From `tools/`, run `go test ./...` and `go run . preview all`. Tests cover deterministic generation, changes to action anchors, translation keys, and notification subjects, text and links across all themes and languages. Fixtures include push, review, reply, workflow and attachment branches. Shared controls and branding are accounted for separately from official notification content.
|
For example, Gitea v28.0.0 has a known placeholder defect in the Polish `mail.team_invite.text_1`. The preview preserves official output for the exact reviewed source text and reports a warning. This exception does not apply to other formatting errors. Include the version, translation key and reproduction details when reporting new issues for review and upstream feedback.
|
||||||
|
|
||||||
For documentation or packaging changes, run from the repository root:
|
### Why does the preview not show a new theme or recent changes?
|
||||||
|
|
||||||
|
The static preview does not build automatically. Run `preview all` again and refresh the page, then confirm that the manifest contains the required themes. With a custom output path, check where the preview interface actually reads its data. With `dev`, first check the terminal for rebuild errors. Go code changes require a server restart; preview interface changes require a manual refresh. If the default port is occupied, select another port with `--port`.
|
||||||
|
|
||||||
|
### Does a successful build mean all Gitea versions are supported?
|
||||||
|
|
||||||
|
Builds target the official inputs specified in the root lock file. Other versions may change template directories, functions or variable structures, so a successful build or preview alone cannot establish backward compatibility. Select release archives using the [compatibility matrix](COMPATIBILITY.md#compatibility-matrix), rather than installing new-version templates directly on older instances.
|
||||||
|
|
||||||
|
### Why does the packaging script reject the current output?
|
||||||
|
|
||||||
|
Run `preview all` before packaging to ensure that every theme and language bundle is present and generated files match the current sources. The version argument must match the tag in the root lock file. Rebuild and regenerate previews after source or generated file changes. The script does not overwrite existing release archives. Use a new output directory when repackaging and retain old artifacts needed for comparison.
|
||||||
|
|
||||||
|
## Other Contribution Information
|
||||||
|
|
||||||
|
### Themes and the Shared Framework
|
||||||
|
|
||||||
|
Use CSS suitable for mail clients. When editing an existing theme, preserve its palette, fonts, borders and layout, keep headings, body text and supporting text distinct, and account for long text, long URLs and mobile widths. Layout fragments use presentation markup and support `table`, `tbody`, `tr`, `td`, `div`, `span` and attributes allowed by the validator. Combined markup must have balanced tags. `__HEADER__` inserts the shared header, `__MAIL_TYPE__` expands to the mail ID, and `__SIDEBAR__` inserts the shared sidebar in footer fragments. Review changes to notification variables and conditions in the build adapter logic, not in theme CSS or layout presets.
|
||||||
|
|
||||||
|
For new themes, update the galleries in both English and Chinese READMEs. Use PNG images of at most 50 KiB each; 10–20 KiB is preferred. Follow the [capture guide](docs/images/README.md) for consistent themes, mail types, languages and cropping.
|
||||||
|
|
||||||
|
### Commits and Pull Requests
|
||||||
|
|
||||||
|
Keep changes focused on a specific problem and avoid unrelated formatting changes. Describe the reason, scope and validation results in the pull request. For visual changes, you can include comparison images generated with sample data. When changing themes, the shared framework or Go tools, run from `tools/`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go test ./...
|
||||||
|
go run . preview all
|
||||||
|
```
|
||||||
|
|
||||||
|
For changes to mail content, links, variables or function adaptation, add regression tests covering affected conditional branches. Existing tests check generated output, translation keys, notification subjects, text and links across every theme and language, including push, review, reply, workflow and attachment branches.
|
||||||
|
|
||||||
|
When changing packaging scripts, run from the repository root:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python -B -m unittest discover -s .github/scripts -p 'test_*.py'
|
python -B -m unittest discover -s .github/scripts -p 'test_*.py'
|
||||||
```
|
```
|
||||||
|
|
||||||
Keep English and Simplified Chinese guides aligned when changing shared instructions. Include a description of the change, relevant checks and screenshots for visual changes in the pull request.
|
For documentation-only changes, check wording, command examples and links. Keep Chinese and English documentation aligned; preserve commands, paths, variables and version information without changing their meaning in translation.
|
||||||
|
|
||||||
### Preparing a Release
|
Use concise commit messages. The following prefixes are available as a reference:
|
||||||
|
|
||||||
Release tags must match the locked Gitea version. The current source refactor is unreleased; retain existing v28.0.0 and historical assets.
|
|
||||||
|
|
||||||
1. Complete the Go tests, documentation checks and preview generation.
|
|
||||||
2. Update documentation and compatibility records with the verification results. Release notes are optional and are not used as the Release body.
|
|
||||||
3. Generate all themes and language bundles with `go run . preview all` from `tools/`.
|
|
||||||
4. Package the release and verify its contents before publication.
|
|
||||||
|
|
||||||
For manual packaging, run from the repository root:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python .github/scripts/package_release.py --version vX.Y.Z --output <new-output-directory>
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace the version and output placeholder with the reviewed tag and a new directory. The script checks source and generated hashes, includes all language bundles, excludes stale theme builds, and refuses to overwrite existing archives.
|
|
||||||
|
|
||||||
The release workflow uses the same script to package templates, previews, documentation, the upstream license and provenance. It publishes only the archives, with the tag as the Release title and an empty body. Version labels, badges and compatibility records are maintained manually; review archive documentation before tagging. Confirm Actions support and write permissions on the configured Gitea host before relying on automated publication. See [version maintenance](COMPATIBILITY.md#version-maintenance).
|
|
||||||
|
|
||||||
### Gitea Workflow Configuration
|
|
||||||
|
|
||||||
The release workflow uses the `linux-amd64-docker-small` runner label. The job image must support the Node.js actions used for checkout and toolchain setup, as well as Git and a POSIX shell. Go and Python are installed by the setup steps.
|
|
||||||
|
|
||||||
Publication uses [`gitea-release-action@v1.3.7`](https://gitea.com/actions/gitea-release-action/src/tag/v1.3.7/action.yml) directly, with the instance URL, repository, built-in `GITEA_TOKEN`, tag, title and the two archive paths. The Release body is empty when created; no notes file or Issue reminder is required. The repository must allow release writes. Action URLs explicitly use `https://gitea.com` rather than depending on `DEFAULT_ACTIONS_URL`.
|
|
||||||
|
|
||||||
Before publication, `actions/setup-node@v4` prepares Node.js 22. The current Gitea runner executes JavaScript actions with `node` from `PATH`; this provides the runtime interfaces used by the release action without `--experimental-fetch`. On repeated publication of an existing tag, the action preserves an existing body and replaces same-name attachments. It does not provide the previous script's draft-until-all-uploads-complete behavior. Review the release and attachments before retrying a failed publication.
|
|
||||||
|
|
||||||
## Reporting Problems
|
|
||||||
|
|
||||||
Include the Gitea version, template release or source commit, theme, mail type, language and steps to reproduce. For source-build problems, include the snapshot tag/commit and output from `go run . upstream verify` or `go run . preview all`. For display problems, include the mail client and a screenshot with personal data removed.
|
|
||||||
|
|
||||||
## Commit Conventions
|
|
||||||
|
|
||||||
| Prefix | Scope |
|
| Prefix | Scope |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `style(<name>):` | Theme presentation |
|
| `style(<name>):` | Theme presentation styles |
|
||||||
| `preview:` | Browser preview |
|
| `preview:` | Preview tools |
|
||||||
| `tools:` | CLI, build and snapshot tools |
|
| `tools:` | CLI, build and snapshot tools |
|
||||||
| `docs:` | Documentation and translations |
|
| `docs:` | Documentation and translations |
|
||||||
| `fix:` | Bug fixes |
|
| `fix:` | Bug fixes |
|
||||||
| `project:` | Repository configuration and project structure |
|
| `project:` | Repository configuration and project structure |
|
||||||
| `refactor:` | Code restructuring |
|
| `refactor:` | Code restructuring |
|
||||||
| `chore:` | Maintenance |
|
| `chore:` | Routine maintenance |
|
||||||
|
|
||||||
## Translations and License
|
### Version and Release Maintenance
|
||||||
|
|
||||||
The [Simplified Chinese guide](docs/CONTRIBUTING.zh-CN.md) covers the same workflow. Contributions are licensed under MIT. Retain Gitea copyright and the upstream license when distributing derived templates; see [third-party notices](THIRD_PARTY_NOTICES.md).
|
Release tags must match the locked Gitea tag. Version labels, badges and compatibility records are maintained manually; changing official inputs does not trigger automatic version maintenance. Retain historical release assets and check documentation and compatibility records before tagging. After validation and generation of all previews, you can package manually from the repository root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python .github/scripts/package_release.py --version v28.2.0 --output build/release-review
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the example version with the tag in the root lock file and use an output directory without release archives of the same name. The script checks source and artifact hashes, packages themes, previews, documentation, the official license and provenance, and excludes stale theme builds.
|
||||||
|
|
||||||
|
`.github/workflows/validate.yml` handles checks for ordinary pushes and pull requests and is also called by the Release workflow. After validation, Release packages the archives and uploads them through the release action. It uses the tag as the title and creates new releases with an empty body, without requiring a release notes file. Republishing an existing tag preserves its existing body and replaces same-name attachments. Check the release and attachment state before retrying a failed publication.
|
||||||
|
|
||||||
|
Workflows use the `linux-amd64-docker-small` runner label, with setup steps preparing Go, Python and Node.js for publication. Actions use `actions/...@version` references, resolved through the runner's action source configuration; consider the current `github_mirror` setting when maintaining them. Publication uses the built-in `GITEA_TOKEN`, and the repository must permit release writes.
|
||||||
|
|
||||||
|
### Reporting Problems
|
||||||
|
|
||||||
|
Include the Gitea version, template release or source commit, theme, mail type, language and steps to reproduce. For build or preview issues, also include the tag in the root lock file, relevant commands and complete error output. For display issues, specify the mail client and attach screenshots with personal information removed.
|
||||||
|
|
||||||
|
For improvement suggestions, explain the use case, expected result and affected themes or tools. For official template or translation defects, preserve the original inputs and provide a minimal example that reproduces the issue.
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
This project uses the [MIT License](LICENSE). Contribute code, styles and images that can be legally redistributed. When generating or distributing derived templates, retain Gitea copyright, the official license and snapshot provenance; release archives already include these files.
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
Gitea Mail Template offers a range of email template styles for self-hosted [Gitea](https://about.gitea.com) instances.
|
Gitea Mail Template offers a range of email template styles for self-hosted [Gitea](https://about.gitea.com) instances.
|
||||||
|
|
||||||
> Latest release: [v28.0.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
> Latest release: [v28.1.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
||||||
|
|
||||||
The repository includes several themes for Gitea emails, suitable for most deployment scenarios and use cases. Before installing, consult the [compatibility matrix](COMPATIBILITY.md#compatibility-matrix) for your Gitea version and choose the corresponding release archive.
|
The repository includes several themes for Gitea emails, suitable for most deployment scenarios and use cases. Before installing, consult the [compatibility matrix](COMPATIBILITY.md#compatibility-matrix) for your Gitea version and choose the corresponding release archive.
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ The gallery shows how the email templates render in the preview tool.
|
|||||||
|  | **Terminal** | Dark background, monospace fonts and green accents |
|
|  | **Terminal** | Dark background, monospace fonts and green accents |
|
||||||
|  | **Terra** | Earth tones, terracotta buttons and serif fonts |
|
|  | **Terra** | Earth tones, terracotta buttons and serif fonts |
|
||||||
|
|
||||||
Screenshots show only the current default build. Use the [local preview](#preview) to view other email types and languages. See the [screenshot guide](docs/images/README.md) when updating screenshots.
|
Screenshots show only the current default build. Use the [preview](#preview) to view other email types and languages. See the [screenshot guide](docs/images/README.md) when updating screenshots.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ go run . build all
|
|||||||
cd ..
|
cd ..
|
||||||
```
|
```
|
||||||
|
|
||||||
Building usable templates requires resources from the official Gitea repository to ensure consistent source inputs. The command automatically downloads the official files pinned by `gitea.lock.json`. Subsequent builds use the cached resources without downloading them again. For missing files or a damaged cache, see [official snapshot updates](#official-snapshot-updates).
|
Building usable templates requires resources from the official Gitea repository to ensure consistent source inputs. The command automatically downloads the official files pinned by `gitea.lock.json`. Subsequent builds use the cached resources without downloading them again.
|
||||||
|
|
||||||
### Install a Theme
|
### Install a Theme
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ go run . dev
|
|||||||
cd ..
|
cd ..
|
||||||
```
|
```
|
||||||
|
|
||||||
Open [http://127.0.0.1:3456](http://127.0.0.1:3456). The Go server watches theme files, the shared framework, the lock file and cache, and preview test data. When a file changes, it rebuilds the email templates and refreshes the page through server-sent events (SSE) to provide live reload.
|
Open [http://127.0.0.1:3456](http://127.0.0.1:3456). The server watches theme files, the shared framework, the lock file and cache, and preview test data. When a file changes, it rebuilds the email templates and refreshes the page through server-sent events (SSE) to provide live reload.
|
||||||
|
|
||||||
### Controls and Keyboard Shortcuts
|
### Controls and Keyboard Shortcuts
|
||||||
|
|
||||||
@@ -126,9 +126,11 @@ Open [http://127.0.0.1:3456](http://127.0.0.1:3456). The Go server watches theme
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
- **Latest tested:** Gitea 28.0.0
|
- **Latest tested:** Gitea 28.2.0
|
||||||
- **Latest release:** [v28.0.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
- **Source build baseline:** Gitea 28.2.0
|
||||||
- **Upstream Gitea 28.1.0:** [PENDING]
|
- **Latest release:** [v28.1.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
||||||
|
|
||||||
|
Gitea 28.2.0 introduces no mail template interface changes, so the published v28.1.0 templates remain compatible. Source builds use the locked v28.2.0 official inputs; see the [compatibility records](COMPATIBILITY.md).
|
||||||
|
|
||||||
## Project Directory Structure
|
## Project Directory Structure
|
||||||
|
|
||||||
@@ -138,7 +140,6 @@ The project is organized around a shared framework, theme styles and build tools
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
.github/ # Workflows and maintenance scripts
|
.github/ # Workflows and maintenance scripts
|
||||||
release-notes/ # Release notes for each version
|
|
||||||
scripts/ # Documentation updates, packaging and Gitea release scripts
|
scripts/ # Documentation updates, packaging and Gitea release scripts
|
||||||
workflows/ # Validation and publication
|
workflows/ # Validation and publication
|
||||||
docs/ # Chinese documentation, documentation index and gallery images
|
docs/ # Chinese documentation, documentation index and gallery images
|
||||||
@@ -155,7 +156,6 @@ tools/ # Go CLI, build tools and tests
|
|||||||
preview/ # Email rendering, locale adaptation and development server
|
preview/ # Email rendering, locale adaptation and development server
|
||||||
upstream/ # Official snapshot downloads, verification and translation key discovery
|
upstream/ # Official snapshot downloads, verification and translation key discovery
|
||||||
gitea.lock.json # Official version tag, commit and file checksums
|
gitea.lock.json # Official version tag, commit and file checksums
|
||||||
README.md
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Official templates provide notification content, conditions, subject lines and links. The shared framework handles email presentation, while themes use metadata and CSS to select layouts and define styles. Theme directories do not contain official email source files or translations.
|
Official templates provide notification content, conditions, subject lines and links. The shared framework handles email presentation, while themes use metadata and CSS to select layouts and define styles. Theme directories do not contain official email source files or translations.
|
||||||
@@ -196,14 +196,13 @@ Gitea currently includes the following 11 email templates [1](#notes):
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions to themes, tools, documentation and translations are welcome. The [contributor guide](CONTRIBUTING.md) covers local environment setup, design guidelines, required checks and the release process.
|
Contributions to themes, tools, documentation and translations are welcome. See the [contributor guide](CONTRIBUTING.md) for details on contributing.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under [MIT](LICENSE). Generated release archives retain Gitea's license and snapshot provenance.
|
This project is licensed under [MIT](LICENSE). Generated release archives retain Gitea's license and snapshot provenance.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
|
|
||||||
[1](#notes): [Mail templates | Gitea Documentation](https://docs.gitea.com/administration/mail-templates/)
|
[1](#notes): [Mail templates | Gitea Documentation](https://docs.gitea.com/administration/mail-templates/)
|
||||||
|
|||||||
+22
-17
@@ -9,26 +9,27 @@
|
|||||||
根据所运行的 Gitea 版本选择对应推荐的模板版本。`[PASS]` 表示已记录为兼容的组合,`[PENDING]` 表示尚未完成验证。
|
根据所运行的 Gitea 版本选择对应推荐的模板版本。`[PASS]` 表示已记录为兼容的组合,`[PENDING]` 表示尚未完成验证。
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> 历史条目仅反映项目已有的兼容性评估,不代表每次发布都重新测试了每一个补丁版本。
|
> 本项目主要采用模板版本号与 Gitea 版本号同步的管理方式。但并非每次 Gitea 发布都会引入邮件模板变更,因此兼容性表中的推荐版本依据兼容性评估确定,不一定与所运行的 Gitea 版本同号。历史条目反映已有评估结果,不代表每次模板发布都会重新测试所有列出的 Gitea 版本。
|
||||||
|
|
||||||
| Gitea 版本 | 推荐模板版本 | 状态 | 说明 |
|
| Gitea 版本 | 推荐模板版本 | 状态 | 说明 |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| 28.1.0 | — | [PENDING] | 等待兼容性验证 |
|
| 28.2.0 | [**v28.1.0**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.1.0) | [PASS] | 邮件模板、模板函数注册及邮件翻译键与 28.1.0 一致 |
|
||||||
| 28.0.0 | **v28.0.0** | [PASS] | Gitea 将邮件函数 `FileSize` 替换为 `FormatByteSize` |
|
| 28.1.0 | [**v28.1.0**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.1.0) | [PASS] | - |
|
||||||
| 1.27.3 | **v1.27.3** | [PASS] | 全部主题已修复拉取请求推送通知的提交链接 |
|
| 28.0.0 | [**v28.1.0**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.1.0) | [PASS] | Gitea 将邮件函数 `FileSize` 替换为 `FormatByteSize` |
|
||||||
| 1.27.2 | **v1.27.3** | [PASS] | 同号 v1.27.2 模板的 Bloom、Ember、Heritage 存在推送通知缺陷 |
|
| 1.27.3 | [**v1.27.3**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) | [PASS] | 全部主题已修复拉取请求推送通知的提交链接 |
|
||||||
| 1.27.1 | **v1.27.3** | [PASS] | 较早 v1.0.x 模板使用过时的推送提交字段 |
|
| 1.27.2 | [**v1.27.3**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) | [PASS] | 同号 v1.27.2 模板的 Bloom、Ember、Heritage 存在推送通知缺陷 |
|
||||||
|
| 1.27.1 | [**v1.27.3**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) | [PASS] | 较早 v1.0.x 模板使用过时的推送提交字段 |
|
||||||
| 1.27.0 | — | [PENDING] | Gitea 使用了新的提交数据结构;v1.27.3 可能适用,但未在此版本上验证 |
|
| 1.27.0 | — | [PENDING] | Gitea 使用了新的提交数据结构;v1.27.3 可能适用,但未在此版本上验证 |
|
||||||
| 1.26.4 | **v1.0.1** | [PASS] | — |
|
| 1.26.4 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.3 | **v1.0.1** | [PASS] | — |
|
| 1.26.3 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.2 | **v1.0.1** | [PASS] | — |
|
| 1.26.2 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.1 | **v1.0.1** | [PASS] | — |
|
| 1.26.1 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.26.0 | **v1.0.1** | [PASS] | — |
|
| 1.26.0 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.25.5 | **v1.0.1** | [PASS] | — |
|
| 1.25.5 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
| 1.25.0 | **v1.0.1** | [PASS] | — |
|
| 1.25.0 | [**v1.0.1**](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.0.1) | [PASS] | — |
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Gitea 1.24.x 及更早版本使用不同的邮件模板布局,属于 `[UNSUPPORTED]`,Gitea Mail Templates 不再另外支持。v1.0.0 模板标签已由 v1.0.1 替代,不再单独推荐。
|
> Gitea 1.24.x 及更早版本使用不同的邮件模板布局,属于 `[UNSUPPORTED]`,Gitea Mail Templates 不再另外支持。
|
||||||
|
|
||||||
## Gitea 历版本对邮件模板影响
|
## Gitea 历版本对邮件模板影响
|
||||||
|
|
||||||
@@ -36,9 +37,10 @@
|
|||||||
|
|
||||||
| Gitea | 发布日期 | 邮件模板变化 | 影响 |
|
| Gitea | 发布日期 | 邮件模板变化 | 影响 |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| **28.1.0** | 2026-10-06 | [PENDING] | [PENDING] |
|
| **28.2.0** | 2026-10-18 | 无模板接口变更 | 自定义关注的通知收件规则及入站回复令牌校验调整,不影响现有模板 |
|
||||||
| **28.0.0** | 2026-09-29 | 邮件函数 `FileSize` 改为 `FormatByteSize` ([PR](https://github.com/go-gitea/gitea/pull/#39083)) | **不兼容变更:** 旧的发布附件模板失效 |
|
| **28.1.0** | 2026-10-06 | 无 | 无 |
|
||||||
|||引入 templates/mail/base/ ([PR](https://github.com/go-gitea/gitea/pull/#38396))| **不兼容变更:**旧版本 Gitea 无法直接使用新版本邮件模板 |
|
| **28.0.0** | 2026-09-29 | 邮件函数 `FileSize` 改为 `FormatByteSize` ([PR](https://github.com/go-gitea/gitea/pull/39083)) | **不兼容变更:** 旧的发布附件模板失效 |
|
||||||
|
|||引入 templates/mail/base/ ([PR](https://github.com/go-gitea/gitea/pull/38396))| **不兼容变更:** 旧版本 Gitea 无法直接使用新版本邮件模板 |
|
||||||
| **1.27.3** | 2026-08-29 | 无 | 无 |
|
| **1.27.3** | 2026-08-29 | 无 | 无 |
|
||||||
| **1.27.2** | 2026-08-14 | 无 | 无 |
|
| **1.27.2** | 2026-08-14 | 无 | 无 |
|
||||||
| **1.27.1** | 2026-07-27 | 内置推送模板改用 `.UserCommit.GitCommit`([PR](https://github.com/go-gitea/gitea/pull/38467)) | **不兼容变更:存在既有未修复缺陷** 旧的自定义拉取请求推送模板可能失效 |
|
| **1.27.1** | 2026-07-27 | 内置推送模板改用 `.UserCommit.GitCommit`([PR](https://github.com/go-gitea/gitea/pull/38467)) | **不兼容变更:存在既有未修复缺陷** 旧的自定义拉取请求推送模板可能失效 |
|
||||||
@@ -54,6 +56,9 @@
|
|||||||
|
|
||||||
## 模板变量参考
|
## 模板变量参考
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> 已对照 [Gitea 28.1.0 与 28.2.0 的源码差异](https://github.com/go-gitea/gitea/compare/v28.1.0...v28.2.0)检查邮件模板、上下文构造、模板函数和翻译键。28.2.0 调整了[自定义关注的邮件通知规则](https://github.com/go-gitea/gitea/pull/39837)和[入站邮件令牌校验](https://github.com/go-gitea/gitea/pull/39841),未改变现有邮件模板所需的变量、函数或翻译键。源码构建输入锁定为 v28.2.0,已发布的 v28.1.0 模板仍可使用。
|
||||||
|
|
||||||
各类邮件上下文由官方模板定义。开发时具体的邮件模板和函数和变量请参考官方邮件模板文档 [1](#注释)。
|
各类邮件上下文由官方模板定义。开发时具体的邮件模板和函数和变量请参考官方邮件模板文档 [1](#注释)。
|
||||||
|
|
||||||
## 翻译键
|
## 翻译键
|
||||||
|
|||||||
+285
-118
@@ -1,10 +1,13 @@
|
|||||||
# 贡献指南
|
# 贡献指南
|
||||||
|
---
|
||||||
|
|
||||||
欢迎改进主题、工具、测试、文档和翻译。本指南介绍当前源码架构的开发流程;安装和版本选择请参阅 [README](README.zh-CN.md#安装)。
|
[English](../CONTRIBUTING.md)
|
||||||
|
|
||||||
|
欢迎改进主题、工具、文档和翻译。本指南介绍开发环境、命令行工具和贡献流程。安装邮件模板和选择发行版本,请参阅 [README](README.zh-CN.md#安装)及[兼容性表](COMPATIBILITY.zh-CN.md#兼容性表)。
|
||||||
|
|
||||||
## 本地开发
|
## 本地开发
|
||||||
|
|
||||||
使用 **Go 1.24 或更高版本**。从仓库根目录开始,准备依赖和锁定的官方文件,再运行检查并生成预览:
|
使用 **Go 1.24 或更高版本**。在仓库根目录执行以下命令,准备依赖和锁定的官方文件,运行测试并生成预览:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd tools
|
cd tools
|
||||||
@@ -14,35 +17,123 @@ go test ./...
|
|||||||
go run . preview all
|
go run . preview all
|
||||||
```
|
```
|
||||||
|
|
||||||
在浏览器中打开 `preview/index.html`,或在 `tools/` 中运行 `go run . dev`,访问 [http://127.0.0.1:3456](http://127.0.0.1:3456) 使用实时预览。开发服务器监听主题、框架、锁文件与缓存、预览测试数据的变化。
|
随后在浏览器中打开 [preview/index.html](../preview/index.html),或运行 `go run . dev` 使用实时预览。检查与打包工作流使用 Python 3.11。
|
||||||
|
|
||||||
CLI 使用 urfave/cli 和 x/net HTML 解析器。文档与打包检查使用 Python 3.11 或更高版本。
|
项目按共享框架、主题样式和构建工具组织。官方模板提供通知内容、条件、主题行和链接;共享框架负责邮件呈现,主题通过元数据和 CSS 选择布局、定义样式。目录说明见 [README](README.zh-CN.md#项目目录结构)。
|
||||||
|
|
||||||
### 常用命令
|
> [!NOTE]
|
||||||
|
> 下载的官方文件、生成的模板和预览数据不纳入版本控制。贡献时提交相应源码、测试和文档,无需提交 `build/`、`dist/` 或生成的预览数据。
|
||||||
|
|
||||||
以下命令均在 `tools/` 中执行。带有位置参数时,将选项放在位置参数之前。
|
## 开发工具
|
||||||
|
|
||||||
|
命令行工具提供官方文件准备、主题管理、模板构建和预览功能。
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> 以下命令均在 `tools/` 中执行;带有位置参数时,将选项放在位置参数之前。示例中的 `my-theme` 表示主题名称,包含空格的路径需要加引号。
|
||||||
|
|
||||||
| 命令 | 用途 |
|
| 命令 | 用途 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `go run . list` | 列出可用主题 |
|
| `upstream` | 准备、同步或校验锁定的官方构建输入 |
|
||||||
| `go run . create my-theme` | 创建主题元数据和 CSS |
|
| `build` | 根据官方输入和共享控件生成可安装的主题 |
|
||||||
| `go run . build my-theme` | 生成指定主题的安装模板 |
|
| `list` | 列出可用主题及其元数据 |
|
||||||
| `go run . build all` | 生成全部主题 |
|
| `create` | 创建使用共享框架的主题 CSS 和元数据 |
|
||||||
| `go run . preview all` | 构建全部主题并渲染所有官方语言 |
|
| `delete` | 删除一个或多个主题源码目录 |
|
||||||
| `go run . dev` | 在端口 3456 启动开发服务器 |
|
| `preview` | 预渲染邮件模板,生成预览和测试数据 |
|
||||||
| `go run . dev --port 3457` | 指定其他本地端口 |
|
| `dev` | 启动通过 SSE 刷新页面的热重载开发服务器 |
|
||||||
| `go run . delete my-theme` | 删除指定主题的源码目录 |
|
| `help`、`h` | 显示命令列表或指定命令的帮助 |
|
||||||
|
|
||||||
`build` 将模板写入 `build/themes/<名称>/mail/`,并在 `build.json` 中记录文件和源码哈希。`preview` 同时完成构建,随后写入 `preview/rendered.js` 和 `preview/rendered/<语言>.js`。这些生成文件和下载的官方文件均被 Git 忽略,无需随贡献提交。
|
### upstream
|
||||||
|
|
||||||
## 添加主题
|
`upstream` 管理 `gitea.lock.json` 锁定的官方文件,包括邮件模板、语言文件、图标、许可证和已评审的适配参考源码。下载的文件保存到 `build/upstream/`。
|
||||||
|
|
||||||
1. 在 `tools/` 中运行 `go run . create my-theme`。
|
| 子命令 | 行为 |
|
||||||
2. 编辑 `themes/my-theme/theme.json` 和 `theme.css`。
|
|---|---|
|
||||||
3. 在 `tools/` 中运行 `go test ./...` 和 `go run . preview all`。
|
| `prepare` | 读取根锁文件。缓存缺失时下载并校验;已有缓存则校验后使用。不修改根锁文件。 |
|
||||||
4. 检查英文、简体中文及至少另一种官方语言的桌面与移动端布局,在拉取请求中附上截图。
|
| `sync --tag <TAG>` | 下载指定稳定版本的官方文件,校验后替换缓存并更新根锁文件。 |
|
||||||
|
| `verify` | 对照根锁文件,只读、离线校验已有缓存。 |
|
||||||
|
|
||||||
主题名称以小写字母开头,可包含小写字母、数字和连字符。主题目录只包含 `theme.json` 和 `theme.css`。
|
首次准备或单独检查输入时执行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . upstream prepare
|
||||||
|
go run . upstream verify
|
||||||
|
```
|
||||||
|
|
||||||
|
三个子命令均支持 `--root`,默认值为相对当前工作目录的 `..`。例如:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
go run . upstream verify --root "C:\Projects\GiteaMailTemplates"
|
||||||
|
```
|
||||||
|
|
||||||
|
根锁文件记录 Gitea 标签、对应提交和文件的 SHA-256。`verify` 检查文件哈希、已评审的适配参考源码,以及官方模板引用的英文翻译键;非英文语言缺少的键会报告警告,并在预览中回退为英文。构建和渲染还会检查框架使用的翻译键及操作链接锚点,缓存校验不能代替这些检查。
|
||||||
|
|
||||||
|
#### 更新官方版本
|
||||||
|
|
||||||
|
只有需要评审新的官方版本时才使用 `sync`。例如,明确同步到 `v28.2.0`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . upstream sync --tag v28.2.0
|
||||||
|
go run . upstream verify
|
||||||
|
go test ./...
|
||||||
|
go run . preview all
|
||||||
|
```
|
||||||
|
|
||||||
|
标签必须采用 `vX.Y.Z` 格式,并且是 Gitea 28 或更高版本的稳定标签;不支持 `latest`、预发布标签或旧版本标签。`sync` 通过 `api.github.com` 解析标签,通过 `raw.githubusercontent.com` 下载文件,不接受本地 Gitea 克隆或认证令牌参数。
|
||||||
|
|
||||||
|
同步后检查锁文件差异,按需调整适配逻辑和预览数据,完成验证后更新兼容性记录。同步不会自动更新文档、发行标签或兼容性结论。
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> 适配参考源码发生变化时,须先评审相关行为,再更新对应参考哈希,不应仅修改哈希以跳过检查。
|
||||||
|
|
||||||
|
网络或校验错误发生在缓存替换前时,原有文件保持不变。缓存替换和根锁文件写入是两个操作;文件系统错误中断操作后,重试前应检查二者是否一致。更新输入前先停止 `dev`,避免多个进程同时写入缓存。
|
||||||
|
|
||||||
|
### build
|
||||||
|
|
||||||
|
`build` 根据锁定的官方文件、共享框架和主题源码生成可安装的邮件模板。必须指定一个或多个主题,或使用 `all` 构建全部主题:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . build aurora
|
||||||
|
go run . build aurora bloom
|
||||||
|
go run . build all
|
||||||
|
```
|
||||||
|
|
||||||
|
| 选项 | 默认值 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| `--folder` | `../themes` | 主题源码目录;工具将其父目录作为项目根目录 |
|
||||||
|
|
||||||
|
使用其他项目路径时,该项目根目录也需要提供锁文件和共享框架:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
go run . build --folder "C:\Projects\GiteaMailTemplates\themes" aurora
|
||||||
|
```
|
||||||
|
|
||||||
|
结果写入 `build/themes/<名称>/mail/`,同级的 `build.json` 记录构建来源和生成文件的校验值。重新构建会更新所选主题的模板并清理其过时模板,不清理未选中的主题。构建不会部署邮件模板,安装步骤见 [README](README.zh-CN.md#安装主题)。
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> 需要修改模板时,应编辑主题源码、共享框架或构建适配逻辑。直接修改生成的 `.tmpl` 文件会在后续构建中被覆盖,也会导致打包时的来源校验失败。
|
||||||
|
|
||||||
|
### list
|
||||||
|
|
||||||
|
`list` 按名称排序,显示主题名称、模式和简短说明:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . list
|
||||||
|
```
|
||||||
|
|
||||||
|
可通过 `--folder` 指定主题目录,默认值为 `../themes`。命令会校验主题元数据和样式,不下载官方文件,也不生成模板。主题格式无效时,应先修复报告的问题。
|
||||||
|
|
||||||
|
### create
|
||||||
|
|
||||||
|
`create` 为新主题创建 `theme.json` 和 `theme.css`,支持一次创建多个主题:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . create my-theme
|
||||||
|
go run . create first-theme second-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
可通过 `--folder` 指定主题源码目录,默认值为 `../themes`。命令不会覆盖已存在的目录。主题名称以小写字母开头,仅包含小写字母、数字和连字符;避免使用 `all`,因为构建和预览命令将其作为全部主题的选择参数。
|
||||||
|
|
||||||
|
编辑生成的元数据和 CSS,定义主题说明及样式。例如:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -53,76 +144,131 @@ CLI 使用 urfave/cli 和 x/net HTML 解析器。文档与打包检查使用 Pyt
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 模式 | 生成的展示结构 |
|
`name` 必须与目录名称一致。主题目录仅保存这两个源码文件,不保存官方邮件模板或翻译副本。
|
||||||
|
|
||||||
|
| 模式 | 展示结构 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `framed` | 使用共享控件和框架布局,由主题 CSS 定义样式。新主题默认使用此模式及 `standard` 布局。 |
|
| `framed` | 使用共享控件和布局,由主题 CSS 定义样式。新主题默认使用此模式及 `standard` 布局。 |
|
||||||
| `shared` | 在官方页头片段中加入 CSS,并保留官方页脚片段;不增加框架控件或各类邮件的覆盖模板。 |
|
| `shared` | 在官方页头片段中加入 CSS,并保留官方页脚片段;不增加框架控件或各类邮件的覆盖模板。 |
|
||||||
|
|
||||||
### 共享框架
|
`framed` 主题可通过 `layout` 选择 `framework/layouts/` 中的布局预设。页头、操作按钮、备用链接、侧栏和页脚位于 `framework/mail/base/`。多个主题共用的结构调整应放在共享框架中,官方内容与控件之间的适配位于 `tools/builder/framework.go`。
|
||||||
|
|
||||||
页头、操作按钮、备用链接、侧栏和页脚位于 `framework/mail/base/`。布局预设位于 `framework/layouts/`,`framed` 主题可通过可选的 `layout` 字段选择预设。配色、字体和间距由主题 CSS 定义。
|
主题 CSS 使用 `email-heading`、`email-text`、`email-subtext` 等现有类定义标题、正文和辅助说明层级。保留官方通知文字、翻译键、变量和功能链接,不通过 CSS 生成文案或隐藏业务内容。样式校验器会拒绝模板表达式、外部资源引用和不受支持的隐藏规则。
|
||||||
|
|
||||||
`tools/builder/framework.go` 将官方操作值和翻译键适配到共享控件。通知条件、主题行、附件和上下文链接由官方模板定义。控件或布局结构的修改应放在框架中,使各主题使用同一套适配逻辑。
|
完成主题后运行测试并生成预览:
|
||||||
|
|
||||||
布局片段组合后必须形成标签配对完整的展示结构。`__HEADER__` 插入共享页头,`__MAIL_TYPE__` 展开为发现的邮件 ID,页脚片段中的 `__SIDEBAR__` 插入共享侧栏。部署模板的 Logo 使用 `{{AppUrl}}assets/img/favicon.png`;生成的预览数据嵌入下载的图标,供离线显示。
|
|
||||||
|
|
||||||
## 设计规范
|
|
||||||
|
|
||||||
- 使用兼容邮件客户端的 CSS。主题 CSS 不得加载外部资源、生成文字或隐藏官方内容。
|
|
||||||
- 布局片段使用展示性标记。校验器接受 `table`、`tbody`、`tr`、`td`、`div`、`span` 及支持的展示属性。
|
|
||||||
- 修改已有主题时,保留其配色、字体、边框、页头、按钮和布局特征。
|
|
||||||
- 检查桌面和 390px 移动端预览,覆盖长文本和长 URL。条件允许时测试 Gmail、Outlook 和 Apple Mail;浏览器预览不能模拟邮件客户端。
|
|
||||||
- 画廊图片使用 PNG,单张不超过 50 KiB,建议为 10–20 KiB。按[截图指南](images/README.md)保持截图一致。
|
|
||||||
|
|
||||||
## 更新官方快照
|
|
||||||
|
|
||||||
`gitea.lock.json` 记录稳定的 Gitea 28+ 标签、对应提交和每个文件的 SHA-256。官方邮件模板、语言文件、图标、许可证和已评审的适配参考源码下载到 `build/upstream/`。仓库仅提交生成的根锁文件,不维护官方文件副本。
|
|
||||||
|
|
||||||
### 命令参考
|
|
||||||
|
|
||||||
在 `tools/` 中执行。每个上游子命令均支持 `--root <仓库根目录>`,默认值为相对当前工作目录的 `..`。参数放在子命令之后,包含空格的路径需要加引号:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
go run . upstream verify --root "C:\Projects\GiteaMailTemplates"
|
|
||||||
```
|
|
||||||
|
|
||||||
| 命令 | 行为 |
|
|
||||||
|---|---|
|
|
||||||
| `go run . upstream prepare` | 读取根锁文件。缓存不存在时下载并校验对应文件;已有缓存则离线校验。不修改根锁文件。 |
|
|
||||||
| `go run . upstream verify` | 对照根锁文件离线、只读检查已有缓存。输出 `[PASS]`,并以 `[FALLBACK]` 列出非英文语言缺少的键。 |
|
|
||||||
| `go run . upstream sync --tag vX.Y.Z` | 通过 GitHub API 解析明确指定的稳定 Gitea 28+ 标签,下载并校验文件,然后替换缓存并生成根锁文件。 |
|
|
||||||
|
|
||||||
`sync` 使用 `api.github.com`,文件下载使用 `raw.githubusercontent.com`。这些命令不接受本地 Gitea 克隆、认证令牌或隐式的 `latest` 版本。网络错误和 API 限流会中止操作;Go 工具链或模块可能仍需单独联网下载。
|
|
||||||
|
|
||||||
### 已有克隆与离线使用
|
|
||||||
|
|
||||||
`build`、`preview` 和 `dev` 会自动准备输入,需要已提交的根锁文件,并在使用缓存前完成校验。缓存、Go 工具链和依赖齐备后,可以离线构建。
|
|
||||||
|
|
||||||
需要单独检查缓存时,使用 `upstream verify`。它校验官方文件哈希、已评审的适配参考源码,以及官方模板引用的英文翻译键。构建和渲染还会检查框架翻译键及主要操作链接的锚点,因此缓存校验只是兼容性测试的一部分。
|
|
||||||
|
|
||||||
### 锁文件缺失与显式更新版本
|
|
||||||
|
|
||||||
已有克隆缺少 `gitea.lock.json` 时,应恢复受版本控制的文件。`build/upstream/lock.json` 中的副本不能替代根锁文件。需要有意初始化锁文件时,执行:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd tools
|
|
||||||
go run . upstream sync --tag v28.0.0
|
|
||||||
go run . upstream verify
|
|
||||||
go test ./...
|
go test ./...
|
||||||
|
go run . preview my-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
### delete
|
||||||
|
|
||||||
|
`delete` 删除指定主题的源码目录,支持一个或多个名称:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . delete my-theme
|
||||||
|
go run . delete first-theme second-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
可通过 `--folder` 指定主题目录,默认值为 `../themes`。
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> 命令校验主题后直接删除目录,不提供确认提示或回收站恢复。执行前确认名称,并保留需要的修改。
|
||||||
|
|
||||||
|
不存在的主题会报告警告;无效主题或符号链接目录会被拒绝。多个主题依次处理,后续失败不会恢复已删除的目录。`all` 不表示删除全部主题。
|
||||||
|
|
||||||
|
删除源码不会移除之前生成的构建文件、预览数据或已部署的模板。重新执行 `preview all` 更新预览清单;需要移除部署的主题时,按实际安装路径单独处理。
|
||||||
|
|
||||||
|
### preview
|
||||||
|
|
||||||
|
`preview` 构建所选主题,并使用示例数据渲染全部锁定的官方语言。必须指定一个或多个主题,或使用 `all`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . preview aurora
|
||||||
|
go run . preview aurora bloom
|
||||||
go run . preview all
|
go run . preview all
|
||||||
```
|
```
|
||||||
|
|
||||||
评审其他版本时,明确指定对应标签。检查锁文件差异,按需更新框架适配逻辑和测试数据,完成检查后,再更新兼容性记录。`sync` 只修改缓存和锁文件,文档更新与版本发布需单独完成。仅缺少缓存时使用 `prepare`。
|
| 选项 | 默认值 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| `--folder` | `../themes` | 主题源码目录;其父目录作为项目根目录 |
|
||||||
|
| `--config` | `./data/templates_config.json` | 邮件类型说明和预览示例数据 |
|
||||||
|
| `--output` | 项目根目录下的 `preview/rendered.js` | 预览清单路径 |
|
||||||
|
|
||||||
已评审的翻译或邮件渲染参考源码发生变化时,须先评审适配逻辑,再更新参考哈希。官方英文必须包含所有引用的翻译键;其他语言缺少的翻译回退为英文。新增邮件类型需要补充框架适配和 `tools/data/templates_config.json` 中的测试数据,该文件提供预览元数据和示例上下文。JSON 测试数据中的整数应保持整数形式,以便 Go 正确格式化。
|
默认输出包括 `preview/rendered.js` 和 `preview/rendered/<语言>.js`。在浏览器中打开 [preview/index.html](../preview/index.html) 即可查看,无需启动服务器。操作和快捷键见 [README](README.zh-CN.md#控制和快捷键)。
|
||||||
|
|
||||||
缓存替换前发生网络或校验错误时,原有文件保持不变。缓存替换和根锁文件写入是两个操作;文件系统错误中断操作后,重试前应检查二者是否一致。
|
> [!NOTE]
|
||||||
|
> 语言名称由 `golang.org/x/text/language/display` 的 CLDR 数据按实际预览语言生成,并写入预览清单的 `language_names`。预览界面直接读取清单,无需维护语言名称表。
|
||||||
|
|
||||||
### 缓存恢复
|
> [!IMPORTANT]
|
||||||
|
> 每次生成会覆盖输出位置的预览清单,不与先前选择的主题合并。例如,执行 `preview aurora` 后,该清单只包含 Aurora;需要恢复全部主题时执行 `preview all`。
|
||||||
|
|
||||||
`prepare` 会报告损坏、不完整或与锁文件不匹配的缓存,不会自动修复。`sync` 同样拒绝替换非空的无效快照。检查错误后,将生成的缓存移至备份位置,再按已评审的根锁文件重新准备。
|
自定义输出示例:
|
||||||
|
|
||||||
例如,在**仓库根目录的 PowerShell** 中,使用尚不存在的备份名称:
|
```bash
|
||||||
|
go run . preview --config ./data/templates_config.json --output ../build/preview-review/rendered.js all
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> 语言数据写入输出文件同级的 `rendered/` 目录。命令不会复制预览界面或修改其脚本引用;现有 `preview/index.html` 仍读取默认位置的数据。
|
||||||
|
|
||||||
|
新增邮件类型或渲染分支时,补充 `tools/data/templates_config.json` 中的说明和示例上下文。JSON 中用于计数、大小等数值的整数应保持整数形式。正文、发布说明和评审内容等 HTML 字段应使用可控的测试内容,避免包含个人信息或真实凭据。
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> 预览用于检查模板结构和展示效果。它使用示例上下文,不能代替目标 Gitea 版本的参数兼容性评审;浏览器与邮件客户端对 CSS 的支持也存在差异。
|
||||||
|
|
||||||
|
### dev
|
||||||
|
|
||||||
|
`dev` 启动本地开发服务器,首次启动时构建全部主题并准备预览数据:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . dev
|
||||||
|
```
|
||||||
|
|
||||||
|
打开 [http://127.0.0.1:3456](http://127.0.0.1:3456)。默认端口为 `3456`,可通过 `--port` 修改:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . dev --port 3457
|
||||||
|
```
|
||||||
|
|
||||||
|
服务器仅监听 `127.0.0.1`。在终端中按 `Ctrl + C` 停止运行。该命令按当前 `tools/` 工作目录定位项目,不提供 `--folder`、`--config` 或 `--root` 选项。
|
||||||
|
|
||||||
|
服务器监听主题源码、共享框架、根锁文件、官方缓存及 `tools/data/` 中的预览数据。文件变化后重新构建,通过服务器发送事件(SSE)刷新预览。构建失败时,根据终端输出修复问题,再保存文件。
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> 修改 `preview/index.html` 后手动刷新页面;修改 Go 工具代码后停止并重新启动服务器。这些文件不属于当前的自动重建监听范围。
|
||||||
|
|
||||||
|
### help、h
|
||||||
|
|
||||||
|
查看全部命令或指定命令的帮助:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . help
|
||||||
|
go run . h
|
||||||
|
go run . help build
|
||||||
|
go run . preview --help
|
||||||
|
```
|
||||||
|
|
||||||
|
查看 `upstream` 子命令的参数时,将 `--help` 放在子命令后:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go run . upstream prepare --help
|
||||||
|
go run . upstream sync --help
|
||||||
|
go run . upstream verify --help
|
||||||
|
```
|
||||||
|
|
||||||
|
工具诊断信息采用 `[LEVEL] [NAME] Message` 格式,`[I]`、`[W]`、`[E]`、`[F]` 分别表示信息、警告、错误和致命错误。在支持颜色的终端中,等级标记使用不同颜色;设置 `NO_COLOR` 可禁用颜色。命令失败时返回非零退出码,排查时保留完整输出。
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
### 缺少锁文件或官方缓存怎么办?
|
||||||
|
|
||||||
|
已有克隆缺少 `gitea.lock.json` 时,应恢复受版本控制的根锁文件。缓存中的 `build/upstream/lock.json` 不能代替它。仅缺少缓存时执行 `upstream prepare`,不要为了恢复缓存而同步到其他版本。`build`、`preview` 和 `dev` 会自动准备官方输入。缓存、Go 工具链和依赖齐备后可以离线使用;`upstream verify` 始终只检查本地文件。首次下载遇到网络错误或 GitHub API 限流时,解决网络问题后重试。
|
||||||
|
|
||||||
|
### 缓存损坏或与锁文件不匹配怎么办?
|
||||||
|
|
||||||
|
`prepare` 不会自动修复损坏的缓存,`sync` 也会拒绝替换非空的无效快照。先停止开发服务器,保留根锁文件,将缓存移至备份位置后重新准备。例如,在**仓库根目录的 PowerShell** 中,使用尚不存在的备份名称:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Move-Item -LiteralPath .\build\upstream -Destination .\build\upstream.backup
|
Move-Item -LiteralPath .\build\upstream -Destination .\build\upstream.backup
|
||||||
@@ -131,63 +277,64 @@ go run . upstream prepare
|
|||||||
go run . upstream verify
|
go run . upstream verify
|
||||||
```
|
```
|
||||||
|
|
||||||
保留 `build/` 中的其他内容,不直接编辑缓存中的官方文件。需要回退快照时,恢复此前已评审的根锁文件,再按同样方式重建缓存。替换输入前先停止 `dev`,避免多个进程同时写入同一缓存。
|
> [!WARNING]
|
||||||
|
> 不要直接修改缓存中的官方文件,也不要删除 `build/` 中的其他内容。回退官方版本时,恢复此前已评审的根锁文件,再按同样方式重建缓存。
|
||||||
|
|
||||||
### 已知上游格式问题
|
### 为什么同步新版本时提示适配源码发生变化?
|
||||||
|
|
||||||
Gitea v28.0.0 的波兰语 `mail.team_invite.text_1` 存在占位符缺陷。预览保留官方输出并报告 `[UPSTREAM-WARN]`。该例外仅匹配已评审的完整原文,其他格式错误会使渲染失败。发现上游问题时应报告问题,不修改缓存中的语言文件。
|
项目固定了已评审的邮件渲染和翻译参考源码。上游修改这些实现后,工具会要求重新评审,避免继续使用不匹配的预览函数或变量结构。检查官方改动,调整适配逻辑和相关测试,再更新参考哈希。新增邮件、翻译键、函数或变量路径都可能需要对应修改。验证通过后再更新[兼容性记录](COMPATIBILITY.zh-CN.md),不要把成功下载等同于完成兼容性确认。
|
||||||
|
|
||||||
## 验证与发布
|
### 为什么部分语言使用英文或出现格式警告?
|
||||||
|
|
||||||
### 拉取请求检查
|
官方英文必须包含所有引用的翻译键;其他语言缺少的键回退为英文,并报告警告。保留官方语言文件,不在缓存中补写译文。
|
||||||
|
|
||||||
在 `tools/` 中运行 `go test ./...` 和 `go run . preview all`。测试覆盖生成结果的确定性、操作锚点变化、翻译键,以及全部主题和语言的通知主题行、正文与链接。测试数据包含推送、评审、回复、工作流和附件分支;共享控件与品牌展示作为附加内容单独处理。
|
例如 Gitea v28.0.0 的波兰语 `mail.team_invite.text_1` 存在已知占位符缺陷。预览对已评审的完整原文保留官方输出并报告警告,该例外不适用于其他格式错误。新增问题应提供版本、翻译键和复现信息,以便评审和向上游反馈。
|
||||||
|
|
||||||
修改文档或打包流程时,在仓库根目录执行:
|
### 为什么预览没有显示新主题或最新修改?
|
||||||
|
|
||||||
|
静态预览不会自动构建。重新执行 `preview all` 并刷新页面,确认预览清单包含所需主题。使用自定义输出路径时,检查预览界面实际读取的位置;使用 `dev` 时,先查看终端是否报告重建失败。Go 代码变更需要重启服务器,预览界面变更需要手动刷新。默认端口被占用时,使用 `--port` 指定其他端口。
|
||||||
|
|
||||||
|
### 构建成功是否意味着支持所有 Gitea 版本?
|
||||||
|
|
||||||
|
构建结果针对根锁文件指定的官方输入。不同版本可能修改模板目录、函数或变量结构,不能仅凭构建或预览成功确认向下兼容。部署时按[兼容性表](COMPATIBILITY.zh-CN.md#兼容性表)选择发行包,不将新版本模板直接用于旧版本实例。
|
||||||
|
|
||||||
|
### 为什么打包脚本拒绝当前产物?
|
||||||
|
|
||||||
|
打包前执行 `preview all`,确保全部主题和语言数据齐备,且生成文件与当前源码一致。版本参数必须与根锁文件中的标签一致。源码或生成文件变化后,应重新构建和预览。脚本不会覆盖已有发行压缩包。重新打包时选择新的输出目录,保留需要对照的旧产物。
|
||||||
|
|
||||||
|
## 其它事宜
|
||||||
|
|
||||||
|
### 主题与共享框架
|
||||||
|
|
||||||
|
使用适合邮件客户端的 CSS。修改已有主题时,保留其配色、字体、边框和布局特征,使标题、正文和辅助说明的层级清晰,并考虑长文本、长 URL 和移动端宽度。布局片段使用展示性标记,支持 `table`、`tbody`、`tr`、`td`、`div`、`span` 及校验器允许的属性。组合后的标签必须完整配对;`__HEADER__` 插入共享页头,`__MAIL_TYPE__` 展开为邮件 ID,页脚中的 `__SIDEBAR__` 插入共享侧栏。业务变量和通知条件的变更应在构建适配逻辑中评审,不放入主题 CSS 或布局预设。
|
||||||
|
|
||||||
|
新增主题时更新中英文 README 的画廊。图片使用 PNG,单张不超过 50 KiB,建议为 10–20 KiB;主题、模板、语言和裁切方式按[截图指南](images/README.md)保持一致。
|
||||||
|
|
||||||
|
### 提交与拉取请求
|
||||||
|
|
||||||
|
围绕一个明确问题组织改动,避免混入无关的格式调整。拉取请求说明修改原因、影响范围和验证结果;涉及视觉变化时,可附上使用示例数据生成的对照图。修改主题、共享框架或 Go 工具时,在 `tools/` 中运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go test ./...
|
||||||
|
go run . preview all
|
||||||
|
```
|
||||||
|
|
||||||
|
涉及邮件内容、链接、变量或函数适配时,补充对应的回归测试,覆盖受影响的条件分支。现有测试检查生成结果、翻译键及全部主题和语言的通知主题行、正文与链接,包括推送、评审、回复、工作流和附件分支。
|
||||||
|
|
||||||
|
修改打包脚本时,在仓库根目录运行:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python -B -m unittest discover -s .github/scripts -p 'test_*.py'
|
python -B -m unittest discover -s .github/scripts -p 'test_*.py'
|
||||||
```
|
```
|
||||||
|
|
||||||
调整通用说明时,同步更新英文和简体中文指南。拉取请求应说明改动内容及相关检查结果,涉及视觉变化时附上截图。
|
纯文档修改检查文字、命令示例和链接即可。中文文档与英文文档应保持内容一致;翻译时保留命令、路径、变量和版本信息,不改变原意。
|
||||||
|
|
||||||
### 准备发行版
|
提交信息使用简短说明,可参考以下前缀:
|
||||||
|
|
||||||
发行标签必须与锁定的 Gitea 版本一致。当前源码重构尚未发布,已有 v28.0.0 和历史版本的附件应保留。
|
|
||||||
|
|
||||||
1. 完成 Go 测试、文档检查和预览生成。
|
|
||||||
2. 按验证结果更新文档和兼容性记录。发行说明为可选内容,不用于 Release 正文。
|
|
||||||
3. 在 `tools/` 中运行 `go run . preview all`,生成全部主题和语言数据。
|
|
||||||
4. 打包并检查发行包内容后再发布。
|
|
||||||
|
|
||||||
手动打包时,在仓库根目录执行:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python .github/scripts/package_release.py --version vX.Y.Z --output <new-output-directory>
|
|
||||||
```
|
|
||||||
|
|
||||||
将版本和输出目录占位符替换为已评审的标签及新的目录。脚本会检查源码与产物哈希,包含所有语言数据包,排除残留的旧主题构建,并拒绝覆盖已有压缩包。
|
|
||||||
|
|
||||||
发布工作流使用同一脚本打包模板、预览、文档、官方许可证和来源信息,仅上传发行归档,以标签作为 Release 标题,新建 Release 的正文为空。版本标记、徽章和兼容性记录均由维护者手动修改,归档文档应在打标签前检查。依赖自动发布前,请确认所用 Gitea 主机的 Actions 支持和写入权限。工作流行为见[版本维护](COMPATIBILITY.zh-CN.md#版本维护)。
|
|
||||||
|
|
||||||
### Gitea 工作流配置
|
|
||||||
|
|
||||||
发布工作流使用 `linux-amd64-docker-small` Runner 标签。任务镜像需要支持检出和工具链安装步骤使用的 Node.js Action,并提供 Git 和 POSIX Shell。Go 与 Python 由安装步骤准备。
|
|
||||||
|
|
||||||
发布直接使用 [`gitea-release-action@v1.3.7`](https://gitea.com/actions/gitea-release-action/src/tag/v1.3.7/action.yml),传入实例地址、仓库、内置 `GITEA_TOKEN`、标签、标题和两个归档路径。新建 Release 的正文为空,不要求发行说明文件,也不创建提醒 Issue。仓库需允许发行版写入。Action 地址显式使用 `https://gitea.com`,不依赖 `DEFAULT_ACTIONS_URL` 配置。
|
|
||||||
|
|
||||||
发布前通过 `actions/setup-node@v4` 准备 Node.js 22。当前 Gitea runner 使用 `PATH` 中的 `node` 执行 JavaScript Action,提供发布 Action 所需的运行接口,无需 `--experimental-fetch`。重复发布已有标签时,Action 保留已有正文并替换同名附件,不具备原脚本在全部附件上传完成前保持草稿的行为。发布失败后,重试前应检查发行版和附件。
|
|
||||||
|
|
||||||
## 报告问题
|
|
||||||
|
|
||||||
请提供 Gitea 版本、模板发行版或源码提交、主题、邮件类型、语言和复现步骤。源码构建问题还应包含快照标签与提交,以及 `go run . upstream verify` 或 `go run . preview all` 的输出。显示问题请注明邮件客户端,并附上移除个人信息后的截图。
|
|
||||||
|
|
||||||
## 提交规范
|
|
||||||
|
|
||||||
| 前缀 | 范围 |
|
| 前缀 | 范围 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `style(<名称>):` | 主题展示样式 |
|
| `style(<名称>):` | 主题展示样式 |
|
||||||
| `preview:` | 浏览器预览 |
|
| `preview:` | 预览工具 |
|
||||||
| `tools:` | CLI、构建与快照工具 |
|
| `tools:` | CLI、构建与快照工具 |
|
||||||
| `docs:` | 文档和翻译 |
|
| `docs:` | 文档和翻译 |
|
||||||
| `fix:` | 问题修复 |
|
| `fix:` | 问题修复 |
|
||||||
@@ -195,6 +342,26 @@ python .github/scripts/package_release.py --version vX.Y.Z --output <new-output-
|
|||||||
| `refactor:` | 代码重构 |
|
| `refactor:` | 代码重构 |
|
||||||
| `chore:` | 日常维护 |
|
| `chore:` | 日常维护 |
|
||||||
|
|
||||||
## 翻译与许可证
|
### 版本与发布维护
|
||||||
|
|
||||||
[英文指南](../CONTRIBUTING.md)介绍相同的开发流程。贡献采用 MIT 许可证;分发派生模板时,请保留 Gitea 版权和官方许可证,详见[第三方声明](../THIRD_PARTY_NOTICES.md)。
|
发行标签必须与锁定的 Gitea 标签一致。版本标记、徽章和兼容性记录由维护者手动更新;修改官方输入不会自动触发版本维护。历史发行附件应保留,文档和兼容性记录应在打标签前检查。完成验证并生成全部预览后,可在仓库根目录手动打包:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python .github/scripts/package_release.py --version v28.2.0 --output build/release-review
|
||||||
|
```
|
||||||
|
|
||||||
|
将示例版本替换为根锁文件中的标签,并使用没有同名发行压缩包的输出目录。脚本检查源码与产物的校验值,打包主题、预览、文档、官方许可证和来源信息,排除残留的旧主题构建。
|
||||||
|
|
||||||
|
`.github/workflows/validate.yml` 负责普通推送和拉取请求检查,也供 Release 工作流调用。Release 验证通过后打包归档,并通过发布 Action 上传附件,以标签作为标题,新建 Release 的正文为空,不要求发行说明文件。重新发布已有标签时保留已有正文并替换同名附件;失败后重试前检查发行版及附件状态。
|
||||||
|
|
||||||
|
工作流使用 `linux-amd64-docker-small` Runner 标签,并通过安装步骤准备 Go、Python 和发布所需的 Node.js。Action 使用 `actions/...@版本` 引用,由 Runner 的 Action 来源配置解析;维护时应考虑当前 `github_mirror` 配置。发布使用内置 `GITEA_TOKEN`,仓库需具备发行版写入权限。
|
||||||
|
|
||||||
|
### 报告问题
|
||||||
|
|
||||||
|
问题报告应包含 Gitea 版本、模板发行版或源码提交、主题、邮件类型、语言和复现步骤。构建或预览问题还应提供根锁文件中的标签、相关命令和完整错误输出;显示问题注明邮件客户端,并附上移除个人信息后的截图。
|
||||||
|
|
||||||
|
提出改进建议时,说明使用场景、预期效果及涉及的主题或工具。发现官方模板或翻译问题时,保留原始输入,提供能够复现问题的最小示例。
|
||||||
|
|
||||||
|
### 许可证
|
||||||
|
|
||||||
|
本项目采用 [MIT 许可证](../LICENSE)。贡献应使用能够合法分发的代码、样式和图片。生成和分发派生模板时,保留 Gitea 版权、官方许可证及快照来源信息;发行包已包含相关文件。
|
||||||
+14
-13
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
Gitea Mail Template 为自托管的 [Gitea](https://about.gitea.com) 提供多种可选、适合的邮件模板风格。
|
Gitea Mail Template 为自托管的 [Gitea](https://about.gitea.com) 提供多种可选、适合的邮件模板风格。
|
||||||
|
|
||||||
> 最新发布版:[v28.0.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
> 最新发布版:[v28.1.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
||||||
|
|
||||||
仓库包含数种主题的 Gitea 邮件模板,适合大多数的部署场景与应用范围。安装前,请根据 Gitea 版本查阅[兼容矩阵](../COMPATIBILITY.md#compatibility-matrix),选择对应的发行包。
|
仓库包含数种主题的 Gitea 邮件模板,适合大多数的部署场景与应用范围。安装前,请根据 Gitea 版本查阅[兼容性表](./COMPATIBILITY.zh-CN.md#兼容性表),选择对应的发行包。
|
||||||
|
|
||||||
## 风格画廊
|
## 风格画廊
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ Gitea Mail Template 为自托管的 [Gitea](https://about.gitea.com) 提供多
|
|||||||
|  | **Terminal** | 深色背景、等宽字体、绿色强调色 |
|
|  | **Terminal** | 深色背景、等宽字体、绿色强调色 |
|
||||||
|  | **Terra** | 大地色调、陶土色按钮、衬线字体 |
|
|  | **Terra** | 大地色调、陶土色按钮、衬线字体 |
|
||||||
|
|
||||||
截图仅展示当前默认构建效果,其他邮件类型和语言可通过[本地预览](#预览)查看;更新截图请参阅[截图指南](images/README.md)。
|
截图仅展示当前默认构建效果,其他邮件类型和语言可通过[预览](#预览)查看;更新截图请参阅[截图指南](images/README.md)。
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
@@ -52,7 +52,8 @@ cd tools
|
|||||||
go run . build all
|
go run . build all
|
||||||
cd ..
|
cd ..
|
||||||
```
|
```
|
||||||
构建可用模板时需要依赖于 Gitea 官方仓库的资源文件,以确保来源的一致性。因此该命令会自动下载由`gitea.lock.json` 文件锁定的官方文件,后续构建无需再次下载,使用缓存目录资源即可运行。文件缺失或缓存损坏的处理方式见[更新官方快照](#更新官方快照)。
|
|
||||||
|
构建可用模板时需要依赖于 Gitea 官方仓库的资源文件,以确保来源的一致性。因此该命令会自动下载由`gitea.lock.json` 文件锁定的官方文件,后续构建无需再次下载,使用缓存目录资源即可运行。
|
||||||
|
|
||||||
### 安装主题
|
### 安装主题
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ systemctl restart gitea
|
|||||||
```
|
```
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 使用源码构建产物时,将复制来源改为 `build/themes/horizon/mail/.`。Docker 和 Windows 部署请使> 用相应的容器或服务管理方式暂停和重启。
|
> 使用源码构建产物时,将复制来源改为 `build/themes/horizon/mail/.`。Docker 和 Windows 部署请使用相应的容器或服务管理方式暂停和重启。
|
||||||
|
|
||||||
### 切换主题
|
### 切换主题
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ go run . dev
|
|||||||
cd ..
|
cd ..
|
||||||
```
|
```
|
||||||
|
|
||||||
打开 [http://127.0.0.1:3456](http://127.0.0.1:3456)。Go 服务器监听主题文件、共享框架、锁文件与缓存、预览测试数据的变化。一旦监听到文件更改,服务器会将邮件模板重新构建后通过发送事件(SSE)刷新页面,以实现实时热重载。
|
打开 [http://127.0.0.1:3456](http://127.0.0.1:3456)。服务器会监听主题文件、共享框架、锁文件与缓存、预览测试数据的变化。一旦监听到文件更改,服务器会将邮件模板重新构建后通过发送事件(SSE)刷新页面,以实现实时热重载。
|
||||||
|
|
||||||
### 控制和快捷键
|
### 控制和快捷键
|
||||||
|
|
||||||
@@ -125,9 +126,11 @@ cd ..
|
|||||||
|
|
||||||
## 兼容性
|
## 兼容性
|
||||||
|
|
||||||
- **最新测试:** Gitea 28.0.0
|
- **最新测试:** Gitea 28.2.0
|
||||||
- **最新发布版:** [v28.0.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
- **源码构建基线:** Gitea 28.2.0
|
||||||
- **上游 Gitea 28.1.0:** [PENDING]
|
- **最新发布版:** [v28.1.0](https://gitea.kenanzhu.com/KenanZhu/GiteaMailTemplates/releases/latest)
|
||||||
|
|
||||||
|
Gitea 28.2.0 未引入邮件模板接口变更,已发布的 v28.1.0 模板仍兼容;源码构建使用锁定的 v28.2.0 官方输入,详见[兼容性记录](COMPATIBILITY.zh-CN.md)。
|
||||||
|
|
||||||
## 项目目录结构
|
## 项目目录结构
|
||||||
|
|
||||||
@@ -137,7 +140,6 @@ cd ..
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
.github/ # 工作流及维护脚本
|
.github/ # 工作流及维护脚本
|
||||||
release-notes/ # 各版本的发行说明
|
|
||||||
scripts/ # 文档更新、打包和 Gitea 发布脚本
|
scripts/ # 文档更新、打包和 Gitea 发布脚本
|
||||||
workflows/ # 验证和发布
|
workflows/ # 验证和发布
|
||||||
docs/ # 中文文档、文档索引和画廊图片
|
docs/ # 中文文档、文档索引和画廊图片
|
||||||
@@ -154,7 +156,6 @@ tools/ # Go 命令行工具、构建工具和测试
|
|||||||
preview/ # 邮件渲染、语言适配和开发服务器
|
preview/ # 邮件渲染、语言适配和开发服务器
|
||||||
upstream/ # 官方快照下载、校验和翻译键发现
|
upstream/ # 官方快照下载、校验和翻译键发现
|
||||||
gitea.lock.json # 官方版本标签、提交和文件校验值
|
gitea.lock.json # 官方版本标签、提交和文件校验值
|
||||||
README.md
|
|
||||||
```
|
```
|
||||||
|
|
||||||
官方模板提供通知内容、条件、主题行和链接;共享框架负责邮件呈现,主题通过元数据和 CSS 选择布局、定义样式。主题目录中不保存官方邮件源码或翻译文件。
|
官方模板提供通知内容、条件、主题行和链接;共享框架负责邮件呈现,主题通过元数据和 CSS 选择布局、定义样式。主题目录中不保存官方邮件源码或翻译文件。
|
||||||
@@ -195,11 +196,11 @@ preview/rendered/<LOCALE>.js # 各语言的预览数据
|
|||||||
|
|
||||||
## 参与贡献
|
## 参与贡献
|
||||||
|
|
||||||
欢迎改进主题、工具、文档和翻译。[贡献指南](CONTRIBUTING.zh-CN.md)介绍了本地环境准备、设计规范、检查要求和发布流程。
|
欢迎改进主题、工具、文档和翻译。[贡献指南](CONTRIBUTING.zh-CN.md)介绍了贡献相关的事宜。
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
本项目采用 [MIT 许可证](../LICENSE)。生成的发行包保留 Gitea 许可证和快照来源信息,详见[第三方声明](../THIRD_PARTY_NOTICES.md)。
|
本项目采用 [MIT 许可证](../LICENSE)。生成的发行包保留 Gitea 许可证和快照来源信息。
|
||||||
|
|
||||||
---
|
---
|
||||||
### 注释
|
### 注释
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"schema": 1,
|
"schema": 1,
|
||||||
"repository": "https://github.com/go-gitea/gitea",
|
"repository": "https://github.com/go-gitea/gitea",
|
||||||
"tag": "v28.0.0",
|
"tag": "v28.2.0",
|
||||||
"commit": "15b8a5805adf57c5189602008d38cccfd3c795e0",
|
"commit": "829b49c1ae96015e345f9d2a0eb1ea7acd5f31e1",
|
||||||
"files": {
|
"files": {
|
||||||
"LICENSE": "ed2f10a9d78b8c6c9ef33f1420d0eb266981891caf2f15d630553f02dc60d3ae",
|
"LICENSE": "ed2f10a9d78b8c6c9ef33f1420d0eb266981891caf2f15d630553f02dc60d3ae",
|
||||||
"modules/templates/mail.go": "fb8204b79f700f88c7c3f0da16e50c3d678a2216e62e98f712805ed1d42ab3a9",
|
"modules/templates/mail.go": "fb8204b79f700f88c7c3f0da16e50c3d678a2216e62e98f712805ed1d42ab3a9",
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"options/locale/locale_cs-CZ.json": "816c4a0cfc6112c8cc9a63e63b3de0bc623819a23d2f2bbb800b09c45d23da66",
|
"options/locale/locale_cs-CZ.json": "816c4a0cfc6112c8cc9a63e63b3de0bc623819a23d2f2bbb800b09c45d23da66",
|
||||||
"options/locale/locale_de-DE.json": "593ec4e3652c0faf9ecb5d5b27a649c1c0a933030ecdfbf4dc810ea4ad69bfb8",
|
"options/locale/locale_de-DE.json": "593ec4e3652c0faf9ecb5d5b27a649c1c0a933030ecdfbf4dc810ea4ad69bfb8",
|
||||||
"options/locale/locale_el-GR.json": "dd03e6e083d6286d8eb2045a37bcf5c578fc339ab87a72a7397e01733078d89e",
|
"options/locale/locale_el-GR.json": "dd03e6e083d6286d8eb2045a37bcf5c578fc339ab87a72a7397e01733078d89e",
|
||||||
"options/locale/locale_en-US.json": "bb58779f10b2cd0ee94f71297b2231a621d4d30f2a56a2b223f3c586f635f592",
|
"options/locale/locale_en-US.json": "0821c7e631d62e8d80a49a119ba0fb4430f27e4da37a3c943b3cd0faee43e163",
|
||||||
"options/locale/locale_es-ES.json": "cbb1cd7bc4709a189b8b189d26a83a06fed0c32e0b5ac5602370fb0f03a39d04",
|
"options/locale/locale_es-ES.json": "cbb1cd7bc4709a189b8b189d26a83a06fed0c32e0b5ac5602370fb0f03a39d04",
|
||||||
"options/locale/locale_fa-IR.json": "ad85f5829335844883608ed5ed09dee5bc5f4800cda7ef9277200aa4a7f35f32",
|
"options/locale/locale_fa-IR.json": "ad85f5829335844883608ed5ed09dee5bc5f4800cda7ef9277200aa4a7f35f32",
|
||||||
"options/locale/locale_fi-FI.json": "3b811b0ee794548399bcb64a887711a26cc0c26e04dfd0305b0846742d065952",
|
"options/locale/locale_fi-FI.json": "3b811b0ee794548399bcb64a887711a26cc0c26e04dfd0305b0846742d065952",
|
||||||
|
|||||||
+33
-159
@@ -29,10 +29,6 @@ body{font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:v
|
|||||||
#topbar .btn-group button+button{border-left:none}
|
#topbar .btn-group button+button{border-left:none}
|
||||||
#topbar .btn-group button.on{background:var(--accent);color:#000;border-color:var(--accent);font-weight:600}
|
#topbar .btn-group button.on{background:var(--accent);color:#000;border-color:var(--accent);font-weight:600}
|
||||||
#topbar .hint{font-size:10px;color:var(--muted);opacity:.5;white-space:nowrap}
|
#topbar .hint{font-size:10px;color:var(--muted);opacity:.5;white-space:nowrap}
|
||||||
#btn-screenshot{display:inline-flex;align-items:center;gap:6px;background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:var(--rad);padding:6px 12px;font-size:12px;cursor:pointer}
|
|
||||||
#btn-screenshot svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;flex-shrink:0}
|
|
||||||
#btn-screenshot:hover:not(:disabled){border-color:var(--accent)}
|
|
||||||
#btn-screenshot:disabled{opacity:.45;cursor:wait}
|
|
||||||
button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
|
button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
|
||||||
|
|
||||||
/* Topbar responsive — progressively compact as width shrinks */
|
/* Topbar responsive — progressively compact as width shrinks */
|
||||||
@@ -129,12 +125,15 @@ section.collapsed .section-chevron{transform:rotate(-90deg)}
|
|||||||
|
|
||||||
/* Collapsible content wrapper */
|
/* Collapsible content wrapper */
|
||||||
.section-content{
|
.section-content{
|
||||||
margin-top:10px;
|
display:grid;grid-template-rows:1fr;opacity:1;margin-top:10px;
|
||||||
|
transition:grid-template-rows .3s ease,opacity .25s ease,margin-top .3s ease;
|
||||||
}
|
}
|
||||||
|
.section-content-inner{min-height:0;overflow:hidden}
|
||||||
section.collapsed .section-content{
|
section.collapsed .section-content{
|
||||||
display:none;
|
grid-template-rows:0fr;opacity:0;margin-top:0;
|
||||||
}
|
}
|
||||||
#sec-params .section-content{max-height:50vh;overflow:auto;overscroll-behavior:contain}
|
#sec-params .section-content-inner{max-height:50vh;overflow:auto;overscroll-behavior:contain}
|
||||||
|
section.collapsed .section-content-inner{overflow:hidden}
|
||||||
|
|
||||||
#panel .card{background:var(--bg);border-radius:var(--rad);padding:10px 12px;margin-bottom:8px}
|
#panel .card{background:var(--bg);border-radius:var(--rad);padding:10px 12px;margin-bottom:8px}
|
||||||
#panel .card:last-child{margin-bottom:0}
|
#panel .card:last-child{margin-bottom:0}
|
||||||
@@ -151,12 +150,12 @@ section.collapsed .section-content{
|
|||||||
#panel .stat{font-size:10px;color:var(--muted);margin-top:6px}
|
#panel .stat{font-size:10px;color:var(--muted);margin-top:6px}
|
||||||
|
|
||||||
/* Viewport */
|
/* Viewport */
|
||||||
#viewport{border-radius:var(--rad);box-shadow:0 8px 32px rgba(0,0,0,.45);flex-shrink:0;max-width:100%;overflow:hidden;background:#fff}
|
#viewport{border:0 solid #1e293b;border-radius:var(--rad);box-shadow:0 8px 32px rgba(0,0,0,.45);flex-shrink:0;max-width:100%;overflow:hidden;background:#fff;display:flex;flex-direction:column;transition:width .3s ease,border-radius .3s ease,border-width .3s ease,box-shadow .3s ease}
|
||||||
#viewport.desktop{width:100%;max-width:1386px;height:780px}
|
#viewport.desktop{width:100%;max-width:1386px;height:780px}
|
||||||
#viewport.mobile{width:390px;height:780px;border-radius:28px;border:3px solid #1e293b;box-shadow:0 8px 32px rgba(0,0,0,.5),inset 0 0 0 1px #0f172a;display:flex;flex-direction:column}
|
#viewport.mobile{width:390px;height:780px;border-radius:28px;border:3px solid #1e293b;box-shadow:0 8px 32px rgba(0,0,0,.5),inset 0 0 0 1px #0f172a;display:flex;flex-direction:column}
|
||||||
#viewport.mobile #preview-frame{flex:1;min-height:0}
|
#viewport::before{content:'';display:block;height:0;background:#1e293b;flex-shrink:0;transition:height .3s ease}
|
||||||
#viewport.mobile::before{content:'';display:block;height:24px;background:#1e293b;flex-shrink:0}
|
#viewport.mobile::before{height:24px}
|
||||||
#preview-frame{width:100%;height:100%;border:none;display:block;background:#fff}
|
#preview-frame{width:100%;height:100%;flex:1;min-height:0;border:none;display:block;background:#fff}
|
||||||
#viewport.desktop #preview-frame{border-radius:var(--rad)}
|
#viewport.desktop #preview-frame{border-radius:var(--rad)}
|
||||||
|
|
||||||
/* Loading */
|
/* Loading */
|
||||||
@@ -171,7 +170,7 @@ section.collapsed .section-content{
|
|||||||
.message code{background:rgba(0,0,0,0.12);padding:1px 6px;border-radius:3px}
|
.message code{background:rgba(0,0,0,0.12);padding:1px 6px;border-radius:3px}
|
||||||
|
|
||||||
/* Scrollbar — neutral gray, consistent across all browsers */
|
/* Scrollbar — neutral gray, consistent across all browsers */
|
||||||
html,body,#preview-area,#panel-body,#sec-params .section-content{
|
html,body,#preview-area,#panel-body,#sec-params .section-content-inner{
|
||||||
scrollbar-width:thin;
|
scrollbar-width:thin;
|
||||||
scrollbar-color:rgba(107,125,153,.25) transparent;
|
scrollbar-color:rgba(107,125,153,.25) transparent;
|
||||||
}
|
}
|
||||||
@@ -179,30 +178,30 @@ html,body,#preview-area,#panel-body,#sec-params .section-content{
|
|||||||
-ms-overflow-style:-ms-autohiding-scrollbar;
|
-ms-overflow-style:-ms-autohiding-scrollbar;
|
||||||
}
|
}
|
||||||
#preview-area::-webkit-scrollbar,
|
#preview-area::-webkit-scrollbar,
|
||||||
#sec-params .section-content::-webkit-scrollbar,
|
#sec-params .section-content-inner::-webkit-scrollbar,
|
||||||
#panel-body::-webkit-scrollbar { width:6px; height:6px }
|
#panel-body::-webkit-scrollbar { width:6px; height:6px }
|
||||||
#preview-area::-webkit-scrollbar-track,
|
#preview-area::-webkit-scrollbar-track,
|
||||||
#sec-params .section-content::-webkit-scrollbar-track,
|
#sec-params .section-content-inner::-webkit-scrollbar-track,
|
||||||
#panel-body::-webkit-scrollbar-track { background:transparent }
|
#panel-body::-webkit-scrollbar-track { background:transparent }
|
||||||
#preview-area::-webkit-scrollbar-thumb,
|
#preview-area::-webkit-scrollbar-thumb,
|
||||||
#sec-params .section-content::-webkit-scrollbar-thumb,
|
#sec-params .section-content-inner::-webkit-scrollbar-thumb,
|
||||||
#panel-body::-webkit-scrollbar-thumb {
|
#panel-body::-webkit-scrollbar-thumb {
|
||||||
background-color:rgba(107,125,153,.25);
|
background-color:rgba(107,125,153,.25);
|
||||||
border-radius:3px;
|
border-radius:3px;
|
||||||
border:1px solid rgba(255,255,255,.06);
|
border:1px solid rgba(255,255,255,.06);
|
||||||
}
|
}
|
||||||
#preview-area::-webkit-scrollbar-thumb:hover,
|
#preview-area::-webkit-scrollbar-thumb:hover,
|
||||||
#sec-params .section-content::-webkit-scrollbar-thumb:hover,
|
#sec-params .section-content-inner::-webkit-scrollbar-thumb:hover,
|
||||||
#panel-body::-webkit-scrollbar-thumb:hover { background-color:rgba(107,125,153,.45) }
|
#panel-body::-webkit-scrollbar-thumb:hover { background-color:rgba(107,125,153,.45) }
|
||||||
#preview-area::-webkit-scrollbar-corner,
|
#preview-area::-webkit-scrollbar-corner,
|
||||||
#sec-params .section-content::-webkit-scrollbar-corner,
|
#sec-params .section-content-inner::-webkit-scrollbar-corner,
|
||||||
#panel-body::-webkit-scrollbar-corner { background:transparent }
|
#panel-body::-webkit-scrollbar-corner { background:transparent }
|
||||||
|
|
||||||
@media(max-width:700px){
|
@media(max-width:700px){
|
||||||
#panel{--panel-w:50vw;margin-top:6px;margin-bottom:6px;margin-right:6px}
|
#panel{--panel-w:50vw;margin-top:6px;margin-bottom:6px;margin-right:6px}
|
||||||
#preview-area{padding:12px}
|
#preview-area{padding:12px}
|
||||||
}
|
}
|
||||||
@media(prefers-reduced-motion:reduce){#panel,#panel-handle svg{transition:none}}
|
@media(prefers-reduced-motion:reduce){#panel,#panel-handle svg,.section-content,.section-chevron,#viewport,#viewport::before{transition:none}}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -237,10 +236,6 @@ html,body,#preview-area,#panel-body,#sec-params .section-content{
|
|||||||
<button id="btn-desk" class="on" onclick="setViewport('desktop')">Desktop</button>
|
<button id="btn-desk" class="on" onclick="setViewport('desktop')">Desktop</button>
|
||||||
<button id="btn-mob" onclick="setViewport('mobile')">Mobile</button>
|
<button id="btn-mob" onclick="setViewport('mobile')">Mobile</button>
|
||||||
</div>
|
</div>
|
||||||
<button id="btn-screenshot" type="button" onclick="capturePreview()" disabled>
|
|
||||||
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 5l1.5-2h5L16 5h4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z"/><circle cx="12" cy="13" r="4"/></svg>
|
|
||||||
<span id="screenshot-label">Screenshot</span>
|
|
||||||
</button>
|
|
||||||
<span class="hint">keys: d/m ←→ tab ↑↓ select p toggle panel</span>
|
<span class="hint">keys: d/m ←→ tab ↑↓ select p toggle panel</span>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@@ -270,6 +265,7 @@ html,body,#preview-area,#panel-body,#sec-params .section-content{
|
|||||||
<svg class="section-chevron" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
<svg class="section-chevron" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-content">
|
<div class="section-content">
|
||||||
|
<div class="section-content-inner">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="label">Type</div>
|
<div class="label">Type</div>
|
||||||
<div class="value" id="panel-name">-</div>
|
<div class="value" id="panel-name">-</div>
|
||||||
@@ -280,6 +276,7 @@ html,body,#preview-area,#panel-body,#sec-params .section-content{
|
|||||||
</div>
|
</div>
|
||||||
<div class="stat" id="panel-stats"></div>
|
<div class="stat" id="panel-stats"></div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="sec-params">
|
<section id="sec-params">
|
||||||
@@ -288,8 +285,10 @@ html,body,#preview-area,#panel-body,#sec-params .section-content{
|
|||||||
<svg class="section-chevron" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
<svg class="section-chevron" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-content">
|
<div class="section-content">
|
||||||
|
<div class="section-content-inner">
|
||||||
<table id="panel-params"><tr><td colspan="2" style="color:var(--muted)">-</td></tr></table>
|
<table id="panel-params"><tr><td colspan="2" style="color:var(--muted)">-</td></tr></table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="sec-source">
|
<section id="sec-source">
|
||||||
@@ -298,14 +297,15 @@ html,body,#preview-area,#panel-body,#sec-params .section-content{
|
|||||||
<svg class="section-chevron" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
<svg class="section-chevron" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-content">
|
<div class="section-content">
|
||||||
|
<div class="section-content-inner">
|
||||||
<div class="card" style="font-family:monospace;font-size:10px;color:var(--muted);word-break:break-all" id="panel-path">-</div>
|
<div class="card" style="font-family:monospace;font-size:10px;color:var(--muted);word-break:break-all" id="panel-path">-</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="lib/html2canvas/html2canvas.min.js"></script>
|
|
||||||
<script src="rendered.js"></script>
|
<script src="rendered.js"></script>
|
||||||
<script>
|
<script>
|
||||||
//
|
//
|
||||||
@@ -320,122 +320,6 @@ let localeRequest = 0;
|
|||||||
let renderRequest = 0, renderTimer;
|
let renderRequest = 0, renderTimer;
|
||||||
const localeLoads = new Map();
|
const localeLoads = new Map();
|
||||||
let devMode = false; // true once SSE connects
|
let devMode = false; // true once SSE connects
|
||||||
let previewReady = false;
|
|
||||||
let capturing = false;
|
|
||||||
|
|
||||||
function updateCaptureButton() {
|
|
||||||
document.getElementById('btn-screenshot').disabled = !previewReady || capturing;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Capture only the visible viewport, including the mobile frame when selected.
|
|
||||||
async function capturePreview() {
|
|
||||||
if (!previewReady || capturing) return;
|
|
||||||
const label = document.getElementById('screenshot-label');
|
|
||||||
const selection = { ...state };
|
|
||||||
const request = renderRequest;
|
|
||||||
const frame = document.getElementById('preview-frame');
|
|
||||||
const viewport = document.getElementById('viewport');
|
|
||||||
capturing = true;
|
|
||||||
label.textContent = 'Capturing…';
|
|
||||||
updateCaptureButton();
|
|
||||||
document.getElementById('capture-message')?.remove();
|
|
||||||
try {
|
|
||||||
if (typeof html2canvas !== 'function') throw new Error('Screenshot library unavailable; restore preview/lib/html2canvas.');
|
|
||||||
const doc = frame.contentDocument;
|
|
||||||
if (!doc) throw new Error('Preview document is not accessible.');
|
|
||||||
if (doc.fonts) await doc.fonts.ready;
|
|
||||||
await Promise.all(Array.from(doc.images, image => image.decode().catch(() => {})));
|
|
||||||
if (request !== renderRequest || !previewReady) throw new Error('Preview changed; capture again after it finishes loading.');
|
|
||||||
const width = viewport.offsetWidth;
|
|
||||||
const height = viewport.offsetHeight;
|
|
||||||
const frameWidth = frame.clientWidth;
|
|
||||||
const frameHeight = frame.clientHeight;
|
|
||||||
const scrollX = frame.contentWindow.scrollX;
|
|
||||||
const scrollY = frame.contentWindow.scrollY;
|
|
||||||
const viewportBounds = viewport.getBoundingClientRect();
|
|
||||||
const frameBounds = frame.getBoundingClientRect();
|
|
||||||
const frameLeft = frameBounds.left - viewportBounds.left;
|
|
||||||
const frameTop = frameBounds.top - viewportBounds.top;
|
|
||||||
const scale = Math.min(window.devicePixelRatio || 1, 2);
|
|
||||||
// Render in the mail document's own coordinates. Rendering nested iframes
|
|
||||||
// with the outer document's context can shift centered tables and text.
|
|
||||||
const mailCanvas = await html2canvas(doc.documentElement, {
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
scale,
|
|
||||||
width: frameWidth,
|
|
||||||
height: frameHeight,
|
|
||||||
windowWidth: frameWidth,
|
|
||||||
windowHeight: frameHeight,
|
|
||||||
x: scrollX,
|
|
||||||
y: scrollY,
|
|
||||||
scrollX,
|
|
||||||
scrollY,
|
|
||||||
useCORS: true,
|
|
||||||
logging: false
|
|
||||||
});
|
|
||||||
const canvas = await html2canvas(viewport, {
|
|
||||||
backgroundColor: null,
|
|
||||||
scale,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
useCORS: true,
|
|
||||||
logging: false,
|
|
||||||
ignoreElements: element => element.id === 'preview-frame',
|
|
||||||
onclone: clone => {
|
|
||||||
const clonedViewport = clone.getElementById('viewport');
|
|
||||||
clonedViewport.style.width = width + 'px';
|
|
||||||
clonedViewport.style.maxWidth = 'none';
|
|
||||||
clonedViewport.style.height = height + 'px';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (request !== renderRequest || !previewReady) throw new Error('Preview changed; capture again after it finishes loading.');
|
|
||||||
const context = canvas.getContext('2d');
|
|
||||||
if (!context) throw new Error('Could not create the screenshot canvas.');
|
|
||||||
const style = getComputedStyle(viewport);
|
|
||||||
const border = parseFloat(style.borderLeftWidth) || 0;
|
|
||||||
const radius = Math.max(0, (parseFloat(style.borderTopLeftRadius) || 0) - border);
|
|
||||||
// Clip the composite to the container's inner rounded border, including
|
|
||||||
// the mobile frame. No top bar or sidebar enters the exported image.
|
|
||||||
const left = border, top = border;
|
|
||||||
const right = width - border, bottom = height - border;
|
|
||||||
const rounding = Math.min(radius, (right - left) / 2, (bottom - top) / 2);
|
|
||||||
context.save();
|
|
||||||
context.scale(scale, scale);
|
|
||||||
context.beginPath();
|
|
||||||
context.moveTo(left + rounding, top);
|
|
||||||
context.arcTo(right, top, right, bottom, rounding);
|
|
||||||
context.arcTo(right, bottom, left, bottom, rounding);
|
|
||||||
context.arcTo(left, bottom, left, top, rounding);
|
|
||||||
context.arcTo(left, top, right, top, rounding);
|
|
||||||
context.closePath();
|
|
||||||
context.clip();
|
|
||||||
context.drawImage(mailCanvas, frameLeft, frameTop, frameWidth, frameHeight);
|
|
||||||
context.restore();
|
|
||||||
const blob = await new Promise((resolve, reject) => canvas.toBlob(
|
|
||||||
value => value ? resolve(value) : reject(new Error('Could not encode the screenshot.')),
|
|
||||||
'image/png'
|
|
||||||
));
|
|
||||||
const filename = [selection.theme, selection.template, selection.locale]
|
|
||||||
.map(value => value.replace(/[<>:"/\\|?*\x00-\x1f]/g, '-')).join('_') + '.png';
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = url;
|
|
||||||
link.download = filename;
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
link.remove();
|
|
||||||
// Give the browser time to start reading the download before releasing it.
|
|
||||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
|
||||||
} catch (error) {
|
|
||||||
const message = showMessage('', 'error');
|
|
||||||
message.id = 'capture-message';
|
|
||||||
message.textContent = 'Screenshot failed: ' + String(error.message || error);
|
|
||||||
} finally {
|
|
||||||
capturing = false;
|
|
||||||
label.textContent = 'Screenshot';
|
|
||||||
updateCaptureButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Client transforms
|
// Client transforms
|
||||||
@@ -470,10 +354,7 @@ function render() {
|
|||||||
const loading = document.getElementById('loading');
|
const loading = document.getElementById('loading');
|
||||||
if(!rendered) return;
|
if(!rendered) return;
|
||||||
|
|
||||||
// Same-origin DOM access is required for capture; scripts remain disabled.
|
frame.setAttribute('sandbox', '');
|
||||||
frame.setAttribute('sandbox', 'allow-same-origin');
|
|
||||||
previewReady = false;
|
|
||||||
updateCaptureButton();
|
|
||||||
|
|
||||||
frame.style.display = 'none';
|
frame.style.display = 'none';
|
||||||
loading.style.display = 'flex';
|
loading.style.display = 'flex';
|
||||||
@@ -490,8 +371,6 @@ function render() {
|
|||||||
loading.style.display = 'none';
|
loading.style.display = 'none';
|
||||||
frame.style.display = 'block';
|
frame.style.display = 'block';
|
||||||
frame.onload = null;
|
frame.onload = null;
|
||||||
previewReady = true;
|
|
||||||
updateCaptureButton();
|
|
||||||
}
|
}
|
||||||
frame.onload = finish;
|
frame.onload = finish;
|
||||||
frame.srcdoc = content;
|
frame.srcdoc = content;
|
||||||
@@ -514,7 +393,8 @@ function togglePanel() {
|
|||||||
|
|
||||||
function toggleSection(id) {
|
function toggleSection(id) {
|
||||||
const sec = document.getElementById(id);
|
const sec = document.getElementById(id);
|
||||||
sec.classList.toggle('collapsed');
|
const collapsed = sec.classList.toggle('collapsed');
|
||||||
|
sec.querySelector('.section-content').inert = collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -556,11 +436,11 @@ function switchTheme(v) { state.theme=v; render(); }
|
|||||||
function switchTemplate(v) { state.template=v; switchLocale(state.locale); }
|
function switchTemplate(v) { state.template=v; switchLocale(state.locale); }
|
||||||
function switchClient(v) { state.client=v; render(); }
|
function switchClient(v) { state.client=v; render(); }
|
||||||
function setViewport(v) {
|
function setViewport(v) {
|
||||||
|
if (state.viewport === v) return;
|
||||||
state.viewport=v;
|
state.viewport=v;
|
||||||
document.getElementById('btn-desk').classList.toggle('on',v==='desktop');
|
document.getElementById('btn-desk').classList.toggle('on',v==='desktop');
|
||||||
document.getElementById('btn-mob').classList.toggle('on',v==='mobile');
|
document.getElementById('btn-mob').classList.toggle('on',v==='mobile');
|
||||||
document.getElementById('viewport').className=v;
|
document.getElementById('viewport').className=v;
|
||||||
render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -602,6 +482,11 @@ function fillSelect(id, entries, selected) {
|
|||||||
select.value=selected;
|
select.value=selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function localeLabel(locale) {
|
||||||
|
const name = manifest?.language_names?.[locale];
|
||||||
|
return name && name !== locale ? locale + ' — ' + name : locale;
|
||||||
|
}
|
||||||
|
|
||||||
function applyManifest(data) {
|
function applyManifest(data) {
|
||||||
if (!data || data.schema !== 1 || !data.languages.length || !data.themes.length) {
|
if (!data || data.schema !== 1 || !data.languages.length || !data.themes.length) {
|
||||||
throw new Error('Invalid preview manifest; regenerate with go run . preview all');
|
throw new Error('Invalid preview manifest; regenerate with go run . preview all');
|
||||||
@@ -612,16 +497,7 @@ function applyManifest(data) {
|
|||||||
if (!data.languages.includes(state.locale)) state.locale=data.languages.includes('en-US') ? 'en-US' : data.languages[0];
|
if (!data.languages.includes(state.locale)) state.locale=data.languages.includes('en-US') ? 'en-US' : data.languages[0];
|
||||||
fillSelect('sel-theme',data.themes.map(t=>[t,t.charAt(0).toUpperCase()+t.slice(1)]),state.theme);
|
fillSelect('sel-theme',data.themes.map(t=>[t,t.charAt(0).toUpperCase()+t.slice(1)]),state.theme);
|
||||||
fillSelect('sel-template',Object.entries(REGISTRY).map(([id,t])=>[id,t.name]),state.template);
|
fillSelect('sel-template',Object.entries(REGISTRY).map(([id,t])=>[id,t.name]),state.template);
|
||||||
fillSelect('sel-locale',data.languages.map(locale=>{
|
fillSelect('sel-locale',data.languages.map(locale=>[locale,localeLabel(locale)]),state.locale);
|
||||||
let name;
|
|
||||||
try {
|
|
||||||
// Show each language in its own language, independent of the browser UI.
|
|
||||||
if (Intl.DisplayNames.supportedLocalesOf([locale]).length) {
|
|
||||||
name=new Intl.DisplayNames([locale],{type:'language',fallback:'none'}).of(locale);
|
|
||||||
}
|
|
||||||
} catch (_) { /* Older browsers can still select languages by locale code. */ }
|
|
||||||
return [locale,name && name!==locale ? locale+' — '+name : locale];
|
|
||||||
}),state.locale);
|
|
||||||
document.querySelectorAll('#sel-locale option').forEach(option=>{
|
document.querySelectorAll('#sel-locale option').forEach(option=>{
|
||||||
option.lang=option.value;
|
option.lang=option.value;
|
||||||
option.dir='auto';
|
option.dir='auto';
|
||||||
@@ -650,8 +526,6 @@ function loadLocale(lang) {
|
|||||||
async function switchLocale(lang) {
|
async function switchLocale(lang) {
|
||||||
if (!manifest?.languages.includes(lang)) return;
|
if (!manifest?.languages.includes(lang)) return;
|
||||||
state.locale=lang; rendered=null;
|
state.locale=lang; rendered=null;
|
||||||
previewReady=false;
|
|
||||||
updateCaptureButton();
|
|
||||||
const request=++localeRequest;
|
const request=++localeRequest;
|
||||||
document.getElementById('preview-frame').style.display='none';
|
document.getElementById('preview-frame').style.display='none';
|
||||||
document.getElementById('loading').style.display='flex';
|
document.getElementById('loading').style.display='flex';
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
Copyright (c) 2012 Niklas von Hertzen
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation
|
|
||||||
files (the "Software"), to deal in the Software without
|
|
||||||
restriction, including without limitation the rights to use,
|
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# html2canvas
|
|
||||||
|
|
||||||
Version: **1.4.1**, distributed under the [MIT license](LICENSE).
|
|
||||||
|
|
||||||
The preview uses this local copy to export the visible email container as PNG without a CDN connection. Release archives include the library and its license.
|
|
||||||
|
|
||||||
- Project: https://github.com/niklasvh/html2canvas
|
|
||||||
- Distribution: https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js
|
|
||||||
- SHA-256: `e87e550794322e574a1fda0c1549a3c70dae5a93d9113417a429016838eab8cb`
|
|
||||||
|
|
||||||
Capture uses DOM rendering, so CSS support and cross-origin images follow [html2canvas's documented limitations](https://html2canvas.hertzen.com/documentation). The iframe permits same-origin DOM access while keeping scripts disabled. Keep the version, license and checksum together when updating the library.
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
/*!
|
|
||||||
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
||||||
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
|
||||||
* Released under MIT License
|
|
||||||
*/
|
|
||||||
!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(A="undefined"!=typeof globalThis?globalThis:A||self).html2canvas=e()}(this,function(){"use strict";
|
|
||||||
/*! *****************************************************************************
|
|
||||||
Copyright (c) Microsoft Corporation.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
***************************************************************************** */var r=function(A,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(A,e){A.__proto__=e}||function(A,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t])})(A,e)};function A(A,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=A}r(A,e),A.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var h=function(){return(h=Object.assign||function(A){for(var e,t=1,r=arguments.length;t<r;t++)for(var B in e=arguments[t])Object.prototype.hasOwnProperty.call(e,B)&&(A[B]=e[B]);return A}).apply(this,arguments)};function a(A,s,o,i){return new(o=o||Promise)(function(t,e){function r(A){try{n(i.next(A))}catch(A){e(A)}}function B(A){try{n(i.throw(A))}catch(A){e(A)}}function n(A){var e;A.done?t(A.value):((e=A.value)instanceof o?e:new o(function(A){A(e)})).then(r,B)}n((i=i.apply(A,s||[])).next())})}function H(t,r){var B,n,s,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},A={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(A[Symbol.iterator]=function(){return this}),A;function e(e){return function(A){return function(e){if(B)throw new TypeError("Generator is already executing.");for(;o;)try{if(B=1,n&&(s=2&e[0]?n.return:e[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,e[1])).done)return s;switch(n=0,(e=s?[2&e[0],s.value]:e)[0]){case 0:case 1:s=e;break;case 4:return o.label++,{value:e[1],done:!1};case 5:o.label++,n=e[1],e=[0];continue;case 7:e=o.ops.pop(),o.trys.pop();continue;default:if(!(s=0<(s=o.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){o=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){o.label=e[1];break}if(6===e[0]&&o.label<s[1]){o.label=s[1],s=e;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(e);break}s[2]&&o.ops.pop(),o.trys.pop();continue}e=r.call(t,o)}catch(A){e=[6,A],n=0}finally{B=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,A])}}}function t(A,e,t){if(t||2===arguments.length)for(var r,B=0,n=e.length;B<n;B++)!r&&B in e||((r=r||Array.prototype.slice.call(e,0,B))[B]=e[B]);return A.concat(r||e)}var d=(B.prototype.add=function(A,e,t,r){return new B(this.left+A,this.top+e,this.width+t,this.height+r)},B.fromClientRect=function(A,e){return new B(e.left+A.windowBounds.left,e.top+A.windowBounds.top,e.width,e.height)},B.fromDOMRectList=function(A,e){e=Array.from(e).find(function(A){return 0!==A.width});return e?new B(e.left+A.windowBounds.left,e.top+A.windowBounds.top,e.width,e.height):B.EMPTY},B.EMPTY=new B(0,0,0,0),B);function B(A,e,t,r){this.left=A,this.top=e,this.width=t,this.height=r}for(var f=function(A,e){return d.fromClientRect(A,e.getBoundingClientRect())},Q=function(A){for(var e=[],t=0,r=A.length;t<r;){var B,n=A.charCodeAt(t++);55296<=n&&n<=56319&&t<r?56320==(64512&(B=A.charCodeAt(t++)))?e.push(((1023&n)<<10)+(1023&B)+65536):(e.push(n),t--):e.push(n)}return e},g=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,A);var t=A.length;if(!t)return"";for(var r=[],B=-1,n="";++B<t;){var s=A[B];s<=65535?r.push(s):(s-=65536,r.push(55296+(s>>10),s%1024+56320)),(B+1===t||16384<r.length)&&(n+=String.fromCharCode.apply(String,r),r.length=0)}return n},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),s=0;s<e.length;s++)n[e.charCodeAt(s)]=s;for(var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="undefined"==typeof Uint8Array?[]:new Uint8Array(256),i=0;i<o.length;i++)c[o.charCodeAt(i)]=i;function w(A,e,t){return A.slice?A.slice(e,t):new Uint16Array(Array.prototype.slice.call(A,e,t))}var U=(l.prototype.get=function(A){var e;if(0<=A){if(A<55296||56319<A&&A<=65535)return e=this.index[A>>5],this.data[e=(e<<2)+(31&A)];if(A<=65535)return e=this.index[2048+(A-55296>>5)],this.data[e=(e<<2)+(31&A)];if(A<this.highStart)return e=this.index[e=2080+(A>>11)],e=this.index[e+=A>>5&63],this.data[e=(e<<2)+(31&A)];if(A<=1114111)return this.data[this.highValueIndex]}return this.errorValue},l);function l(A,e,t,r,B,n){this.initialValue=A,this.errorValue=e,this.highStart=t,this.highValueIndex=r,this.index=B,this.data=n}for(var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="undefined"==typeof Uint8Array?[]:new Uint8Array(256),F=0;F<C.length;F++)u[C.charCodeAt(F)]=F;function p(A,e,t,r){var B=r[t];if(Array.isArray(A)?-1!==A.indexOf(B):A===B)for(var n=t;n<=r.length;){if((o=r[++n])===e)return 1;if(o!==D)break}if(B===D)for(n=t;0<n;){var s=r[--n];if(Array.isArray(A)?-1!==A.indexOf(s):A===s)for(var o,i=t;i<=r.length;){if((o=r[++i])===e)return 1;if(o!==D)break}if(s!==D)break}}function E(A,e){for(var t=A;0<=t;){var r=e[t];if(r!==D)return r;t--}return 0}function I(t,A){var e=(B=function(A,r){void 0===r&&(r="strict");var B=[],n=[],sLine truncated
|
|
||||||
@@ -20,11 +20,7 @@ func UpstreamCommand() *cli.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logging.Info("Upstream", "%s: %d mail files, %d languages", s.Lock.Tag, len(s.Templates), len(s.Locales))
|
logging.Info("Upstream", "%s: %d mail files, %d languages", s.Lock.Tag, len(s.Templates), len(s.Locales))
|
||||||
for _, lang := range s.Languages() {
|
logging.WarnMissingTranslations(missing)
|
||||||
if keys := missing[lang]; len(keys) > 0 {
|
|
||||||
logging.Warn("Locale", "%s -> en-US: %v", lang, keys)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ go 1.24.0
|
|||||||
require (
|
require (
|
||||||
github.com/urfave/cli/v2 v2.27.7
|
github.com/urfave/cli/v2 v2.27.7
|
||||||
golang.org/x/net v0.46.0
|
golang.org/x/net v0.46.0
|
||||||
|
golang.org/x/text v0.31.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGC
|
|||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
||||||
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
||||||
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
||||||
|
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||||
|
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WarnMissingTranslations groups missing keys without wrapping long key lists.
|
||||||
|
func WarnMissingTranslations(missing map[string][]string) {
|
||||||
|
if message := missingTranslations(missing); message != "" {
|
||||||
|
Warn("Locale", "%s", message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func missingTranslations(missing map[string][]string) string {
|
||||||
|
languages := make([]string, 0, len(missing))
|
||||||
|
width := len("Language")
|
||||||
|
for lang, keys := range missing {
|
||||||
|
if len(keys) > 0 {
|
||||||
|
languages = append(languages, lang)
|
||||||
|
width = max(width, len(lang))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(languages) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
sort.Strings(languages)
|
||||||
|
var message strings.Builder
|
||||||
|
fmt.Fprintf(&message, "Missing translation keys:\n%-*s %-8s %s\n", width, "Language", "Fallback", "Key")
|
||||||
|
for _, lang := range languages {
|
||||||
|
keys := append([]string(nil), missing[lang]...)
|
||||||
|
sort.Strings(keys)
|
||||||
|
for i, key := range keys {
|
||||||
|
label, fallback := "", ""
|
||||||
|
if i == 0 {
|
||||||
|
label, fallback = lang, "en-US"
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&message, "%-*s %-8s %s\n", width, label, fallback, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings.TrimSuffix(message.String(), "\n")
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMissingTranslations(t *testing.T) {
|
||||||
|
missing := map[string][]string{
|
||||||
|
"fr-FR": {"mail.second", "mail.first"},
|
||||||
|
"en-US": nil,
|
||||||
|
"de-DE": {"mail.first"},
|
||||||
|
}
|
||||||
|
want := "Missing translation keys:\n" +
|
||||||
|
"Language Fallback Key\n" +
|
||||||
|
"de-DE en-US mail.first\n" +
|
||||||
|
"fr-FR en-US mail.first\n" +
|
||||||
|
" mail.second"
|
||||||
|
message := missingTranslations(missing)
|
||||||
|
if message != want {
|
||||||
|
t.Fatalf("got %q, want %q", message, want)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(missing["fr-FR"], []string{"mail.second", "mail.first"}) {
|
||||||
|
t.Fatal("report mutated input keys")
|
||||||
|
}
|
||||||
|
var output bytes.Buffer
|
||||||
|
write(&output, true, "W", "Locale", message)
|
||||||
|
for _, line := range strings.Split(strings.TrimSuffix(output.String(), "\n"), "\n") {
|
||||||
|
if !strings.HasPrefix(line, "\033[33m[W]\033[0m [Locale] ") {
|
||||||
|
t.Fatalf("missing warning prefix: %q", line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if missingTranslations(nil) != "" || missingTranslations(map[string][]string{"en-US": nil}) != "" {
|
||||||
|
t.Fatal("empty report produced a warning")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ type PreviewResult struct {
|
|||||||
Registry map[string]map[string]string
|
Registry map[string]map[string]string
|
||||||
Params map[string]map[string]string
|
Params map[string]map[string]string
|
||||||
Languages []string
|
Languages []string
|
||||||
|
LanguageNames map[string]string
|
||||||
Themes []string
|
Themes []string
|
||||||
Upstream string
|
Upstream string
|
||||||
Commit string
|
Commit string
|
||||||
@@ -92,6 +93,7 @@ func RenderAll(themesDir string, cfg *config.TemplatesConfig, filter map[string]
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result := &PreviewResult{Rendered: map[string]map[string]map[string]string{}, Registry: config.Registry(cfg), Params: map[string]map[string]string{}, Languages: s.Languages(), Upstream: s.Lock.Tag, Fallback: missing, Warnings: map[string]map[string][]string{}}
|
result := &PreviewResult{Rendered: map[string]map[string]map[string]string{}, Registry: config.Registry(cfg), Params: map[string]map[string]string{}, Languages: s.Languages(), Upstream: s.Lock.Tag, Fallback: missing, Warnings: map[string]map[string][]string{}}
|
||||||
|
result.LanguageNames = languageNames(result.Languages)
|
||||||
for id, t := range cfg.Templates {
|
for id, t := range cfg.Templates {
|
||||||
result.Params[id] = config.FlattenParams(t.Params)
|
result.Params[id] = config.FlattenParams(t.Params)
|
||||||
}
|
}
|
||||||
@@ -236,6 +238,7 @@ func WriteRenderedJS(result *PreviewResult, output string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
manifest := map[string]any{"schema": 1, "upstream": result.Upstream, "languages": result.Languages, "themes": result.Themes, "registry": result.Registry, "params": result.Params, "fallback": result.Fallback, "warnings": result.Warnings}
|
manifest := map[string]any{"schema": 1, "upstream": result.Upstream, "languages": result.Languages, "themes": result.Themes, "registry": result.Registry, "params": result.Params, "fallback": result.Fallback, "warnings": result.Warnings}
|
||||||
|
manifest["language_names"] = result.LanguageNames
|
||||||
manifest["logo"] = "data:image/png;base64," + base64.StdEncoding.EncodeToString(result.Logo)
|
manifest["logo"] = "data:image/png;base64," + base64.StdEncoding.EncodeToString(result.Logo)
|
||||||
manifest["upstream_commit"] = result.Commit
|
manifest["upstream_commit"] = result.Commit
|
||||||
data, err := json.Marshal(manifest)
|
data, err := json.Marshal(manifest)
|
||||||
@@ -267,10 +270,8 @@ func PrintDetailedSummary(result *PreviewResult, _ string, _ *config.TemplatesCo
|
|||||||
logging.Warn("Upstream", "%s", strings.TrimPrefix(warning, "[UPSTREAM-WARN] "))
|
logging.Warn("Upstream", "%s", strings.TrimPrefix(warning, "[UPSTREAM-WARN] "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if keys := result.Fallback[lang]; len(keys) > 0 {
|
|
||||||
logging.Warn("Locale", "%s -> en-US: %s", lang, strings.Join(keys, ", "))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
logging.WarnMissingTranslations(result.Fallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func markSafeHTML(data map[string]any) {
|
func markSafeHTML(data map[string]any) {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/text/language"
|
||||||
|
"golang.org/x/text/language/display"
|
||||||
|
)
|
||||||
|
|
||||||
|
// languageNames derives native names from CLDR for the generated preview locales.
|
||||||
|
func languageNames(locales []string) map[string]string {
|
||||||
|
names := make(map[string]string, len(locales))
|
||||||
|
for _, locale := range locales {
|
||||||
|
name := locale
|
||||||
|
if tag, err := language.Parse(locale); err == nil {
|
||||||
|
if native := display.Self.Name(tag); native != "" {
|
||||||
|
name = native
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names[locale] = name
|
||||||
|
}
|
||||||
|
return names
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gitea-mail-templates/tools/upstream"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNativeLanguageNames(t *testing.T) {
|
||||||
|
snapshot, err := upstream.LoadPinned(filepath.Join("..", ".."))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
locales := snapshot.Languages()
|
||||||
|
names := languageNames(locales)
|
||||||
|
if len(names) != len(locales) {
|
||||||
|
t.Fatal("language names do not match preview locales")
|
||||||
|
}
|
||||||
|
for _, locale := range locales {
|
||||||
|
if names[locale] == "" || names[locale] == locale {
|
||||||
|
t.Errorf("missing native name for %s", locale)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for locale, want := range map[string]string{"ga-IE": "Gaeilge", "is-IS": "íslenska"} {
|
||||||
|
if names[locale] != want {
|
||||||
|
t.Errorf("%s: got %q, want %q", locale, names[locale], want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if got := languageNames([]string{"!invalid"})["!invalid"]; got != "!invalid" {
|
||||||
|
t.Fatalf("invalid locale fallback: %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -294,6 +294,7 @@ func TestSubjectSplitAndMissingFixture(t *testing.T) {
|
|||||||
|
|
||||||
func TestPreviewBundles(t *testing.T) {
|
func TestPreviewBundles(t *testing.T) {
|
||||||
result := &PreviewResult{Rendered: map[string]map[string]map[string]string{"en-US": {"test": {"activate": "<body>hello</body>"}}, "zh-CN": {"test": {"activate": "<body>你好</body>"}}}, Languages: []string{"en-US", "zh-CN"}, Themes: []string{"test"}, Registry: map[string]map[string]string{}, Upstream: "v28.0.0"}
|
result := &PreviewResult{Rendered: map[string]map[string]map[string]string{"en-US": {"test": {"activate": "<body>hello</body>"}}, "zh-CN": {"test": {"activate": "<body>你好</body>"}}}, Languages: []string{"en-US", "zh-CN"}, Themes: []string{"test"}, Registry: map[string]map[string]string{}, Upstream: "v28.0.0"}
|
||||||
|
result.LanguageNames = languageNames(result.Languages)
|
||||||
output := filepath.Join(t.TempDir(), "rendered.js")
|
output := filepath.Join(t.TempDir(), "rendered.js")
|
||||||
if err := WriteRenderedJS(result, output); err != nil {
|
if err := WriteRenderedJS(result, output); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -305,6 +306,9 @@ func TestPreviewBundles(t *testing.T) {
|
|||||||
if bytes.Contains(manifest, []byte("<body>")) {
|
if bytes.Contains(manifest, []byte("<body>")) {
|
||||||
t.Fatal("manifest embeds mail payload")
|
t.Fatal("manifest embeds mail payload")
|
||||||
}
|
}
|
||||||
|
if !bytes.Contains(manifest, []byte(`"language_names":`)) || !bytes.Contains(manifest, []byte(fmt.Sprintf("%q:%q", "en-US", result.LanguageNames["en-US"]))) {
|
||||||
|
t.Fatal("manifest does not include generated native language names")
|
||||||
|
}
|
||||||
for _, lang := range result.Languages {
|
for _, lang := range result.Languages {
|
||||||
data, err := os.ReadFile(filepath.Join(filepath.Dir(output), "rendered", lang+".js"))
|
data, err := os.ReadFile(filepath.Join(filepath.Dir(output), "rendered", lang+".js"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ import (
|
|||||||
// TrN keys. Dynamic translation keys require an explicit adapter review.
|
// TrN keys. Dynamic translation keys require an explicit adapter review.
|
||||||
func ReferencedKeys(s *Snapshot) ([]string, error) {
|
func ReferencedKeys(s *Snapshot) ([]string, error) {
|
||||||
fns := template.FuncMap{}
|
fns := template.FuncMap{}
|
||||||
for _, name := range []string{"AppUrl", "AppName", "AppDomain", "DotEscape", "QueryEscape", "ShortSha", "HTMLFormat", "PathEscapeSegments", "FormatByteSize", "Dict", "dict", "StringUtils", "SliceUtils", "JsonUtils", "QueryBuild", "PathEscape", "SanitizeHTML"} {
|
for _, name := range []string{
|
||||||
|
"AppUrl", "AppName", "AppDomain", "DotEscape", "QueryEscape",
|
||||||
|
"ShortSha", "HTMLFormat", "PathEscapeSegments", "FormatByteSize",
|
||||||
|
"Dict", "dict", "StringUtils", "SliceUtils", "JsonUtils", "QueryBuild",
|
||||||
|
"PathEscape", "SanitizeHTML"} {
|
||||||
|
|
||||||
fns[name] = func(...any) string { return "" }
|
fns[name] = func(...any) string { return "" }
|
||||||
}
|
}
|
||||||
keys := map[string]bool{}
|
keys := map[string]bool{}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func TestSnapshotAndKeys(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if s.Lock.Tag != "v28.0.0" || len(s.Templates) != 13 || len(s.Locales) != 28 {
|
if s.Lock.Tag != "v28.2.0" || len(s.Templates) != 13 || len(s.Locales) != 28 {
|
||||||
t.Fatalf("unexpected baseline %s", s.Lock.Tag)
|
t.Fatalf("unexpected baseline %s", s.Lock.Tag)
|
||||||
}
|
}
|
||||||
keys, err := ReferencedKeys(s)
|
keys, err := ReferencedKeys(s)
|
||||||
@@ -32,7 +32,7 @@ func TestSnapshotAndKeys(t *testing.T) {
|
|||||||
if ValidateKeys(s) == nil {
|
if ValidateKeys(s) == nil {
|
||||||
t.Fatal("missing English key accepted")
|
t.Fatal("missing English key accepted")
|
||||||
}
|
}
|
||||||
if !validTag("v28.0.0") || validTag("v1.27.3") || validTag("v28.1.0-rc1") {
|
if !validTag("v28.0.0") || !validTag("v28.2.0") || validTag("v1.27.3") || validTag("v28.2.0-rc1") {
|
||||||
t.Fatal("tag policy")
|
t.Fatal("tag policy")
|
||||||
}
|
}
|
||||||
for _, p := range []string{"../x", "/x", "C:/x", "mail\\x"} {
|
for _, p := range []string{"../x", "/x", "C:/x", "mail\\x"} {
|
||||||
|
|||||||
Reference in new issue
Block a user