Skip to content
This repository was archived by the owner on Nov 15, 2026. It is now read-only.

feat: save a page from the phone with a bookmarklet - #10

Merged
bketelsen merged 1 commit into
mainfrom
feat/save-bookmarklet
Oct 21, 2026
Merged

bketelsen merged 1 commit into
mainfrom
feat/save-bookmarklet

Conversation

@bketelsen

@bketelsen bketelsen commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Save a page to Read later from the phone with a bookmarklet (Brian's choice, 2026-10-21). This is night-shift goal 2 of 3, from Odrade.

How it works

  1. The bookmarklet sends the tab to https://LODGE/read/save?url=…&title=…. lodge's browser checks accept a top-level navigation to a shell page from any site. The shell opens Read's frame at that route, with the query string kept.
  2. The save page shows the page's title, host and address as text. It saves only when you tap Save, because any site can open this route.
  3. Save calls later.save on the app's own lodge session. The daemon still checks the URL with fetch.Check (netguard, ADR-0003), so javascript:, file:, loopback, private, tailnet (*.ts.net) and homelab (*.local, single-label) addresses are refused.
  4. After a save, the page shows Saved with Open in Read and Read later. Your browser's Back button returns you to the page.

There is no token in the bookmarklet, and the visited page never calls lodge. The code is built from the frame's own origin, so no host is written into the bundle.

Changes

  • API: later.save takes an optional title. The daemon removes control characters, collapses white space, and cuts it to 300 runes. An empty title becomes the host name, as before. MCP save_url and readctl save pass no title.
  • Web:
    • the /save page;
    • the /bookmarklet page ("Save from your phone", linked from the sidebar), with the link to drag, the code with a Copy button, the install steps for iOS Safari, and the desktop steps;
    • a save route over 2,048 characters is not reported to the shell (MAX_ROUTE).
  • ADR-0006 (Proposed): save from another page through a confirm page that a bookmarklet opens. It also covers the alternatives: an iOS Shortcut, a share target, a fetch from the page, a save with no confirm, a pop-up.
  • Docs:
    • specs/api.md: the title param, and a new Web routes section with the exact bookmarklet code;
    • design/overview.md;
    • roadmap Phase 7;
    • docs/README.md and README.md.
  • Schema: api/read.go names schema/rpc/read.yaml, but that file did not exist. It is now written for the read domain, with later.save's title.

Tests

  • Engine:
    • the refusal of 127.0.0.1, 192.0.2.1, [::1], lodge.example.ts.net, nas.local, router and javascript:, with nothing stored;
    • a table test for title cleaning;
    • the host-name fallback;
    • saving the same URL twice keeps the first title.
  • Store: a saved title survives an extraction that finds no title.
  • readapi: the API keeps the title.
  • Web (Vitest):
    • the routes, and a round trip of a save path;
    • the bookmarklet code and the URL it builds;
    • the save page (a title with <b> stays text, nothing is saved before the tap, and errors show in role="alert");
    • the bookmarklet page;
    • the store.

Gates on a laptop: make check, make race, make web-fmt and make web-check (16 files, 84 tests) all pass. I also checked both pages on a 390 px viewport in vite dev with the mock transport. I ran the generated bookmarklet in Chromium: it built /read/save?url=…&title=…, and that address opened the save page and saved the item.

Deploy (after Brian merges)

These are the same steps as the #9 redeploy: ssh to the host, then incus exec into the hub VM as root.

On a laptop, from main at the merged commit:

make web-build                                     # nsl
make lodge-package LODGE_DESTDIR=build/deploy-root
tar -C build/deploy-root -czf frostread-<sha>.tar.gz .

In the VM, make a rollback archive first, then install:

tar -czf /root/frostread-rollback-9c98f90-$(date +%Y%m%d).tar.gz \
  /usr/share/lodge/apps/read /usr/local/bin/readd /usr/local/bin/readctl
rm -rf /usr/share/lodge/apps/read
tar -C / --no-same-owner -xzf /root/frostread-<sha>.tar.gz
chmod 0644 /usr/share/lodge/apps/read/app.json
systemctl daemon-reload
systemctl restart frostread.service
/opt/lodge/bin/lodgectl reload

To roll back:

rm -rf /usr/share/lodge/apps/read
tar -C / -xzf /root/frostread-rollback-9c98f90-<date>.tar.gz
systemctl restart frostread.service
/opt/lodge/bin/lodgectl reload

There is no schema migration, so the database needs no rollback.

Live check

  1. In lodge, open Read and choose Save from your phone in the sidebar.
  2. Open https://LODGE/read/save?url=https%3A%2F%2Fexample.com%2F&title=Example. Check that the page shows "Example" and example.com, then tap Save. It must show Saved, and the item must be in Read later.
  3. Open https://LODGE/read/save?url=http%3A%2F%2Fnas.local%2F. Tap Save. It must show "Read does not fetch addresses inside your network …" and save nothing.
  4. On the iPhone: install the bookmarklet with the page's steps, open any public page, and tap the bookmark. This is the Phase 7 Done when.

The bookmarklet navigates the tab to /read/save?url=&title=. The save page
shows the page as text and saves only on the owner's tap, through
later.save on the app's own lodge session. later.save takes an optional
title, cleaned and cut to 300 runes; the URL is still checked with
fetch.Check (ADR-0003). /bookmarklet hands out the code and the install
steps for iOS Safari. ADR-0006 is Proposed. schema/rpc/read.yaml, which
api/read.go names, is written for the read domain.
@bketelsen
bketelsen merged commit e0fca2e into main Oct 21, 2026
3 checks passed
@frostyard-machines
frostyard-machines deleted the feat/save-bookmarklet branch October 26, 2026 00:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant