-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix: Resolve Thymeleaf 3.1.4+ TemplateProcessingException in variables.css (Issue #5251) #5264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
|
|
||
| import de.codecentric.boot.admin.server.ui.config.AdminServerUiProperties.PollTimer; | ||
| import de.codecentric.boot.admin.server.ui.config.AdminServerUiProperties.UiTheme; | ||
| import de.codecentric.boot.admin.server.ui.config.CssColorUtils; | ||
| import de.codecentric.boot.admin.server.ui.extensions.UiExtension; | ||
| import de.codecentric.boot.admin.server.ui.extensions.UiExtensions; | ||
| import de.codecentric.boot.admin.server.web.AdminController; | ||
|
|
@@ -50,10 +51,13 @@ public class UiController { | |
|
|
||
| private final Settings uiSettings; | ||
|
|
||
| public UiController(String publicUrl, UiExtensions uiExtensions, Settings uiSettings) { | ||
| private final CssColorUtils cssColorUtils; | ||
|
|
||
| public UiController(String publicUrl, UiExtensions uiExtensions, Settings uiSettings, CssColorUtils cssColorUtils) { | ||
| this.publicUrl = publicUrl; | ||
| this.uiExtensions = uiExtensions; | ||
| this.uiSettings = uiSettings; | ||
| this.cssColorUtils = cssColorUtils; | ||
| } | ||
|
|
||
| @ModelAttribute(value = "baseUrl", binding = false) | ||
|
|
@@ -97,6 +101,23 @@ public Map<String, Object> getUser(@Nullable Principal principal) { | |
| return emptyMap(); | ||
| } | ||
|
|
||
| @ModelAttribute(value = "cssColors", binding = false) | ||
| public Map<String, String> getCssColors() { | ||
| var palette = uiSettings.getTheme().getPalette(); | ||
| return Map.of( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that the values here come from the configuration, I would personally just compute this map once in the constructor when the controller is created and just reuse that value every time the endpoint gets called. That's just a small optimisation :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the properties may be changed at runtime (via Spring Boot Admin's Properties UI + Spring Cloud mechanisms), i tend to have it in a method instead of a constructor.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok. I was not aware of this possibility. |
||
| "shade50Rgb", cssColorUtils.hexToRgb(palette.getShade50()), | ||
| "shade100Rgb", cssColorUtils.hexToRgb(palette.getShade100()), | ||
| "shade200Rgb", cssColorUtils.hexToRgb(palette.getShade200()), | ||
| "shade300Rgb", cssColorUtils.hexToRgb(palette.getShade300()), | ||
| "shade400Rgb", cssColorUtils.hexToRgb(palette.getShade400()), | ||
| "shade500Rgb", cssColorUtils.hexToRgb(palette.getShade500()), | ||
| "shade600Rgb", cssColorUtils.hexToRgb(palette.getShade600()), | ||
| "shade700Rgb", cssColorUtils.hexToRgb(palette.getShade700()), | ||
| "shade800Rgb", cssColorUtils.hexToRgb(palette.getShade800()), | ||
| "shade900Rgb", cssColorUtils.hexToRgb(palette.getShade900()) | ||
| ); | ||
| } | ||
|
|
||
| @GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE) | ||
| @RegisterReflectionForBinding(String.class) | ||
| public String index() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have extended/changed the controller constructor, check all parts where this is used. I guess that at least the tests are broken.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EIHEI2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to build this PR locally ... compile error:
./mvnw clean install -DskipTests -Dspring-javaformat.skip=true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed the expectations from @SteKoe were correct then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahoehma the bean is already registered in the context.
Therefore, for the sake of testing, you can just add it as parameter in https://github.com/codecentric/spring-boot-admin/blob/master/spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/config/AdminServerUiAutoConfiguration.java#L100 and then pass that parameter to https://github.com/codecentric/spring-boot-admin/blob/master/spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/config/AdminServerUiAutoConfiguration.java#L127.
Moreover, I would suggest you to run it with
-Dmaven.test.skip=trueinstead of-DskipTestsso that Maven doesn't even try to compile the tests (which maybe would fail as well).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the few compile errors by myself ... now I try to include the 4.1.0-SNAPSHOT into my project ... keep you informed asap :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm ... I'm using the snapshot now ... build is fine ... startup also fine .. but then when I try to open sba ...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please try removing the spring standard dialect bean which was added in the PR?
I suspect there is already one coming from Spring Boot itself, therefore now Thymeleaf doesn't know which one to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Now its up and running - CSS issues gone! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix-issue-47-followup.patch