diff --git a/app/components/blacklight/facet_field_list_component.rb b/app/components/blacklight/facet_field_list_component.rb index 9c815481c3..70640c84b1 100644 --- a/app/components/blacklight/facet_field_list_component.rb +++ b/app/components/blacklight/facet_field_list_component.rb @@ -3,6 +3,7 @@ module Blacklight class FacetFieldListComponent < ::ViewComponent::Base extend Deprecation + self.deprecation_horizon = 'blacklight 9.0' def initialize(facet_field:, layout: nil) @facet_field = facet_field diff --git a/app/helpers/blacklight/render_partials_helper_behavior.rb b/app/helpers/blacklight/render_partials_helper_behavior.rb index bb827f917e..77a78dc68c 100644 --- a/app/helpers/blacklight/render_partials_helper_behavior.rb +++ b/app/helpers/blacklight/render_partials_helper_behavior.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true module Blacklight::RenderPartialsHelperBehavior + extend Deprecation + self.deprecation_horizon = 'blacklight 9.0' + ## # Render the document index view # @@ -22,6 +25,7 @@ def render_document_partials(doc, partials = [], locals = {}) render_document_partial(doc, action_name, locals) end, "\n") end + deprecation_deprecate render_document_partials: 'Render the document_component instead' ## # Return the list of xml for a given solr document. Doesn't safely escape for HTML. diff --git a/app/views/catalog/_document.atom.builder b/app/views/catalog/_document.atom.builder index 7721ce365c..a2afb99cf8 100644 --- a/app/views/catalog/_document.atom.builder +++ b/app/views/catalog/_document.atom.builder @@ -20,9 +20,8 @@ xml.entry do with_format(:html) do xml.summary "type" => "html" do - xml.text! render_document_partials(document, - blacklight_config.view_config(:atom).summary_partials, - document_counter: document_counter) + document_component = blacklight_config.view_config(:atom).summary_component + xml.text! render document_component.new(presenter: document_presenter(document), component: :div, show: true) end end diff --git a/lib/blacklight/configuration.rb b/lib/blacklight/configuration.rb index 277b0954cc..92829d400c 100644 --- a/lib/blacklight/configuration.rb +++ b/lib/blacklight/configuration.rb @@ -115,7 +115,7 @@ def default_values atom: { if: false, # by default, atom should not show up as an alternative view partials: [:document], - summary_partials: [:index] + summary_component: Blacklight::DocumentComponent }, rss: { if: false, # by default, rss should not show up as an alternative view diff --git a/spec/views/catalog/index.atom.builder_spec.rb b/spec/views/catalog/index.atom.builder_spec.rb index eb0d4a7068..1e83fbb436 100644 --- a/spec/views/catalog/index.atom.builder_spec.rb +++ b/spec/views/catalog/index.atom.builder_spec.rb @@ -5,11 +5,11 @@ RSpec.describe "catalog/index" do let(:document_list) do 10.times.map do |i| - doc = SolrDocument.new(id: i) - allow(doc).to receive(:export_as_some_format).and_return("") - allow(doc).to receive(:to_semantic_values).and_return(author: ['xyz']) if i.zero? - doc.will_export_as(:some_format, "application/some-format") if i == 1 - doc + SolrDocument.new(id: i, title_tsim: "Title #{i}").tap do |doc| + allow(doc).to receive(:export_as_some_format).and_return("") + allow(doc).to receive(:to_semantic_values).and_return(author: ['xyz']) if i.zero? + doc.will_export_as(:some_format, "application/some-format") if i == 1 + end end end @@ -86,15 +86,22 @@ end it "has a summary" do - stub_template "catalog/_index.html.erb" => "partial content" render template: 'catalog/index', formats: [:atom] - expect(rendered).to have_selector("entry > summary", text: 'partial content') + expect(rendered).to have_selector("entry > summary", text: 'Title 0') end - context 'with a custom HTML partial' do + context 'with a custom template' do before do - blacklight_config.view.atom.summary_partials = ['whatever'] - stub_template 'catalog/_whatever_default.html.erb' => 'whatever content' + my_template = Class.new(ViewComponent::Base) do + def call + 'whatever content' + end + + def self.name + 'TestComponent' + end + end + blacklight_config.view.atom.summary_component = my_template end it "has the customized summary" do