fix(theme): let a renamed copy of the bootstrap theme load its own assets - #3470
Merged
Merged
Conversation
…sets
The bundled README tells theme authors to copy the bootstrap directory,
rename it and change theme.yml#name. The copy's index.html still named
themes/bootstrap/ for its stylesheet, logos and app.js, and app.js loads
the i18n and help bundles relative to itself, so the copy kept rendering
the bootstrap CSS, logos and messages: edits to them never showed up.
A relative URL cannot fix this, because Fess serves index.html at /,
/search, /help and the error paths under a <base href="{context path}/">.
StaticThemeResponder now replaces {{themePath}} in the entry file with
themes/<theme name>, the path StaticThemeFilter serves the theme's assets
under, and the bundled index.html refers to its files through it. Themes
that do not use the placeholder are served unchanged.
Rewrite the README customising steps to match, including where the ZIP
needs theme.yml and how to activate the copy.
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.
Why
The page design editor is gone, so the way to change the look of the search pages is to copy the bundled
bootstrapstatic theme. Following the bundled README (copy the directory, rename it, changetheme.yml#name, upload it as a ZIP), the copy's CSS, logo and message edits never appeared: itsindex.htmlhardcodedthemes/bootstrap/for the stylesheet, both logos andapp.js, andapp.jsloads the i18n and help bundles relative to itself, so the copy kept running the bootstrap files.Relative URLs cannot fix this alone. Fess serves
index.htmlat/,/search,/help, the error paths and so on, and inserts<base href="{context path}/">, so a relative URL resolves against the web application root at every depth (/search/xtoo), never against the theme's directory.What changes
StaticThemeResponderreplaces{{themePath}}in the entry file withthemes/<theme name>, the pathStaticThemeFilterserves the theme's assets under. It applies to both the normal and the error-page responses, since both read the entry throughreadEntryBytes(). A theme without the placeholder is served unchanged, so existing themes that name their own directory keep working.index.htmlrefers to its stylesheet, logos andapp.jsas{{themePath}}/assets/….name(and bumpversion), edit, ZIP withtheme.ymlat the top level, upload, then set the copy as the default or bind it to a virtual host.StaticThemeResponderTestcovers the expansion onserveIndex(under a context path) andserveErrorPage, and the unchanged pass-through.BundledBootstrapThemeTestrequiresindex.htmlnot to namethemes/bootstrapand every{{themePath}}reference to exist.The theme version stays 1.3.0: it was set for 15.9 and has not been released yet.
Verification
mvn test -Dtest=BundledBootstrapThemeTest,StaticThemeResponderTest,StaticThemeFilterTest,ErrorPageServletTest: 230 tests passed.mythemefollowing the README, with one rule added to itsstyles.css(body { background-color: rgb(253, 246, 227) !important; }), uploaded on the admin Theme page and made the default. Before (main) → after, on/,/search?q=…and a 404 at a two-segment path:/api/v2/ui/config)mythememythemethemes/bootstrap/assets/styles.css,themes/bootstrap/assets/app.jsthemes/mytheme/assets/styles.css,themes/mytheme/assets/app.jsthemes/bootstrap/assets/logo*.pngthemes/mytheme/assets/logo*.png/themes/bootstrap/i18n/messages.ja.json/themes/mytheme/i18n/messages.ja.jsonbodybackgroundrgb(255, 255, 255)(edit ignored)rgb(253, 246, 227)