SPB Git forge

spb/sorti-ka

Public

Toutes les sorties et tous les événements du Québec, un seul endroit — 7 connecteurs, fiches SSR, design Groupe KA.

58commits 1branches 0releases
13.7 MBsize
maindefault branch
17 days agolast push
HTML 82.9% Python 15.2% TypeScript 0.9% JavaScript 0.7%

widget ka-agent v4.1 : parseur ka-card tolerant (JSON multi-lignes/tableau) — sync ka-ui a508e7c

Simon-Pierre Boucher committed 1 mo ago (Aug 25, 2026) parent bdd9e43

1 changed file +12 −4

modified frontend/ka-agent.js +12 −4
@@ -159,12 +159,20 @@
159 159 };
160 160 function httpUrl(u) { return typeof u === "string" && /^https:\/\//.test(u) ? u : ""; }
161 161 function cards(lines) {
162 var html = "";
163 lines.forEach(function (ln) {
162 + var objs = [];
163 + lines.forEach(function (ln) { // format demandé : un JSON par ligne
164 164 ln = ln.trim();
165 165 if (!ln) return;
166 var o = null;
167 try { o = JSON.parse(ln); } catch (e) { return; } // ligne incomplète (streaming) → ignorée
166 + try { objs.push(JSON.parse(ln)); } catch (e) {} // ligne incomplète (streaming) → ignorée
167 + });
168 + if (!objs.length) { // filet : le modèle aère parfois son JSON
169 + try {
170 + var w = JSON.parse(lines.join("\n"));
171 + objs = Array.isArray(w) ? w : [w];
172 + } catch (e) {}
173 + }
174 + var html = "";
175 + objs.forEach(function (o) {
168 176 if (!o || !o.titre || !httpUrl(o.lien)) return;
169 177 var pal = ECO[o.site] || ["Groupe KA", "var(--accent,#d9f26b)", "var(--on-accent,#141814)"];
170 178 var img = httpUrl(o.image);
171 179