blacklight 7.10.0 → 7.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -7
  3. data/.rubocop_todo.yml +113 -98
  4. data/.travis.yml +0 -2
  5. data/Gemfile +0 -7
  6. data/README.md +1 -0
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/blacklight/blacklight.js +1 -2
  9. data/app/components/blacklight/document/bookmark_component.html.erb +16 -0
  10. data/app/components/blacklight/document/bookmark_component.rb +19 -0
  11. data/app/components/blacklight/document/citation_component.html.erb +9 -0
  12. data/app/components/blacklight/document/citation_component.rb +24 -0
  13. data/app/components/blacklight/document/more_like_this_component.html.erb +12 -0
  14. data/app/components/blacklight/document/more_like_this_component.rb +21 -0
  15. data/app/components/blacklight/document_component.html.erb +29 -0
  16. data/app/components/blacklight/document_component.rb +121 -0
  17. data/app/components/blacklight/document_metadata_component.html.erb +5 -0
  18. data/app/components/blacklight/document_metadata_component.rb +21 -0
  19. data/app/components/blacklight/facet_item_component.rb +6 -6
  20. data/app/components/blacklight/metadata_field_component.html.erb +8 -0
  21. data/app/components/blacklight/metadata_field_component.rb +31 -0
  22. data/app/components/blacklight/metadata_field_layout_component.html.erb +2 -0
  23. data/app/components/blacklight/metadata_field_layout_component.rb +16 -0
  24. data/app/components/blacklight/response/facet_group_component.html.erb +25 -0
  25. data/app/components/blacklight/response/facet_group_component.rb +19 -0
  26. data/app/components/blacklight/response/pagination_component.html.erb +3 -0
  27. data/app/components/blacklight/response/pagination_component.rb +17 -0
  28. data/app/components/blacklight/response/sort_component.html.erb +6 -0
  29. data/app/components/blacklight/response/sort_component.rb +16 -0
  30. data/app/components/blacklight/response/spellcheck_component.html.erb +7 -0
  31. data/app/components/blacklight/response/spellcheck_component.rb +20 -0
  32. data/app/components/blacklight/search_bar_component.html.erb +29 -0
  33. data/app/components/blacklight/search_bar_component.rb +45 -0
  34. data/app/components/blacklight/search_context_component.html.erb +10 -0
  35. data/app/components/blacklight/search_context_component.rb +30 -0
  36. data/app/components/blacklight/system/dropdown_component.html.erb +12 -0
  37. data/app/components/blacklight/system/dropdown_component.rb +42 -0
  38. data/app/components/blacklight/system/modal_component.html.erb +25 -0
  39. data/app/components/blacklight/system/modal_component.rb +9 -0
  40. data/app/controllers/concerns/blacklight/catalog.rb +5 -4
  41. data/app/controllers/concerns/blacklight/default_component_configuration.rb +2 -2
  42. data/app/controllers/concerns/blacklight/searchable.rb +11 -0
  43. data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -3
  44. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -0
  45. data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
  46. data/app/helpers/blacklight/configuration_helper_behavior.rb +6 -0
  47. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  48. data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
  49. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +7 -10
  50. data/app/helpers/blacklight/url_helper_behavior.rb +3 -3
  51. data/app/javascript/blacklight/search_context.js +0 -1
  52. data/app/models/blacklight/icon.rb +1 -0
  53. data/app/models/concerns/blacklight/document.rb +1 -0
  54. data/app/models/record_mailer.rb +1 -1
  55. data/app/presenters/blacklight/document_presenter.rb +7 -1
  56. data/app/presenters/blacklight/field_presenter.rb +1 -0
  57. data/app/presenters/blacklight/rendering/microdata.rb +1 -1
  58. data/app/services/blacklight/field_retriever.rb +1 -0
  59. data/app/services/blacklight/search_service.rb +1 -0
  60. data/app/views/catalog/_bookmark_control.html.erb +1 -36
  61. data/app/views/catalog/_citation.html.erb +4 -25
  62. data/app/views/catalog/_did_you_mean.html.erb +1 -5
  63. data/app/views/catalog/_document.atom.builder +3 -3
  64. data/app/views/catalog/_document.html.erb +5 -5
  65. data/app/views/catalog/_facet_group.html.erb +5 -19
  66. data/app/views/catalog/_index.html.erb +1 -10
  67. data/app/views/catalog/_paginate_compact.html.erb +6 -6
  68. data/app/views/catalog/_per_page_widget.html.erb +9 -12
  69. data/app/views/catalog/_previous_next_doc.html.erb +1 -12
  70. data/app/views/catalog/_results_pagination.html.erb +1 -3
  71. data/app/views/catalog/_search_form.html.erb +6 -27
  72. data/app/views/catalog/_show.html.erb +6 -8
  73. data/app/views/catalog/_show_main_content.html.erb +19 -13
  74. data/app/views/catalog/_show_sidebar.html.erb +1 -11
  75. data/app/views/catalog/_sort_widget.html.erb +5 -12
  76. data/app/views/catalog/email.html.erb +7 -7
  77. data/app/views/catalog/email_success.html.erb +5 -12
  78. data/app/views/catalog/facet.html.erb +14 -17
  79. data/app/views/catalog/index.atom.builder +0 -1
  80. data/app/views/catalog/sms.html.erb +7 -7
  81. data/app/views/catalog/sms_success.html.erb +5 -12
  82. data/blacklight.gemspec +3 -2
  83. data/config/i18n-tasks.yml +3 -0
  84. data/config/locales/blacklight.ar.yml +2 -0
  85. data/config/locales/blacklight.de.yml +2 -0
  86. data/config/locales/blacklight.en.yml +2 -0
  87. data/config/locales/blacklight.es.yml +4 -2
  88. data/config/locales/blacklight.fr.yml +2 -0
  89. data/config/locales/blacklight.hu.yml +2 -0
  90. data/config/locales/blacklight.it.yml +2 -0
  91. data/config/locales/blacklight.nl.yml +2 -0
  92. data/config/locales/blacklight.pt-BR.yml +2 -0
  93. data/config/locales/blacklight.sq.yml +2 -0
  94. data/config/locales/blacklight.zh.yml +2 -0
  95. data/lib/blacklight.rb +10 -0
  96. data/lib/blacklight/configuration.rb +8 -3
  97. data/lib/blacklight/configuration/fields.rb +5 -7
  98. data/lib/blacklight/engine.rb +1 -1
  99. data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -0
  100. data/lib/blacklight/search_state.rb +21 -7
  101. data/lib/blacklight/solr/response.rb +1 -0
  102. data/lib/blacklight/solr/response/facets.rb +9 -8
  103. data/lib/generators/blacklight/models_generator.rb +2 -0
  104. data/lib/generators/blacklight/templates/config/blacklight.yml +1 -0
  105. data/lib/railties/blacklight.rake +18 -13
  106. data/package.json +1 -1
  107. data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -0
  108. data/spec/components/blacklight/document_component_spec.rb +129 -0
  109. data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
  110. data/spec/components/blacklight/metadata_field_component_spec.rb +41 -0
  111. data/spec/controllers/blacklight/search_fields_spec.rb +2 -2
  112. data/spec/controllers/catalog_controller_spec.rb +20 -0
  113. data/spec/features/search_context_spec.rb +12 -2
  114. data/spec/features/search_filters_spec.rb +4 -0
  115. data/spec/features/search_results_spec.rb +1 -0
  116. data/spec/features/sitelinks_search_box.rb +1 -0
  117. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -0
  118. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -0
  119. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +2 -0
  120. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -1
  121. data/spec/helpers/blacklight_helper_spec.rb +14 -1
  122. data/spec/helpers/catalog_helper_spec.rb +1 -4
  123. data/spec/lib/blacklight/search_state_spec.rb +32 -0
  124. data/spec/models/blacklight/configuration_spec.rb +5 -0
  125. data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
  126. data/spec/models/blacklight/document/email_spec.rb +2 -0
  127. data/spec/models/blacklight/document/sms_spec.rb +2 -0
  128. data/spec/models/blacklight/facet_paginator_spec.rb +3 -0
  129. data/spec/models/blacklight/icon_spec.rb +6 -0
  130. data/spec/models/blacklight/solr/document_spec.rb +10 -0
  131. data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
  132. data/spec/models/blacklight/solr/response/group_response_spec.rb +2 -0
  133. data/spec/models/blacklight/solr/search_builder_spec.rb +10 -0
  134. data/spec/models/record_mailer_spec.rb +9 -0
  135. data/spec/models/search_spec.rb +1 -0
  136. data/spec/presenters/blacklight/show_presenter_spec.rb +8 -0
  137. data/spec/routing/catalog_routing_spec.rb +4 -0
  138. data/spec/services/blacklight/search_service_spec.rb +7 -0
  139. data/spec/spec_helper.rb +1 -1
  140. data/spec/views/catalog/_document.html.erb_spec.rb +13 -11
  141. data/spec/views/catalog/_facet_group.html.erb_spec.rb +1 -0
  142. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -0
  143. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +4 -0
  144. data/spec/views/catalog/index.atom.builder_spec.rb +40 -3
  145. data/spec/views/catalog/show.html.erb_spec.rb +14 -0
  146. data/tasks/blacklight.rake +7 -7
  147. metadata +56 -6
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Response
5
+ class FacetGroupComponent < ::ViewComponent::Base
6
+ def initialize(response:, fields: [], title: nil, id: nil)
7
+ @response = response
8
+ @fields = fields
9
+ @title = title
10
+ @id = id ? "facets-#{id}" : 'facets'
11
+ @panel_id = id ? "facet-panel-#{id}-collapse" : 'facet-panel-collapse'
12
+ end
13
+
14
+ def render?
15
+ @view_context.has_facet_values?(@fields, @response)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ <%= content_tag :nav, class: 'pagination', role: 'region', **@html_attr do %>
2
+ <%= pagination %>
3
+ <% end %>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Response
5
+ class PaginationComponent < ::ViewComponent::Base
6
+ def initialize(response:, html: {}, **pagination_args)
7
+ @response = response
8
+ @html_attr = { aria: { label: t('views.pagination.aria.container_label') } }.merge(html)
9
+ @pagination_args = { outer_window: 2, theme: 'blacklight' }.merge(pagination_args)
10
+ end
11
+
12
+ def pagination
13
+ @view_context.paginate @response, **@pagination_args
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ <%= render(Blacklight::System::DropdownComponent.new(
2
+ param: @param,
3
+ choices: @choices,
4
+ id: @id,
5
+ search_state: @search_state,
6
+ selected: @selected)) %>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Response
5
+ class SortComponent < ViewComponent::Base
6
+ def initialize(param: 'sort', choices: {}, search_state:, id: 'sort-dropdown', classes: [], selected: nil)
7
+ @param = param
8
+ @choices = choices
9
+ @search_state = search_state
10
+ @id = id
11
+ @classes = classes
12
+ @selected = selected
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ <div id="spell">
2
+ <h3 class="suggest">
3
+ <em>
4
+ <%= t('blacklight.did_you_mean', options: safe_join(@options.map { |word| link_to_query(word) }, " #{t('blacklight.or')} ")).html_safe %>
5
+ </em>
6
+ </h3>
7
+ </div>
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Response
5
+ class SpellcheckComponent < ViewComponent::Base
6
+ def initialize(response:, options: nil)
7
+ @response = response
8
+ @options = options || @response&.spelling&.words
9
+ end
10
+
11
+ def link_to_query(query)
12
+ @view_context.link_to_query(query)
13
+ end
14
+
15
+ def render?
16
+ @options.any? && @view_context.should_show_spellcheck_suggestions?(@response)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => t('blacklight.search.form.submit') do %>
2
+ <%= render_hash_as_hidden_fields(@params) %>
3
+ <% if @search_fields.length > 1 %>
4
+ <label for="search_field" class="sr-only"><%= t('blacklight.search.form.search_field.label') %></label>
5
+ <% end %>
6
+ <div class="input-group">
7
+ <% if @search_fields.length > 1 %>
8
+ <%= select_tag(:search_field,
9
+ options_for_select(@search_fields, h(@search_field)),
10
+ title: t('blacklight.search.form.search_field.title'),
11
+ id: "#{@prefix}search_field",
12
+ class: "custom-select search-field") %>
13
+ <% elsif @search_fields.length == 1 %>
14
+ <%= hidden_field_tag :search_field, @search_fields.first.last %>
15
+ <% end %>
16
+
17
+ <label for="<%= @prefix %>q" class="sr-only"><%= t('blacklight.search.form.search.label') %></label>
18
+ <%= text_field_tag :q, @q, placeholder: t('blacklight.search.form.search.placeholder'), class: "search-q q form-control rounded-#{@search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: @autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: @autocomplete_path.present?, autocomplete_path: @autocomplete_path } %>
19
+
20
+ <%= content %>
21
+
22
+ <span class="input-group-append">
23
+ <button type="submit" class="btn btn-primary search-btn" id="<%= @prefix %>search">
24
+ <span class="submit-search-text"><%= t('blacklight.search.form.submit') %></span>
25
+ <%= blacklight_icon :search, aria_hidden: true %>
26
+ </button>
27
+ </span>
28
+ </div>
29
+ <% end %>
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class SearchBarComponent < ::ViewComponent::Base
5
+ # rubocop:disable Metrics/ParameterLists
6
+ def initialize(url:, params:, classes: ['search-query-form'], presenter: nil, prefix: '', method: 'GET', q: nil, search_field: nil, search_fields: [], autocomplete_path: nil, autofocus: nil)
7
+ @url = url
8
+ @q = q || params[:q]
9
+ @search_field = search_field || params[:search_field]
10
+ @params = params.except(:q, :search_field, :utf8, :page)
11
+ @prefix = prefix
12
+ @classes = classes
13
+ @presenter = presenter
14
+ @method = method
15
+ @autocomplete_path = autocomplete_path
16
+ @autofocus = autofocus
17
+ @search_fields = search_fields
18
+ end
19
+ # rubocop:enable Metrics/ParameterLists
20
+
21
+ def autocomplete_path
22
+ return nil unless presenter.autocomplete_enabled?
23
+
24
+ @autocomplete_path
25
+ end
26
+
27
+ def autofocus
28
+ if @autofocus.nil?
29
+ presenter.autofocus?
30
+ else
31
+ @autofocus
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def presenter
38
+ @presenter ||= blacklight_config.index.search_bar_presenter_class.new(controller, blacklight_config)
39
+ end
40
+
41
+ def blacklight_config
42
+ @view_context.blacklight_config
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ <div class='pagination-search-widgets'>
2
+
3
+ <div class="page-links">
4
+ <%= link_to_previous_document @search_context[:prev] %> |
5
+
6
+ <%= item_page_entry_info %> |
7
+
8
+ <%= link_to_next_document @search_context[:next] %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class SearchContextComponent < ::ViewComponent::Base
5
+ with_collection_parameter :search_context
6
+
7
+ def initialize(search_context:, search_session:)
8
+ @search_context = search_context
9
+ @search_session = search_session
10
+ end
11
+
12
+ def render?
13
+ @search_context.present? && (@search_context[:prev] || @search_context[:next])
14
+ end
15
+
16
+ def item_page_entry_info
17
+ Deprecation.silence(Blacklight::CatalogHelperBehavior) do
18
+ @view_context.item_page_entry_info
19
+ end
20
+ end
21
+
22
+ def link_to_previous_document(*args)
23
+ @view_context.link_to_previous_document(*args)
24
+ end
25
+
26
+ def link_to_next_document(*args)
27
+ @view_context.link_to_next_document(*args)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ <%= content_tag :div, id: @id, class: @classes.join(' ') do %>
2
+ <button type="button" class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
3
+ <%= t(:button_label_html, default: :label_html, scope: "blacklight.search.#{@param}", @interpolation => label_for_value(@selected)) %> <span class="caret"></span>
4
+ </button>
5
+
6
+ <div class="dropdown-menu" role="menu">
7
+ <%- @choices.each do |option| %>
8
+ <% text, value = option_text_and_value(option) %>
9
+ <%= link_to(text, url_for(@search_state.params_for_search(@param => value)), class: 'dropdown-item', role: 'menuitem') %>
10
+ <%- end -%>
11
+ </div>
12
+ <% end %>
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module System
5
+ class DropdownComponent < ViewComponent::Base
6
+ # rubocop:disable Metrics/ParameterLists
7
+ def initialize(param:, choices:, search_state:, id: nil, classes: [], default: nil, selected: nil, interpolation: :field)
8
+ @param = param
9
+ @choices = choices
10
+ @search_state = search_state
11
+ @id = id
12
+ @classes = classes.concat(['btn-group', "#{param.to_s.parameterize}-dropdown"])
13
+ @selected = selected || default || option_text_and_value(@choices.first)&.first
14
+ @interpolation = interpolation
15
+ end
16
+ # rubocop:enable Metrics/ParameterLists
17
+
18
+ def render?
19
+ @choices.many?
20
+ end
21
+
22
+ # rubocop:disable Style/CaseEquality
23
+ # This method is from Rails to mirror how it handles native dropdowns
24
+ def option_text_and_value(option)
25
+ # Options are [text, value] pairs or strings used for both.
26
+ if !option.is_a?(String) && option.respond_to?(:first) && option.respond_to?(:last)
27
+ option = option.reject { |e| Hash === e } if Array === option
28
+ [option.first, option.last]
29
+ else
30
+ [option, option]
31
+ end
32
+ end
33
+ # rubocop:enable Style/CaseEquality
34
+
35
+ def label_for_value(value)
36
+ choice = @choices.find { |option| option_text_and_value(option).last == value }
37
+
38
+ choice && option_text_and_value(choice).first
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ <div data-blacklight-modal="container">
2
+ <%= prefix %>
3
+
4
+ <div class="modal-header">
5
+ <%= header || (capture do %>
6
+ <h1 class="modal-title"><%= title %></h1>
7
+ <% end) %>
8
+
9
+ <button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="<%= t('blacklight.modal.close') %>">
10
+ <span aria-hidden="true">&times;</span>
11
+ </button>
12
+ </div>
13
+
14
+ <%= body || (capture do %>
15
+ <div class="modal-body">
16
+ <%= content %>
17
+ </div>
18
+ <% end) %>
19
+
20
+ <% if footer.present? %>
21
+ <div class="modal-footer">
22
+ <%= footer %>
23
+ </div>
24
+ <% end %>
25
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module System
5
+ class ModalComponent < ViewComponent::Base
6
+ with_content_areas :prefix, :header, :title, :body, :footer
7
+ end
8
+ end
9
+ end
@@ -67,13 +67,14 @@ module Blacklight::Catalog
67
67
  search_session['counter'] = params[:counter]
