Skip to content

Continue Reading Phase 3: My Books Landing Page Carousel - #13283

Draft
Sadashii wants to merge 6 commits into
internetarchive:masterfrom
Sadashii:13274/feature/continue-reading-carousel
Draft

Continue Reading Phase 3: My Books Landing Page Carousel#13283
Sadashii wants to merge 6 commits into
internetarchive:masterfrom
Sadashii:13274/feature/continue-reading-carousel

Conversation

@Sadashii

@Sadashii Sadashii commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Closes #13274

Feature: Implement client-side "Continue Reading" carousel on the My Books landing page (/account/books/) backed by localStorage.ol_read_history.

Note

This is a Draft PR stacked on top of PR #13282 (13273/feature/client-side-read-tracking).

Technical

  • Template (openlibrary/templates/account/mybooks.html): Added #continue-reading-container section (initially hidden) beneath the My Loans section for owners_page.
  • Client-Side Module (openlibrary/plugins/openlibrary/js/my-books/continueReading.js):
    • Implements initContinueReading() to query localStorage.ol_read_history via store/readingHistory.getHistory().
    • Unhides #continue-reading-container if local reading history exists.
    • Dynamically builds standard carousel cards for each history entry, setting work link, cover thumbnail (cover ID or OLID), title, author byline, and Read button CTA.
  • My Books Initialization (openlibrary/plugins/openlibrary/js/my-books/index.js): Invokes initContinueReading() inside initMyBooksAffordances().
  • Unit Tests (tests/unit/js/continueReading.test.js): Added Jest unit test suite covering DOM initialization, empty history guard, card rendering, and HTML escaping.

Testing

  • Ran Jest unit test suite:

    npx jest tests/unit/js/continueReading.test.js

    (4/4 tests passing)

  • Manual Verification Steps:

    1. Open any book page and click "Read" or "Borrow".
    2. Navigate to /account/books/.
    3. Verify the "Continue Reading" carousel appears displaying the previously clicked book(s).

Screenshot

N/A — Client-side progressive enhancement carousel on My Books landing page.

Stakeholders

@Sadashii @mekarpeles

Sadashii and others added 6 commits August 9, 2026 22:09
Merge active user loans with past loan history into a unified carousel on the My Books landing page.

Previously, the My Loans carousel only displayed active loans retrieved from get_loans_of_user(). Patrons with returned books would see an empty or sparse carousel despite having borrowing history.

Key changes:
- Extracted get_loan_history_data() from account.py into core/lending.py for reuse across endpoints and template handlers.
- Updated My Books landing page logic in mybooks.py to perform a two-pass merge: active loans first (following up to 5 redirect hops), followed by historical loans deduplicated by work key.
- Preserved active loan status overlay badges (FormatExpiry macro, waitlist count, ADE notices) and return form buttons (with explicit aria-label) for active bookreader loans.
- Consolidated badge and action-row styles into components/carousel.css using Open Library design tokens (soft-green, red-two, button-hover-blue) and z-index variables.
- Sorted merged entries with active loans prioritized, followed by loan timestamp descending, preserving total_results count and capping carousel display at 18 books.
- Added comprehensive unit and integration test coverage for the merged loans carousel.

Closes internetarchive#13272
Implement a lightweight, self-contained localStorage-backed reading tracker
in the Open Library frontend.

Key changes:
- readingHistory.js: new store module implementing addEntry (upserts by OLID,
  promotes to front on re-read, caps at 20 entries), getHistory (sorted by
  timestamp descending), and clearHistory. No PII stored, only public book metadata.
- ReadButton.html & LoanStatus.html: thread work/cover/author metadata down
  and attach data-ol-action and data-ol-book JSON attributes to Read/Borrow links.
- index.js: register global delegated click listener targeting Read/Borrow links,
  dynamically importing readingHistory.js on first qualifying click.
- readingHistory.test.js: 16 Jest unit tests covering store operations,
  deduplication, promotion, capping, field coercion, sorting, clearing, and
  corrupt storage recovery.

Closes internetarchive#13273
Merge active user loans with past loan history into a unified carousel on the My Books landing page.

Previously, the My Loans carousel only displayed active loans retrieved from get_loans_of_user(). Patrons with returned books would see an empty or sparse carousel despite having borrowing history.

Key changes:
- Extracted get_loan_history_data() from account.py into core/lending.py for reuse across endpoints and template handlers.
- Updated My Books landing page logic in mybooks.py to perform a two-pass merge: active loans first (following up to 5 redirect hops), followed by historical loans deduplicated by work key.
- Preserved active loan status overlay badges (FormatExpiry macro, waitlist count, ADE notices) and return form buttons (with explicit aria-label) for active bookreader loans.
- Consolidated badge and action-row styles into components/carousel.css using Open Library design tokens (soft-green, red-two, button-hover-blue) and z-index variables.
- Sorted merged entries with active loans prioritized, followed by loan timestamp descending, preserving total_results count and capping carousel display at 18 books.
- Added comprehensive unit and integration test coverage for the merged loans carousel.

Closes internetarchive#13272
Implement the Phase 3 Continue Reading carousel component on the My Books
landing page (/account/books/).

Key changes:
- continueReading.js: client-side module that reads localStorage.ol_read_history
  via store/readingHistory.getHistory() and dynamically renders carousel card
  elements for stored books, setting title, cover thumbnail, work link, and Read CTA.
- mybooks.html: add #continue-reading-container section (initially hidden) under
  owners_page block on the My Books landing page.
- my-books/index.js: invoke initContinueReading() within initMyBooksAffordances().
- continueReading.test.js: unit test suite covering DOM initialization,
  empty history guard, card rendering, and HTML escaping.
@Sadashii
Sadashii force-pushed the 13274/feature/continue-reading-carousel branch from 7cf6711 to 72253cb Compare August 9, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Continue Reading" Phase 3: Merge Local Storage Read History into Carousel

1 participant