internetarchive / bookreader

The Internet Archive BookReader
https://openlibrary.org/dev/docs/bookreader
GNU Affero General Public License v3.0
996 stars 418 forks source link

iiif plugin, last image of an even number of pages is lost #1350

Closed glorieux-f closed 1 month ago

glorieux-f commented 1 month ago

Description

With https://github.com/internetarchive/bookreader/blob/master/BookReaderDemo/demo-iiif.html a 2 image manifest shows only the first one https://glorieux-f.github.io/iiif_tests/bookreader_issue_even-pages.json

Evidence / Screenshot (if possible)

Only one image shown in BookReader, impossible to go to the last one. image

Same manifest in Mirador image

Expectation

See the last and second image. image

Context

All.

Proposal & Constraints

Push last page if any.

https://github.com/internetarchive/bookreader/blob/a9c279c66b9eb0d394304dd3fa88aaef88bdfaa9/src/plugins/plugin.iiif.js#L75 https://github.com/internetarchive/bookreader/blob/a9c279c66b9eb0d394304dd3fa88aaef88bdfaa9/src/plugins/plugin.iiif.js#L115

Stakeholders

???

glorieux-f commented 1 month ago

Drini Cami, thanks for your fast reaction, even if your services are down right now. Feel free to ask me for more obedience to your coding standarts. We like (love?) your viewer for iiif books, we need some more features (iiif chapters). I will make it work for us, I will make my best to make it work for all.

cdrini commented 1 month ago

Thank you for helping improve bookreader! I'm glad you like it 😊

And please, issue/pr welcome for adding iiif table of contents support. You should just have to update the same file to specify the table_of_contents option with the expected fields (see https://github.com/internetarchive/bookreader/blob/0198d87898fcc6d7a06cad9f29f7216ee50dabf6/src/BookReader/options.js#L184 )

Edit: and add the chapters plugin script to the iiif demo if it's not already there!

glorieux-f commented 1 month ago

Yes, I seen it, but I need to see working examples when archive.org will be back. Here is our working site for proofreading of the complete works of “Piaget” (a Swiss psychologist). I’m not sure we are full OK on rights, but we should be one day. https://oeuvres.unige.ch/piaget/iiif/

cdrini commented 1 month ago

Oh very cool! Oh here's a rough example that should work:

table_of_contents: [
    {"level": 1, "label": "Chapter 1", "title": "Through the Looking Glass", "pagenum": "13"},
    {"level": 1, "label": "Chapter 2", "title": "There and Back again", "pagenum": "18"},
    ...
]

And add the chapter plugin script to your html. Note that this will look up and try to find the page with the given pagenum. If you want to make it explicit, and an pageIndex parameter to each table of contents entry with the exact index of the page. EDIT: Our code appears to ignore the specified pageIndex! It always overrides it. If you want to use that flow, create an issue; it seems like a simple fix.

See the type definity for TocEntry:

https://github.com/internetarchive/bookreader/blob/0198d87898fcc6d7a06cad9f29f7216ee50dabf6/src/plugins/plugin.chapters.js#L84-L100

Thanks for your patience while we work to bring archive.org back up!