68
68
  search_session['id'] = params[:search_id]
69
69
  search_session['per_page'] = params[:per_page]
70
+ search_session['document_id'] = params[:document_id]
70
71
 
71
72
  if params[:redirect] && (params[:redirect].starts_with?('/') || params[:redirect] =~ URI::DEFAULT_PARSER.make_regexp)
72
73
  uri = URI.parse(params[:redirect])
73
74
  path = uri.query ? "#{uri.path}?#{uri.query}" : uri.path
74
- redirect_to path, status: 303
75
+ redirect_to path, status: :see_other
75
76
  else
76
- redirect_to({ action: :show, id: params[:id] }, status: 303)
77
+ redirect_to({ action: :show, id: params[:id] }, status: :see_other)
77
78
  end
78
79
  end
79
80
 
@@ -184,7 +185,7 @@ module Blacklight::Catalog
184
185
  # @note Make sure your format has a well known mime-type or is registered in config/initializers/mime_types.rb
185
186
  # @example
186
187
  # config.index.respond_to.txt = Proc.new { render plain: "A list of docs." }
187
- def additional_response_formats format
188
+ def additional_response_formats(format)
188
189
  blacklight_config.index.respond_to.each do |key, config|
189
190
  format.send key do
190
191
  case config
@@ -214,7 +215,7 @@ module Blacklight::Catalog
214
215
 
