From e962f1b9b336b37e82661fee82ac29b680b55129 Mon Sep 17 00:00:00 2001 From: bkoschicek Date: Tue, 26 Sep 2023 16:38:57 +0200 Subject: [PATCH] trying to get host with subdomain --- openatlas/api/endpoints/iiif.py | 83 ++++++--------------------------- 1 file changed, 15 insertions(+), 68 deletions(-) diff --git a/openatlas/api/endpoints/iiif.py b/openatlas/api/endpoints/iiif.py index a8f3fc043..4acb82f30 100644 --- a/openatlas/api/endpoints/iiif.py +++ b/openatlas/api/endpoints/iiif.py @@ -8,69 +8,13 @@ def getManifest(id_): - # entity = get_entity_by_id(id_) - # url_root = app.config['IIIF_URL'] or f"{request.url_root}iiif/" - # # get metadata from the image api - # req = requests.get( - # f"{url_root}{app.config['IIIF_PREFIX']}{id_}/info.json") - # image_api = req.json() - # iiif_id = f"{url_root}{id_}" - # manifest = { - # "@context": "http://iiif.io/api/presentation/2/context.json", - # "@id": f"{request.base_url}", - # "@type": "sc:Manifest", - # "label": entity.name, - # "metadata": [], - # "description": [{ - # "@value": entity.description, - # "@language": "en"}], - # "license": "http://rightsstatements.org/vocab/NoC-NC/1.0/", - # "attribution": "By OpenAtlas", - # "sequences": [{ - # "@id": "http://c8b09ce6-df6d-4d5e-9eba-17507dc5c185", - # "@type": "sc:Sequence", - # "label": [{ - # "@value": "Normal Sequence", - # "@language": "en"}], - # "canvases": [{ - # "@id": "http://251a31df-761d-46df-85c3-66cb967b8a67", - # "@type": "sc:Canvas", - # "label": entity.name, - # "height": int(image_api['height']), - # "width": int(image_api['width']), - # "description": { - # "@value": entity.description, - # "@language": "en"}, - # "images": [{ - # "@context": - # "http://iiif.io/api/presentation/2/context.json", - # "@id": "http://a0a3ec3e-2084-4253-b0f9-a5f87645e15d", - # "@type": "oa:Annotation", - # "motivation": "sc:painting", - # "resource": { - # "@id": f"{iiif_id}/full/full/0/default.jpg", - # "@type": "dctypes:Image", - # "format": "image/jpeg", - # "service": { - # "@context": - # "http://iiif.io/api/image/2/context.json", - # "@id": iiif_id, - # "profile": image_api['profile'] - # }, - # "height": int(image_api['height']), - # "width": int(image_api['width'])}, - # "on": "http://251a31df-761d-46df-85c3-66cb967b8a67"}], - # "related": ""}]}], - # "structures": []} - # entity = get_entity_by_id(id_) - url_root = app.config['IIIF_SERVER'] or request.url_root - + url_root = app.config['IIIF_URL'] or f"{request.headers.get('Host')}iiif/" # get metadata from the image api req = requests.get( - f"{url_root}iiif/{app.config['IIIF_PREFIX']}{id_}/info.json") + f"{url_root}{app.config['IIIF_PREFIX']}{id_}/info.json") image_api = req.json() - print(image_api) + iiif_id = f"{url_root}{id_}" manifest = { "@context": "http://iiif.io/api/presentation/2/context.json", "@id": f"{request.base_url}", @@ -80,7 +24,7 @@ def getManifest(id_): "description": [{ "@value": entity.description, "@language": "en"}], - "license": "https://creativecommons.org/licenses/by/3.0/", + "license": get_license_name(entity), "attribution": "By OpenAtlas", "sequences": [{ "@id": "http://c8b09ce6-df6d-4d5e-9eba-17507dc5c185", @@ -92,31 +36,34 @@ def getManifest(id_): "@id": "http://251a31df-761d-46df-85c3-66cb967b8a67", "@type": "sc:Canvas", "label": entity.name, - "height": 450, - "width": 600, + "height": int(image_api['height']), + "width": int(image_api['width']), "description": { "@value": entity.description, "@language": "en"}, "images": [{ - "@context": "http://iiif.io/api/presentation/2/context.json", + "@context": + "http://iiif.io/api/presentation/2/context.json", "@id": "http://a0a3ec3e-2084-4253-b0f9-a5f87645e15d", "@type": "oa:Annotation", "motivation": "sc:painting", "resource": { - "@id": f"{url_root}iiif/{id_}/full/full/0/default.jpg", + "@id": f"{iiif_id}/full/full/0/default.jpg", "@type": "dctypes:Image", "format": "image/jpeg", "service": { - "@context": "http://iiif.io/api/image/2/context.json", - "@id": f"{url_root}iiif/{id_}", + "@context": + "http://iiif.io/api/image/2/context.json", + "@id": iiif_id, "profile": image_api['profile'] }, - "height": 450, - "width": 600}, + "height": int(image_api['height']), + "width": int(image_api['width'])}, "on": "http://251a31df-761d-46df-85c3-66cb967b8a67"}], "related": ""}]}], "structures": []} + return manifest