Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure embed components for testing. #3163

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 %>
6 changes: 6 additions & 0 deletions app/helpers/spotlight/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ 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? || Blacklight.version < '8.0'

view_config.document_presenter_class.new(document, self, view_config: view_config)
end

def resource_alt_text(options, default)
return '' if options[:decorative].present?
return options[:alt_text] if options[:alt_text].present?
Expand Down
2 changes: 1 addition & 1 deletion app/models/spotlight/blacklight_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@jcoyne jcoyne Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to put something in the CatalogController template that shows the usage of embed_component?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Some future version of the blacklight_gallery:install generator will do that.

config.view.embed.document_component = Spotlight::SolrDocumentLegacyEmbedComponent
end
config.view.embed.if = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="box" data-id="<%= document.id %>">
<% 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? %>
Expand Down
17 changes: 15 additions & 2 deletions spec/test_app_templates/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down