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

🎁 Filter certain file sets from manifests #683

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading