Reading lists / bookmarks for readers - #249
Merged
Merged
Conversation
Readers bookmark posts from post cards and post pages and view them at /reading-list. Anonymous readers' lists live in localStorage; signed-in readers (subscribers and staff, keyed on Identity) are stored in the new reading_list_items table, and a device's list is merged into the account the first time the reader loads a page signed in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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 free
to 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
Readers can bookmark posts (icon on every post card and on the post page) and see them at
/reading-list, linked from a new bookmark icon in the masthead. Readers without an account keep their list inlocalStorage. Signed-in readers' lists are stored in the database. The first time someone loads a page signed in, any posts saved on that device are merged into their account, so the list follows them across devices.Changes
ReadingListItem(identity ↔ post, unique per pair, capped at 500 per identity) +Identity::ReadingListable(bookmark!,unbookmark!,reading_list_posts,reading_list_post_ids,import_reading_list!). Only live posts are ever listed.GET /reading-list(page),GET /reading-list/posts?ids=(cards for alocalStoragelist, rendered into a turbo frame),POST/DELETE /reading-list/itemsandPOST /reading-list/import(JSON, for signed-in readers; they return401JSON when signed out).lib/reading_list.jsholds the list state for the whole page.bookmark_controllerhandles one button.reading_list_controllerloads a signed-out reader's saved posts onto the page.posts/_postandposts/show; masthead icon group (.masthead__actions); new BEM components_bookmark-btn.cssand_reading-list.css; en + es strings;reading-listadded to reserved page slugs.Design notes / assumptions
identity_id, notsubscriber_idas the issue suggested. This matchesLoveandComment, and it means staff users signed into the public site get a reading list too.hiddenand identical for everyone, and JS fills in whether it's saved. A test checks that a cached card never carries one reader's saved state to another.<meta>tag on every page. When a reader hits Back, Turbo restores an old copy of the page head, which can be from before their last save. The meta is only read again when itsdata-keychanges, i.e. on sign-in or sign-out.Out of scope
Documentation
Testing
/signed out, click a bookmark icon, open the masthead bookmark → the post is listed. Sign in as a subscriber via magic link → the post is still saved and is now inreading_list_items.bin/rails test(1456 runs) andbin/rails test:system(31 runs) passCloses #41
🤖 Generated with Claude Code