#!/usr/bin/env python3 """Assemble le site publiable de vercors.me dans /site-v2/ à partir de la maquette. site-v2/index.html, a-propos.html, statistiques.html, 404.html, llms.txt, llms-full.txt, (cgu.html, confidentialite.html si présents), polices/, tuiles/, data/ (vide) Les JSON de données (data/*.json, data/semaine/) sont produits sur cornafserver et copiés sur le serveur public à part. Usage : python assembler.py """ import os import shutil import sys ICI = os.path.dirname(os.path.abspath(__file__)) DEST = os.path.join(os.path.dirname(os.path.dirname(ICI)), "site-v2") # CGU et confidentialité : retirées de la version publique jusqu'à la relecture juridique (textes dans maquettes/ et Documents/Meteo-Vercors/08-Juridique) PAGES = ("index.html", "a-propos.html", "statistiques.html") def main(): shutil.rmtree(DEST, ignore_errors=True) os.makedirs(os.path.join(DEST, "data")) for nom in PAGES: src = os.path.join(ICI, "a-propos-build.html" if nom == "a-propos.html" else nom) if os.path.exists(src): shutil.copy(src, os.path.join(DEST, nom)) # forum non ouvert : pas de lien vers des pages qui n'existent pas encore en ligne ip = os.path.join(DEST, "index.html") t = open(ip, encoding="utf-8").read() t = t.replace('
  • CGU
  • ', '').replace('
  • Confidentialité
  • ', '') t = t.replace('href="forum/index.html"', 'aria-disabled="true"').replace('href="forum/connexion.html"', 'aria-disabled="true"') open(ip, "w", encoding="utf-8").write(t) # statistiques : CGU et confidentialité non publiées, on retire leurs liens de la page copiée sp = os.path.join(DEST, "statistiques.html") if os.path.exists(sp): t = open(sp, encoding="utf-8").read() t = t.replace(' Voir la politique de confidentialité.', '') t = t.replace('Conditions d\'utilisation · Confidentialité · ', '') open(sp, "w", encoding="utf-8").write(t) for fixe in ("404.html", "llms.txt", "llms-full.txt"): if os.path.exists(os.path.join(ICI, fixe)): shutil.copy(os.path.join(ICI, fixe), os.path.join(DEST, fixe)) open(os.path.join(DEST, "robots.txt"), "w", encoding="utf-8").write("User-agent: *\nAllow: /\nSitemap: https://vercors.me/sitemap.xml\n") urls = "".join("https://vercors.me/%s" % u for u in ("", "a-propos", "statistiques")) open(os.path.join(DEST, "sitemap.xml"), "w", encoding="utf-8").write('%s\n' % urls) for dossier in ("polices", "tuiles"): src = os.path.join(ICI, dossier) if os.path.isdir(src): shutil.copytree(src, os.path.join(DEST, dossier), ignore=shutil.ignore_patterns("*.css")) # contrôle : aucune ressource distante dans les pages for nom in os.listdir(DEST): if nom.endswith(".html"): texte = open(os.path.join(DEST, nom), encoding="utf-8").read() for motif in ("https://fonts.", "//cdn.", "