Fichiers
meteo-vercors/maquettes/accueil-carte/assembler.py
T
Théo GastineletClaude Opus 5.5 1df8be2be1 humans.txt, security.txt, ads.txt, interdiction d'entraînement d'IA, liens CGU/confidentialité
- humans.txt, ads.txt (ligne placeholder IAB), ai.txt, .well-known/security.txt (RFC 9116), .well-known/tdmrep.json
- robots.txt : robots d'entraînement d'IA refusés ; robots de recherche et de lecture laissés libres
- À propos : section « Intelligence artificielle » (#ia)
- <link rel="privacy-policy"> et "terms-of-service" (vers /a-propos#mentions) dans toutes les pages et le forum ; <link rel="author"> dans l'accueil
- assembler.py copie les nouveaux fichiers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 01:00:43 +01:00

75 lignes
4.7 KiB
Python

#!/usr/bin/env python3
"""Assemble le site publiable de vercors.me dans <projet>/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 re
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", "climat.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 = re.sub(r'<li><a href="(?:cgu|confidentialite)\.html"[^>]*>[^<]*</a></li>', '', t) # pages en attente de l'avocate
# forum ouvert le 05/11/2026 : les liens /forum/ restent tels quels
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 <a href="confidentialite.html">politique de confidentialité</a>.', '')
t = t.replace('<a href="cgu.html">Conditions d\'utilisation</a> · <a href="confidentialite.html">Confidentialité</a> · ', '')
open(sp, "w", encoding="utf-8").write(t)
for fixe in ("404.html", "llms.txt", "llms-full.txt", "charte.html", "charte-vercors.pdf"):
if os.path.exists(os.path.join(ICI, fixe)):
shutil.copy(os.path.join(ICI, fixe), os.path.join(DEST, fixe))
# robots d'ENTRAÎNEMENT d'IA refusés ; robots de recherche / lecture à la demande (OAI-SearchBot, ChatGPT-User, Claude-User, Claude-SearchBot, PerplexityBot, Googlebot) autorisés
entrainement = ("GPTBot", "Google-Extended", "CCBot", "ClaudeBot", "anthropic-ai", "Applebot-Extended", "Bytespider", "meta-externalagent",
"FacebookBot", "Amazonbot", "cohere-ai", "Diffbot", "Omgilibot", "ImagesiftBot", "Timpibot")
robots = "# Entraînement d'IA interdit (voir /ai.txt). Lecture pour répondre à une question permise.\n"
robots += "".join("User-agent: %s\nDisallow: /\n\n" % b for b in entrainement)
robots += "User-agent: *\nAllow: /\nDisallow: /forum/connexion\nDisallow: /forum/api/\nDisallow: /forum/photo/\n\nSitemap: https://vercors.me/sitemap.xml\n"
open(os.path.join(DEST, "robots.txt"), "w", encoding="utf-8").write(robots)
for fixe in ("humans.txt", "ads.txt", "ai.txt"):
shutil.copy(os.path.join(ICI, fixe), os.path.join(DEST, fixe))
os.makedirs(os.path.join(DEST, ".well-known"), exist_ok=True)
for fixe in ("security.txt", "tdmrep.json"):
shutil.copy(os.path.join(ICI, "well-known", fixe), os.path.join(DEST, ".well-known", fixe))
urls = "".join("<url><loc>https://vercors.me/%s</loc></url>" % u for u in ("", "climat", "a-propos", "statistiques", "charte", "forum/"))
open(os.path.join(DEST, "sitemap.xml"), "w", encoding="utf-8").write('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">%s</urlset>\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"), dirs_exist_ok=True)
# 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.", "<script src=\"http", "<link href=\"http"):
if motif in texte:
print("ATTENTION : ressource distante dans", nom, motif)
return 1
taille = sum(os.path.getsize(os.path.join(d, f)) for d, _, fs in os.walk(DEST) for f in fs)
print("site-v2 assemblé : %d fichiers, %.1f Mo -> %s" % (sum(len(f) for _, _, f in os.walk(DEST)), taille / 1e6, DEST))
return 0
if __name__ == "__main__":
sys.exit(main())