Skip to content

Commit

Permalink
Add version number to v2 manifest requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markpbaggett committed Feb 20, 2025
1 parent aa76cfb commit 992c8f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion iiify/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def manifest2(identifier):
identifier, page = identifier.split('$')
page = int(page)
try:
return ldjsonify(create_manifest(identifier, domain=domain, page=page))
return ldjsonify(create_manifest(identifier, domain=domain, page=page, version='2/'))
except Exception as excpt:
print("Exception occurred in manifest2:")
print(excpt)
Expand Down
4 changes: 2 additions & 2 deletions iiify/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ def manifest_page(identifier, label='', page='', width='', height='', metadata=N
}


def create_manifest(identifier, domain=None, page=None):
def create_manifest(identifier, domain=None, page=None, version=""):
path = os.path.join(media_root, identifier)
resp = requests.get('%s/metadata/%s' % (ARCHIVE, identifier)).json()
metadata = resp.get("metadata", {})

manifest = {
'@context': PRZ_CTX,
'@id': '%s%s/manifest.json' % (domain, identifier),
'@id': '%s%s%s/manifest.json' % (domain, version, identifier),
'@type': 'sc:Manifest',
'description': metadata.get('description', ''),
'logo': 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcReMN4l9cgu_qb1OwflFeyfHcjp8aUfVNSJ9ynk2IfuHwW1I4mDSw',
Expand Down
8 changes: 4 additions & 4 deletions tests/test_manifests_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_v2_image_manifest(self):
self.assertEqual(resp.status_code, 200)
manifest = resp.json

self.assertEqual(manifest['@id'], 'https://localhost/iiif/rashodgson68/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
self.assertEqual(manifest['@id'], 'https://localhost/iiif/2/rashodgson68/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
self.assertEqual(manifest['@type'], "sc:Manifest", f"Unexpected type. Expected Manifest got {manifest['@type']}")
self.assertEqual(len(manifest['sequences'][0]['canvases']),32,f"Expected 32 canvases but got: {len(manifest['sequences'][0]['canvases'])}")
self.assertEqual(manifest['sequences'][0]['canvases'][0]['@id'],"https://iiif.archivelab.org/iiif/rashodgson68$0/canvas",f"v2 canvas id has changed")
Expand All @@ -26,7 +26,7 @@ def test_v2_image_api(self):
self.assertEqual(resp.status_code, 200)
manifest = resp.json

self.assertEqual(manifest['@id'], 'https://localhost/iiif/1991-12-compute-magazine/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
self.assertEqual(manifest['@id'], 'https://localhost/iiif/2/1991-12-compute-magazine/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
image = manifest['sequences'][0]['canvases'][0]['images'][0]['resource']
self.assertEqual(image['@id'], "https://localhost/iiif/1991-12-compute-magazine$0/full/full/0/default.jpg", "Resource not using new image server")
self.assertEqual(image['service']['@id'], 'https://localhost/iiif/1991-12-compute-magazine$0', "V2 service not using the new image server")
Expand All @@ -36,7 +36,7 @@ def test_v2_single_image(self):
self.assertEqual(resp.status_code, 200)
manifest = resp.json

self.assertEqual(manifest['@id'], 'https://localhost/iiif/img-8664_202009/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
self.assertEqual(manifest['@id'], 'https://localhost/iiif/2/img-8664_202009/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
canvas = manifest['sequences'][0]['canvases'][0]
self.assertEqual(canvas['@id'], 'https://iiif.archivelab.org/iiif/img-8664_202009/canvas', 'Expected canvas id to be the same')
image = canvas['images'][0]['resource']
Expand All @@ -48,7 +48,7 @@ def test_v2_single_text_manifest(self):
self.assertEqual(resp.status_code, 200)
manifest = resp.json

self.assertEqual(manifest['@id'], 'https://localhost/iiif/fbf_3chords_1_/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
self.assertEqual(manifest['@id'], 'https://localhost/iiif/2/fbf_3chords_1_/manifest.json', 'V2 Manifest ID is using new infrastructure changed')
canvas = manifest['sequences'][0]['canvases'][0]
self.assertEqual(canvas['@id'], 'https://iiif.archivelab.org/iiif/fbf_3chords_1_$0/canvas', 'Expected canvas id to be the same')
image = canvas['images'][0]['resource']
Expand Down

0 comments on commit 992c8f4

Please sign in to comment.