weather: add possibility to override njk's and css#4051
weather: add possibility to override njk's and css#4051KristjanESPERANTO merged 2 commits intoMagicMirrorOrg:developfrom
Conversation
|
Weather doesn’t use njk in next release |
|
I used last |
|
Weird. I thought he removed them, we had that conversation.. |
|
weather was moved from browser-only to using server-side but the "gui" was not touched |
|
Nice! I think it would be great to have this possibility 🙌 One question without digging into the changes: in the linked issue #2909, @sdetweil suggested a simpler approach – just adding config variables for the template file names and css, defaulting to the current values, something like: currentNjk: "defaultmodules/weather/current.njk",
hourlyNjk: "defaultmodules/weather/hourly.njk",
forecastNjk: "defaultmodules/weather/forecast.njk",
weatherCss: "defaultmodules/weather/weather.css",Users could then override only what they need with a path relative to the MM root, e.g.: currentNjk: "config/mycurrent.njk",That would already allow users to point to custom files without touching the module code. Would that cover the main use case, or do you think the |
Ah, that wouldn't be possible with the simpler approach... Right? |
|
I think to define another dir is a simpler approach instead of 4 variables. You find my (testing) example here, I need 2 additional scripts Can explain more tomorrow if needed (now too late) ... |
|
I think I'm starting to understand where you are going with this – looking at MMM-WeatherBridge it makes more sense and gives impressive flexibility 👍 One concern though: wouldn't |
|
think so, had no better idea as |
Me neither, but maybe that's (multiple weather instances with different themes) an edge case that we don't need to support and should just accept as a known limitation. |
yes, and the user can implement the multiple instances stuff inside the 2 procedures if needed. |
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
|
Looks good to me! 🙂 One thought: now that the infrastructure is in place, would it make sense to already ship some themes in core (e.g. under On the other hand, bundled themes also mean ongoing maintenance responsibility for us. Maybe better to merge this as-is and see if the community picks it up first? |
I think so. I didn't want to burden this repository with my weather setup as well. The idea is to add a detailed example to the documentation after the merge. |
|
Nice! I'll definitely play around with it, as it has the potential to make many third-party weather modules unnecessary. |
Follow up for #4051 - fix loading default weather.css (the construction with `./weather.css` gave a 404) - accept `themeDir` with and without trailing slash
This is an approach for #2909
It adds 2 values to the config:
themeDirmust be specified relative to the weather dir.Example config:
The
themeDirmust contain the 4 filesYou can add more files (if needed) and add them to the
themeCustomScriptsso they are loaded as script.There are 2 methods inserted which are called if defined:
I see this as a simple approach for overriding the default njk templates and css. I did already convert my MMM-WeatherBridge into a template.