From d7d9b98c5191b90ebfe5b248c117401270ae4594 Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Fri, 5 Jun 2026 11:59:49 +0200 Subject: [PATCH] feat(panes): searchable bookmark collection pane + container-pane support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browser (data-browser-panes.js): panes are now offered containers as well as single resources. render() may be async and may return null to decline, in which case the browser falls through to the folder table / JSON (no regression for ordinary folders). h gains isContainer, path, children, and an async fetchResource(url) helper so a pane can render a collection. Collection pane (examples/panes/bookmark-collection.js): canHandles the /public/bookmark/ container and renders its bookmark:Bookmark members as a searchable feed — compact cards (favicon, title, host, summary snippet, tags), a live search box (inline oninput, no script tag), card body -> the bookmark's .jsonld detail page, corner arrow -> the original link. Returns null when the folder holds no bookmarks. No version bump: the browser change lands on gh-pages but won't reach the cdn until a future publish; pods can use it via a --mashlib-module override. Refs #73 --- data-browser-panes.js | 57 +++++++++++----- examples/panes/bookmark-collection.js | 96 +++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 15 deletions(-) create mode 100644 examples/panes/bookmark-collection.js diff --git a/data-browser-panes.js b/data-browser-panes.js index e0a654e..0072d0f 100644 --- a/data-browser-panes.js +++ b/data-browser-panes.js @@ -10,9 +10,18 @@ // 3. No matching pane → pretty-printed JSON-LD (same as data-browser.js). // // Single file, no build, no framework. Local pane contract (ES module): -// export default { canHandle(node, h) -> boolean, render(node, h) -> htmlString } -// where h = { escape, prop, propAll, first, idOf, types, host, fmtDate, localName }. -// (prop may return an array for multi-valued JSON-LD; use h.first for single values.) +// export default { +// canHandle(node, h) -> boolean, +// render(node, h) -> htmlString | Promise // null/'' declines +// } +// Panes are offered BOTH single resources and containers (h.isContainer marks +// which). A pane that returns null is skipped, so a container pane can decline a +// folder it doesn't recognise and fall through to the folder table. +// h = { escape, prop, propAll, first, idOf, types, host, fmtDate, localName, +// isContainer, path, children, fetchResource(url) } +// - prop may return an array for multi-valued JSON-LD; use h.first for one value. +// - children: parsed [{ url, type, ... }] of a container's members. +// - fetchResource(url): async, returns a child's primary node (for collections). document.head.insertAdjacentHTML('beforeend', ` +
+
+
+
Collection
+
Bookmarks ${items.length}
+
+ +
+
${items.map(card).join('')}
+ +
`; + } +};