Add public read-only note sharing with /n/<token> links - #26
Merged
Conversation
Share an open note via a revocable public link that always serves the note's latest saved markdown, plus a copy-raw-markdown tool on both the private editor and the public page. - models: NoteShare (one-per-note, unique token, delete-orphan); Note.to_dict exposes public_share_token - routes/notes: POST/DELETE /api/notes/<id>/share (idempotent, audited) - routes/pages: GET /n/<token> — public, no auth, server-rendered every request so it reflects the latest version; unknown/revoked token 404s - templates/public_note.html: read-only, preview-locked EasyMDE with a copy-raw-markdown toolbar tool - notes.js: Share/Copy-link/Stop-sharing buttons + copy-markdown tool - migrate_db: additive note_shares table + indexes - tests + docs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzQsU2rYQodWiDhyNFckz2
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements public read-only sharing for notes. Users can create a shareable link to any note that renders the latest markdown in a read-only EasyMDE preview. The share is revocable and tied to a single opaque token per note.
Key Changes
Database & Models
NoteSharemodel with one-to-one relationship toNote(unique token per note)Note.to_dict()to includepublic_share_tokenfieldAPI Routes (
/api/notes/<id>/share)POSTcreates or returns existing share token (idempotent)DELETErevokes the share (idempotent, 204 whether or not one existed)record_change()for audit trailPublic Page (
/n/<token>)pages.py(no auth required)UI Updates
Styling
.notes-toolbar-actionsflex container for grouped toolbar buttonsDatabase Migration
note_sharestable with indexes onnote_idandtokennote_idFKImplementation Details
secrets.token_urlsafe(16)(22-char URL-safe string)state.currentNoteto avoid refetch on button state changeshttps://claude.ai/code/session_01BzQsU2rYQodWiDhyNFckz2