From edd713755de944ab330f877cae57e62dbe94b095 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Thu, 7 Nov 2024 21:31:24 +0000 Subject: [PATCH] Adding new Collection helper --- iiify/app.py | 2 ++ iiify/templates/helpers/collection.html | 38 +++++++++++++++++++++++++ tests/test_helper.py | 23 +++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 iiify/templates/helpers/collection.html create mode 100644 tests/test_helper.py diff --git a/iiify/app.py b/iiify/app.py index ace5689..fedb737 100755 --- a/iiify/app.py +++ b/iiify/app.py @@ -116,6 +116,8 @@ def helper(identifier): return render_template('helpers/movies.html', identifier=identifier) elif mediatype == "texts": return render_template('helpers/texts.html', identifier=identifier) + elif mediatype == "collection": + return render_template('helpers/collection.html', identifier=identifier) else: return render_template('helpers/unknown.html', identifier=identifier) diff --git a/iiify/templates/helpers/collection.html b/iiify/templates/helpers/collection.html new file mode 100644 index 0000000..3311349 --- /dev/null +++ b/iiify/templates/helpers/collection.html @@ -0,0 +1,38 @@ + + + + + + IIIF Collection Helper + + + + + + + + + +
+ +
+
+ +

IIIF Collection Helper

+ +

The IA collection page URL is: https://archive.org/details/{{ identifier }}

+ +

The IA identifier is: {{ identifier }}

+ +

The IIIF collection URL is: https://iiif.archive.org/iiif/3/{{ identifier }}/collection.json

+ +

IIIF viewer options

+ + + + diff --git a/tests/test_helper.py b/tests/test_helper.py new file mode 100644 index 0000000..0208411 --- /dev/null +++ b/tests/test_helper.py @@ -0,0 +1,23 @@ +import os +os.environ["FLASK_CACHE_DISABLE"] = "true" + +import unittest +from flask.testing import FlaskClient +from iiify.app import app + +class TestHelper(unittest.TestCase): + + def setUp(self) -> None: + self.test_app = FlaskClient(app) + + def test_single_image(self): + resp = self.test_app.get("/iiif/helper/img-8664_202009/") + self.assertEqual(resp.status_code, 200) + + self.assertIn('Mirador', resp.text, "Couldn't find Mirador link in helper page.") + + def test_collection(self): + resp = self.test_app.get("/iiif/helper/frankbford/") + self.assertEqual(resp.status_code, 200) + + self.assertIn('Mirador', resp.text, "Couldn't find Mirador link in helper page.") \ No newline at end of file