Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
85 lignes
6.3 KiB
Python
85 lignes
6.3 KiB
Python
p='modele.html'; s=open(p,encoding='utf-8').read()
|
|
def sub(a,b):
|
|
global s
|
|
assert s.count(a)==1, a[:60]; s=s.replace(a,b)
|
|
# ---- pied de page sombre, avec contact et SIRET comme sur gastinel.me ----
|
|
i=s.index('<footer class="pied">'); j=s.index('</footer>',i)+9
|
|
s=s[:i]+'''<footer class="pied">
|
|
<div class="pied-grille">
|
|
<div>
|
|
<p class="accroche">Des stations de chez nous, des chiffres d'ici.</p>
|
|
<p>Données : Météo-France (Licence Ouverte), Infoclimat (CC BY ou CC BY-NC selon la station), WeatherLink, station Gastinel. Fond de carte : IGN, licence ouverte.</p>
|
|
</div>
|
|
<div>
|
|
<h4>Contact</h4>
|
|
<ul><li><a href="mailto:studio@gastinel.me">studio@gastinel.me</a></li>
|
|
<li><a href="https://wa.me/message/XAHBYTJZNQ6TK1" rel="noopener">WhatsApp</a></li>
|
|
<li><a href="tel:+33636276419">06 36 27 64 19</a></li></ul>
|
|
</div>
|
|
<div>
|
|
<h4>Le site</h4>
|
|
<ul><li><a href="a-propos.html">À propos</a></li><li><a href="a-propos.html#sources">Sources et licences</a></li><li><a href="a-propos.html#mentions">Mentions légales</a></li><li><a href="cgu.html">CGU</a></li><li><a href="confidentialite.html">Confidentialité</a></li></ul>
|
|
<p>SIRET <a href="https://entreprises.lefigaro.fr/nd-38/entreprise-104816749" rel="noopener">10481674900014</a></p>
|
|
</div>
|
|
</div>
|
|
<p class="pied-bas">© Théo Gastinel · Météo Vercors</p>
|
|
</footer>'''+s[j:]
|
|
a=s.index('.pied{max-width:1080px'); b=s.index('.pied a{color:var(--sapin)}')+len('.pied a{color:var(--sapin)}')
|
|
s=s[:a]+""".pied{background:#303336;color:#d1d3d6;padding:34px 28px 22px;font-size:13px;line-height:1.7;border-top:4px solid #1c1d1f}
|
|
.pied-grille{max-width:1080px;margin:0 auto;display:grid;grid-template-columns:1.4fr 1fr 1fr;gap:34px}
|
|
.pied p{margin:6px 0}
|
|
.pied h4{margin:0 0 8px;font-family:var(--texte);font-size:11.5px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:#fff;border-bottom:1px solid #4a4d51;padding-bottom:7px}
|
|
.pied ul{list-style:none;margin:0;padding:0}
|
|
.pied .accroche{font-family:var(--titre);font-style:italic;font-size:17px;color:#fff}
|
|
.pied a{color:#b9c2cc;text-decoration:none;font-weight:500}
|
|
.pied a:hover{color:#fff;text-decoration:underline}
|
|
.pied-bas{max-width:1080px;margin:26px auto 0!important;padding-top:14px;border-top:1px solid #45484c;font-size:12px;color:#8e9298}"""+s[b:]
|
|
sub(" .pied{padding:18px 16px 36px}"," .pied{padding:26px 16px 30px}\n .pied-grille{grid-template-columns:1fr;gap:22px}")
|
|
# ---- mise en avant (record) : saisonnière, réglable ----
|
|
a=s.index("function phraseDuJour(){"); b=s.index("\n}\n",a)+3
|
|
s=s[:a]+"""let RECORD = 'auto';
|
|
try { RECORD = localStorage.getItem('vm-record') || 'auto'; } catch (e) {}
|
|
// saisons météorologiques : hiver = décembre à février, été = juin à août
|
|
function saisonMeteo(){
|
|
const m = parseInt(new Intl.DateTimeFormat('fr-FR', {month: 'numeric', timeZone: 'Europe/Paris'}).format(new Date()), 10);
|
|
return m === 12 || m <= 2 ? 'hiver' : m >= 6 && m <= 8 ? 'ete' : 'entre';
|
|
}
|
|
function phraseDuJour(){
|
|
const toutes = Object.values(STATIONS), reelles = toutes.filter(x => x.t != null);
|
|
if (!reelles.length) {
|
|
document.getElementById('phrase').textContent = 'Relevés en cours de chargement…';
|
|
document.getElementById('reseau').textContent = `${toutes.length} stations dans le massif`;
|
|
return;
|
|
}
|
|
const l = [...reelles].sort((a, b) => a.t - b.t), f = l[0], c = l[l.length - 1], deg = t => fmt(t).replace('°', ' °C');
|
|
const sais = saisonMeteo(), mode = RECORD !== 'auto' ? RECORD : sais === 'hiver' ? 'froid' : sais === 'ete' ? 'chaud' : 'ecart';
|
|
const mom = MOMENT(heureParis());
|
|
let s;
|
|
if (mode === 'chaud') s = `${mom}, <strong>${deg(c.t)} à ${court(c.nom)}</strong>, le point le plus chaud du massif en ce moment.`;
|
|
else if (mode === 'ecart') s = `${mom}, de <strong>${deg(f.t)} à ${court(f.nom)}</strong> à <strong>${deg(c.t)} à ${court(c.nom)}</strong> : le plus froid et le plus chaud du massif.`;
|
|
else if (mode === 'vent') {
|
|
const v = toutes.filter(x => x.vent != null && capteur(Object.keys(STATIONS).find(k => STATIONS[k] === x), 'vent')).sort((a, b) => b.vent - a.vent)[0];
|
|
s = v ? `${mom}, <strong>${Math.round(v.vent)} km/h à ${court(v.nom)}</strong>, le vent moyen le plus fort du massif.` : `${mom}, aucun vent mesuré pour l'instant.`;
|
|
} else if (mode === 'pluie') {
|
|
const r = toutes.filter(x => x.pluie != null && x.pluie > 0).sort((a, b) => b.pluie - a.pluie)[0];
|
|
s = r ? `${mom}, <strong>${nb1(r.pluie)} mm en une heure à ${court(r.nom)}</strong>, la pluie la plus forte du massif.` : `${mom}, pas de pluie mesurée dans le massif.`;
|
|
} else {
|
|
s = `${mom}, <strong>${deg(f.t)} à ${court(f.nom)}</strong>, le point le plus froid du massif en ce moment.`;
|
|
const h = l.filter(x => x.alt - f.alt >= 300 && x.t - f.t >= 3).sort((a, b) => b.alt - a.alt)[0];
|
|
if (h) s += ` ${h.alt - f.alt} m plus haut, ${court(h.nom)} : ${deg(h.t)}. L'air froid est resté au fond.`;
|
|
}
|
|
document.getElementById('phrase').innerHTML = s;
|
|
document.getElementById('reseau').textContent = `${reelles.length} stations en direct sur ${toutes.length} · Météo-France, Infoclimat, station Gastinel`;
|
|
}
|
|
"""+s[b:]
|
|
sub('</div>\n <p class="compte">','''<label class="record">Mise en avant <select id="record"><option value="auto">Selon la saison</option><option value="froid">Plus froid</option><option value="chaud">Plus chaud</option><option value="vent">Plus de vent</option><option value="pluie">Plus de pluie</option></select></label>
|
|
</div>
|
|
<p class="compte">''')
|
|
sub(".compte{margin:10px 0 0;",".record{flex:0 0 100%;font-size:11.5px;color:var(--gris)}\n.record select{font:inherit;font-size:11.5px;color:var(--sapin);background:#fff;border:1px solid var(--pierre);border-radius:0;padding:3px 4px;margin-left:4px}\n.compte{margin:10px 0 0;")
|
|
sub("['rech', 'modes'].forEach(","""const selRecord = document.getElementById('record');
|
|
selRecord.value = RECORD;
|
|
selRecord.addEventListener('change', () => { RECORD = selRecord.value; try { localStorage.setItem('vm-record', RECORD); } catch (e) {} phraseDuJour(); });
|
|
['rech', 'modes'].forEach(""")
|
|
sub("if (ev.target.closest('a, button, input, .rech') || carte.clientWidth >= 720) return;","if (ev.target.closest('a, button, input, select, label, .rech') || carte.clientWidth >= 720) return;")
|
|
open(p,'w',encoding='utf-8').write(s)
|