215
216
  ##
216
217
  # Try to render a response from the document export formats available
217
- def document_export_formats format
218
+ def document_export_formats(format)
218
219
  format.any do
219
220
  format_name = params.fetch(:format, '').to_sym
220
221
  if @response.export_formats.include? format_name
@@ -24,7 +24,7 @@ module Blacklight
24
24
 
25
25
  module ClassMethods
26
26
  # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
27
- # rubocop:disable Metrics/LineLength
27
+ # rubocop:disable Layout/LineLength
28
28
 
29
29
  # @!macro partial_if_unless
30
30
  # @param name [String] the name of the document partial
@@ -41,7 +41,7 @@ module Blacklight
41
41
  blacklight_config.add_show_tools_partial(name, opts)
42
42
  ActionBuilder.new(self, name, opts).build
43
43
  end
44
- # rubocop:enable Metrics/LineLength
44
+ # rubocop:enable Layout/LineLength
45
45
 
46
46
  deprecation_deprecate add_show_tools_partial: 'use blacklight_config.add_show_tools_partial instead'
47
47
 
@@ -1,4 +1,15 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # The Searchable module can be included onto classes that need to initialize a SearchService.
4
+ # There are three dependencies you must provide on the including class. Typically these
5
+ # would be provided by Blacklight::Controller
6
+ # 1. search_state
7
+ # 2. blacklight_config
8
+ # 3. search_service_class
9
+ #
10
+ # Additionally, the including class may override the search_service_context method to provide
11
+ # further context to the SearchService. For example you could override this to provide the
12
+ # currently signed in user.
2
13
  module Blacklight::Searchable
