manifold
manifold copied to clipboard
Bookmarking and storing last read position in texts
This is going to be tricky. Here's my initial thinking on this, which could change.
-
Let's make a bookmark record. Bookmarks belong_to a text_section and they belong to a user. Bookmarks delegate text to the text_section. = Bookmarks have a boolean "automatic" property that we can use to distinguish between user generated bookmarks and bookmarks created automatically to save the user's place. There can only be one automatic bookmark per text, and it is used to record the last reading position in the text. Bookmarks have a node_uuid property that references the text node that was bookmarked. Let's also store the contents of the bookmarked text node.
-
Expose bookmarks via a CRUD mechanism. Nest these under the "me/relationships" since bookmarks will always be created
-
Use a route exit transition (we use this to check when users are leaving an unsaved form) to automatically create a new bookmark in the API when the user leaves a text. Remember, only one auto-generated bookmark per text.
-
When a user comes to a text, check and see if there's an autogenerated bookmark for the text. If so, prompt the user with a modal that asks them if they'd like to go to the last read point. We might show a snippet in that modal showing them where they were last, or at least the section title.
This is still a rough concept, so I expect some refinement as it's developed. If you have suggestions on how we can improve this, speak up.
Re: 1, rather than a boolean, it may be desirable to express it as an enum kind
. automatic
, user
. It would be easier to add to if we end up expanding this feature (e.g. being able to create recommended
bookmarks, a user recommending a bookmark to another if they want to share right through the system)
Regarding the automatic place-saving bookmarks, it would still be possible to make an efficient unique index to enforce:
add_index :bookmarks, %i[text_section_id user_id], unique: true, where: %["kind" = 'automatic'], name: :udx_bookmarks_enforce_automatic_uniqueness
Yep, enum sounds like a better approach. Thanks!
Seeing this reminded me that in the realm of bookmarks, I could see something like a progress bar in the reader as a useful thing. Many of my students balk if they don't know how long an assignment is. Some means of visualizing the length (and therefore gauging the reading commitment) might be a nice feature.