No description
  • HTML 95.5%
  • JavaScript 4.5%
Find a file
2026-10-27 16:10:53 +01:00
bookmarks.json update 2026-10-27 16:10:53 +01:00
bookmarks.json.bak update 2026-10-27 16:10:53 +01:00
CLAUDE.md added claude files 2026-10-01 08:20:27 +02:00
embed.js editmode 2026-09-30 17:12:07 +02:00
index.html update 2026-10-27 16:10:53 +01:00
README.md added claude files 2026-10-01 08:20:27 +02:00
server.js editmode 2026-09-30 17:12:07 +02:00
server.log update 2026-10-01 11:05:49 +02:00

Bookmarks dashboard — project notes

A self-hosted bookmarks / services page for the homelab: one page (index.html) backed by one data file (bookmarks.json), with an optional local server for editing. No framework, no build step, no external dependencies beyond Bootstrap (loaded from a CDN) and Node's own built-ins.

Files

File What it is
index.html The page itself. All CSS and JS live inline on purpose, so the file can be moved around on its own.
bookmarks.json The data — the single source of truth for every bookmark/service.
server.js Optional local server (Node, no dependencies). Serves the page and also exposes a save endpoint, which is what makes editing possible.
embed.js Bakes the current bookmarks.json into index.html as a read-only fallback snapshot, for browsers that block file:// fetches. Run automatically by server.js after every save.
docs/ This folder — project notes and a copy of Claude's memory about it.

Running it, three ways

  1. Double-click index.html (file://). Works in every browser. What it shows depends on the browser: Firefox fetches bookmarks.json directly (read-only, always current); every other browser (Chrome, Edge, Safari, ...) blocks that outright, so it falls back to the snapshot baked into the file by embed.js — read-only, and only as fresh as the last save made through server.js.
  2. Any static file server, e.g. python -m http.server 8000 then open http://localhost:8000/. Same as Firefox above, but in any browser: read-only, always current (reads bookmarks.json fresh on every load).
  3. node server.js, then open http://localhost:8000/. The only way to edit. Serves the same files, plus a save endpoint. The edit controls (pencil icons, "New service", ...) only appear once that server answers — there is no local cache to fall back on.

Architecture

Loading (load() in index.html)

Three tiers, tried in order, each one the fallback for the one before it:

  1. GET /api/bookmarks — only answers if server.js is running. Reads bookmarks.json straight off disk on every request. This is the only tier where edits can be saved.
  2. GET bookmarks.json (fetched directly) — works from any other static server, and from file:// in Firefox specifically. Read-only, but always current.
  3. EMBEDDED_SNAPSHOT — a copy of the data baked directly into index.html's own JS. The only tier that works when file:// is blocked outright (Chrome, Edge, Safari, ...). Read-only, and only as fresh as the last save made through server.js (or the last manual node embed.js).

The page shows which tier it's in via the dots menu: edit controls are hidden entirely outside tier 1, and a note explains why ("Read-only — run node server.js here to edit", or "Read-only snapshot from <time>" for tier 3).

Saving (persist() in index.html → server.js)

Every edit (add, edit, delete, bulk actions) goes through the same path:

  1. The page POSTs the full {meta, bookmarks} object to /api/bookmarks.
  2. server.js validates it, backs up whatever was in bookmarks.json before overwriting it (bookmarks.json.bak), then writes the new content atomically (write to a temp file, then rename).
  3. server.js then re-runs embed.js, so the file:// fallback snapshot in index.html stays in step with what was just saved. A failure at this step is only logged — it never blocks the actual save, since the real data (bookmarks.json) is already safely written by that point.

There is no localStorage involved anywhere in this flow (an earlier version cached edits there; that's been removed — bookmarks.json is the only place data lives).

Known limitations

  • No concurrency control. This is built for single-user, one-tab-at-a- time use. If two tabs/devices save at the same time, the last one to save wins and silently overwrites the other's changes.
  • The file:// snapshot can go stale. If bookmarks.json is edited by hand (outside the app) without a subsequent save through server.js, the baked-in snapshot won't reflect that change until the next save, or until node embed.js is run by hand.

Change history (high level)

  1. Original page — index.html + bookmarks.json, read-only, loaded via fetch(), with a small hardcoded demo set as a fallback for when the fetch failed.
  2. Edits via the UI were added at some point, but persisted only to the browser's localStorage — meaning bookmarks.json on disk was never actually updated, and different browsers/devices saw different data.
  3. Phase 2 — removed localStorage entirely; added server.js, a dependency-free local Node server with a save endpoint, so edits write straight back to bookmarks.json. This is the only way to edit.
  4. Phase 3 — added embed.js and the EMBEDDED_SNAPSHOT tier, so that opening index.html directly (file://) shows real data instead of the old 4-item demo set, in every browser — not just Firefox.