0 Votes

Code source wiki de News

Modifié par john le 2026/09/26 17:02

Masquer les derniers auteurs
john 2.1 1 Page //news// : capteurs du Pico W, image astronomique du jour, flux RSS, vols à Roissy, actualités, crypto-monnaies. Déploiement et configuration commune : [[Dashy>>Wiki Batcave John.Infrastructure.ServeurPrincipal.Dashy.WebHome]].
john 1.1 2
john 2.1 3 {{toc/}}
john 1.1 4
john 2.1 5 == pageInfo ==
6
john 1.1 7 {{code language="yaml"}}
8 pageInfo:
9 title: News
10 description: Some RSS feed
11 navLinks:
12 - title: Home
13 path: /
john 2.1 14 {{/code}}
15
16 == pages ==
17
18 {{code language="yaml"}}
john 1.1 19 pages:
20 - name: bookmarks
21 path: bookmark.yml
22 - name: cpu
23 path: cpu.yml
24 - name: news
25 path: news.yml
26 {{/code}}
27
john 2.1 28 == Widgets ==
john 1.1 29
john 2.1 30 |=Widget|=Section|=Affiche|=Identifiants
31 |##embed##|IoT — Pico W|Température, humidité, pression et altitude du Pico W|—
32 |##apod##|NASA|Image astronomique du jour de la NASA|—
33 |##rss-feed##|Debian CVE, News|Derniers articles d'un flux RSS|—
34 |##flight-data##|Aeroport|Départs et arrivées d'un aéroport|Clé RapidAPI
35 |##news-headlines##|Medias|Titres d'actualité par pays et langue|Clé Currents API
36 |##crypto-watch-list##|Crypto market|Cours CoinGecko des monnaies listées|—
37 |##wallet-balance##|Binance Wallets, Uphold Wallets|Solde et transactions d'une adresse Ethereum|—
john 1.1 38
john 2.1 39 == Sections ==
john 1.1 40
john 2.1 41 === IoT — Pico W ===
john 1.1 42
43 {{code language="yaml"}}
john 2.1 44 sections:
45 - name: IoT — Pico W
46 icon: hl-raspberry-pi
47 displayData:
48 cols: 1
49 rows: 2
50 items:
john 1.1 51 - title: Pico W
52 description: Interface Web LED + État
53 icon: hl-raspberry-pi
54 url: http://<IP_PICO>
55 statusCheck: true
john 2.1 56 id: 0_268_picow
57 widgets:
john 1.1 58 - type: embed
59 options:
60 html: |
61 <div id="pico-widget">
62 <div id="pico-content">
63 <p style="text-align:center;color:#888;">Chargement…</p>
64 </div>
65 </div>
66 css: |
67 #pico-widget { font-family: sans-serif; color: #e0e0e0; padding: 8px 4px; }
68 #pico-widget .pico-grid { display: flex; gap: 12px; justify-content: space-around; flex-wrap: wrap; }
69 #pico-widget .pico-card { background: rgba(255,255,255,0.06); border-radius: 12px; padding: 14px 18px; text-align: center; min-width: 90px; flex: 1; }
70 #pico-widget .pico-icon { font-size: 1.8em; margin-bottom: 6px; }
71 #pico-widget .pico-value { font-size: 1.5em; font-weight: bold; color: #fff; }
72 #pico-widget .pico-label { font-size: 0.72em; color: #aaa; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
73 #pico-widget .pico-footer { text-align: center; font-size: 0.68em; color: #666; margin-top: 10px; }
74 #pico-widget .pico-error { color: #ff6b6b; text-align: center; padding: 10px; font-size: 0.85em; }
75 script: |
76 (function() {
77 var API = 'http://<IP_PICO>/api';
78 function getColor(t) {
79 if (t < 10) return '#74b9ff';
80 if (t < 20) return '#55efc4';
81 if (t < 27) return '#fdcb6e';
82 return '#ff7675';
83 }
84 function render(d) {
85 var now = new Date().toLocaleTimeString('fr-FR', {hour:'2-digit',minute:'2-digit',second:'2-digit'});
86 document.getElementById('pico-content').innerHTML =
87 '<div class="pico-grid">' +
88 '<div class="pico-card"><div class="pico-icon">🌡️</div>' +
89 '<div class="pico-value" style="color:' + getColor(d.temperature) + '">' + d.temperature.toFixed(1) + '°C</div>' +
90 '<div class="pico-label">Température</div></div>' +
91 '<div class="pico-card"><div class="pico-icon">💧</div>' +
92 '<div class="pico-value">' + d.humidity.toFixed(1) + '%</div>' +
93 '<div class="pico-label">Humidité</div></div>' +
94 '<div class="pico-card"><div class="pico-icon">🔵</div>' +
95 '<div class="pico-value">' + d.pressure.toFixed(1) + '</div>' +
96 '<div class="pico-label">Pression hPa</div></div>' +
97 '<div class="pico-card"><div class="pico-icon">⛰️</div>' +
98 '<div class="pico-value">' + d.altitude.toFixed(1) + ' m</div>' +
99 '<div class="pico-label">Altitude</div></div>' +
100 '</div>' +
john 2.1 101 '<div class="pico-footer">Mis à jour à ' + now + ' · Pico W <IP_PICO></div>';
john 1.1 102 }
103 function fetchData() {
104 fetch('/cors-proxy', { headers: { 'Target-URL': API } })
105 .then(function(r) { return r.json(); })
106 .then(render)
107 .catch(function() {
108 document.getElementById('pico-content').innerHTML =
john 2.1 109 '<p class="pico-error">⚠️ Impossible de joindre le Pico (<IP_PICO>)</p>';
john 1.1 110 });
111 }
112 fetchData();
113 setInterval(fetchData, 30000);
114 })();
john 2.1 115 id: 0_268_picow_sensor
john 1.1 116 {{/code}}
117
john 2.1 118 Le script du widget ##embed## appelle ##/cors-proxy## avec l'en-tête ##Target-URL##, car le Pico est en http sur le LAN. L'API du Pico renvoie un JSON avec ##temperature##, ##humidity##, ##pressure## et ##altitude##. ##<IP_PICO>## doit figurer dans ##allowed_internal## de SWAG.
john 1.1 119
john 2.1 120 === NASA ===
john 1.1 121
122 {{code language="yaml"}}
john 2.1 123 sections:
124 - name: NASA
125 icon: hl-nasa
126 displayData:
127 sortBy: default
128 rows: 1
129 cols: 1
130 collapsed: false
131 hideForGuests: false
132 items: []
133 widgets:
john 1.1 134 - type: apod
john 2.1 135 id: 0_291_apod
john 1.1 136 {{/code}}
137
john 2.1 138 === Debian CVE ===
john 1.1 139
140 {{code language="yaml"}}
john 2.1 141 sections:
142 - name: Debian CVE
143 icon: hl-debian-linux
144 useProxy: true
145 widgets:
john 1.1 146 - type: rss-feed
147 options:
john 2.1 148 rssUrl: https://www.debian.org/security/dsa
149 id: 0_833_rssfeed
john 1.1 150 {{/code}}
151
john 2.1 152 ##useProxy## est placé sur la section : il est ignoré, le widget appelle rss2json directement.
john 1.1 153
john 2.1 154 === Aeroport ===
john 1.1 155
156 {{code language="yaml"}}
john 2.1 157 sections:
158 - name: Aeroport
159 icon: hl-flightaware
160 useProxy: true
161 widgets:
john 1.1 162 - type: flight-data
163 options:
john 2.1 164 airport: LFPG
john 1.1 165 apiKey: <CLE_API_RAPIDAPI>
166 limit: 12
167 direction: all
john 2.1 168 id: 0_844_flightdata
john 1.1 169 {{/code}}
170
john 2.1 171 * ##apiKey## : créer un compte RapidAPI, s'abonner à l'API AeroDataBox (offre gratuite) et copier la clé ##X-RapidAPI-Key##.
172 * La clé est envoyée dans un en-tête que ##/cors-proxy## ne relaie pas : laisser ce widget sans ##useProxy##. Celui de la section est ignoré.
173 * ##airport## : code OACI de l'aéroport.
john 1.1 174
john 2.1 175 === News ===
john 1.1 176
john 2.1 177 {{code language="yaml"}}
178 sections:
179 - name: News
180 icon: fad fa-newspaper
181 displayData:
182 rows: 1
183 sortBy: random
184 cols: 1
185 collapsed: true
186 hideForGuests: false
187 widgets:
188 - type: rss-feed
189 options:
190 limit: '2'
191 rssUrl: https://omgubuntu.co.uk/feed
192 id: 0_413_rssfeed
193 {{/code}}
john 1.1 194
john 2.1 195 === Medias ===
196
john 1.1 197 {{code language="yaml"}}
john 2.1 198 sections:
199 - name: Medias
200 icon: hl-youtube
201 displayData:
202 rows: 1
203 cols: 1
204 sortBy: default
205 collapsed: true
206 hideForGuests: false
207 widgets:
john 1.1 208 - type: news-headlines
209 useProxy: true
210 options:
211 lang: fr
212 country: FR
john 2.1 213 count: '2'
john 1.1 214 apiKey: <CLE_API_CURRENTS>
john 2.1 215 id: 0_595_newsheadlines
john 1.1 216 {{/code}}
217
john 2.1 218 ##apiKey## : clé obtenue en créant un compte gratuit sur Currents API. Elle passe dans l'URL et traverse ##/cors-proxy## sans réglage.
john 1.1 219
john 2.1 220 === Crypto market ===
john 1.1 221
222 {{code language="yaml"}}
john 2.1 223 sections:
224 - name: Crypto market
225 icon: hl-bitcoin
226 widgets:
john 1.1 227 - type: crypto-watch-list
228 options:
229 currency: EUR
230 assets:
231 - ethereum
232 - bnb
john 2.1 233 - wrapped-beacon-eth
john 1.1 234 - basic-attention-token
john 2.1 235 - paris-saint-germain-fan-token
236 - fc-porto
237 id: 0_1317_cryptowatchlist
238 displayData:
239 sortBy: default
240 rows: 1
241 cols: 1
242 collapsed: false
243 hideForGuests: false
john 1.1 244 {{/code}}
245
john 2.1 246 === Binance Wallets ===
john 1.1 247
john 2.1 248 {{code language="yaml"}}
249 sections:
250 - name: Binance Wallets
251 icon: hl-gollum
252 widgets:
253 - type: wallet-balance
254 options:
255 coin: eth
256 network: main
257 address: '<ADRESSE_WALLET_1>'
258 id: 0_1452_walletbalance
259 displayData:
260 sortBy: default
261 rows: 2
262 cols: 2
263 collapsed: false
264 hideForGuests: false
265 {{/code}}
john 1.1 266
john 2.1 267 === Uphold Wallets ===
john 1.1 268
269 {{code language="yaml"}}
john 2.1 270 sections:
271 - name: Uphold Wallets
272 icon: https://uphold.com/favicon.ico
273 widgets:
john 1.1 274 - type: wallet-balance
275 options:
276 coin: eth
277 network: main
john 2.1 278 address: '<ADRESSE_WALLET_2>'
279 id: 0_1384_walletbalance
280 displayData:
281 sortBy: default
282 rows: 2
283 cols: 2
284 collapsed: false
285 hideForGuests: false
john 1.1 286 {{/code}}
287
john 2.1 288 == Fichier complet ==
289
290 Le fichier ##news.yml## en un seul bloc, à copier tel quel dans ##user-data##.
291
292 {{html wiki="true"}}
293 <details><summary>Afficher news.yml complet</summary>
294
295 {{code language="yaml"}}
296 pageInfo:
297 title: News
298 description: Some RSS feed
299 navLinks:
300 - title: Home
301 path: /
302 pages:
303 - name: bookmarks
304 path: bookmark.yml
305 - name: cpu
306 path: cpu.yml
307 - name: news
308 path: news.yml
309 sections:
310 - name: IoT — Pico W
311 icon: hl-raspberry-pi
312 displayData:
313 cols: 1
314 rows: 2
315 items:
316 - title: Pico W
317 description: Interface Web LED + État
318 icon: hl-raspberry-pi
319 url: http://<IP_PICO>
320 statusCheck: true
321 id: 0_268_picow
322 widgets:
323 - type: embed
324 options:
325 html: |
326 <div id="pico-widget">
327 <div id="pico-content">
328 <p style="text-align:center;color:#888;">Chargement…</p>
329 </div>
330 </div>
331 css: |
332 #pico-widget { font-family: sans-serif; color: #e0e0e0; padding: 8px 4px; }
333 #pico-widget .pico-grid { display: flex; gap: 12px; justify-content: space-around; flex-wrap: wrap; }
334 #pico-widget .pico-card { background: rgba(255,255,255,0.06); border-radius: 12px; padding: 14px 18px; text-align: center; min-width: 90px; flex: 1; }
335 #pico-widget .pico-icon { font-size: 1.8em; margin-bottom: 6px; }
336 #pico-widget .pico-value { font-size: 1.5em; font-weight: bold; color: #fff; }
337 #pico-widget .pico-label { font-size: 0.72em; color: #aaa; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
338 #pico-widget .pico-footer { text-align: center; font-size: 0.68em; color: #666; margin-top: 10px; }
339 #pico-widget .pico-error { color: #ff6b6b; text-align: center; padding: 10px; font-size: 0.85em; }
340 script: |
341 (function() {
342 var API = 'http://<IP_PICO>/api';
343 function getColor(t) {
344 if (t < 10) return '#74b9ff';
345 if (t < 20) return '#55efc4';
346 if (t < 27) return '#fdcb6e';
347 return '#ff7675';
348 }
349 function render(d) {
350 var now = new Date().toLocaleTimeString('fr-FR', {hour:'2-digit',minute:'2-digit',second:'2-digit'});
351 document.getElementById('pico-content').innerHTML =
352 '<div class="pico-grid">' +
353 '<div class="pico-card"><div class="pico-icon">🌡️</div>' +
354 '<div class="pico-value" style="color:' + getColor(d.temperature) + '">' + d.temperature.toFixed(1) + '°C</div>' +
355 '<div class="pico-label">Température</div></div>' +
356 '<div class="pico-card"><div class="pico-icon">💧</div>' +
357 '<div class="pico-value">' + d.humidity.toFixed(1) + '%</div>' +
358 '<div class="pico-label">Humidité</div></div>' +
359 '<div class="pico-card"><div class="pico-icon">🔵</div>' +
360 '<div class="pico-value">' + d.pressure.toFixed(1) + '</div>' +
361 '<div class="pico-label">Pression hPa</div></div>' +
362 '<div class="pico-card"><div class="pico-icon">⛰️</div>' +
363 '<div class="pico-value">' + d.altitude.toFixed(1) + ' m</div>' +
364 '<div class="pico-label">Altitude</div></div>' +
365 '</div>' +
366 '<div class="pico-footer">Mis à jour à ' + now + ' · Pico W <IP_PICO></div>';
367 }
368 function fetchData() {
369 fetch('/cors-proxy', { headers: { 'Target-URL': API } })
370 .then(function(r) { return r.json(); })
371 .then(render)
372 .catch(function() {
373 document.getElementById('pico-content').innerHTML =
374 '<p class="pico-error">⚠️ Impossible de joindre le Pico (<IP_PICO>)</p>';
375 });
376 }
377 fetchData();
378 setInterval(fetchData, 30000);
379 })();
380 id: 0_268_picow_sensor
381 - name: NASA
382 icon: hl-nasa
383 displayData:
384 sortBy: default
385 rows: 1
386 cols: 1
387 collapsed: false
388 hideForGuests: false
389 items: []
390 widgets:
391 - type: apod
392 id: 0_291_apod
393 - name: Debian CVE
394 icon: hl-debian-linux
395 useProxy: true
396 widgets:
397 - type: rss-feed
398 options:
399 rssUrl: https://www.debian.org/security/dsa
400 id: 0_833_rssfeed
401 - name: Aeroport
402 icon: hl-flightaware
403 useProxy: true
404 widgets:
405 - type: flight-data
406 options:
407 airport: LFPG
408 apiKey: <CLE_API_RAPIDAPI>
409 limit: 12
410 direction: all
411 id: 0_844_flightdata
412 - name: News
413 icon: fad fa-newspaper
414 displayData:
415 rows: 1
416 sortBy: random
417 cols: 1
418 collapsed: true
419 hideForGuests: false
420 widgets:
421 - type: rss-feed
422 options:
423 limit: '2'
424 rssUrl: https://omgubuntu.co.uk/feed
425 id: 0_413_rssfeed
426 - name: Medias
427 icon: hl-youtube
428 displayData:
429 rows: 1
430 cols: 1
431 sortBy: default
432 collapsed: true
433 hideForGuests: false
434 widgets:
435 - type: news-headlines
436 useProxy: true
437 options:
438 lang: fr
439 country: FR
440 count: '2'
441 apiKey: <CLE_API_CURRENTS>
442 id: 0_595_newsheadlines
443 - name: Crypto market
444 icon: hl-bitcoin
445 widgets:
446 - type: crypto-watch-list
447 options:
448 currency: EUR
449 assets:
450 - ethereum
451 - bnb
452 - wrapped-beacon-eth
453 - basic-attention-token
454 - paris-saint-germain-fan-token
455 - fc-porto
456 id: 0_1317_cryptowatchlist
457 displayData:
458 sortBy: default
459 rows: 1
460 cols: 1
461 collapsed: false
462 hideForGuests: false
463 - name: Binance Wallets
464 icon: hl-gollum
465 widgets:
466 - type: wallet-balance
467 options:
468 coin: eth
469 network: main
470 address: '<ADRESSE_WALLET_1>'
471 id: 0_1452_walletbalance
472 displayData:
473 sortBy: default
474 rows: 2
475 cols: 2
476 collapsed: false
477 hideForGuests: false
478 - name: Uphold Wallets
479 icon: https://uphold.com/favicon.ico
480 widgets:
481 - type: wallet-balance
482 options:
483 coin: eth
484 network: main
485 address: '<ADRESSE_WALLET_2>'
486 id: 0_1384_walletbalance
487 displayData:
488 sortBy: default
489 rows: 2
490 cols: 2
491 collapsed: false
492 hideForGuests: false
493 {{/code}}
494
495 </details>
496 {{/html}}
497