SPB Git forge

spb/api-ka

Public

API-KA — plateforme centrale : collecte quotidienne des 8 services KA, historisation append-only et API publique sur www.api-ka.com

48commits 1branches 0releases
5.9 MBsize
maindefault branch
19 days agolast push
Python 60.9% HTML 21% TypeScript 7.3% JavaScript 5.2% CSS 4.8% Shell 0.8%

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 2ce399e

1 changed file +12 −4

modified src/api/web/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