blacklight 9.0.0.beta6 → 9.0.0.beta8

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/app/Dockerfile +2 -1
  3. data/.github/matrix.json +21 -3
  4. data/.solr_wrapper.yml +1 -1
  5. data/VERSION +1 -1
  6. data/app/assets/javascripts/blacklight/blacklight.esm.js +9 -5
  7. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  8. data/app/assets/javascripts/blacklight/blacklight.js +9 -5
  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/constraints_component.html.erb +3 -8
  12. data/app/components/blacklight/constraints_component.rb +57 -14
  13. data/app/components/blacklight/document/bookmark_component.rb +1 -1
  14. data/app/components/blacklight/document/page_header_component.rb +1 -1
  15. data/app/components/blacklight/document_component.rb +20 -24
  16. data/app/components/blacklight/facet_item_pivot_component.rb +4 -0
  17. data/app/components/blacklight/facets/filters_component.rb +1 -1
  18. data/app/components/blacklight/facets/item_component.rb +3 -0
  19. data/app/components/blacklight/facets/selected_value_component.rb +1 -1
  20. data/app/components/blacklight/facets/suggest_component.rb +2 -3
  21. data/app/components/blacklight/header_component.rb +2 -2
  22. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  23. data/app/components/blacklight/metadata_field_component.rb +2 -1
  24. data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
  25. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  26. data/app/controllers/concerns/blacklight/catalog.rb +8 -4
  27. data/app/javascript/blacklight-frontend/facet_suggest.js +2 -1
  28. data/app/javascript/blacklight-frontend/modal.js +7 -4
  29. data/app/presenters/blacklight/constraint_presenter.rb +22 -0
  30. data/app/presenters/blacklight/document_presenter.rb +6 -5
  31. data/app/presenters/blacklight/facet_field_presenter.rb +10 -3
  32. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
  33. data/app/presenters/blacklight/facet_item_presenter.rb +0 -18
  34. data/app/presenters/blacklight/field_presenter.rb +4 -2
  35. data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
  36. data/app/presenters/blacklight/rendering/join.rb +9 -5
  37. data/app/presenters/blacklight/rendering/terminator.rb +1 -1
  38. data/app/views/catalog/_document.atom.builder +1 -1
  39. data/app/views/catalog/_document.html.erb +1 -1
  40. data/app/views/catalog/_show_main_content.html.erb +9 -5
  41. data/app/views/catalog/index.html.erb +0 -1
  42. data/app/views/catalog/show.html.erb +2 -2
  43. data/blacklight.gemspec +1 -1
  44. data/config/locales/blacklight.ar.yml +1 -2
  45. data/config/locales/blacklight.ca.yml +1 -2
  46. data/config/locales/blacklight.de.yml +1 -2
  47. data/config/locales/blacklight.en.yml +2 -3
  48. data/config/locales/blacklight.es.yml +1 -2
  49. data/config/locales/blacklight.fr.yml +1 -2
  50. data/config/locales/blacklight.hu.yml +1 -2
  51. data/config/locales/blacklight.it.yml +1 -2
  52. data/config/locales/blacklight.nl.yml +1 -2
  53. data/config/locales/blacklight.pt-BR.yml +1 -2
  54. data/config/locales/blacklight.sq.yml +1 -2
  55. data/config/locales/blacklight.zh.yml +1 -2
  56. data/lib/blacklight/component.rb +7 -1
  57. data/lib/blacklight/configuration/facet_field.rb +4 -0
  58. data/lib/blacklight/configuration/view_config.rb +30 -16
  59. data/lib/blacklight/configuration.rb +58 -5
  60. data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
  61. data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
  62. data/lib/blacklight/solr/repository.rb +5 -5
  63. data/lib/blacklight/solr/search_builder_behavior.rb +19 -2
  64. data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
  65. data/lib/generators/blacklight/templates/.solr_wrapper.yml +1 -1
  66. data/lib/generators/blacklight/templates/catalog_controller.rb +26 -4
  67. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -67
  68. data/package.json +1 -1
  69. data/spec/components/blacklight/constraints_component_spec.rb +2 -2
  70. data/spec/components/blacklight/document_component_spec.rb +8 -15
  71. data/spec/components/blacklight/facets/filters_component_spec.rb +2 -2
  72. data/spec/components/blacklight/facets/index_navigation_component_spec.rb +2 -1
  73. data/spec/components/blacklight/facets/suggest_component_spec.rb +15 -1
  74. data/spec/components/blacklight/search_bar_component_spec.rb +24 -1
  75. data/spec/controllers/blacklight/catalog_spec.rb +1 -1
  76. data/spec/features/advanced_search_spec.rb +39 -20
  77. data/spec/features/search_filters_spec.rb +3 -3
  78. data/spec/features/search_spec.rb +3 -3
  79. data/spec/models/blacklight/configuration_spec.rb +126 -0
  80. data/spec/models/blacklight/solr/repository_spec.rb +6 -0
  81. data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +52 -6
  82. data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
  83. data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
  84. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
  85. data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
  86. data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
  87. data/spec/support/presenter_test_helpers.rb +1 -1
  88. data/spec/views/catalog/index.atom.builder_spec.rb +2 -0
  89. metadata +18 -10
  90. data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
  91. data/spec/features/sitelinks_search_box_spec.rb +0 -13
