blacklight 9.0.0.beta7 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/app/Dockerfile +2 -1
  3. data/.github/matrix.json +21 -20
  4. data/README.md +2 -2
  5. data/VERSION +1 -1
  6. data/app/assets/javascripts/blacklight/blacklight.esm.js +13 -7
  7. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  8. data/app/assets/javascripts/blacklight/blacklight.js +13 -7
  9. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  10. data/app/components/blacklight/advanced_search_form_component.rb +2 -1
  11. data/app/components/blacklight/document_component.rb +10 -13
  12. data/app/components/blacklight/facets/filters_component.rb +2 -2
  13. data/app/components/blacklight/facets/suggest_component.html.erb +17 -12
  14. data/app/components/blacklight/facets/suggest_component.rb +2 -3
  15. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  16. data/app/components/blacklight/metadata_field_component.rb +2 -1
  17. data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
  18. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  19. data/app/controllers/concerns/blacklight/catalog.rb +3 -4
  20. data/app/javascript/blacklight-frontend/checkbox_submit.js +2 -2
  21. data/app/javascript/blacklight-frontend/facet_suggest.js +4 -1
  22. data/app/javascript/blacklight-frontend/modal.js +7 -4
  23. data/app/presenters/blacklight/document_presenter.rb +6 -5
  24. data/app/presenters/blacklight/facet_field_presenter.rb +10 -3
  25. data/app/presenters/blacklight/field_presenter.rb +4 -2
  26. data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
  27. data/app/presenters/blacklight/rendering/join.rb +9 -5
  28. data/app/presenters/blacklight/rendering/terminator.rb +1 -1
  29. data/app/services/blacklight/search_service.rb +4 -2
  30. data/app/views/catalog/_show_main_content.html.erb +9 -5
  31. data/app/views/catalog/index.html.erb +0 -1
  32. data/app/views/catalog/show.html.erb +2 -2
  33. data/config/locales/blacklight.en.yml +1 -1
  34. data/lib/blacklight/component.rb +2 -0
  35. data/lib/blacklight/configuration/facet_field.rb +2 -0
  36. data/lib/blacklight/configuration/view_config.rb +30 -16
  37. data/lib/blacklight/configuration.rb +56 -9
  38. data/lib/blacklight/routes/searchable.rb +1 -1
  39. data/lib/blacklight/search_builder.rb +160 -1
  40. data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
  41. data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
  42. data/lib/blacklight/solr/repository.rb +5 -5
  43. data/lib/blacklight/solr/search_builder_behavior.rb +73 -7
  44. data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
  45. data/lib/generators/blacklight/templates/catalog_controller.rb +27 -5
  46. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -67
  47. data/package.json +1 -1
  48. data/spec/components/blacklight/document_component_spec.rb +0 -7
  49. data/spec/components/blacklight/facets/filters_component_spec.rb +3 -3
  50. data/spec/components/blacklight/facets/suggest_component_spec.rb +14 -1
  51. data/spec/components/blacklight/search_bar_component_spec.rb +24 -1
  52. data/spec/controllers/blacklight/catalog_spec.rb +1 -1
  53. data/spec/features/advanced_search_spec.rb +39 -20
  54. data/spec/features/facets_spec.rb +9 -0
  55. data/spec/models/blacklight/configuration_spec.rb +126 -0
  56. data/spec/models/blacklight/search_builder_spec.rb +11 -1
  57. data/spec/models/blacklight/solr/repository_spec.rb +6 -0
  58. data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +214 -8
  59. data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
  60. data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
  61. data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
  62. metadata +8 -16
  63. data/app/controllers/concerns/blacklight/facetable.rb +0 -34
  64. data/app/models/facet_search_builder.rb +0 -5
  65. data/app/services/blacklight/facet_search_service.rb +0 -44
  66. data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
  67. data/lib/blacklight/abstract_search_builder.rb +0 -154
  68. data/lib/blacklight/facet_search_builder.rb +0 -18
  69. data/lib/blacklight/solr/facet_search_builder_behavior.rb +0 -62
  70. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  71. data/spec/models/blacklight/facet_search_builder_spec.rb +0 -19
  72. data/spec/models/blacklight/solr/facet_search_builder_behavior_spec.rb +0 -929
