From 6733e8135612bac4f743c038c3752d9fd0fecf82 Mon Sep 17 00:00:00 2001 From: KenanZhu Date: Sun, 11 Oct 2026 11:05:48 +0800 Subject: [PATCH] preview: improve sidebar layout and screenshot export --- .github/scripts/package_release.py | 3 + .github/scripts/test_package_release.py | 10 + CONTRIBUTING.md | 37 +--- docs/CONTRIBUTING.zh-CN.md | 37 +--- preview/index.html | 237 +++++++++++++++------ preview/lib/html2canvas/LICENSE | 22 ++ preview/lib/html2canvas/README.md | 11 + preview/lib/html2canvas/html2canvas.min.js | 20 ++ 8 files changed, 259 insertions(+), 118 deletions(-) create mode 100644 preview/lib/html2canvas/LICENSE create mode 100644 preview/lib/html2canvas/README.md create mode 100644 preview/lib/html2canvas/html2canvas.min.js diff --git a/.github/scripts/package_release.py b/.github/scripts/package_release.py index eecc0de..3b0171c 100644 --- a/.github/scripts/package_release.py +++ b/.github/scripts/package_release.py @@ -21,6 +21,9 @@ REQUIRED_FILES = ( "docs/README.zh-CN.md", "docs/CONTRIBUTING.zh-CN.md", "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") DOCUMENTATION_DIRECTORIES = ("docs", ".github/release-notes") diff --git a/.github/scripts/test_package_release.py b/.github/scripts/test_package_release.py index 4118c1b..33f6476 100644 --- a/.github/scripts/test_package_release.py +++ b/.github/scripts/test_package_release.py @@ -30,6 +30,9 @@ class PackagingTests(unittest.TestCase): "docs/README.zh-CN.md", "docs/CONTRIBUTING.zh-CN.md", "preview/index.html", + "preview/lib/html2canvas/html2canvas.min.js", + "preview/lib/html2canvas/LICENSE", + "preview/lib/html2canvas/README.md", "docs/images/README.md", ) @@ -130,8 +133,15 @@ class PackagingTests(unittest.TestCase): self.assertEqual(expected_members, zipped) self.assertEqual(expected_members, tarred) 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)) + 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): PACKER.package(self.root, self.VERSION, self.output) original_archives = { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d38a150..428d9a7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing to Gitea Mail Templates -[简体中文](docs/CONTRIBUTING.zh-CN.md) · [Project overview](README.md) · [Compatibility](COMPATIBILITY.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). @@ -18,7 +18,7 @@ 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. -The CLI uses urfave/cli and the x/net HTML parser. Python 3.11 or later is used by the documentation and packaging checks. Node.js and the dependencies in `tools/qa` are needed only for browser QA. +The CLI uses urfave/cli and the x/net HTML parser. Python 3.11 or later is used by the documentation and packaging checks. ### Common Commands @@ -114,7 +114,7 @@ go test ./... 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 and matching-instance smoke test before updating compatibility records. `sync` changes the cache and lock only; documentation and release publication are separate steps. Use `prepare` for a missing cache. +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. 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. @@ -145,7 +145,7 @@ Gitea v28.0.0 contains a Polish `mail.team_invite.text_1` placeholder defect. Pr 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 documentation, tracker or packaging changes, run from the repository root: +For documentation or packaging changes, run from the repository root: ```bash python -B -m unittest discover -s .github/scripts -p 'test_*.py' @@ -153,29 +153,12 @@ 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. -### Browser and Gitea Checks - -After generating preview data, run the optional browser suite: - -```bash -cd tools/qa -npm install -npx playwright install chromium -npm test -``` - -To use installed Chrome or Edge, set `BROWSER_EXECUTABLE_PATH` instead of installing Chromium. Set `PREVIEW_DEV_URL` to include a running HTTP preview in the checks. `npm test -- --update-gallery` also refreshes gallery screenshots. - -Before a release, test generated overrides in an isolated Gitea instance matching the locked version and capture a real password-reset or notification email. The administration test-email button bypasses custom templates. - -The optional `tools/integration` test uses disposable SQLite data, users, Git/SSH paths and loopback SMTP. Set `GITEA_SMOKE_BINARY` to a checksum-verified official binary matching the lock, then run `go test ./integration -v -count=1` from `tools/`. It captures mail locally without sending to real users. Without this variable, the test is skipped. The release workflow does not run the optional browser or real-Gitea checks automatically. - ### Preparing a Release Release tags must match the locked Gitea version. The current source refactor is unreleased; retain existing v28.0.0 and historical assets. -1. Complete automated checks, preview review and the matching-instance smoke test. -2. Add reviewed notes at `.github/release-notes/vX.Y.Z.md` and update compatibility records with the verification results. +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. @@ -187,15 +170,15 @@ python .github/scripts/package_release.py --version vX.Y.Z --output @@ -256,6 +237,10 @@ html,body,#preview-area,#panel-body{ + keys: d/m   ←→ tab   ↑↓ select   p toggle panel @@ -274,12 +259,9 @@ html,body,#preview-area,#panel-body{ +