From 9303e853256ce0e6c223d26ae6106ccb7d588700 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 27 Sep 2024 09:42:04 -0700 Subject: [PATCH 1/4] Don't populate the embed partial if an embed component is defined. --- app/models/spotlight/blacklight_configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spotlight/blacklight_configuration.rb b/app/models/spotlight/blacklight_configuration.rb index e2b0badd7..f1c0a022b 100644 --- a/app/models/spotlight/blacklight_configuration.rb +++ b/app/models/spotlight/blacklight_configuration.rb @@ -123,7 +123,7 @@ def blacklight_config config.view.embed! # This is blacklight-gallery's openseadragon partial unless config.view.embed.document_component - config.view.embed.partials ||= ['openseadragon'] + config.view.embed.partials ||= ['openseadragon'] unless config.view.embed.embed_component config.view.embed.document_component = Spotlight::SolrDocumentLegacyEmbedComponent end config.view.embed.if = false From 63f41925b9b85ce2f7fb7c1f140440e4ffe76663 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 27 Sep 2024 09:46:17 -0700 Subject: [PATCH 2/4] Configure embed components for testing for Blacklight 8 --- app/helpers/spotlight/pages_helper.rb | 6 ++++++ spec/test_app_templates/catalog_controller.rb | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/helpers/spotlight/pages_helper.rb b/app/helpers/spotlight/pages_helper.rb index 85de2c4db..72f55ceea 100644 --- a/app/helpers/spotlight/pages_helper.rb +++ b/app/helpers/spotlight/pages_helper.rb @@ -87,5 +87,11 @@ def resource_alt_text(options, default) default end + + def embedded_document_presenter(document, view_config: nil) + return document_presenter(document) if view_config.nil? || Blacklight.version < '8.0' + + view_config.document_presenter_class.new(document, self, view_config: view_config) + end end end diff --git a/spec/test_app_templates/catalog_controller.rb b/spec/test_app_templates/catalog_controller.rb index 427401fa4..acd8f30cb 100644 --- a/spec/test_app_templates/catalog_controller.rb +++ b/spec/test_app_templates/catalog_controller.rb @@ -12,8 +12,21 @@ 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.show.tile_source_field = :content_metadata_image_iiif_info_ssm - config.show.partials.insert(1, :openseadragon) + + if Blacklight.version > '8.0' + 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.embed_component = Blacklight::Gallery::OpenseadragonEmbedComponent + else + config.show.tile_source_field = :content_metadata_image_iiif_info_ssm + config.show.partials.insert(1, :openseadragon) + end + ## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params config.default_solr_params = { qt: 'search', From 4d03d1a354e82c52a6faf52d3bccb9213b15c89c Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 27 Sep 2024 14:00:28 -0700 Subject: [PATCH 3/4] Blacklight 8 always inflicts a blank partial slot on us, so we have to check if there's actually content. --- .../solr_document_legacy_embed_component.html.erb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/components/spotlight/solr_document_legacy_embed_component.html.erb b/app/components/spotlight/solr_document_legacy_embed_component.html.erb index c428f9208..dc8926e65 100644 --- a/app/components/spotlight/solr_document_legacy_embed_component.html.erb +++ b/app/components/spotlight/solr_document_legacy_embed_component.html.erb @@ -1,11 +1,14 @@ <% if body.present? %> <%= body %> -<% elsif partials? %> - <% partials.each do |partial| %> - <%= partial %> +<% elsif partials? || embed? %> + <% partial_content = capture do %> + <% partials.each do |partial| %> + <%= partial %> + <% end %> <% end %> -<% elsif embed? %> - <%= embed %> + + <%= partial_content if partial_content.present? %> + <%= embed if embed? && partial_content.blank? %> <% elsif thumbnail? %> <%= thumbnail %> <% end %> From ea0377cc9b87bd1fbc10504309323757f2f9ccd7 Mon Sep 17 00:00:00 2001 From: Cory Lown Date: Wed, 12 Feb 2025 14:02:13 -0500 Subject: [PATCH 4/4] Drop BL 7 support --- ...r_document_legacy_embed_component.html.erb | 11 ++--------- app/helpers/spotlight/pages_helper.rb | 6 ------ .../blocks/_embedded_document.html.erb | 6 +----- spec/test_app_templates/catalog_controller.rb | 19 ++++++------------- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/app/components/spotlight/solr_document_legacy_embed_component.html.erb b/app/components/spotlight/solr_document_legacy_embed_component.html.erb index dc8926e65..d1a05e31d 100644 --- a/app/components/spotlight/solr_document_legacy_embed_component.html.erb +++ b/app/components/spotlight/solr_document_legacy_embed_component.html.erb @@ -1,14 +1,7 @@ <% if body.present? %> <%= body %> -<% elsif partials? || embed? %> - <% partial_content = capture do %> - <% partials.each do |partial| %> - <%= partial %> - <% end %> - <% end %> - - <%= partial_content if partial_content.present? %> - <%= embed if embed? && partial_content.blank? %> +<% elsif embed? %> + <%= embed %> <% elsif thumbnail? %> <%= thumbnail %> <% end %> diff --git a/app/helpers/spotlight/pages_helper.rb b/app/helpers/spotlight/pages_helper.rb index 72f55ceea..85de2c4db 100644 --- a/app/helpers/spotlight/pages_helper.rb +++ b/app/helpers/spotlight/pages_helper.rb @@ -87,11 +87,5 @@ def resource_alt_text(options, default) default end - - def embedded_document_presenter(document, view_config: nil) - return document_presenter(document) if view_config.nil? || Blacklight.version < '8.0' - - view_config.document_presenter_class.new(document, self, view_config: view_config) - 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 160b8ea15..66dc97d92 100644 --- a/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb +++ b/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb @@ -1,8 +1,4 @@
<% view_config = blacklight_config.view_config(:embed) %> - <%= render (view_config.document_component || Spotlight::SolrDocumentLegacyEmbedComponent).new((Blacklight.version > '8.0' ? :document : :presenter) => document_presenter(document, view_config: view_config), counter: nil, block: local_assigns[:block]) 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? %> - <% end %> + <%= render (view_config.document_component || Spotlight::SolrDocumentLegacyEmbedComponent).new(:document => document_presenter(document, view_config: view_config), counter: nil, block: local_assigns[:block]) %>
diff --git a/spec/test_app_templates/catalog_controller.rb b/spec/test_app_templates/catalog_controller.rb index acd8f30cb..efedbcb4a 100644 --- a/spec/test_app_templates/catalog_controller.rb +++ b/spec/test_app_templates/catalog_controller.rb @@ -13,19 +13,12 @@ class CatalogController < ApplicationController 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) - if Blacklight.version > '8.0' - 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.embed_component = Blacklight::Gallery::OpenseadragonEmbedComponent - else - config.show.tile_source_field = :content_metadata_image_iiif_info_ssm - config.show.partials.insert(1, :openseadragon) - end + 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.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 = {