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

Commit 9e77506

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 9e77506

File tree

3 files changed

+24
-193
lines changed

3 files changed

+24
-193
lines changed

app/services/iiif_print/manifest_builder_service_behavior_decorator.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,5 @@ def rendering(presenter:)
3030
}
3131
end
3232
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
5433
end
5534
# 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)