Conversation
5d39a35 to
304a558
Compare
304a558 to
940345c
Compare
940345c to
2e5f15e
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the template rendering system in Gitea to improve separation of concerns and code organization. The main changes involve splitting the monolithic HTML renderer into separate page and mail renderers with distinct responsibilities.
Changes:
- Introduced separate
PageRendererandMailRendererimplementations with distinct lifecycles and initialization - Refactored template loading to use a common
tmplRenderstruct with configurable template collection and content reading functions - Migrated from
http.FileSystemtofs.FSinassetfsfor better standard library alignment - Improved error page rendering to support both HTML and plain text responses
- Consolidated template-related utility functions and removed obsolete error types
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| modules/templates/page.go | New file implementing PageRenderer with sync.OnceValue initialization and auto-reloading support |
| modules/templates/mail.go | New file implementing MailRenderer with double-checked locking and template mocking for tests |
| modules/templates/htmlrenderer.go | Refactored into generic tmplRender with collectTemplateNames and readTemplateContent callbacks |
| modules/templates/base.go | Removed template listing utility functions (moved into renderer implementations) |
| modules/templates/vars/vars.go | Simplified error handling by removing custom error types, fixed typo in comment |
| modules/templates/scopedtmpl/scopedtmpl.go | Added HasTemplate helper method |
| services/mailer/mailer.go | Simplified initialization to call MailRenderer() |
| services/mailer/mail.go | Changed LoadedTemplates to return MailRender, removed atomic.Pointer |
| services/mailer/mail_test.go | Updated to use new mockMailTemplates helper function |
| services/mailer/mail_release_test.go | Replaced manual variable restoration with test.MockVariableValue |
| services/mailer/mail_issue_common.go | Used util.IfZero for subject fallback, changed Lookup to HasTemplate |
| services/context/context.go | Added ContexterInstallPage helper to reduce duplication |
| services/context/package.go | Renamed HTMLRenderer to PageRenderer |
| services/markup/*_test.go | Updated test mocks to use PageRenderer |
| routers/web/web.go | Removed redundant HTMLRenderer initialization |
| routers/web/user/home_test.go | Updated test to use PageRenderer |
| routers/web/repo/pull_review_test.go | Updated test to use PageRenderer |
| routers/web/devtest/mail_preview.go | Updated to handle empty subject with util.IfZero |
| routers/private/manager.go | Renamed ReloadHTMLTemplates to ReloadAllTemplates |
| routers/install/install.go | Refactored installContexter to use ContexterInstallPage |
| routers/init.go | Removed redundant HTMLRenderer initialization |
| routers/common/qos.go | Refactored renderServiceUnavailable to use common renderServerErrorPage |
| routers/common/qos_test.go | Removed test (moved to errpage_test.go) |
| routers/common/errpage.go | Added renderServerErrorPage helper with Accept header detection |
| routers/common/errpage_test.go | Added Plain subtest for non-HTML response handling |
| modules/assetfs/layered.go | Migrated from http.FileSystem to fs.FS throughout |
| modules/public/public.go | Updated to use http.FS(assetFS) for compatibility |
| cmd/web.go | Removed panic recovery handler (now handled by processStartupTemplateError), added PageRenderer initialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f68fb64 to
9bae931
Compare
* giteaofficial/main: Normalize guessed languages for code highlighting (go-gitea#36450) Add `knip` linter (go-gitea#36442) Fix various bugs (go-gitea#36446) Update tool dependencies (go-gitea#36445) Update JS dependencies, adjust webpack config, misc fixes (go-gitea#36431) fix: Improve image captcha contrast for dark mode (go-gitea#36265) Refactor template render (go-gitea#36438) Add documentation for markdown anchor post-processing (go-gitea#36443) Fix markup heading parsing, fix emphasis parsing (go-gitea#36284) Front port changelog for 1.25.4 (go-gitea#36432) Bugfix: Potential incorrect runID in run status update (go-gitea#36437) Restrict branch naming when new change matches with protection rules (go-gitea#36405)
No description provided.