From b0f2c442c18809c31f4cfe02e995558655dfa2b4 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Wed, 1 Nov 2023 12:23:11 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=81=20Modify=20labels=20in=20UV=20for?= =?UTF-8?q?=20V3=20manifests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit will add the same treatment as we have for V2 manifests to V3 manifests. This will allow the UV to add a more human readable label to the pages. Ref: - https://github.com/scientist-softserv/adventist-dl/issues/628 --- .../canvas_builder_decorator.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/iiif_manifest/v3/manifest_builder/canvas_builder_decorator.rb diff --git a/lib/iiif_manifest/v3/manifest_builder/canvas_builder_decorator.rb b/lib/iiif_manifest/v3/manifest_builder/canvas_builder_decorator.rb new file mode 100644 index 000000000..990bd1409 --- /dev/null +++ b/lib/iiif_manifest/v3/manifest_builder/canvas_builder_decorator.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# OVERRIDE IIIFManifest v1.3.1 to use the parent's title as the label instead of the filename + +module IIIFManifest + module V3 + module ManifestBuilderDecorator + module CanvasBuilderDecorator + def apply_record_properties + super + canvas.label = if record.to_s.present? + ManifestBuilder.language_map(record['parent_title_tesim']&.first || record.to_s) + end + end + end + end + end +end + +IIIFManifest::V3::ManifestBuilder.prepend(IIIFManifest::V3::ManifestBuilderDecorator) +IIIFManifest::V3::ManifestBuilder::CanvasBuilder.prepend(IIIFManifest::V3::ManifestBuilder::CanvasBuilderDecorator)