Skip to content

Commit

Permalink
Merge pull request #84 from internetarchive/issue-79
Browse files Browse the repository at this point in the history
Adding easy way to find info.jsons
  • Loading branch information
mekarpeles authored Oct 8, 2024
2 parents 4bfadf8 + dbe4037 commit bea2357
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions iiify/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ def info(identifier):
cantaloupe_url = f"{image_server}/2/{cantaloupe_id}/info.json"
return redirect(cantaloupe_url, code=302)

@app.route('/iiif/3/<identifier>/info.json')
def info3(identifier):
cantaloupe_id = cantaloupe_resolver(identifier)
cantaloupe_url = f"{image_server}/3/{cantaloupe_id}/info.json"
return redirect(cantaloupe_url, code=302)

@app.route('/iiif/2/<identifier>/info.json')
def info2(identifier):
cantaloupe_id = cantaloupe_resolver(identifier)
cantaloupe_url = f"{image_server}/2/{cantaloupe_id}/info.json"
return redirect(cantaloupe_url, code=302)

@app.route('/iiif/<identifier>/<region>/<size>/<rotation>/<quality>.<fmt>')
def image_processor(identifier, region, size, rotation, quality, fmt):
Expand Down
24 changes: 24 additions & 0 deletions tests/test_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
os.environ["FLASK_CACHE_DISABLE"] = "true"

import unittest
from flask.testing import FlaskClient
from iiify.app import app

class TestImages(unittest.TestCase):

def setUp(self) -> None:
self.test_app = FlaskClient(app)

def test_v3_resolving(self):
resp = self.test_app.get("/iiif/3/jewishinterpreta00morg$267/info.json")
self.assertEqual(resp.status_code, 302)
self.assertEqual("https://iiif.archive.org/image/iiif/3/jewishinterpreta00morg%2fjewishinterpreta00morg_jp2.zip%2fjewishinterpreta00morg_jp2%2fjewishinterpreta00morg_0267.jp2/info.json", resp.location, "Expected to be redirected to full JSON URl.")

def test_v2_resolving(self):
resp = self.test_app.get("/iiif/2/jewishinterpreta00morg$267/info.json")
self.assertEqual(resp.status_code, 302)
self.assertEqual("https://iiif.archive.org/image/iiif/2/jewishinterpreta00morg%2fjewishinterpreta00morg_jp2.zip%2fjewishinterpreta00morg_jp2%2fjewishinterpreta00morg_0267.jp2/info.json", resp.location, "Expected to be redirected to full JSON URl.")



0 comments on commit bea2357

Please sign in to comment.