@@ -34,27 +34,24 @@ module Blacklight
34
34
 
35
35
  # The document title with some reasonable default behavior
36
36
  renders_one :title, (lambda do |component: nil, **kwargs|
37
- component ||= view_config.title_component || Blacklight::DocumentTitleComponent
37
+ component ||= view_config.document_title_component
38
38
 
39
- component.new(counter: @counter, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
39
+ component&.new(counter: @counter, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
40
40
  end)
41
41
 
42
42
  renders_one :embed, (lambda do |static_content = nil, component: nil, **kwargs|
43
43
  next static_content if static_content.present?
44
44
 
45
- component ||= view_config.embed_component
46
-
47
- next unless component
48
-
49
- component.new(presenter: @presenter, document_counter: @document_counter, **kwargs)
45
+ component ||= view_config.document_embed_component
46
+ component&.new(presenter: @presenter, document_counter: @document_counter, **kwargs)
50
47
  end)
51
48
 
52
49
  # The primary metadata section
53
50
  renders_one :metadata, (lambda do |static_content = nil, component: nil, fields: nil, **kwargs|
54
51
  next static_content if static_content.present?
55
52
 
56
- component ||= view_config.metadata_component || Blacklight::DocumentMetadataComponent
57
- component.new(fields: fields || @presenter&.field_presenters || [], **kwargs)
53
+ component ||= view_config.document_metadata_component
54
+ component&.new(fields: fields || @presenter&.field_presenters || [], **kwargs)
58
55
  end)
59
56
 
60
57
  # Additional metadata sections
@@ -63,9 +60,9 @@ module Blacklight
63
60
  renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, component: nil, **kwargs|
64
61
  next image_options_or_static_content if image_options_or_static_content.is_a? String
65
62
 
66
- component ||= view_config.thumbnail_component || Blacklight::Document::ThumbnailComponent
63
+ component ||= view_config.document_thumbnail_component
67
64
 
68
- component.new(presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
65
+ component&.new(presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
69
66
  end)
70
67
 
71
68
  # A container for partials rendered using the view config partials configuration. Its use is discouraged, but necessary until
@@ -96,7 +93,7 @@ module Blacklight
96
93
 
97
94
  @component = component
98
95
  @title_component = title_component
99
- @id = id || ('document' if show)
96
+ @id = id
100
97
  @classes = classes
101
98
 
102
99
  @counter = counter
@@ -119,7 +116,7 @@ module Blacklight
119
116
 
120
117
  def before_render
121
118
  with_title unless title
122
- with_thumbnail unless thumbnail || show?
119
+ with_thumbnail unless thumbnail
123
120
  with_metadata(fields: presenter.field_presenters, show: @show) unless metadata
124
121
  with_embed unless embed
125
122
 
@@ -3,7 +3,7 @@
3
3
  module Blacklight::Facets
4
4
  class FiltersComponent < Blacklight::Component
5
5
  # @param [Blacklight::FacetFieldPresenter] presenter
6
- def initialize(presenter:, classes: 'facet-filters card card-body bg-light p-3 mb-3 border-0',
6
+ def initialize(presenter:, classes: 'facet-filters mt-1 mb-3',
7
7
  suggestions_component: Blacklight::Facets::SuggestComponent,
8
8
  index_navigation_component: Blacklight::Facets::IndexNavigationComponent)
9
9
  @presenter = presenter
@@ -21,7 +21,7 @@ module Blacklight::Facets
21
21
  delegate :display_facet, to: :presenter
22
22
 
23
23
  def render?
24
- facet.suggest != false || render_index_navigation?
24
+ presenter.suggest? || render_index_navigation?
25
25
  end
26
26
 
27
27
  def render_index_navigation?
@@ -1,12 +1,17 @@
1
- <label class="form-label" for="facet_suggest_<%= key %>">
2
- <%= I18n.t('blacklight.search.facets.suggest.label', field_label: label) %>
3
- </label>
4
- <%= text_field_tag "facet_suggest_#{key}",
5
- nil,
6
- class: "facet-suggest form-control mb-3",
7
- data: {
8
- facet_field: key,
9
- facet_search_context: helpers.search_facet_path(id: key)
10
- },
11
- placeholder: I18n.t('blacklight.search.form.search.placeholder')
12
- %>
1
+ <div class="input-group">
2
+ <label class="input-group-text" for="facet_suggest_<%= key %>">
3
+ <%= I18n.t('blacklight.search.facets.suggest.label', field_label: label.downcase.pluralize) %>
4
+ </label>
5
+ <%= search_field_tag "facet_suggest_#{key}",
6
+ nil,
7
+ class: "facet-suggest form-control",
8
+ data: {
9
+ facet_field: key,
10
+ facet_search_context: helpers.search_facet_path(id: key)
11
+ },
12
+ placeholder: I18n.t('blacklight.search.facets.suggest.placeholder')
13
+ %>
14
+ <span class="input-group-text">
15
+ <%= render Blacklight::Icons::SearchComponent.new %>
16
+ </span>
17
+ </div>
@@ -11,11 +11,10 @@ module Blacklight
11
11
 
12
12
  attr_accessor :presenter
13
13
 
14
- delegate :suggest, :key, :label, to: :presenter
14
+ delegate :key, :label, to: :presenter
15
15
 
16
16
  def render?
17
- # Draw if suggest is true or not present
18
- suggest != false
17
+ presenter.suggest?
19
18
  end
20
19
  end
21
20
  end
@@ -2,7 +2,7 @@
2
2
  <% component.with_label do %>
3
3
  <%= label %>
4
4
  <% end %>
5
- <% component.with_value do %>
6
- <%= render_field %>
5
+ <% render_field_values.each_with_index do |value, index| %>
6
+ <% component.with_value(value: value, index: index) %>
7
7
  <% end %>
8
8
  <% end %>
@@ -27,7 +27,8 @@ module Blacklight
27
27
  end
28
28
 
29
29
  # Override this method in a subclass to change the way this value is rendered
30
- def render_field
30
+ # @return [Array]
31
+ def render_field_values
31
32
  @field.render
32
33
  end
33
34
 
@@ -4,23 +4,28 @@ module Blacklight
4
4
  class MetadataFieldLayoutComponent < Blacklight::Component
5
5
  with_collection_parameter :field
6
6
  renders_one :label
7
- renders_many :values, (lambda do |value: nil, &block|
7
+ renders_many :values, (lambda do |index:, value: nil, &block|
8
+ classes = [@value_class, "blacklight-#{@key}"]
9
+ classes.unshift @offset_class unless index.zero?
10
+ classes.join(' ')
11
+
8
12
  if @value_tag.nil?
9
13
  block&.call || value
10
14
  elsif block
11
- content_tag @value_tag, class: "#{@value_class} blacklight-#{@key}", &block
15
+ content_tag @value_tag, class: classes, &block
12
16
  else
13
- content_tag @value_tag, value, class: "#{@value_class} blacklight-#{@key}"
17
+ content_tag @value_tag, value, class: classes
14
18
  end
15
19
  end)
16
20
 
17
21
  # @param field [Blacklight::FieldPresenter]
18
- def initialize(field:, value_tag: 'dd', label_class: 'col-md-3', value_class: 'col-md-9')
22
+ def initialize(field:, value_tag: 'dd', label_class: 'col-md-3', value_class: 'col-md-9', offset_class: 'offset-md-3')
19
23
  @field = field
20
24
  @key = @field.key.parameterize
21
25
  @label_class = label_class
22
26
  @value_tag = value_tag
23
27
  @value_class = value_class
28
+ @offset_class = offset_class
24
29
  end
25
30
  end
26
31
  end
@@ -36,6 +36,6 @@
36
36
  <% end %>
37
37
 
38
38
  <% if advanced_search_enabled? %>
39
- <%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-secondary'%>
39
+ <%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-link text-body' %>
40
40
  <% end %>
41
41
  </search>
@@ -9,7 +9,6 @@ module Blacklight::Catalog
9
9
  include Blacklight::Configurable
10
10
  include Blacklight::SearchContext
11
11
  include Blacklight::Searchable
12
- include Blacklight::Facetable
13
12
 
14
13
  # The following code is executed when someone includes blacklight::catalog in their
15
14
  # own controller.
@@ -82,11 +81,11 @@ module Blacklight::Catalog
82
81
  raise ActionController::RoutingError, 'Not Found' unless @facet
83
82
 
84
83
  @response = if params[:query_fragment].present?
85
- facet_search_service.facet_suggest_response(@facet.key, params[:query_fragment])
84
+ search_service.facet_suggest_response(@facet.key, params[:query_fragment])
86
85
  else
87
- facet_search_service.facet_field_response(@facet.key)
86
+ search_service.facet_field_response(@facet.key)
88
87
  end
89
-
88
+ # @display_facet is a Blacklight::Solr::Response::Facets::FacetField
90
89
  @display_facet = @response.aggregations[@facet.field]
91
90
 
92
91
  # @presenter is a Blacklight::FacetFieldPresenter
@@ -10,7 +10,7 @@
10
10
  attribute (HTML5-style doc-*) that contains the id/primary key
11
11
  of the object in question -- used by plugin for a unique value for
12
12
  DOM id's.
13
- Uses HTML for a checkbox compatible with Bootstrap 4.
13
+ Uses HTML for a checkbox compatible with Bootstrap.
14
14
  new CheckboxSubmit(document.querySelector('form.something')).render()
15
15
  */
16
16
  export default class CheckboxSubmit {
@@ -36,7 +36,7 @@ export default class CheckboxSubmit {
36
36
  }).then((json) => {
37
37
  this.labelTarget.removeAttribute('disabled')
38
38
  this.checkboxTarget.removeAttribute('disabled')
39
- // For accessibility return keyboard focus
39
+ // For accessibility return keyboard focus
40
40
  // back to the checkbox after form submission
41
41
  this.checkboxTarget.focus()
42
42
  this.updateStateFor(!this.checked)
@@ -16,10 +16,13 @@ const FacetSuggest = async (e) => {
16
16
 
17
17
  // Drop facet.page so a filtered suggestion list will always start on page 1
18
18
  url.searchParams.delete('facet.page');
19
+ // add our queryFragment for facet filtering
20
+ url.searchParams.append('query_fragment', queryFragment);
21
+
19
22
  const facetSearchParams = url.searchParams.toString();
20
23
  const basePathComponent = url.pathname.split('/')[1];
21
24
 
22
- const urlToFetch = `/${basePathComponent}/facet_suggest/${facetField}/${queryFragment}?${facetSearchParams}`;
25
+ const urlToFetch = `/${basePathComponent}/facet_suggest/${facetField}?${facetSearchParams}`;
23
26
 
24
27
  const response = await fetch(urlToFetch);
25
28
  if (response.ok) {
@@ -160,11 +160,14 @@ const Modal = (() => {
160
160
 
161
161
  // Make sure user-agent dismissal of html 'dialog', etc `esc` key, triggers
162
162
  // our hide logic, including events and scroll restoration.
163
- modal.target().addEventListener('cancel', (e) => {
164
- e.preventDefault(); // 'hide' will close the modal unless cancelled
163
+ const modalDom = modal.target();
164
+ if (modalDom) {
165
+ modal.target().addEventListener('cancel', (e) => {
166
+ e.preventDefault(); // 'hide' will close the modal unless cancelled
165
167
 
166
- modal.hide();
167
- });
168
+ modal.hide();
169
+ });
170
+ }
168
171
  };
169
172
 
170
173
  modal.hide = function (el) {
@@ -44,11 +44,11 @@ module Blacklight
44
44
  #
45
45
  # @return [String]
46
46
  def heading
47
- return field_value(view_config.title_field) if view_config.title_field.is_a? Blacklight::Configuration::Field
47
+ return field_value(view_config.title_field, join: true).first if view_config.title_field.is_a? Blacklight::Configuration::Field
48
48
 
49
49
  fields = Array.wrap(view_config.title_field) + [configuration.document_model.unique_key]
50
50
  f = fields.lazy.map { |field| field_config(field) }.detect { |field_config| field_presenter(field_config).any? }
51
- f ? field_value(f, except_operations: [Rendering::HelperMethod]) : ""
51
+ f ? field_value(f, except_operations: [Rendering::HelperMethod], join: true).first : ""
52
52
  end
53
53
 
54
54
  ##
@@ -58,12 +58,12 @@ module Blacklight
58
58
  # @see #document_heading
59
59
  # @return [String]
60
60
  def html_title
61
- return field_value(view_config.html_title_field) if view_config.html_title_field.is_a? Blacklight::Configuration::Field
61
+ return field_value(view_config.html_title_field, join: true).first if view_config.html_title_field.is_a? Blacklight::Configuration::Field
62
62
 
63
63
  if view_config.html_title_field
64
64
  fields = Array.wrap(view_config.html_title_field) + [configuration.document_model.unique_key]
65
65
  f = fields.lazy.map { |field| field_config(field) }.detect { |field_config| field_presenter(field_config).any? }
66
- field_value(f)
66
+ field_value(f, join: true).first
67
67
  else
68
68
  heading
69
69
  end
@@ -93,8 +93,9 @@ module Blacklight
93
93
  # @param [Configuration::Field] field_config
94
94
  # @param [Hash] options
95
95
  # @option options [String] :value
96
+ # @return [Array]
96
97
  def field_value field_config, options = {}
97
- field_presenter(field_config, options).render
98
+ Array.wrap(field_presenter(field_config, options).render)
98
99
  end
99
100
 
100
101
  def thumbnail_presenter_class
@@ -4,18 +4,18 @@ module Blacklight
4
4
  class FacetFieldPresenter
5
5
  attr_reader :facet_field, :display_facet, :view_context, :search_state
6
6
 
7
- delegate :key, :suggest, to: :facet_field
7
+ delegate :key, to: :facet_field
8
8
  delegate :field_name, to: :display_facet
9
9
 
10
10
  # @param [Blacklight::Configuration::FacetField] facet_field
11
11
  # @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
12
12
  # @param [#search_action_path,#facet_field_presenter] view_context
13
13
  # @param [Blacklight::SearchState] search_state
14
- def initialize(facet_field, display_facet, view_context, search_state = view_context.search_state)
14
+ def initialize(facet_field, display_facet, view_context, search_state = nil)
15
15
  @facet_field = facet_field
16
16
  @display_facet = display_facet
17
17
  @view_context = view_context
18
- @search_state = search_state
18
+ @search_state = search_state || view_context&.search_state
19
19
  end
20
20
 
21
21
  # @param [Blacklight::Solr::Response::Facets::FacetItem, String] facet_item
@@ -23,6 +23,13 @@ module Blacklight
23
23
  facet_field.item_presenter.new(facet_item, facet_field, view_context, key, search_state)
24
24
  end
25
25
 
26
+ # Is facet suggest feature configured on for this facet, or by global default.
27
+ #
28
+ # @return [Boolean]
29
+ def suggest?
30
+ !!(facet_field.suggest.nil? ? blacklight_config.default_facet_suggest : facet_field.suggest)
31
+ end
32
+
26
33
  def collapsed?
27
34
  !active? && facet_field.collapse
28
35
  end
@@ -33,9 +33,11 @@ module Blacklight
33
33
 
34
34
  delegate :key, :component, to: :field_config
35
35
 
36
- # @return [String]
36
+ # @return [Array<String>]
37
37
  def render
38
- Rendering::Pipeline.new(values, field_config, document, view_context, pipeline_steps, options).render
38
+ Array.wrap(
39
+ Rendering::Pipeline.new(values, field_config, document, view_context, pipeline_steps, options).render
40
+ )
39
41
  end
40
42
 
41
43
  # @return [Enumerable]
@@ -22,7 +22,13 @@ module Blacklight
22
22
  end
23
23
 
24
24
  def html?
25
- options[:format].nil? || options[:format].to_s == 'html'
25
+ format.nil? || format.to_s == 'html'
26
+ end
27
+
28
+ def format
29
+ return options[:format] unless context.respond_to?(:search_state)
30
+
31
+ options[:format] || context.search_state&.params&.dig(:format)
26
32
  end
27
33
  end
28
34
  end
@@ -5,12 +5,11 @@ module Blacklight
5
5
  class Join < AbstractStep
6
6
  def render
7
7
  options = config.separator_options || {}
8
- if values.one? || values.none?
9
- next_step(values.first)
10
- elsif !html?
11
- next_step(values.to_sentence(options))
12
- else
8
+
9
+ if join? && html? && values.many?
13
10
  next_step(values.map { |x| x.html_safe? ? x : html_escape(x) }.to_sentence(options).html_safe)
11
+ else
12
+ next_step(values)
14
13
  end
15
14
  end
16
15
 
@@ -19,6 +18,11 @@ module Blacklight
19
18
  def html_escape(*)
20
19
  ERB::Util.html_escape(*)
21
20
  end
21
+
22
+ # @return [Boolean]
23
+ def join?
24
+ options[:join] || config.join || config.separator_options
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -4,7 +4,7 @@ module Blacklight
4
4
  module Rendering
5
5
  class Terminator < AbstractStep
6
6
  def render
7
- values
7
+ Array.wrap values
8
8
  end
9
9
  end
10
10
  end
@@ -22,8 +22,10 @@ module Blacklight
22
22
  @search_state.class
23
23
  end
24
24
 
25
- # a solr query method
26
- # @yield [search_builder] optional block yields configured SearchBuilder, caller can modify or create new SearchBuilder to be used. Block should return SearchBuilder to be used.
25
+ # Fetch query results from solr
26
+ # @yield [search_builder] optional block yields configured SearchBuilder, caller can modify or create new
27
+ # SearchBuilder to be used. Block should return SearchBuilder to be used.
28
+ # This is used in blacklight_range_limit
27
29
  # @return [Blacklight::Solr::Response] the solr response object
28
30
  def search_results
29
31
  builder = search_builder.with(search_state)
@@ -1,14 +1,18 @@
1
- <%= render blacklight_config.view_config(:show).document_header_component.new(document: @document, search_context: @search_context, search_session: search_session) %>
2
- <% @page_title = t('blacklight.search.show.title', document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %>
1
+ <%# locals: (presenter: nil) %>
2
+ <% presenter ||= document_presenter(@document) %>
3
+
4
+ <% @page_title = t('blacklight.search.show.title', document_title: presenter.html_title, application_name: application_name).html_safe %>
3
5
  <% content_for(:head) { render_link_rel_alternates } %>
4
6
 
5
- <% document_component = blacklight_config.view_config(:show).document_component -%>
6
- <%= render document_component.new(document: document_presenter(@document), component: :div, show: true, partials: blacklight_config.view_config(:show).partials) do |component| %>
7
+ <%= render presenter.view_config.document_header_component.new(document: @document, search_context: @search_context, search_session: search_session) %>
8
+
9
+ <% document_component = presenter.view_config.document_component -%>
10
+ <%= render document_component.new(id: 'document', document: presenter, component: :div, show: true, partials: presenter.view_config.partials) do |component| %>
7
11
  <% component.with_title(as: 'h1', classes: '', link_to_document: false, actions: false) %>
8
12
  <% component.with_footer do %>
9
13
  <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
10
14
  <!-- COinS, for Zotero among others. -->
11
- <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(document_presenter(@document).display_type) %>"></span>
15
+ <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(presenter.display_type) %>"></span>
12
16
  <% end %>
13
17
  <% end %>
14
18
  <% end %>
@@ -11,7 +11,6 @@
11
11
  <% unless has_search_parameters? %>
12
12
  <%# if there are no input/search related params, display the "home" partial -%>
13
13
  <%= render 'home' %>
14
- <%= render 'shared/sitelinks_search_box' %>
15
14
  <% else %>
16
15
  <%= render 'search_results' %>
17
16
  <% end %>
@@ -1,6 +1,6 @@
1
- <%= render 'show_main_content' %>
1
+ <% presenter = document_presenter(@document) %>
2
+ <%= render 'show_main_content', presenter: presenter %>
2
3
 
3
4
  <% content_for(:sidebar) do %>
4
- <% presenter = document_presenter(@document) %>
5
5
  <%= render presenter.view_config.sidebar_component.new(presenter: presenter) %>
6
6
  <% end %>
@@ -11,7 +11,7 @@ en:
11
11
  sort_label: Sort results by
12
12
  start_over_html: Start over
13
13
  title: Advanced search
14
- more_options: More options
14
+ more_options: Advanced search
15
15
  op:
16
16
  label: search operator
17
17
  must: all
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'view_component/version'
4
+
3
5
  module Blacklight
4
6
  class Component < ViewComponent::Base
5
7
  class << self
@@ -16,6 +16,8 @@ module Blacklight
16
16
  # @return [Boolean] whether to show the facet to the user or not (very similar to the more generic if/unless)
17
17
  # @!attribute index_range
18
18
  # @return [Enumerable] a list of facet prefixes (default: A-Z) to allow users to 'jump' to particular values
19
+ # @!attribute suggest
20
+ # @return [Boolean] whether to display a suggest/autocomplete on the detailed facet view that allows users to filter facet values
19
21
  # @!attribute date
20
22
  # @return [Symbol|Hash] the i18n localization option for a date or time value; used as the second parameter for the I18n.l method
21
23
  # @!attribute link_to_facet
@@ -8,6 +8,14 @@ class Blacklight::Configuration
8
8
  # @return [Class] document presenter class used by helpers and views
9
9
  # @!attribute document_component
10
10
  # @return [Class] component class used to render a document; defaults to Blacklight::DocumentComponent
11
+ # @!attribute document_title_component
12
+ # @return [Class] component class used to render a document title
13
+ # @!attribute document_metadata_component
14
+ # @return [Class] component class used to render the document metadata
15
+ # @!attribute document_thumbnail_component
16
+ # @return [Class] component class used to render a document thumbnail
17
+ # @!attribute document_embed_component
18
+ # @return [Class] component class used to render a document embed
11
19
  # @!attribute title_field
12
20
  # @return [String, Symbol] solr field to use to render a document title
13
21
  # @!attribute display_type_field
@@ -46,19 +54,33 @@ class Blacklight::Configuration
46
54
  end
47
55
  end
48
56
 
57
+ # Provide backwards compatibility with the configuration keys without the document_ prefix
58
+ def title_component(*) = document_title_component(*)
59
+ def metadata_component(*) = document_metadata_component(*)
60
+ def thumbnail_component(*) = document_thumbnail_component(*)
61
+ def embed_component(*) = document_embed_component(*)
62
+
63
+ def title_component=(value)
64
+ self.document_title_component = value
65
+ end
66
+
67
+ def metadata_component=(value)
68
+ self.document_metadata_component = value
69
+ end
70
+
71
+ def thumbnail_component=(value)
72
+ self.document_thumbnail_component = value
73
+ end
74
+
75
+ def embed_component=(value)
76
+ self.document_embed_component = value
77
+ end
78
+
49
79
  class Show < ViewConfig
50
80
  # @!attribute route
51
81
  # @return [Hash] Default route parameters for 'show' requests.
52
82
  # Set this to a hash with additional arguments to merge into the route,
53
83
  # or set `controller: :current` to route to the current controller.
54
-
55
- def document_presenter_class
56
- super || Blacklight::ShowPresenter
57
- end
58
-
59
- def to_h
60
- super.merge(document_presenter_class: document_presenter_class)
61
- end
62
84
  end
63
85
 
64
86
  class Index < ViewConfig
@@ -69,14 +91,6 @@ class Blacklight::Configuration
69
91
  # see Blacklight::Catalog#additional_response_formats for information about the OpenStruct data
70
92
  # @!attribute collection_actions
71
93
  # @return [String, Symbol]
72
-
73
- def document_presenter_class
74
- super || Blacklight::IndexPresenter
75
- end
76
-
77
- def to_h
78
- super.merge(document_presenter_class: document_presenter_class)
79
- end
80
94
  end
81
95
  end
82
96
  end