From 75f00526fe125f26e6ac6b8fd75e001fb63ada76 Mon Sep 17 00:00:00 2001 From: bkoschicek Date: Mon, 9 Oct 2023 12:20:38 +0200 Subject: [PATCH] added Logo to manifest --- config/iiif.py | 2 +- openatlas/api/endpoints/iiif.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config/iiif.py b/config/iiif.py index 574796e07..9ef935d74 100644 --- a/config/iiif.py +++ b/config/iiif.py @@ -9,4 +9,4 @@ 'compression': 'deflate' # 'deflate' or 'jpeg' } -IIIF_IMAGE_EXT = ALLOWED_IMAGE_EXT + ['.pdf'] \ No newline at end of file +IIIF_IMAGE_EXT = ALLOWED_IMAGE_EXT + ['.pdf'] diff --git a/openatlas/api/endpoints/iiif.py b/openatlas/api/endpoints/iiif.py index 3e2260c0b..cbbbe8c7f 100644 --- a/openatlas/api/endpoints/iiif.py +++ b/openatlas/api/endpoints/iiif.py @@ -1,7 +1,7 @@ from typing import Any import requests -from flask import jsonify, Response, url_for +from flask import jsonify, Response, url_for, g, request from flask_restful import Resource from openatlas import app @@ -124,6 +124,7 @@ def get_manifest_version_2(id_: int) -> dict[str, Any]: "@language": "en"}], "license": get_license_name(entity), "attribution": "By OpenAtlas", + "logo": get_logo(), "sequences": [ IIIFSequence.build_sequence(get_metadata(entity))], "structures": []} @@ -136,3 +137,17 @@ def get_metadata(entity: Entity) -> dict[str, Any]: req = requests.get(f"{image_url}/info.json") image_api = req.json() return {'entity': entity, 'img_url': image_url, 'img_api': image_api} + + +def get_logo() -> dict[str, Any]: + return { + "@id": url_for( + 'api.display', + filename=g.settings['logo_file_id'], + _external=True), + "service": { + "@context": "http://iiif.io/api/image/2/context.json", + "@id": url_for('overview', _external=True), + "profile": "http://iiif.io/api/image/2/level2.json" + } + }