3
14
  # @return [Blacklight::SearchService]
4
15
  def search_service
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  # Methods added to this helper will be available to all templates in the hosting application
3
3
  module Blacklight::BlacklightHelperBehavior
4
+ extend Deprecation
5
+
4
6
  include Blacklight::UrlHelperBehavior
5
7
  include Blacklight::HashAsHiddenFieldsHelperBehavior
6
8
  include Blacklight::LayoutHelperBehavior
@@ -148,9 +150,12 @@ module Blacklight::BlacklightHelperBehavior
148
150
  document = args.first
149
151
 
150
152
  field = options[:field]
151
- label = options[:label] || index_field_label(document, field)
153
+ label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
154
+ options[:label] || index_field_label(document, field)
155
+ end
152
156
  html_escape t(:"blacklight.search.index.#{document_index_view_type}.label", default: :'blacklight.search.index.label', label: label)
153
157
  end
158
+ deprecation_deprecate render_index_field_label: 'Use Blacklight::MetadataFieldComponent instead'
154
159
 
155
160
  ##
156
161
  # Render the show field label for a document
@@ -170,10 +175,13 @@ module Blacklight::BlacklightHelperBehavior
170
175
  document = args.first
171
176
 
172
177
  field = options[:field]
173
- label = options[:label] || document_show_field_label(document, field)
178
+ label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
179
+ options[:label] || document_show_field_label(document, field)
180
+ end
174
181
 
