From 8951982e556a56073da8cb7de0d0981df96fb509 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 27 Sep 2024 09:46:17 -0700 Subject: [PATCH] Configure embed components for testing. --- app/helpers/spotlight/pages_helper.rb | 6 ++++++ .../sir_trevor/blocks/_embedded_document.html.erb | 2 +- spec/test_app_templates/catalog_controller.rb | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/helpers/spotlight/pages_helper.rb b/app/helpers/spotlight/pages_helper.rb index 1ed55a4cf9..809f7083d1 100644 --- a/app/helpers/spotlight/pages_helper.rb +++ b/app/helpers/spotlight/pages_helper.rb @@ -80,5 +80,11 @@ def render_contact_email_address(address) def configurations_for_current_page Spotlight::PageConfigurations.new(context: self, page: @page).as_json end + + def embedded_document_presenter(document, view_config: nil) + return document_presenter(document) if view_config.nil? + + view_config.document_presenter_class.new(document, self) + end end end diff --git a/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb b/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb index cb18e6944c..fba30e390b 100644 --- a/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb +++ b/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb @@ -1,6 +1,6 @@
<% view_config = blacklight_config.view_config(:embed) %> - <%= render (view_config.document_component || Spotlight::SolrDocumentLegacyEmbedComponent).new((Blacklight.version > '8.0' ? :document : :presenter) => document_presenter(document), counter: nil) do |component| %> + <%= render (view_config.document_component || Spotlight::SolrDocumentLegacyEmbedComponent).new((Blacklight.version > '8.0' ? :document : :presenter) => embedded_document_presenter(document, view_config: view_config), counter: nil) do |component| %> <% component.with_partial do %> <%= render_document_partials document, view_config.partials, component: component, document_counter: nil, view_config: view_config, block: local_assigns[:block], **(view_config.locals) %> <% end if view_config&.partials&.any? %> diff --git a/spec/test_app_templates/catalog_controller.rb b/spec/test_app_templates/catalog_controller.rb index b3252ba993..ffde19864f 100644 --- a/spec/test_app_templates/catalog_controller.rb +++ b/spec/test_app_templates/catalog_controller.rb @@ -11,8 +11,16 @@ class CatalogController < ApplicationController # config.view.gallery.classes = 'row-cols-2 row-cols-md-3' config.view.masonry(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::MasonryComponent) config.view.slideshow(document_component: Blacklight::Gallery::SlideshowComponent, icon: Blacklight::Gallery::Icons::SlideshowComponent) + + config.view.embed(if: false, + partials: [], + document_component: Spotlight::SolrDocumentLegacyEmbedComponent, + embed_component: Blacklight::Gallery::OpenseadragonEmbedComponent) + config.show.tile_source_field = :content_metadata_image_iiif_info_ssm - config.show.partials.insert(1, :openseadragon) + + config.show.embed_component = Blacklight::Gallery::OpenseadragonEmbedComponent + ## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params config.default_solr_params = { qt: 'search',