Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 4e75400

Browse files
author
Kirk Wang
committed
🎁 Filter certain file sets from manifests
This commit will remove thumbnail file sets and non-image file sets at a much higher level than before. Previously, we were filtering out the thumbnails at the manifest builder level which is right before the manifest gets generated. This caused issues with serverless IIIF resources when the file sets (such as thumbnails or text files) were not properly ingested. This shouldn't break the manifest generation since these kinds of file sets are not able to be displayed in the Universal Viewer. Filtering these out at a higher level means it doesn't even make it to the serverless IIIF portion of the code in IIIF Print. Ref: - https://github.com/scientist-softserv/adventist-dl/issues/679
1 parent 99517e4 commit 4e75400

File tree

3 files changed

+24
-195
lines changed

3 files changed

+24
-195
lines changed

app/services/iiif_print/manifest_builder_service_behavior_decorator.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# OVERRIDE IiifPrint v1.0.0 to not render thumbnail files in the UV
44

5-
# rubocop:disable Metrics/BlockLength
65
IiifPrint::ManifestBuilderServiceBehavior.module_eval do
76
def build_manifest(presenter:)
87
manifest = manifest_factory.new(presenter).to_h
@@ -30,26 +29,4 @@ def rendering(presenter:)
3029
}
3130
end
3231
end
33-
34-
def sanitize_v2(hash:, presenter:, solr_doc_hits:)
35-
hash['label'] = sanitize_label(hash['label']) if hash.key?('label')
36-
hash.delete('description') # removes default description since it's in the metadata fields
37-
hash['sequences']&.each do |sequence|
38-
# removes canvases if there are thumbnail files
39-
sequence['canvases'].reject! do |canvas|
40-
sanitize_label(canvas['label']).end_with?('.TN.jpg')
41-
end
42-
43-
sequence['canvases']&.each do |canvas|
44-
canvas['label'] = sanitize_label(canvas['label'])
45-
apply_metadata_to_canvas(canvas: canvas, presenter: presenter, solr_doc_hits: solr_doc_hits)
46-
end
47-
end
48-
hash
49-
end
50-
51-
def sanitize_label(label)
52-
CGI.unescapeHTML(sanitize_value(label))
53-
end
5432
end
55-
# rubocop:enable Metrics/BlockLength
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
# OVERRIDE IIIFManifest v0.5.0 to remove thumbnail and other non-image files from the manifest
4+
5+
module IIIFManifest
6+
module ManifestBuilderDecorator
7+
module CanvasBuilderFactoryDecorator
8+
THUMBNAIL_FILE_SUFFIX = '.tn.jpg'
9+
10+
def from(work)
11+
composite_builder.new(
12+
*file_set_presenters(work).map do |presenter|
13+
next if presenter.label.downcase.end_with?(THUMBNAIL_FILE_SUFFIX) || !presenter.image?
14+
15+
canvas_builder_factory.new(presenter, work)
16+
end
17+
)
18+
end
19+
end
20+
end
21+
end
22+
23+
IIIFManifest::ManifestBuilder::CanvasBuilderFactory
24+
.prepend(IIIFManifest::ManifestBuilderDecorator::CanvasBuilderFactoryDecorator)

spec/services/iiif_print/manifest_builder_service_behavior_decorator_spec.rb

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)