diff --git a/diigo-cache/package.json b/diigo-cache/package.json index fa69e9a..340400b 100644 --- a/diigo-cache/package.json +++ b/diigo-cache/package.json @@ -11,6 +11,7 @@ "devDependencies": { "@cloudflare/vitest-plugin": "1.3.6", "@types/node": "^22", + "microformats-parser": "^2.0.6", "typescript": "^5.9.0", "vitest": "4.1.11", "wrangler": "^4.148.0" diff --git a/diigo-cache/pnpm-lock.yaml b/diigo-cache/pnpm-lock.yaml index f11d5a6..020b31b 100644 --- a/diigo-cache/pnpm-lock.yaml +++ b/diigo-cache/pnpm-lock.yaml @@ -18,6 +18,9 @@ importers: '@types/node': specifier: ^22 version: 22.20.5 + microformats-parser: + specifier: ^2.0.6 + version: 2.0.6 typescript: specifier: ^5.9.0 version: 5.9.3 @@ -613,6 +616,10 @@ packages: resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} engines: {node: '>=8'} + entities@6.0.1: + resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==} + engines: {node: '>=0.12'} + error-stack-parser-es@1.0.5: resolution: {integrity: sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==} @@ -722,6 +729,10 @@ packages: magic-string@0.30.21: resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + microformats-parser@2.0.6: + resolution: {integrity: sha512-VTnLImF17yd+ZfBH40sddHMJp5Rrker4ge+oPjgnBQ3jluQO0YmsNVA4UcEfHRBV8zrikBSMkAzAub+nTRX85g==} + engines: {node: '>=18'} + miniflare@5.20261001.0-alpha: resolution: {integrity: sha512-GaimS5mSIOMyvd16ga+e1/QkI8cmp3z35QPHFex0DktqNQf2RVZQwMPQXdyoUreUiFP/0Gpe2MoQInTyMAD5xA==} engines: {node: '>=22.0.0'} @@ -739,6 +750,9 @@ packages: resolution: {integrity: sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==} engines: {node: '>=12.20.0'} + parse5@7.3.0: + resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==} + path-to-regexp@6.3.0: resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} @@ -1366,6 +1380,8 @@ snapshots: detect-libc@2.1.2: {} + entities@6.0.1: {} + error-stack-parser-es@1.0.5: {} es-module-lexer@2.3.2: {} @@ -1467,6 +1483,10 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.6.0 + microformats-parser@2.0.6: + dependencies: + parse5: 7.3.0 + miniflare@5.20261001.0-alpha(@types/node@22.20.5): dependencies: '@cspotcode/source-map-support': 0.8.1 @@ -1497,6 +1517,10 @@ snapshots: obug@2.2.1: {} + parse5@7.3.0: + dependencies: + entities: 6.0.1 + path-to-regexp@6.3.0: {} pathe@2.0.3: {} diff --git a/diigo-cache/src/index.ts b/diigo-cache/src/index.ts index febd4cc..7c01c0b 100644 --- a/diigo-cache/src/index.ts +++ b/diigo-cache/src/index.ts @@ -515,8 +515,8 @@ async function publicPage(request: Request, env: Env, username: string): Promise notice = `
no page ${esc(String(raw))}: pages run 1–${pages}
`; } const nav = (n: number, label: string) => - n >= 1 && n <= pages ? `${label}` : `${label}`; - const list = notice ? "" : itemList(items, "updated"); + n >= 1 && n <= pages ? `${label}` : `${label}`; + const list = notice ? "" : itemList(items, "updated", here); const body = publicFrame( username, `${pages} page${pages === 1 ? "" : "s"} (diigo's, ${PUBLIC_PER_PAGE} bookmarks each; private ones are left out, so a page may show fewer).
@@ -555,7 +555,7 @@ function filteredPage( const kept = [...params].filter(([k, v]) => k !== "page" && v !== ""); const href = (n: number) => `${here}?${new URLSearchParams([...kept, ["page", String(n)]])}`; const nav = (n: number, label: string) => - n >= 1 && n <= pages ? `${label}` : `${label}`; + n >= 1 && n <= pages ? `${label}` : `${label}`; const status = found.matched ? `${found.matched} match${found.matched === 1 ? "" : "es"}, page ${pageN} of ${pages}, newest ${query.by} first` : "no matches"; @@ -566,7 +566,7 @@ function filteredPage( ${fill ? fillLine(fill) : ""} ${filterForm(here, params)}${nav(pageN - 1, "← prev")} ${nav(pageN + 1, "next →")} all, by diigo page
-${itemList(items, query.by)}`, +${itemList(items, query.by, here)}`, ); return new Response(body, { headers: { "content-type": "text/html;charset=utf-8" } }); } @@ -602,19 +602,39 @@ words, "phrases", #tags, -negation, and after:, before:, newer_than:7d, during:2 `; } -/** bookmarks as a list, each led by its `by` date */ -function itemList(items: Item[], by: Query["by"]): string { - return `