@@ -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
@@ -21,7 +21,7 @@ xml.entry do
21
21
  with_format(:html) do
22
22
  xml.summary "type" => "html" do
23
23
  document_component = blacklight_config.view_config(:atom).summary_component
24
- xml.text! render document_component.new(document_component.collection_parameter => document_presenter(document), component: :div, show: true)
24
+ xml.text! render document_component.new(document: document_presenter(document), component: :div, show: true)
25
25
  end
26
26
  end
27
27
 
@@ -1,4 +1,4 @@
1
1
  <% # container for a single doc -%>
2
2
  <% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type, action_name: action_name) %>
3
3
  <% document_component = view_config.document_component -%>
4
- <%= render document_component.new(document_component.collection_parameter => document_presenter(document), counter: document_counter_with_offset(document_counter), partials: view_config&.partials) %>
4
+ <%= render document_component.new(document: document_presenter(document), counter: document_counter_with_offset(document_counter), partials: view_config&.partials) %>
@@ -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_component.collection_parameter => 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 %>
data/blacklight.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
32
32
  s.add_dependency "i18n", '>= 1.7.0' # added named parameters
33
33
  s.add_dependency "ostruct", '>= 0.3.2'
34
- s.add_dependency "view_component", '~> 3.9'
34
+ s.add_dependency "view_component", '>= 3.0', '< 5.0'
35
35
  s.add_dependency "zeitwerk"
36
36
 
37
37
  s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
@@ -120,7 +120,7 @@ ar:
120
120
  remove:
121
121
  label_value: "إزالة القيد %{label}: %{value}"
122
122
  value: إزالة القيد %{value}
123
- title: "لقد بحثت عن:"
123
+ title: "اختياراتك:"
124
124
  form:
125
125
  search:
126
126
  label: ابحث عن
@@ -160,7 +160,6 @@ ar:
160
160
  submit: تحديث
161
161
  title: عدد النتائج المعروضة في الصفحة
162
162
  rss_feed: خلاصات RSS للنتائج
163
- search_constraints_header: قيود البحث
164
163
  search_results: نتائج البحث
165
164
  show:
166
165
  label: "%{label}:"
@@ -136,7 +136,6 @@ ca:
136
136
  many_constraint_values: "%{values} seleccionat"
137
137
  joiner: " / "
138
138
  header: "Cerca"
139
- search_constraints_header: "Filtres de la cerca"
140
139
  search_results: "Resultats de la cerca"
141
140
  errors:
142
141
  invalid_solr_id: "El registre que heu sol·licitat no existeix."
@@ -194,7 +193,7 @@ ca:
194
193
  group:
195
194
  more: "més »"
196
195
  filters:
197
- title: "Heu cercat per:"
196
+ title: "Les teves seleccions:"
198
197
  label: "%{label}:"
199
198
  remove:
200
199
  value: "Eliminar el filtre %{value}"
@@ -111,7 +111,7 @@ de:
111
111
  remove:
112
112
  label_value: "Filter %{label}: %{value} entfernen"
