Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pageorder #31

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions iiify/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add comment saying that it won't be set if the book reader brOptions has something other than mode/1up

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test to see if pageProgression key exists in brOptions or try catch Key not found error.

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':
Expand Down
18 changes: 18 additions & 0 deletions tests/test_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ def test_provider_logo(self):
self.assertEqual(manifest['provider'][0]['homepage'][0]['id'] == "https://archive.org", True, f"Expected 'https://archive.org' but got {manifest['provider'][0]['id']}")
self.assertEqual(manifest['provider'][0]['logo'][0]['id'] == "https://archive.org/images/glogo.png", True, f"Expected logo URI but got {manifest['provider'][0]['logo'][0]['id']}")

def test_page_behavior(self):
resp = self.test_app.get("/iiif/3/rbmsbk_ap2-v4_2001_V55N4/manifest.json")
self.assertEqual(resp.status_code, 200)
manifest = resp.json
self.assertEqual(len(manifest['items']),116,f"Expected 116 canvas but got: {len(manifest['items'])}")
self.assertEqual(manifest['viewingDirection'],"left-to-right",f"Expected 'left-to-right' canvas but got: {manifest['viewingDirection']}")
self.assertEqual(manifest['behavior'][0],"paged",f"Expected 'paged' but got: {manifest['behavior'][0]}")

def test_page_behavior_r_to_l(self):
resp = self.test_app.get("/iiif/3/nybc314063/manifest.json")
self.assertEqual(resp.status_code, 200)
manifest = resp.json
self.assertEqual(len(manifest['items']),544,f"Expected 544 canvas but got: {len(manifest['items'])}")
self.assertEqual(manifest['viewingDirection'],"right-to-left",f"Expected 'right-to-left' canvas but got: {manifest['viewingDirection']}")
self.assertEqual(manifest['behavior'][0],"paged",f"Expected 'paged' but got: {manifest['behavior'][0]}")



''' to test:
kaled_jalil (no derivatives)
Dokku_obrash (geo-restricted?)
Expand Down
Loading