internetarchive / iiif

The official Internet Archive IIIF service
GNU General Public License v3.0
22 stars 4 forks source link

Integrate paging direction, when known #9

Closed hadro closed 1 year ago

hadro commented 1 year ago

Some items have paging direction in the IA metadata, including when they should be R-L instead of L-R which is the default for many viewers. An example: https://archive.org/details/Maslak-ul-akhyar-PersianManuscript/ https://archive.org/metadata/Maslak-ul-akhyar-PersianManuscript/

the metadata contains the following we can use: page-progression: "rl"

glenrobson commented 1 year ago

Maybe a larger a question on behaviours for IIIF. IIIF defaults to individuals if we can tell if its a paged item we can add that.

digitaldogsbody commented 1 year ago

BookReadJSIA has some fields that might be of interest: https://ia800901.us.archive.org/BookReader/BookReaderJSIA.php?id=rashodgson68&itemPath=/19/items/rashodgson68&server=ia800901.us.archive.org&format=jsonp&subPrefix=rashodgson68

glenrobson commented 1 year ago

Potentially:

"defaults":"mode\/1up"
digitaldogsbody commented 1 year ago

E.g the leaves have pageSide and pageType

[{"width":7379,"height":1699,"uri":"https:\/\/ia800901.us.archive.org\/BookReader\/BookReaderImages.php?zip=\/19\/items\/rashodgson68\/rashodgson68_jp2.zip&file=rashodgson68_jp2\/rashodgson68_0002.jp2&id=rashodgson68","leafNum":2,"pageType":"Cover","pageSide":"R"}]

glenrobson commented 1 year ago

Discussed in meeting on the 28th of Sept and decided it would be good to default to paged for text items as all of these will be from the book reader which defaults to paged behaviour.

Book reader has the text direction and @hadro will add this field to the ticket.

@digitaldogsbody can we integrate this into the fixes branch?

hadro commented 1 year ago

Here's some attempts at code for setting these behaviors correctly that would go after the canvas generation code for the if mediatype == 'texts': section:

            # Setting logic for paging behavior and starting canvases
            # Start with paged (default) or individual behaviors
            try:
                if bookreader['data']['brOptions']['defaults'] == "mode/1up":
                    manifest.behavior = "individuals"
            except:
                manifest.behavior = "paged"

            # Then set left-to-right or right-to-left if present
            if bookreader['data']['brOptions']['pageProgression'] == "lr":
                viewingDirection = "left-to-right"
            elif bookreader['data']['brOptions']['pageProgression'] == "rl":
                viewingDirection = "right-to-left"
            if viewingDirection:
                manifest.viewingDirection = viewingDirection

The logic for setting an arbitrary start canvas is a little beyond what I can do at a quick take on this, but that's probably less of a concern for us (maybe not even a concern for us at all?) given that I think the IIIF canvas order maps explicitly to whatever is coming from the IA book reader.