Skip to content

Commit

Permalink
added IIIFManifest to licensed_file_overview
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Oct 25, 2023
1 parent 1201ec3 commit 0a8b31c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
14 changes: 12 additions & 2 deletions openatlas/api/endpoints/display_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
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
from openatlas.display.util import get_file_path, check_iiif_activation, \
check_iiif_file_exist


class DisplayImage(Resource):
Expand Down Expand Up @@ -43,6 +44,14 @@ def get() -> tuple[Any, int]:
for entity in entities:
if license_ := get_license_name(entity):
if path := get_file_path(entity):
iiif_manifest = ''
if check_iiif_activation() \
and check_iiif_file_exist(entity.id):
iiif_manifest = url_for(
'api.iiif_manifest',
version=app.config['IIIF']['version'],
id_=entity.id,
_external=True)
files_dict[path.stem] = {
'extension': path.suffix,
'display': url_for(
Expand All @@ -54,5 +63,6 @@ def get() -> tuple[Any, int]:
image_size='thumbnail',
filename=path.stem,
_external=True),
'license': license_}
'license': license_,
'IIIFManifest': iiif_manifest}
return marshal(files_dict, licensed_file_template(entities)), 200
3 changes: 2 additions & 1 deletion openatlas/api/resources/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ def licensed_file_template(entities: list[Entity]) -> dict[str, Any]:
'display': fields.String,
'thumbnail': fields.String,
'extension': fields.String,
'license': fields.String}
'license': fields.String,
'IIIFManifest': fields.String}

dict_: dict[str, Any] = defaultdict()
for entity in entities:
Expand Down
6 changes: 5 additions & 1 deletion openatlas/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3140,7 +3140,8 @@
"display",
"thumbnail",
"extension",
"license"
"license",
"IIIFManifest"
],
"properties": {
"id": {
Expand All @@ -3157,6 +3158,9 @@
},
"license": {
"type": "string"
},
"IIIFManifest": {
"type": "string"
}
}
}
Expand Down

0 comments on commit 0a8b31c

Please sign in to comment.