113
113
  value: Filter %{value} entfernen
114
- title: "Sie suchten nach:"
114
+ title: "Ihre Auswahl:"
115
115
  form:
116
116
  search:
117
117
  label: suchen nach
@@ -147,7 +147,6 @@ de:
147
147
  submit: Aktualisieren
148
148
  title: Anzahl der Ergebnisse, die pro Seite angezeigt werden
149
149
  rss_feed: RSS für Ergebnisse
150
- search_constraints_header: Suchen
151
150
  search_results: Suchergebnisse
152
151
  show:
153
152
  label: "%{label}:"
@@ -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
@@ -129,7 +129,7 @@ en:
129
129
  remove:
130
130
  label_value: "Remove constraint %{label}: %{value}"
131
131
  value: Remove constraint %{value}
132
- title: "You searched for:"
132
+ title: "Your selections:"
133
133
  form:
134
134
  search:
135
135
  label: search for
@@ -165,7 +165,6 @@ en:
165
165
  submit: Update
166
166
  title: Number of results to display per page
167
167
  rss_feed: RSS for results
168
- search_constraints_header: Search Constraints
169
168
  search_results: Search Results
170
169
  show:
171
170
  label: "%{label}:"
@@ -110,7 +110,7 @@ es:
110
110
  remove:
111
111
  label_value: "Eliminar la restricción%{label}: %{value}"
112
112
  value: Eliminar la restricción %{value}
113
- title: "Usted ha buscado:"
113
+ title: "Tus selecciones:"
114
114
  form:
115
115
  search:
116
116
  label: buscar
@@ -146,7 +146,6 @@ es:
146
146
  submit: Actualización
147
147
  title: El número de resultados a mostrar por página
148
148
  rss_feed: RSS de los resultados
149
- search_constraints_header: Buscar
150
149
  search_results: Resultados de la búsqueda
151
150
  show:
152
151
  label: "%{label}:"
@@ -110,7 +110,7 @@ fr:
110
110
  remove:
111
111
  label_value: "Supprimer la restriction %{label}: %{value}"
112
112
  value: Supprimer la restriction %{value}
113
- title: "Vous avez demandé :"
113
+ title: "Vos sélections:"
114
114
  form:
115
115
  search:
116
116
  label: Rechercher
@@ -146,7 +146,6 @@ fr:
146
146
  submit: mettre à jour
147
147
  title: Nombre de résultats à afficher par page
148
148
  rss_feed: RSS pour les résultats
149
- search_constraints_header: Recherche
150
149
  search_results: Résultats de recherche
151
150
  show:
152
151
  label: "%{label}:"
@@ -108,7 +108,7 @@ hu:
108
108
  remove:
109
109
  label_value: "Feltétel eltávolítása %{label}: %{value}"
110
110
  value: Feltételek eltávolítása %{value}
111
- title: "Ön ezt kereste:"
111
+ title: "Az Ön választása:"
112
112
  form:
113
113
  search:
114
114
  label: keresés
@@ -144,7 +144,6 @@ hu:
144
144
  submit: Frissítés
145
145
  title: Az eredmények száma oldalanként
146
146
  rss_feed: Eredmények RSS-ként
147
- search_constraints_header: Keresés feltételei
148
147
  search_results: Keresés eredményei
149
148
  show:
150
149
  label: "%{label}:"
@@ -111,7 +111,7 @@ it:
111
111
  remove:
112
112
  label_value: "Cancella il filtro %{label}: %{value}"
113
113
  value: Cancella il filtro %{value}
114
- title: "Hai cercato per:"
114
+ title: "Le tue selezioni:"
115
115
  form:
116
116
  search:
117
117
  label: cerca per
@@ -147,7 +147,6 @@ it:
147
147
  submit: Aggiorna
148
148
  title: Risultati per pagina
149
149
  rss_feed: RSS per i risultati
150
- search_constraints_header: Ricerca
151
150
  search_results: Risultati della ricerca
152
151
  show:
153
152
  label: "%{label}:"
@@ -108,7 +108,7 @@ nl:
108
108
  remove:
109
109
  label_value: "Verwijder zoekfilter %{label}: %{value}"
