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

Commit

Permalink
🎁 Filter certain file sets from manifests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kirkkwang committed Nov 29, 2023
1 parent 99517e4 commit 4e75400
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

# rubocop:disable Metrics/BlockLength
IiifPrint::ManifestBuilderServiceBehavior.module_eval do
def build_manifest(presenter:)
manifest = manifest_factory.new(presenter).to_h
Expand Down Expand Up @@ -30,26 +29,4 @@ def rendering(presenter:)
}
end
end

def sanitize_v2(hash:, presenter:, solr_doc_hits:)
hash['label'] = sanitize_label(hash['label']) if hash.key?('label')
hash.delete('description') # removes default description since it's in the metadata fields
hash['sequences']&.each do |sequence|
# removes canvases if there are thumbnail files
sequence['canvases'].reject! do |canvas|
sanitize_label(canvas['label']).end_with?('.TN.jpg')
end

sequence['canvases']&.each do |canvas|
canvas['label'] = sanitize_label(canvas['label'])
apply_metadata_to_canvas(canvas: canvas, presenter: presenter, solr_doc_hits: solr_doc_hits)
end
end
hash
end

def sanitize_label(label)
CGI.unescapeHTML(sanitize_value(label))
end
end
# rubocop:enable Metrics/BlockLength
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

# OVERRIDE IIIFManifest v0.5.0 to remove thumbnail and other non-image files from the manifest

module IIIFManifest
module ManifestBuilderDecorator
module CanvasBuilderFactoryDecorator
THUMBNAIL_FILE_SUFFIX = '.tn.jpg'

def from(work)
composite_builder.new(
*file_set_presenters(work).map do |presenter|
next if presenter.label.downcase.end_with?(THUMBNAIL_FILE_SUFFIX) || !presenter.image?

canvas_builder_factory.new(presenter, work)
end
)
end
end
end
end

IIIFManifest::ManifestBuilder::CanvasBuilderFactory
.prepend(IIIFManifest::ManifestBuilderDecorator::CanvasBuilderFactoryDecorator)

This file was deleted.

0 comments on commit 4e75400

Please sign in to comment.