diff --git a/install/data_test.sql b/install/data_test.sql index f457ce32b..1c44132e9 100644 --- a/install/data_test.sql +++ b/install/data_test.sql @@ -26,3 +26,10 @@ INSERT INTO web.user_log (user_id, entity_id, action) VALUES (2, 6666, 'insert') -- Needed to test external reference systems for hierarchies INSERT INTO web.reference_system_openatlas_class (reference_system_id, openatlas_class_name) VALUES ((SELECT entity_id FROM web.reference_system WHERE name='Wikidata'), 'type'); + +-- IIIF activation +UPDATE web.settings SET value = 'True' WHERE name = 'iiif'; +UPDATE web.settings SET value = '/var/www/iipsrv'WHERE name = 'iiif_path'; +UPDATE web.settings SET value = 'http://localhost/iiif/'WHERE name = 'iiif_url'; +UPDATE web.settings SET value = '2' WHERE name = 'iiif_version'; +UPDATE web.settings SET value = 'deflate' WHERE name = 'iiif_conversion'; diff --git a/openatlas/api/endpoints/content.py b/openatlas/api/endpoints/content.py index 8efd9cf6e..72f22b534 100644 --- a/openatlas/api/endpoints/content.py +++ b/openatlas/api/endpoints/content.py @@ -43,9 +43,9 @@ def get() -> Union[tuple[Resource, int], Response]: app.config['IMAGE_SIZE'] if g.settings['image_processing'] else None}, 'IIIF': { - 'enabled': app.config['IIIF']['enabled'], - 'url': app.config['IIIF']['url'], - 'version': app.config['IIIF']['version']}} + 'enabled': g.settings['iiif'], + 'url': g.settings['iiif_url'], + 'version': int(g.settings['iiif_version'])}} if parser['download']: download(details, backend_details_template(), 'content') return marshal(details, backend_details_template()), 200 diff --git a/openatlas/api/endpoints/display_image.py b/openatlas/api/endpoints/display_image.py index 80ce7e88a..908bb32e2 100644 --- a/openatlas/api/endpoints/display_image.py +++ b/openatlas/api/endpoints/display_image.py @@ -1,19 +1,19 @@ from pathlib import Path as Pathlib_path from typing import Any -from flask import Response, send_file, url_for +from flask import Response, g, send_file, url_for from flask_restful import Resource, marshal from openatlas import app -from openatlas.api.resources.error import DisplayFileNotFoundError, \ - NoLicenseError -from openatlas.api.resources.parser import image, files +from openatlas.api.resources.error import ( + DisplayFileNotFoundError, NoLicenseError) +from openatlas.api.resources.model_mapper import ( + get_entities_by_ids, get_entities_by_system_classes, get_entity_by_id) +from openatlas.api.resources.parser import files, image from openatlas.api.resources.templates import licensed_file_template from openatlas.api.resources.util import get_license_name -from openatlas.api.resources.model_mapper import get_entity_by_id, \ - get_entities_by_system_classes, get_entities_by_ids -from openatlas.display.util import get_file_path, check_iiif_activation, \ - check_iiif_file_exist +from openatlas.display.util import ( + check_iiif_activation, check_iiif_file_exist, get_file_path) class DisplayImage(Resource): @@ -49,7 +49,7 @@ def get() -> tuple[Any, int]: and check_iiif_file_exist(entity.id): iiif_manifest = url_for( 'api.iiif_manifest', - version=app.config['IIIF']['version'], + version=g.settings['iiif']['version'], id_=entity.id, _external=True) files_dict[path.stem] = { diff --git a/tests/test_file.py b/tests/test_file.py index 815d3cfcc..7b8a3fed8 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -1,7 +1,7 @@ from pathlib import Path from typing import Any -from flask import url_for +from flask import g, url_for from openatlas import app from openatlas.models.entity import Entity @@ -120,16 +120,18 @@ def test_file(self) -> None: url_for( 'api.iiif_manifest', id_=file_id, - version=app.config['IIIF']['version'])) + version=g.settings['iiif_version'])) rv = rv.get_json() assert bool(rv['label'] == 'Updated file') rv = self.app.get(url_for('api.iiif_sequence', id_=file_id)) rv = rv.get_json() assert bool(str(file_id) in rv['@id']) + rv = self.app.get(url_for('api.iiif_image', id_=file_id)) rv = rv.get_json() assert bool(str(file_id) in rv['@id']) + rv = self.app.get(url_for('api.iiif_canvas', id_=file_id)) rv = rv.get_json() assert bool(str(file_id) in rv['@id']) @@ -140,16 +142,9 @@ def test_file(self) -> None: rv = self.app.get(url_for('view', id_=place.id)) assert b'/full/!100,100/0/default.jpg' in rv.data - app.config['IIIF']['conversion'] = False - rv = self.app.get(url_for('view', id_=place.id)) - assert b'/full/!100,100/0/default.jpg' in rv.data - - app.config['IIIF']['activate'] = False rv = self.app.get(url_for('view', id_=place.id)) assert b'Logo' in rv.data - app.config['IIIF']['activate'] = True - app.config['IIIF']['conversion'] = True for file in files: rv = self.app.get( url_for('delete', id_=file.id),