Repository navigation
feat: let themes choose their logos and icons on each request - #5322
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: no issue filed.
Changes proposed in this pull request:
#5319 lets a theme set the forum's logos and icons, but only as fixed files. A theme with switchable brand sets, seasonal ones for example, still has to write the image settings itself, where the admin can overwrite them. And while a theme sets an image, code reading the image settings directly still gets the admin's old upload.
Extend\Theme(logo(),logoDarkMode(),emailLogo(),favicon()and its SVG,appIcon()and its background) also accepts a callable that returns one, with its parameters resolved from the container. Returning null leaves the image to the admin. Returning a different file draws the image again.logo_path,logo_dark_mode_path,favicon_path,email_logo_pathandemail_logo_sizehold the drawn file, when it is the kind of file an upload stores there. An SVG logo leaveslogo_pathas it was. The admin's values come back when the theme stops setting the image. fof/seo, fof/pwa and ianm/twofactor read these settings./favicon.icoredirect, and emails already sent, and taken back if the image returns to them. They were deleted at once.Docs: flarum/docs#694
Reviewers should focus on:
ThemeImagesis built, about twice per forum page, so they should be cheap and give the same answer within a request.has()now brings the stored state up to date first. Nothing did once a theme stopped setting every image, so its files were never removed.theme_imagesstate format changed. It is unreleased, so a 2.x snapshot install just draws its theme images once more.ThemeImagesTestallows repeatedsettingswrites: drawing writes each image's settings once.Necessity
Confirmed
yarn testinjs/).composer test).