-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into i84-support-dynamic-metadata
- Loading branch information
Showing
31 changed files
with
212 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,4 @@ def destroy | |
end | ||
end | ||
end | ||
Hyrax::Actors::FileSetActor.prepend(IiifPrint::Actors::FileSetActorDecorator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ def uv_search_param | |
end | ||
end | ||
end | ||
Hyrax::IiifHelper.prepend(IiifPrint::IiifHelperDecorator) |
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
app/indexers/concerns/iiif_print/child_work_indexer_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
module IiifPrint | ||
module ChildWorkIndexerDecorator | ||
def to_solr | ||
super.tap do |index_document| | ||
index_solr_doc(index_document) | ||
end | ||
end | ||
|
||
def generate_solr_document | ||
super.tap do |solr_doc| | ||
index_solr_doc(solr_doc) | ||
end | ||
end | ||
|
||
private | ||
|
||
def index_solr_doc(solr_doc) | ||
object ||= @object || resource | ||
solr_doc['is_child_bsi'] ||= object.try(:is_child) | ||
solr_doc['split_from_pdf_id_ssi'] ||= object.try(:split_from_pdf_id) | ||
solr_doc['is_page_of_ssim'] = iiif_print_lineage_service.ancestor_ids_for(object) | ||
solr_doc['member_ids_ssim'] = iiif_print_lineage_service.descendent_member_ids_for(object) | ||
end | ||
end | ||
end | ||
|
||
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYRAX_VALKYRIE', false)) | ||
# Newer versions of Hyrax favor `Hyrax::Indexers::PcdmObjectIndexer` and deprecate | ||
# `Hyrax::ValkyrieWorkIndexer` | ||
indexers = Hyrax.config.curation_concerns.map do |concern| | ||
"#{concern}ResourceIndexer".safe_constantize | ||
end | ||
indexers.each { |indexer| indexer.prepend(IiifPrint::ChildWorkIndexerDecorator) } | ||
|
||
# Versions 3.0+ of Hyrax have `Hyrax::ValkyrieWorkIndexer` so we want to decorate that as | ||
# well. We want to use the elsif construct because later on Hyrax::ValkyrieWorkIndexer | ||
# inherits from Hyrax::Indexers::PcdmObjectIndexer and only implements: | ||
# `def initialize(*args); super; end` | ||
'Hyrax::ValkyrieWorkIndexer'.safe_constantize&.prepend(IiifPrint::ChildWorkIndexerDecorator) | ||
else | ||
# The ActiveFedora::Base indexer for Works | ||
Hyrax::WorkIndexer.prepend(IiifPrint::ChildWorkIndexerDecorator) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
module IiifPrint | ||
module SolrDocumentDecorator | ||
def digest_sha1 | ||
digest[/urn:sha1:([\w]+)/, 1] | ||
end | ||
|
||
def method_missing(method_name, *args, &block) | ||
super unless iiif_print_solr_field_names.include? method_name.to_s | ||
self[IiifPrint.solr_name(method_name.to_s)] | ||
end | ||
|
||
def respond_to_missing?(method_name, include_private = false) | ||
iiif_print_solr_field_names.include?(method_name.to_s) || super | ||
end | ||
|
||
# @see https://github.com/samvera/hyrax/commit/7108409c619cd2ba4ae8c836b9f3b429a7e9837b | ||
def file_set_ids | ||
# Yes, this looks a little odd. But the truth is the prior key (e.g. `file_set_ids_ssim`) was | ||
# an alias of `member_ids_ssim`. | ||
self['member_ids_ssim'] | ||
end | ||
|
||
def any_highlighting? | ||
response&.[]('highlighting')&.[](id)&.present? | ||
end | ||
|
||
def solr_document | ||
self | ||
end | ||
end | ||
end | ||
|
||
SolrDocument.prepend(IiifPrint::SolrDocumentDecorator) | ||
SolrDocument.attribute :is_child, Hyrax::SolrDocument::Metadata::Solr::String, 'is_child_bsi' | ||
SolrDocument.attribute :split_from_pdf_id, Hyrax::SolrDocument::Metadata::Solr::String, 'split_from_pdf_id_ssi' | ||
SolrDocument.attribute :digest, Hyrax::SolrDocument::Metadata::Solr::String, 'digest_ssim' | ||
|
||
# @note These properties came from the newspaper_works gem. They are configurable. | ||
SolrDocument.class_attribute :iiif_print_solr_field_names, default: %w[alternative_title genre | ||
issn lccn oclcnum held_by text_direction | ||
page_number section author photographer | ||
volume issue_number geographic_coverage | ||
extent publication_date height width | ||
edition_number edition_name frequency preceded_by | ||
succeeded_by] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ def solr_params | |
end | ||
end | ||
end | ||
::BlacklightIiifSearch::IiifSearch.prepend(IiifPrint::IiifSearchDecorator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ def show_split_button? | |
end | ||
end | ||
end | ||
Hyrax::FileSetPresenter.prepend(IiifPrint::FileSetPresenterDecorator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/presenters/iiif_print/iiif_manifest_presenter_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# mixin to provide URL for IIIF Content Search service | ||
module IiifPrint | ||
module IiifManifestPresenterDecorator | ||
extend ActiveSupport::Concern | ||
|
||
# Extending the presenter to the base url which includes the protocol. | ||
# We need the base url to render the facet links and normalize the interface. | ||
attr_accessor :base_url | ||
|
||
def manifest_metadata | ||
# ensure we are using a SolrDocument | ||
@manifest_metadata ||= IiifPrint.manifest_metadata_from(work: model.solr_document, presenter: self) | ||
end | ||
|
||
def search_service | ||
Rails.application.routes.url_helpers.solr_document_iiif_search_url(id, host: hostname) | ||
end | ||
|
||
# OVERRIDE: Hyrax 3x, avoid nil returning to IIIF Manifest gem | ||
# @see https://github.com/samvera/iiif_manifest/blob/c408f90eba11bef908796c7236ba6bcf8d687acc/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb#L28 | ||
## | ||
# @return [Array<Hash{String => String}>] | ||
def sequence_rendering | ||
Array(try(:rendering_ids)).map do |file_set_id| | ||
rendering = file_set_presenters.find { |p| p.id == file_set_id } | ||
return [] unless rendering | ||
|
||
{ '@id' => Hyrax::Engine.routes.url_helpers.download_url(rendering.id, host: hostname), | ||
'format' => rendering.mime_type.presence || I18n.t("hyrax.manifest.unknown_mime_text"), | ||
'label' => I18n.t("hyrax.manifest.download_text") + (rendering.label || '') } | ||
end.flatten | ||
end | ||
end | ||
end | ||
Hyrax::IiifManifestPresenter.prepend(IiifPrint::IiifManifestPresenterDecorator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ def config_search_paths | |
end | ||
end | ||
end | ||
Hyrax::SimpleSchemaLoader.prepend(IiifPrint::SimpleSchemaLoaderDecorator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.