/* ============================================ Projet : API-KA Fichier : src/api/web/ka/ka-shell.js Node : m3u96b Author : Simon-Pierre Boucher Contact : contact@spboucher.ai Date : 2026-08-17 ============================================ Coquille commune Groupe KA pour les pages statiques d'API-KA : · footer commun .ka-footer (équivalent vanilla de ka-ui/KaFooter.tsx), alimenté par /ka/ecosystem.json (source de vérité unique) ; · cartes contact (page /contact, conteneur #ka-contacts) ; · état de connexion KA ID dans le header (conteneur #ka-auth). */ "use strict"; const KA_SITE_ID = "api-ka"; async function kaEco() { const r = await fetch("/ka/ecosystem.json"); return r.json(); } function el(tag, cls, html) { const e = document.createElement(tag); if (cls) e.className = cls; if (html !== undefined) e.innerHTML = html; return e; } function esc(s) { return String(s).replace(/&/g, "&").replace(//g, ">"); } /* ---------- footer commun (structure .ka-footer de tokens.css) ---------- */ function kaRenderFooter(eco) { const root = document.getElementById("ka-footer-root"); if (!root) return; const site = eco.sites.find((s) => s.id === KA_SITE_ID); const others = eco.sites.filter((s) => s.id !== KA_SITE_ID); const year = new Date().getFullYear(); root.innerHTML = ` Groupe KA

${esc(eco.org.tagline)} Des centaines de connecteurs lisent les sites à la source, normalisent la donnée et se resynchronisent seuls. ${site ? `${esc(site.wordmark)} — ${esc(site.tagline)} — est un service Groupe KA.` : ""}

${esc(eco.org.disclaimer)}

${eco.contacts.map((c) => `

${c.email}${esc(c.role)}

`).join("")}
`; } /* ---------- cartes contact (page /contact) ---------- */ function kaRenderContacts(eco) { const zone = document.getElementById("ka-contacts"); if (!zone) return; zone.innerHTML = eco.contacts .map( (c) => `
${esc(c.role)} ${c.email}
` ) .join(""); const hub = document.getElementById("ka-hub-link"); if (hub) hub.href = eco.hub.url + eco.hub.loginPath; } /* ---------- connexion KA ID dans le header (#ka-auth) ---------- */ async function kaRenderAuth() { const zone = document.getElementById("ka-auth"); if (!zone) return; try { const r = await fetch("/api/auth/me", { headers: { Accept: "application/json" } }); if (r.ok) { const u = await r.json(); zone.innerHTML = ` ${u.picture ? `` : ""} ${esc(u.name || "membre")} `; zone.querySelector(".ka-logout").addEventListener("click", async () => { await fetch("/api/auth/logout", { method: "POST" }); location.reload(); }); return; } } catch {} zone.innerHTML = `Se connecter avec KA`; } (async () => { kaRenderAuth(); try { const eco = await kaEco(); kaRenderFooter(eco); kaRenderContacts(eco); } catch {} })();