110
110
  value: Verwijder zoekfilter %{value}
111
- title: "U zocht op:"
111
+ title: "Uw selecties:"
112
112
  form:
113
113
  search:
114
114
  label: zoeken op
@@ -144,7 +144,6 @@ nl:
144
144
  submit: Update
145
145
  title: Toon aantal zoekresultaten per pagina
146
146
  rss_feed: RSS voor zoekresultaten
147
- search_constraints_header: Zoek filters
148
147
  search_results: Zoek resultaten
149
148
  show:
150
149
  label: "%{label}:"
@@ -109,7 +109,7 @@ pt-BR:
109
109
  remove:
110
110
  label_value: "Remover %{label}: %{value}"
111
111
  value: Remover filtro %{value}
112
- title: "Sua busca por:"
112
+ title: "Suas seleções:"
113
113
  form:
114
114
  search:
115
115
  label: busca
@@ -145,7 +145,6 @@ pt-BR:
145
145
  submit: Atualizar
146
146
  title: Número de resultados para mostrar por página
147
147
  rss_feed: RSS para resultadoss
148
- search_constraints_header: Busca
149
148
  search_results: Resultados da Busca
150
149
  show:
151
150
  label: "%{label}:"
@@ -108,7 +108,7 @@ sq:
108
108
  remove:
109
109
  label_value: "Fshij kufizimin %{label}: %{value}"
110
110
  value: Fshij kufizimin %{value}
111
- title: "Ju keni kërkuar për:"
111
+ title: "Zgjedhjet tuaja:"
112
112
  form:
113
113
  search:
114
114
  label: kërko për
@@ -144,7 +144,6 @@ sq:
144
144
  submit: Përditëso
145
145
  title: Numri i rezultateve që do të shfaqen për faqe
146
146
  rss_feed: RSS për rezultatet
147
- search_constraints_header: Kufizimet e kërkimit
148
147
  search_results: Rezultatet e kërkimit
149
148
  show:
150
149
  label: "%{label}:"
@@ -108,7 +108,7 @@ zh:
108
108
  remove:
109
109
  label_value: "删除限定条件 %{label}: %{value}"
110
110
  value: 删除限定条件 %{value}
111
- title: 你在搜索:
111
+ title: 您的选择:
112
112
  form:
113
113
  search:
114
114
  label: 搜索
@@ -144,7 +144,6 @@ zh:
144
144
  submit: 更新
145
145
  title: 每页显示结果数
146
146
  rss_feed: 搜索结果RSS
147
- search_constraints_header: 搜索条件
148
147
  search_results: 搜索结果
149
148
  show:
150
149
  label: "%{label}:"
@@ -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
@@ -9,9 +11,13 @@ module Blacklight
9
11
  @__vc_compiler = nil
10
12
  end
11
13
 
14
+ # This allows the host application to provide erb templates that override the templates
15
+ # provided by Blacklight.
12
16
  def sidecar_files(*args, **kwargs)
13
17
  upstream_sidecar_files(*args, **kwargs).map do |path|
14
- app_path = Rails.root.join(path.slice(path.index(view_component_path)..-1).to_s).to_s
18
+ components_path = ViewComponent::VERSION::MAJOR == 3 ? view_component_path : config.generate.path
19
+
20
+ app_path = Rails.root.join(path.slice(path.index(components_path)..-1).to_s).to_s
15
21
 
16
22
  if File.exist?(app_path)
17
23
  app_path
@@ -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
@@ -76,6 +78,8 @@ module Blacklight
76
78
  self.index_range = 'A'..'Z' if index_range == true
77
79
  self.presenter ||= Blacklight::FacetFieldPresenter
78
80
  self.item_presenter ||= Blacklight::FacetItemPresenter
81
+ self.constraint_presenter ||= Blacklight::ConstraintPresenter
82
+
79
83
  self.component = Blacklight::Facets::ListComponent if component.nil? || component == true
80
84
  self.advanced_search_component ||= Blacklight::Facets::CheckboxesComponent
81
85
  self.item_component ||= Blacklight::Facets::ItemComponent
@@ -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
@@ -73,7 +73,8 @@ module Blacklight
73
73
  # @!attribute json_solr_path
