diff --git a/app/models/iiif_print/iiif_search_response_decorator.rb b/app/models/iiif_print/iiif_search_response_decorator.rb new file mode 100644 index 00000000..8f8b76bf --- /dev/null +++ b/app/models/iiif_print/iiif_search_response_decorator.rb @@ -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 diff --git a/lib/iiif_print.rb b/lib/iiif_print.rb index 6a0d2fd0..2e3c509e 100644 --- a/lib/iiif_print.rb +++ b/lib/iiif_print.rb @@ -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 diff --git a/lib/iiif_print/catalog_controller_decorator.rb b/lib/iiif_print/catalog_controller_decorator.rb deleted file mode 100644 index 2ec235c2..00000000 --- a/lib/iiif_print/catalog_controller_decorator.rb +++ /dev/null @@ -1,26 +0,0 @@ -module IiifPrint - module CatalogControllerDecorator - # rubocop:disable Metrics/MethodLength - def iiif_search - _parent_response, @parent_document = fetch(params[:solr_document_id]) - iiif_search = ::BlacklightIiifSearch::IiifSearch.new(iiif_search_params, iiif_search_config, - @parent_document) - @response, _document_list = search_results(iiif_search.solr_params) - iiif_search_response = ::BlacklightIiifSearch::IiifSearchResponse.new(@response, - @parent_document, - self) - json_results = iiif_search_response.annotation_list - 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 - - render json: json_results, - content_type: 'application/json' - end - end - # rubocop:enable Metrics/MethodLength -end diff --git a/lib/iiif_print/engine.rb b/lib/iiif_print/engine.rb index d9540701..39b36a69 100644 --- a/lib/iiif_print/engine.rb +++ b/lib/iiif_print/engine.rb @@ -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.