SPB Git forge

spb/crea-ka

Public

Créa·Ka — annuaire public cross-plateforme des créateurs de contenu québécois (crea-ka.com)

52commits 1branches 0releases
11.3 MBsize
maindefault branch
19 days agolast push
Python 73.6% HTML 13.2% TypeScript 6% JavaScript 4.5% CSS 1.7% Dockerfile 0.6%
2.4 KB · 50 lines python
Raw Blame History
1# ==============================================================================2# Author: Simon-Pierre Boucher <contact@spboucher.ai>3# File:   scripts/build_frontend.py4# Desc:   Construit frontend/dist/index.html à partir du gabarit en injectant :5#         __ICONS__     — tracés SVG des marques (simple-icons, licence CC0)6#         __KA_TOKENS__ — ka/tokens.css (design system commun Groupe KA,7#                         importé EN PREMIER dans le <head>)8#         __KA_ECO__    — ka/ecosystem.json (contacts, sites & mentions légales9#                         du groupe : footer commun + page /contact)10# ==============================================================================11"""Usage : python3 scripts/build_frontend.py1213Lit frontend/src/index.template.html + frontend/src/icons.json +14frontend/src/ka/{tokens.css,ecosystem.json} et produit frontend/dist/index.html15(remplacement des marqueurs __ICONS__, __KA_TOKENS__ et __KA_ECO__)."""16from __future__ import annotations1718import json19from pathlib import Path2021ROOT = Path(__file__).resolve().parent.parent22SRC = ROOT / "frontend" / "src"23KA = SRC / "ka"24DIST = ROOT / "frontend" / "dist"252627def main() -> None:28    icons = json.loads((SRC / "icons.json").read_text(encoding="utf-8"))29    tokens = (KA / "tokens.css").read_text(encoding="utf-8")30    eco = json.loads((KA / "ecosystem.json").read_text(encoding="utf-8"))31    html = (SRC / "index.template.html").read_text(encoding="utf-8")32    for marker in ("__ICONS__", "__KA_TOKENS__", "__KA_ECO__"):33        if marker not in html:34            raise SystemExit(f"[crea-ka] marqueur manquant dans le gabarit : {marker}")35    html = html.replace("__ICONS__", json.dumps(icons, separators=(",", ":")))36    html = html.replace("__KA_TOKENS__", tokens)37    html = html.replace("__KA_ECO__", json.dumps(eco, ensure_ascii=False, separators=(",", ":")))38    DIST.mkdir(parents=True, exist_ok=True)39    (DIST / "index.html").write_text(html, encoding="utf-8")40    # Widget KA Agent (bulle de chat IA Groupe KA) — source perenne dans41    # frontend/src/, copie vers dist/ a chaque build (dist est regenere).42    (DIST / "ka-agent.js").write_bytes((SRC / "ka-agent.js").read_bytes())43    (DIST / "ka-id.js").write_bytes((SRC / "ka-id.js").read_bytes())44    print(f"[crea-ka] frontend construit → {DIST/'index.html'} "45          f"({len(html)//1024} Ko, {len(icons)} icônes, tokens ka-ui + écosystème injectés)")464748if __name__ == "__main__":49    main()50