From 728ba62a84e483e3b98948244e161ffe79ad9cf0 Mon Sep 17 00:00:00 2001 From: Josh Hadro Date: Wed, 11 Oct 2023 10:40:40 -0400 Subject: [PATCH] Put logic in the right place --- iiify/resolver.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/iiify/resolver.py b/iiify/resolver.py index aefad13..b6c08c0 100644 --- a/iiify/resolver.py +++ b/iiify/resolver.py @@ -387,6 +387,25 @@ def create_manifest3(identifier, domain=None, page=None): # id=f"https://iiif.archivelab.org/iiif/{identifier}${pageCount}/canvas", # label=f"{page['leafNum']}") pageCount += 1 + + + # 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 + + elif mediatype == 'image': singleImage(metadata, identifier, manifest, uri) elif mediatype == 'audio' or mediatype == 'etree': @@ -442,23 +461,6 @@ def create_manifest3(identifier, domain=None, page=None): c.add_item(ap) manifest.add_item(c) - # 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 - - elif mediatype == "movies": # sort the files into originals and derivatives, splitting the derivatives into buckets based on the original originals = []