Skip to content

Commit

Permalink
Refactor CatalogController
Browse files Browse the repository at this point in the history
In this commit, we refactored the `CatalogControllerDecorator` to be a
bit more focused.  Instead of overriding a controller, we're overriding
the `IiifSearchResponse#annotation_list` method so it becomes more
durable.
  • Loading branch information
kirkkwang committed Jan 26, 2023
1 parent 752fbb2 commit 1a66d40
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
17 changes: 17 additions & 0 deletions app/models/iiif_print/iiif_search_response_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module IiifPrint
module IiifSearchResponseDecorator
# Enable the user to search for child metadata in the parent's UV
# @see https://github.com/scientist-softserv/louisville-hyku/commit/67467e5cf9fdb755f54419f17d3c24c87032d0af
def annotation_list
json_results = super
json_results&.[]('resources')&.each do |result_hit|
next if result_hit['resource'].present?
result_hit['resource'] = {
"@type": "cnt:ContentAsText",
"chars": "Metadata match, see sidebar for details"
}
end
json_results
end
end
end
1 change: 0 additions & 1 deletion lib/iiif_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
require "iiif_print/tiff_derivative_service"
require "iiif_print/metadata"
require "iiif_print/works_controller_behavior"
require "iiif_print/catalog_controller_decorator"

module IiifPrint
extend ActiveSupport::Autoload
Expand Down
26 changes: 0 additions & 26 deletions lib/iiif_print/catalog_controller_decorator.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/iiif_print/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Engine < ::Rails::Engine
Hyrax::WorksControllerBehavior.prepend(IiifPrint::WorksControllerBehaviorDecorator)
Hyrax::WorkShowPresenter.prepend(IiifPrint::WorkShowPresenterDecorator)
Hyrax::FileSetIndexer.prepend(IiifPrint::FileSetIndexer)
CatalogController.prepend(IiifPrint::CatalogControllerDecorator)
BlacklightIiifSearch::IiifSearchResponse.prepend(IiifPrint::IiifSearchResponseDecorator)

# 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.
Expand Down

0 comments on commit 1a66d40

Please sign in to comment.