Commit 35cd4d8
authored
weather: add possibility to override njk's and css (#4051)
This is an approach for #2909
It adds 2 values to the config:
```js
themeDir: "./",
themeCustomScripts: []
```
`themeDir` must be specified relative to the weather dir.
Example config:
```js
{
module: "weather",
position: "top_center",
config: {
weatherProvider: "openmeteo",
type: "current",
lat: 40.776676,
lon: -73.971321,
themeDir: "../../../modules/MyWeatherTemplate/",
themeCustomScripts: [ "skycons.js", "weathertheme.js" ],
}
},
```
The `themeDir` must contain the 4 files
- current.njk
- forecast.njk
- hourly.njk
- weather.css
You can add more files (if needed) and add them to the
`themeCustomScripts` so they are loaded as script.
There are 2 methods inserted which are called if defined:
- initWeatherTheme: For doing special things when starting the module
- updateWeatherTheme: For doing special things before updating the dom
I see this as a simple approach for overriding the default njk templates
and css. I did already convert my
[MMM-WeatherBridge](https://gitlab.com/khassel/MMM-WeatherBridge) into a
template.1 parent cb61aeb commit 35cd4d8
1 file changed
+20
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| 107 | + | |
| 108 | + | |
101 | 109 | | |
102 | 110 | | |
103 | 111 | | |
| |||
211 | 219 | | |
212 | 220 | | |
213 | 221 | | |
214 | | - | |
| 222 | + | |
215 | 223 | | |
216 | | - | |
| 224 | + | |
217 | 225 | | |
218 | 226 | | |
219 | | - | |
| 227 | + | |
220 | 228 | | |
221 | 229 | | |
222 | | - | |
| 230 | + | |
223 | 231 | | |
224 | 232 | | |
225 | 233 | | |
| |||
242 | 250 | | |
243 | 251 | | |
244 | 252 | | |
245 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
246 | 258 | | |
247 | 259 | | |
248 | 260 | | |
| |||
0 commit comments