openvibers/openvibe.actor Commits

Home folds say how much they hold (#254)

OP OpenVibers committed 11 days ago · 996b647133 · 2 files, +16 −2

Changes

ddiff --git a/public/css/home.css b/public/css/home.css
iindex 7c317cf..bfb85de 100644
---- a/public/css/home.css
++++ b/public/css/home.css
@@@ -51,6 +51,7 @@
.fold-h > h2 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -.02em; flex: 1 1 auto; }
.fold-h:focus-within { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
.fold-mark { flex: none; }
++.fold-n { flex: none; font-size: .82rem; font-weight: 600; color: var(--text-muted, #7386a3); font-variant-numeric: tabular-nums; }
.fold-mark::after { content: "+"; font-size: 20px; font-weight: 400; color: var(--text-muted, #7386a3); }
.fold-toggle:checked ~ .fold-h .fold-mark::after { content: "\2212"; }
.fold-body { display: none; }
@@@ -66,7 +67,7 @@
.fold { margin-top: 56px; }
.fold-toggle { display: none; }
.fold-h { min-height: 0; margin-bottom: 10px; cursor: default; }
-- .fold-mark { display: none; }
++ .fold-mark, .fold-n { display: none; }
.fold-body { display: block; }
.fold-bare > .fold-h { display: none; }
.fold-bare { margin-top: 0; }
ddiff --git a/server/render/short.js b/server/render/short.js
iindex ec74c00..21f62f2 100644
---- a/server/render/short.js
++++ b/server/render/short.js
@@@ -24,11 +24,24 @@ const str = (v) => (v && typeof v === 'object' && typeof v.s === 'string') ? v.s
*
* foldBlock({ id, head, html, bare })
*/
++/**
++ * What a fold holds, counted, for its line ("7 questions", "latest 5", "3 items"): a folded part still says how much
++ * is behind it (the owner's rule, 2026-10-31: folds show their count). The 11-01 pass missed this checkbox fold.
++ */
++function foldMeta(body, cls = '') {
++ const s = typeof body === 'string' ? body : String((body && (body.s || body.html || body.value)) || body || '');
++ const n = (re) => (s.match(re) || []).length;
++ const shipped = /data-ov-shipped="list"[^>]*?data-limit="(\d+)"|data-limit="(\d+)"[^>]*?data-ov-shipped="list"/.exec(s);
++ const q = n(/<details[\s>]/g), li = n(/<li[\s>]/g), a = n(/<a\s/g);
++ const text = shipped ? `latest ${shipped[1] || shipped[2]}` : q > 1 ? `${q} questions` : li > 1 ? `${li} items` : a > 1 ? `${a} links` : '';
++ return text ? `<span${cls ? ` class="${cls}"` : ''}>${text}</span>` : '';
++}
++
function foldBlock({ id, head, html, bare = false }) {
const key = `fold-${esc(id)}`;
return `<div class="fold${bare ? ' fold-bare' : ''}" id="${key}">`
+ `<input class="fold-toggle" type="checkbox" id="${key}-open">`
-- + `<label class="fold-h" for="${key}-open">${str(head)}<span class="fold-mark" aria-hidden="true"></span></label>`
++ + `<label class="fold-h" for="${key}-open">${str(head)}${foldMeta(str(html), 'fold-n')}<span class="fold-mark" aria-hidden="true"></span></label>`
+ `<div class="fold-body">${str(html)}</div></div>`;
}