E-books: a section for every poet (tabs, covers), right-to-left PDF reader, page bookmarks, book details #70

Merged
anas merged 1 commits from feature/ebooks-section into main 2026-10-09 13:17:32 +00:00
Owner

Owner requests (follow-up to #67).

Section

  • Every poet page has an ای بکس card beside their books and genres (غزل, نعت…), with its count, shown even when there are none yet.
  • /<poet>/ebooks has tabs پی ڈی ایف (PDF), ای پب (ePUB) and یونیکوڈ متن (Unicode), plus آرکائیو (archive.org) when there are such books, and a grid of cover thumbnails.

Covers (the server has no PDF tools, so the browser makes them)

  • PDF: the first page is rendered with pdf.js (Apache-2.0) in the moderator's browser while uploading.
  • EPUB: its own cover, read with epub.js.
  • archive.org: its thumbnail service.
  • Text: a styled card with the title.
  • The moderator can also choose their own image.
  • Existing books get سرورق بنائیں on their page.
  • API: POST /api/mod/ebooks/:id/cover (JPEG, PNG or WebP, up to 5 MB, e-books permission) and GET /api/ebook/:id/cover.

PDF reader, right to left (pdf.js)

  • Next page is to the left: the button, the ← key, or a click on the left half.
  • Facing pages on wide screens: the cover alone, then 2|3 with page 2 on the right. Phones show one page at a time.
  • Books marked LTR turn the other way.
  • Full screen (button or F), and open in a new tab.
  • The file route answers byte ranges (206/416), so a 16 MB scan loads only the pages shown.

Page bookmarks

  • صفحہ محفوظ کریں in the reader saves the page to the reader's library (kind page). The saved pages show as chips in the reader and as کتابوں کے محفوظ صفحات in نشانات; each opens at that page (?page=).
  • On a two-page spread it saves the first page of the pair.

Book details (upload and review, through the pipeline)

  • Writer's name as printed (prefilled with the poet).
  • Co-authors: picked from the site's poets with the Urdu name box (linked, and the book is also listed on their ای بکس), or new names (kept as text, marked نیا). Creating a full poet page for a new name waits for the poet editor (#32).
  • Language (اردو، فارسی، عربی، انگریزی، ہندی، پنجابی، سندھی، پشتو، دیگر) and reading direction (RTL/LTR, defaulting from the language; the reader follows it).
  • Extra tags: free ٹیگ, shown on tag pages.
  • Source, copyright and note, as before.

Also

  • The word lookup and selection menu now work only on reading text (poems and prose, intros, e-book text, search snippets, library couplets), not on menus, buttons or tabs (owner report).
  • Schema: the library kind check is defined once, with page. It was being re-added without it.

Tested

  • npm test: 42 pass. The e-books test now also covers:
    • the language and direction defaults and checks;
    • a co-author linked to /p266 and listed for him, with the new name as plain text;
    • tags;
    • cover upload (only images, the same bytes served);
    • byte ranges;
    • page bookmarks (save, unsave, library list, no bookmarks in a book under review).
  • Headless Chrome:
    • the card and tabs;
    • حدائقِ بخشش in the reader: opening on the cover, spread 2|3 with 2 on the right, ← to 4|5, only the bytes needed fetched;
    • a cover made from the first page and shown in the grid;
    • the upload form: writer prefilled, co-author chips (غالب linked, a new name), English with LTR, an automatic cover preview;
    • the review form shows every detail; the book page shows them; the reader is LTR;
    • a page bookmark appears in the library;
    • selecting header text does not open the word sidebar, while a poem word does.
  • The test book and its files were removed.

Local setup: apply db/schema.sql; run npm install in web for pdfjs-dist.

🤖 Generated with Claude Code

Owner requests (follow-up to #67). **Section** - Every poet page has an **ای بکس** card beside their books and genres (غزل, نعت…), with its count, shown even when there are none yet. - `/<poet>/ebooks` has tabs **پی ڈی ایف (PDF)**, **ای پب (ePUB)** and **یونیکوڈ متن (Unicode)**, plus **آرکائیو (archive.org)** when there are such books, and a **grid of cover thumbnails**. **Covers** (the server has no PDF tools, so the browser makes them) - PDF: the first page is rendered with **pdf.js** (Apache-2.0) in the moderator's browser while uploading. - EPUB: its own cover, read with epub.js. - archive.org: its thumbnail service. - Text: a styled card with the title. - The moderator can also choose their own image. - Existing books get **سرورق بنائیں** on their page. - API: `POST /api/mod/ebooks/:id/cover` (JPEG, PNG or WebP, up to 5 MB, e-books permission) and `GET /api/ebook/:id/cover`. **PDF reader, right to left** (pdf.js) - Next page is to the left: the button, the ← key, or a click on the left half. - Facing pages on wide screens: the cover alone, then 2|3 with page 2 on the right. Phones show one page at a time. - Books marked LTR turn the other way. - **Full screen** (button or F), and **open in a new tab**. - The file route answers **byte ranges** (206/416), so a 16 MB scan loads only the pages shown. **Page bookmarks** - **صفحہ محفوظ کریں** in the reader saves the page to the reader's library (kind `page`). The saved pages show as chips in the reader and as **کتابوں کے محفوظ صفحات** in نشانات; each opens at that page (`?page=`). - On a two-page spread it saves the first page of the pair. **Book details** (upload and review, through the pipeline) - Writer's name as printed (prefilled with the poet). - **Co-authors:** picked from the site's poets with the Urdu name box (linked, and the book is also listed on their ای بکس), or new names (kept as text, marked نیا). Creating a full poet page for a new name waits for the poet editor (#32). - **Language** (اردو، فارسی، عربی، انگریزی، ہندی، پنجابی، سندھی، پشتو، دیگر) and **reading direction** (RTL/LTR, defaulting from the language; the reader follows it). - **Extra tags:** free ٹیگ, shown on tag pages. - Source, copyright and note, as before. **Also** - The word lookup and selection menu now work only on reading text (poems and prose, intros, e-book text, search snippets, library couplets), not on menus, buttons or tabs (owner report). - Schema: the library kind check is defined once, with `page`. It was being re-added without it. **Tested** - `npm test`: 42 pass. The e-books test now also covers: - the language and direction defaults and checks; - a co-author linked to /p266 and listed for him, with the new name as plain text; - tags; - cover upload (only images, the same bytes served); - byte ranges; - page bookmarks (save, unsave, library list, no bookmarks in a book under review). - Headless Chrome: - the card and tabs; - حدائقِ بخشش in the reader: opening on the cover, spread 2|3 with 2 on the right, ← to 4|5, only the bytes needed fetched; - a cover made from the first page and shown in the grid; - the upload form: writer prefilled, co-author chips (غالب linked, a new name), English with LTR, an automatic cover preview; - the review form shows every detail; the book page shows them; the reader is LTR; - a page bookmark appears in the library; - selecting header text does not open the word sidebar, while a poem word does. - The test book and its files were removed. **Local setup:** apply `db/schema.sql`; run `npm install` in web for pdfjs-dist. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
anas added 1 commit 2026-10-09 13:16:30 +00:00
- ای بکس card beside the poet's books and genres on every poet page; /<poet>/ebooks with tabs
  پی ڈی ایف (PDF) / ای پب (ePUB) / یونیکوڈ متن (Unicode) (+ آرکائیو when present) and a grid of covers.
- Covers: made in the moderator's browser from a PDF's first page (pdf.js) or an EPUB's cover (epub.js); archive.org's
  thumbnail; a styled card for text; or the moderator's own image. سرورق بنائیں on existing books.
- PDF reader (pdf.js) reading right to left: next page to the left (button, ← key, left half), facing pages with the
  cover alone then 2|3; left to right for LTR books; full screen (F); opens in a new tab; byte-range requests.
- Page bookmarks in the reader's library (kind 'page'), listed in نشانات and opening at that page.
- Details: writer as printed, co-authors (linked to poets on the site, who list the book too; new names kept as text),
  language, reading direction (RTL/LTR), extra tags (on tag pages), source, copyright, note; in upload and review.
- Word lookup and selection menu only on reading text, not menus, buttons or tabs.
- Schema: the library kind check lists 'page' where it is defined (it was re-added without it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anas merged commit 3f6f7e503a into main 2026-10-09 13:17:32 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: anas/divan#70
No description provided.