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

Commit

Permalink
Merge pull request #683 from scientist-softserv/i679-remove-thumbnail…
Browse files Browse the repository at this point in the history
…s-and-non-image-file-sets

🎁 Filter certain file sets from manifests
  • Loading branch information
kirkkwang authored Nov 29, 2023
2 parents 99517e4 + 3526791 commit c89ad7c
Show file tree
Hide file tree
Showing 3 changed files with 23 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,23 @@
# 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 c89ad7c

Please sign in to comment.