74
74
  # @since v7.34.0
75
75
  # @return [String] The url path (relative to the solr base url) to use when using Solr's JSON Query DSL (as with the advanced search)
76
- property :json_solr_path, default: 'advanced'
76
+ # @note You can configure a separate custom 'advanced' requestHandler in solrconfig.xml if desired, but it isn't necessary; the default 'select' handler will work.
77
+ property :json_solr_path, default: 'select'
77
78
  # @!attribute document_unique_id_param
78
79
  # @since v5.2.0
79
80
  # @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
@@ -147,9 +148,15 @@ module Blacklight
147
148
  # @return [Blacklight::Configuration::ViewConfig::Index]
148
149
  property :index, default: ViewConfig::Index.new(
149
150
  # document presenter class used by helpers and views
150
- document_presenter_class: nil,
151
+ document_presenter_class: Blacklight::IndexPresenter,
152
+ # document presenter used for json responses
153
+ json_presenter_class: Blacklight::JsonPresenter,
151
154
  # component class used to render a document
152
155
  document_component: Blacklight::DocumentComponent,
156
+ document_embed_component: nil,
157
+ document_metadata_component: Blacklight::DocumentMetadataComponent,
158
+ document_thumbnail_component: Blacklight::Document::ThumbnailComponent,
159
+ document_title_component: Blacklight::DocumentTitleComponent,
153
160
  sidebar_component: Blacklight::Search::SidebarComponent,
154
161
  dropdown_component: Blacklight::System::DropdownComponent,
155
162
  # solr field to use to render a document title
@@ -185,8 +192,9 @@ module Blacklight
185
192
  # @return [Blacklight::Configuration::ViewConfig::Show]
186
193
  property :show, default: ViewConfig::Show.new(
187
194
  # document presenter class used by helpers and views
188
- document_presenter_class: nil,
195
+ document_presenter_class: Blacklight::ShowPresenter,
189
196
  document_component: Blacklight::DocumentComponent,
197
+ document_thumbnail_component: nil,
190
198
  show_tools_component: Blacklight::Document::ShowToolsComponent,
191
199
  show_header_tools_component: nil,
192
200
  document_header_component: Blacklight::Document::PageHeaderComponent,
@@ -267,6 +275,10 @@ module Blacklight
267
275
  # @since v5.10.0
268
276
  # @return [Integer]
269
277
  property :default_facet_limit, default: 10
278
+ # @!attribute default_facet_suggest
279
+ # @since v9.0.0
280
+ # @return [Boolean]
281
+ property :default_facet_suggest, default: true
270
282
  # @!attribute default_more_limit
271
283
  # @since v7.0.0
272
284
  # @return [Integer]
@@ -297,8 +309,13 @@ module Blacklight
297
309
 
298
310
  # @!attribute advanced_search
299
311
  # @since v7.15.0
300
- # @return [#enabled]
301
- property :advanced_search, default: OpenStruct.new(enabled: false)
312
+ # @return [OpenStructWithHashAccess] Configuration for advanced search, including:
313
+ # enabled: (Boolean) whether advanced search is enabled
314
+ # form_solr_parameters: (Hash) optional parameters to send to Solr for the advanced search
315
+ # form; can override values that are set automatically via the
316
+ # #copy_facet_field_config_to_advanced! method
317
+ property :advanced_search, default: OpenStructWithHashAccess.new(enabled: true,
318
+ form_solr_parameters: {})
302
319
 
303
320
  # @!attribute enable_search_bar_autofocus
304
321
  # @since v7.2.0
@@ -455,6 +472,42 @@ module Blacklight
455
472
  facet_fields.map { |_facet, opts| opts[:group] }.uniq
456
473
  end
457
474
 
475
+ # Use existing search field configs to automatically prepare fields for use
476
+ # by the advanced search form.
477
+ def copy_search_field_config_to_advanced!
478
+ search_fields.each_value do |field|
479
+ next if field.include_in_advanced_search == false
480
+ next if field.clause_params
481
+
482
+ field.clause_params = {}
483
+ field.clause_params[:edismax] = field.solr_parameters.dup || {}
484
+ end
485
+ end
486
+
487
+ # Use existing facet field configs to automatically prepare fields for use
488
+ # by the advanced search form. If more specific config is needed, e.g., to
489
+ # set the facet limit for one field to a value other than -1, it can be
490
+ # expressed in the configuration in advanced_search.form_solr_parameters
491
+ def copy_facet_field_config_to_advanced!
492
+ advanced_search.form_solr_parameters ||= {}
493
+ advanced_search.form_solr_parameters['facet.sort'] ||= 'count'
494
+ advanced_search.form_solr_parameters['facet.field'] ||= []
495
+
496
+ facet_fields.each_value do |field|
497
+ next if field.include_in_advanced_search == false
498
+ # Skip query-type and pivot facets that can't be requested via facet.field
499
+ next if field.query || field.pivot || field.range
500
+
501
+ # Add the facet field to the advanced search configuration
502
+ advanced_search.form_solr_parameters['facet.field'] << field.field unless
503
+ advanced_search.form_solr_parameters['facet.field'].include?(field.field)
504
+
505
+ # Set the facet field's limit to -1 to show ALL values in advanced search
506
+ advanced_search.form_solr_parameters["f.#{field.field}.facet.limit"] = -1 unless
507
+ advanced_search.form_solr_parameters["f.#{field.field}.facet.limit"]
508
+ end
509
+ end
510
+
458
511
  # Add any configured facet fields to the default solr parameters hash
459
512
  # @overload add_facet_fields_to_solr_request!
460
513
  # add all facet fields to the solr request
@@ -102,7 +102,7 @@ module Blacklight
102
102
  end
103
103
  queries.uniq!
104
104
  end
105
- [(queries - existing)]
105
+ [queries - existing]
106
106
  end
107
107
  end
108
108
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight::Solr
4
+ class FieldReflectionSearchBuilder < SearchBuilder
5
+ self.default_processor_chain = [:add_params]
6
+
7
+ def add_params(request)
8
+ request.reverse_merge!({ fl: '*', 'json.nl' => 'map' })
9
+ end
10
+ end
11
+ end
@@ -7,8 +7,7 @@ module Blacklight::Solr
7
7
  # @param [String] id document's unique key value
8
8
  # @param [Hash] params additional solr query parameters
9
9
  def find id, params = {}
10
- doc_params = params.reverse_merge(blacklight_config.default_document_solr_params)
11
- .merge(blacklight_config.document_unique_id_param => id)
10
+ doc_params = SingleDocSearchBuilder.new(self, id, params)
12
11
 
13
12
  solr_response = send_and_receive blacklight_config.document_solr_path || blacklight_config.solr_path, doc_params
14
13
  raise Blacklight::Exceptions::RecordNotFound if solr_response.documents.empty?
@@ -24,14 +23,14 @@ module Blacklight::Solr
24
23
 
25
24
  ##
26
25
  # Execute a search query against solr
27
- # @param [Hash] params solr query parameters
26
+ # @param [Hash,Blacklight::SearchBuilder] params solr query parameters
28
27
  # @param [String] path solr request handler path
29
28
  def search pos_params = nil, path: nil, params: nil, **kwargs
30
29
  if pos_params
31
30
  Blacklight.deprecation.warn("Passing positional arguments to search() is deprecated. Use the params kwarg instead.")
32
31
  end
33
32
 
34
- request_params = (params || pos_params).reverse_merge(kwargs).reverse_merge({ qt: blacklight_config.qt })
33
+ request_params = (params || pos_params || {}).reverse_merge(kwargs).reverse_merge({ qt: blacklight_config.qt })
35
34
 
36
35
  send_and_receive(path || default_search_path(request_params), request_params)
37
36
  end
@@ -47,7 +46,8 @@ module Blacklight::Solr
47
46
  # Gets a list of available fields
48
47
  # @return [Hash]
49
48
  def reflect_fields
50
- send_and_receive('admin/luke', params: { fl: '*', 'json.nl' => 'map' })['fields']
49
+ doc_params = FieldReflectionSearchBuilder.new(self)
50
+ send_and_receive('admin/luke', doc_params)['fields']
51
51
  end
52
52
 
53
53
  ##