175
182
  t(:'blacklight.search.show.label', label: label)
176
183
  end
184
+ deprecation_deprecate render_document_show_field_label: 'Use Blacklight::MetadataFieldComponent instead'
177
185
 
178
186
  ##
179
187
  # Get the value of the document's "title" field, or a placeholder
@@ -252,8 +260,11 @@ module Blacklight::BlacklightHelperBehavior
252
260
  ##
253
261
  # Should we render a grouped response (because the response
254
262
  # contains a grouped response instead of the normal response)
263
+ #
264
+ # Default to false if there's no response object available (sometimes the case
265
+ # for tests, but might happen in other circumstances too..)
255
266
  def render_grouped_response? response = @response
256
- response.grouped?
267
+ response&.grouped?
257
268
  end
258
269
 
259
270
  ##
@@ -103,6 +103,7 @@ module Blacklight::CatalogHelperBehavior
103
103
  total: number_with_delimiter(search_session['total']),
104
104
  count: search_session['total'].to_i).html_safe
105
105
  end
106
+ deprecation_deprecate item_page_entry_info: 'Use Blacklight::SearchContextComponent methods instead'
106
107
 
107
108
  ##
108
109
  # Look up search field user-displayable label
@@ -38,7 +38,7 @@ module Blacklight
38
38
  def render_index_doc_actions(document, options = {})
39
39
  wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
40
40
  rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options))
41
- content_tag("div", rendered, class: wrapping_class) if rendered.present?
41
+ tag.div(rendered, class: wrapping_class) if rendered.present?
42
42
  end
43
43
 
44
44
  ##
@@ -51,7 +51,7 @@ module Blacklight
51
51
  def render_results_collection_tools(options = {})
52
52
  wrapping_class = options.delete(:wrapping_class) || "search-widgets"
53
53
  rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options)
54
- content_tag("div", rendered, class: wrapping_class) if rendered.present?
54
+ tag.div(rendered, class: wrapping_class) if rendered.present?
55
55
  end
56
56
 
57
57
  ##