-
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.
Loading status checks…
move everything to the established decorator pattern
1 parent
830a9af
commit c029383
Showing
23 changed files
with
101 additions
and
93 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 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
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 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,13 @@ | ||
module IiifPrint | ||
module WorksControllerBehaviorDecorator | ||
# Extending the presenter to the base url which includes the protocol. | ||
# We need the base url to render the facet links. | ||
def iiif_manifest_presenter | ||
super.tap { |i| i.base_url = request.base_url } | ||
end | ||
end | ||
end | ||
Hyrax::WorksControllerBehavior.prepend(IiifPrint::WorksControllerBehaviorDecorator) | ||
# Hyku::WorksControllerBehavior was introduced in Hyku v6.0.0+. Yes we don't depend on Hyku, | ||
# but this allows us to do minimal Hyku antics with IiifPrint. | ||
'Hyku::WorksControllerBehavior'.safe_constantize&.prepend(IiifPrint::WorksControllerBehaviorDecorator) |
2 changes: 1 addition & 1 deletion
2
.../iiif_manifest_presenter_behavior_spec.rb → ...iiif_manifest_presenter_decorator_spec.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
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
2 changes: 1 addition & 1 deletion
2
...manifest_builder_service_behavior_spec.rb → ...anifest_builder_service_decorator_spec.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