Skip to content

Commit

Permalink
iiif: move config, refactor proxy and decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Apr 23, 2024
1 parent 19ecf1c commit 4b4aaec
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 154 deletions.
3 changes: 0 additions & 3 deletions invenio_rdm_records/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,3 @@ def lock_edit_published_files(service, identity, record=None):

RDM_DATACITE_FUNDER_IDENTIFIERS_PRIORITY = ("ror", "doi", "grid", "isni", "gnd")
"""Priority of funder identifiers types to be used for DataCite serialization."""

RDM_IIIF_SERVER_URL = ""
"""IIIF image server URL."""
3 changes: 1 addition & 2 deletions invenio_rdm_records/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""Invenio RDM module to create REST APIs."""

from .config import (
IIIFResourceConfig,
RDMCommunityRecordsResourceConfig,
RDMDraftFilesResourceConfig,
RDMGrantUserAccessResourceConfig,
Expand All @@ -20,7 +19,7 @@
RDMRecordRequestsResourceConfig,
RDMRecordResourceConfig,
)
from .iiif import IIIFResource
from .iiif import IIIFResource, IIIFResourceConfig
from .resources import (
RDMCommunityRecordsResource,
RDMGrantsAccessResource,
Expand Down
56 changes: 0 additions & 56 deletions invenio_rdm_records/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,59 +512,3 @@ class RDMRecordRequestsResourceConfig(ResourceConfig, ConfiguratorMixin):
request_extra_args = {
"expand": ma.fields.Boolean(),
}


#
# IIIF
#
class IIIFResourceConfig(ResourceConfig, ConfiguratorMixin):
"""IIIF resource configuration."""

blueprint_name = "iiif"

url_prefix = "/iiif"

routes = {
"manifest": "/<path:uuid>/manifest",
"sequence": "/<path:uuid>/sequence/default",
"canvas": "/<path:uuid>/canvas/<path:file_name>",
"image_base": "/<path:uuid>",
"image_info": "/<path:uuid>/info.json",
"image_api": "/<path:uuid>/<region>/<size>/<rotation>/<quality>.<image_format>",
}

request_view_args = {
"uuid": ma.fields.Str(),
"file_name": ma.fields.Str(),
"region": ma.fields.Str(),
"size": ma.fields.Str(),
"rotation": ma.fields.Str(),
"quality": ma.fields.Str(),
"image_format": ma.fields.Str(),
}

request_read_args = {
"dl": ma.fields.Str(),
}

request_headers = {
"If-Modified-Since": ma.fields.DateTime(),
}

response_handler = {"application/json": ResponseHandler(JSONSerializer())}

supported_formats = {
"gif": "image/gif",
"jp2": "image/jp2",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"pdf": "application/pdf",
"png": "image/png",
"tif": "image/tiff",
"tiff": "image/tiff",
}

proxy_cls = FromConfig(
"IIIF_PROXY_CLASS",
default=None,
)
Loading

0 comments on commit 4b4aaec

Please sign in to comment.