Add format-aware monograph reader selection and dual-format indexing#3991
Draft
Copilot wants to merge 3 commits into
Draft
Add format-aware monograph reader selection and dual-format indexing#3991Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
[WIP] Add choose format dropdown for EPUB and PDF
Add format-aware monograph reader selection and dual-format indexing
May 31, 2026
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.
Monographs with both public EPUB and PDF featured representatives always resolved to EPUB, with no user-facing way to select format. This change adds a format-selection flow (
reader_format) to reader/ToC behavior and updates indexing to include accessibility metadata and ToCs from both ebook formats.Reader format selection + visibility gating
reader_ebook_id_for_format(format_param)while preserving existingreader_ebook_idEPUB-preferred behavior.both_ebook_formats_public?to detect when EPUB+PDF reps both exist and are publicly visible.@reader_format(epub|pdfonly) inMonographCatalogController.reader_links_displayvisibility checks to evaluate the selected ebook format, not implicit EPUB.Catalog UI updates
reader_formaton the monograph catalog URL.princess_de_clevesrouting behavior.monograph_catalog.index.choose_formatlocale string.ToC format-awareness
_index_epub_tocto select EPUB/PDF presenter based on@reader_format.Indexer: include both formats
maybe_index_accessibility_metadatanow indexes both EPUB and PDF metadata when present and writes multivaluedreader_ebook_format_sim.table_of_contentsnow aggregates titles from both EPUB and PDF ToCs and de-duplicates fortable_of_contents_tesim.Spec updates
reader_ebook_id_for_formatandboth_ebook_formats_public?.reader_formatsanitization and format-aware reader visibility behavior.Original prompt
Overview
When a Monograph has both an EPUB and a PDF
FeaturedRepresentative(each with a public FileSet), users should be able to choose which format to read. Currently the system always silently prefers the EPUB. This PR introduces:?reader_format=pdfURL parameter — selecting PDF from the dropdown appends this param to the reader URL, and all presenter / ToC logic respects it.MonographIndexer#maybe_index_accessibility_metadata.MonographIndexer#table_of_contents(thetable_of_contents_tesimfield is multivalued and is only used for Monograph discovery at the Press level).Detailed Changes
1. New presenter method:
both_ebook_formats_public?Add to
app/presenters/concerns/featured_representatives/monograph_presenter.rb:2. Update
reader_ebook_idto respect?reader_format=pdfThe presenter currently has no knowledge of the request. Pass the optional format preference into
reader_ebook_id(or add a separatepreferred_reader_ebook_id(format: nil)helper). The cleanest approach that avoids threadingrequestthrough the presenter is to add a new method and keep the original for backwards compatibility:3. Thread
reader_formatparam throughMonographCatalogControllerIn
monograph_auth_for(andreader_links_display), expose@reader_format = params[:reader_format]and set it on the instance. Pass it to view helpers where needed.Update
reader_links_displayto usereader_ebook_id_for_format(@reader_format)when checking visibility:4. Update
_read_download_buy.html.erb— add "Choose Format" dropdownInsert the new dropdown before the Read Book button (i.e. it appears to the left of it). Show it only when
@monograph_presenter.both_ebook_formats_public?and the reader is shown (not tombstoned, noteepress, etc.).5. Update the Read Book button href to carry
reader_formatthrough to the readerThe Read Book button currently links directly to
epub_path(@monograph_presenter.reader_ebook). When `@reader_format ==...This pull request was created from Copilot chat.