blacklight 7.11.1 → 7.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.solr_wrapper.yml +5 -0
  4. data/VERSION +1 -1
  5. data/app/builders/blacklight/action_builder.rb +6 -0
  6. data/app/components/blacklight/constraint_component.html.erb +5 -0
  7. data/app/components/blacklight/constraint_component.rb +13 -0
  8. data/app/components/blacklight/constraint_layout_component.rb +2 -1
  9. data/app/components/blacklight/constraints_component.html.erb +10 -0
  10. data/app/components/blacklight/constraints_component.rb +65 -0
  11. data/app/components/blacklight/document/action_component.html.erb +9 -0
  12. data/app/components/blacklight/document/action_component.rb +38 -0
  13. data/app/components/blacklight/document/actions_component.html.erb +13 -0
  14. data/app/components/blacklight/document/actions_component.rb +26 -0
  15. data/app/components/blacklight/document/bookmark_component.html.erb +1 -1
  16. data/app/components/blacklight/document/bookmark_component.rb +8 -0
  17. data/app/components/blacklight/document/citation_component.html.erb +4 -2
  18. data/app/components/blacklight/document/citation_component.rb +8 -1
  19. data/app/components/blacklight/document/group_component.html.erb +9 -0
  20. data/app/components/blacklight/document/group_component.rb +26 -0
  21. data/app/components/blacklight/document/more_like_this_component.rb +2 -0
  22. data/app/components/blacklight/document/thumbnail_component.html.erb +12 -0
  23. data/app/components/blacklight/document/thumbnail_component.rb +25 -0
  24. data/app/components/blacklight/document_component.rb +27 -26
  25. data/app/components/blacklight/facet_field_filter_component.html.erb +12 -0
  26. data/app/components/blacklight/facet_field_filter_component.rb +25 -0
  27. data/app/components/blacklight/facet_field_pagination_component.html.erb +19 -0
  28. data/app/components/blacklight/facet_field_pagination_component.rb +21 -0
  29. data/app/components/blacklight/facet_item_component.rb +4 -8
  30. data/app/components/blacklight/response/facet_group_component.html.erb +3 -1
  31. data/app/components/blacklight/response/facet_group_component.rb +8 -1
  32. data/app/components/blacklight/response/pagination_component.rb +3 -0
  33. data/app/components/blacklight/response/sort_component.html.erb +1 -1
  34. data/app/components/blacklight/response/spellcheck_component.rb +9 -2
  35. data/app/components/blacklight/response/view_type_component.html.erb +11 -0
  36. data/app/components/blacklight/response/view_type_component.rb +36 -0
  37. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  38. data/app/components/blacklight/search_bar_component.rb +6 -0
  39. data/app/components/blacklight/search_context_component.rb +6 -2
  40. data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
  41. data/app/components/blacklight/system/flash_message_component.html.erb +4 -0
  42. data/app/components/blacklight/system/flash_message_component.rb +24 -0
  43. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  44. data/app/controllers/concerns/blacklight/controller.rb +12 -3
  45. data/app/controllers/concerns/blacklight/facet.rb +19 -5
  46. data/app/controllers/concerns/blacklight/search_fields.rb +7 -1
  47. data/app/helpers/blacklight/blacklight_helper_behavior.rb +127 -17
  48. data/app/helpers/blacklight/catalog_helper_behavior.rb +36 -5
  49. data/app/helpers/blacklight/component_helper_behavior.rb +36 -6
  50. data/app/helpers/blacklight/configuration_helper_behavior.rb +32 -4
  51. data/app/helpers/blacklight/facets_helper_behavior.rb +31 -8
  52. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +5 -0
  53. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +28 -11
  54. data/app/helpers/blacklight/render_partials_helper_behavior.rb +8 -3
  55. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +4 -2
  56. data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
  57. data/app/helpers/blacklight/url_helper_behavior.rb +23 -3
  58. data/app/models/blacklight/icon.rb +0 -1
  59. data/app/models/concerns/blacklight/document.rb +1 -1
  60. data/app/models/concerns/blacklight/suggest/response.rb +1 -1
  61. data/app/models/record_mailer.rb +1 -1
  62. data/app/presenters/blacklight/document_presenter.rb +42 -1
  63. data/app/presenters/blacklight/facet_field_presenter.rb +3 -1
  64. data/app/presenters/blacklight/facet_item_presenter.rb +8 -0
  65. data/app/presenters/blacklight/field_presenter.rb +9 -6
  66. data/app/presenters/blacklight/json_presenter.rb +3 -1
  67. data/app/presenters/blacklight/show_presenter.rb +4 -30
  68. data/app/presenters/blacklight/thumbnail_presenter.rb +5 -1
  69. data/app/services/blacklight/document_factory.rb +3 -0
  70. data/app/services/blacklight/field_retriever.rb +18 -4
  71. data/app/services/blacklight/search_service.rb +0 -1
  72. data/app/views/bookmarks/_tools.html.erb +12 -7
  73. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  74. data/app/views/catalog/_constraints.html.erb +12 -7
  75. data/app/views/catalog/_document.atom.builder +9 -6
  76. data/app/views/catalog/_document.rss.builder +4 -2
  77. data/app/views/catalog/_facet_index_navigation.html.erb +1 -10
  78. data/app/views/catalog/_facet_pagination.html.erb +1 -19
  79. data/app/views/catalog/_facets.html.erb +1 -1
  80. data/app/views/catalog/_group.html.erb +1 -9
  81. data/app/views/catalog/_index.html.erb +1 -1
  82. data/app/views/catalog/_search_results.html.erb +1 -1
  83. data/app/views/catalog/_show.html.erb +1 -1
  84. data/app/views/catalog/_show_header.html.erb +1 -1
  85. data/app/views/catalog/_show_main_content.html.erb +2 -2
  86. data/app/views/catalog/_show_tools.html.erb +12 -8
  87. data/app/views/catalog/_start_over.html.erb +1 -1
  88. data/app/views/catalog/_thumbnail.html.erb +1 -5
  89. data/app/views/catalog/_view_type_group.html.erb +5 -13
  90. data/app/views/catalog/index.json.jbuilder +8 -6
  91. data/app/views/catalog/show.json.jbuilder +1 -1
  92. data/app/views/shared/_flash_msg.html.erb +1 -15
  93. data/blacklight.gemspec +1 -0
  94. data/config/locales/blacklight.ca.yml +241 -0
  95. data/lib/blacklight/abstract_repository.rb +13 -4
  96. data/lib/blacklight/configuration.rb +11 -5
  97. data/lib/blacklight/configuration/display_field.rb +50 -0
  98. data/lib/blacklight/configuration/facet_field.rb +58 -1
  99. data/lib/blacklight/configuration/field.rb +13 -0
  100. data/lib/blacklight/configuration/index_field.rb +5 -0
  101. data/lib/blacklight/configuration/search_field.rb +3 -0
  102. data/lib/blacklight/configuration/show_field.rb +5 -0
  103. data/lib/blacklight/configuration/sort_field.rb +3 -0
  104. data/lib/blacklight/configuration/tool_config.rb +1 -0
  105. data/lib/blacklight/configuration/view_config.rb +25 -0
  106. data/lib/blacklight/search_state.rb +4 -2
  107. data/lib/blacklight/solr/repository.rb +1 -1
  108. data/lib/generators/blacklight/templates/catalog_controller.rb +8 -7
  109. data/spec/components/blacklight/document/action_component_spec.rb +43 -0
  110. data/spec/components/blacklight/document/group_component_spec.rb +45 -0
  111. data/spec/components/blacklight/document_component_spec.rb +8 -0
  112. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +0 -1
  113. data/spec/components/blacklight/system/flash_message_component_spec.rb +54 -0
  114. data/spec/controllers/blacklight/search_fields_spec.rb +2 -0
  115. data/spec/controllers/catalog_controller_spec.rb +2 -0
  116. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +6 -1
  117. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +2 -0
  118. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +2 -0
  119. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +3 -1
  120. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +2 -0
  121. data/spec/helpers/blacklight_helper_spec.rb +10 -0
  122. data/spec/helpers/catalog_helper_spec.rb +4 -4
  123. data/spec/lib/blacklight/configuration/facet_field_spec.rb +17 -0
  124. data/spec/models/blacklight/search_builder_spec.rb +1 -1
  125. data/spec/models/blacklight/solr/search_builder_spec.rb +8 -0
  126. data/spec/presenters/blacklight/field_presenter_spec.rb +30 -5
  127. data/spec/services/blacklight/search_service_spec.rb +1 -5
  128. data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -1
  129. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -2
  130. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  131. data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -0
  132. data/tasks/blacklight.rake +27 -12
  133. metadata +47 -2
@@ -0,0 +1,12 @@
1
+ <nav class="alpha-filter">
2
+ <ol class="pagination pagination-sm justify-content-center">
3
+ <li class="page-item <%= 'active' if prefix.blank? %>">
4
+ <%= link_to t('blacklight.search.facets.all'), clear_facet_prefix_url, data: { blacklight_modal: "preserve" }, class: 'page-link' %>
5
+ </li>
6
+ <% @facet_field.facet_field.index_range.each do |letter| %>
7
+ <li class="page-item <%= 'active' if prefix == letter %>">
8
+ <%= link_to(letter, facet_prefix_url(letter), class: 'page-link', data: { blacklight_modal: "preserve" }) %>
9
+ </li>
10
+ <% end %>
11
+ </ol>
12
+ </nav>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class FacetFieldFilterComponent < ::ViewComponent::Base
5
+ def initialize(facet_field:)
6
+ @facet_field = facet_field
7
+ end
8
+
9
+ def render?
10
+ @facet_field.facet_field.index_range.any?
11
+ end
12
+
13
+ def prefix
14
+ @facet_field.paginator.prefix
15
+ end
16
+
17
+ def clear_facet_prefix_url
18
+ @facet_field.paginator.params_for_resort_url('index', @facet_field.search_state.to_h.except(@facet_field.paginator.request_keys[:prefix]))
19
+ end
20
+
21
+ def facet_prefix_url(letter)
22
+ @facet_field.paginator.params_for_resort_url('index', @facet_field.search_state.to_h.merge(@facet_field.paginator.request_keys[:prefix] => letter))
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ <div class="prev_next_links btn-group">
2
+ <%= link_to_previous_page @facet_field.paginator, raw(t('views.pagination.previous')), params: @facet_field.search_state.to_h, param_name: param_name, class: 'btn btn-link', data: { blacklight_modal: "preserve" } do %>
3
+ <%= content_tag :span, raw(t('views.pagination.previous')), class: 'disabled btn' %>
4
+ <% end %>
5
+
6
+ <%= link_to_next_page @facet_field.paginator, raw(t('views.pagination.next')), params: @facet_field.search_state.to_h, param_name: param_name, class: 'btn btn-link', data: { blacklight_modal: "preserve" } do %>
7
+ <%= content_tag :span, raw(t('views.pagination.next')), class: 'disabled btn' %>
8
+ <% end %>
9
+ </div>
10
+
11
+ <div class="sort-options btn-group">
12
+ <% if @facet_field.paginator.sort == 'index' -%>
13
+ <span class="active az btn btn-outline-secondary"><%= t('blacklight.search.facets.sort.index') %></span>
14
+ <%= link_to(t('blacklight.search.facets.sort.count'), sort_facet_url('count'), class: "sort_change numeric btn btn-outline-secondary", data: { blacklight_modal: "preserve" }) %>
15
+ <% elsif @facet_field.paginator.sort == 'count' -%>
16
+ <%= link_to(t('blacklight.search.facets.sort.index'), sort_facet_url('index'), class: "sort_change az btn btn-outline-secondary", data: { blacklight_modal: "preserve" }) %>
17
+ <span class="active numeric btn btn-outline-secondary"><%= t('blacklight.search.facets.sort.count') %></span>
18
+ <% end -%>
19
+ </div>
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class FacetFieldPaginationComponent < ::ViewComponent::Base
5
+ def initialize(facet_field:)
6
+ @facet_field = facet_field
7
+ end
8
+
9
+ def render?
10
+ @facet_field.facet_field.index_range&.any?
11
+ end
12
+
13
+ def sort_facet_url(sort)
14
+ @facet_field.paginator.params_for_resort_url(sort, @facet_fieldsearch_state.to_h)
15
+ end
16
+
17
+ def param_name
18
+ @facet_field.paginator.class.request_keys[:page]
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Blacklight
4
4
  class FacetItemComponent < ::ViewComponent::Base
5
+ extend Deprecation
6
+
5
7
  with_collection_parameter :facet_item
6
8
 
7
9
  def initialize(facet_item:, wrapping_element: 'li', suppress_link: false)
@@ -55,7 +57,7 @@ module Blacklight
55
57
  # @deprecated
56
58
  # @private
57
59
  def content_from_legacy_view_helper
58
- Deprecation.warn('Calling out to the #render_facet_item helper for backwards compatibility.')
60
+ Deprecation.warn(self.class, 'Calling out to the #render_facet_item helper for backwards compatibility.')
59
61
  Deprecation.silence(Blacklight::FacetsHelperBehavior) do
60
62
  @view_context.render_facet_item(@facet_item.facet_field, @facet_item.facet_item)
61
63
  end
@@ -66,10 +68,6 @@ module Blacklight
66
68
  # partial and catalog/facet expanded list. Will output facet value name as
67
69
  # a link to add that to your restrictions, with count in parens.
68
70
  #
69
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
70
- # @param [Blacklight::Solr::Response::Facets::FacetItem] item
71
- # @param [Hash] options
72
- # @option options [Boolean] :suppress_link display the facet, but don't link to it
73
71
  # @return [String]
74
72
  # @private
75
73
  def render_facet_value
@@ -81,8 +79,7 @@ module Blacklight
81
79
  ##
82
80
  # Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
83
81
  # @see #render_facet_value
84
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
85
- # @param [String] item
82
+ #
86
83
  # @private
87
84
  def render_selected_facet_value
88
85
  tag.span(class: "facet-label") do
@@ -99,7 +96,6 @@ module Blacklight
99
96
  # Renders a count value for facet limits. Can be over-ridden locally
100
97
  # to change style. And can be called by plugins to get consistent display.
101
98
  #
102
- # @param [Integer] num number of facet results
103
99
  # @param [Hash] options
104
100
  # @option options [Array<String>] an array of classes to add to count span.
105
101
  # @return [String]
@@ -20,6 +20,8 @@
20
20
  </div>
21
21
 
22
22
  <%= content_tag :div, id: @panel_id, class: 'facets-collapse collapse' do %>
23
- <%= @view_context.render_facet_partials @fields, response: @response %>
23
+ <% Deprecation.silence(Blacklight::FacetsHelperBehavior) do %>
24
+ <%= @view_context.render_facet_partials @fields, response: @response %>
25
+ <% end %>
24
26
  <% end %>
25
27
  <% end %>
@@ -2,7 +2,12 @@
2
2
 
3
3
  module Blacklight
4
4
  module Response
5
+ # Render a group of facet fields
5
6
  class FacetGroupComponent < ::ViewComponent::Base
7
+ # @param [Blacklight::Response] response
8
+ # @param [Array<String>] fields facet fields to render
9
+ # @param [String] title the title of the facet group section
10
+ # @param [String] id a unique identifier for the group
6
11
  def initialize(response:, fields: [], title: nil, id: nil)
7
12
  @response = response
8
13
  @fields = fields
@@ -12,7 +17,9 @@ module Blacklight
12
17
  end
13
18
 
14
19
  def render?
15
- @view_context.has_facet_values?(@fields, @response)
20
+ Deprecation.silence(Blacklight::FacetsHelperBehavior) do
21
+ @view_context.has_facet_values?(@fields, @response)
22
+ end
16
23
  end
17
24
  end
18
25
  end
@@ -2,7 +2,10 @@
2
2
 
3
3
  module Blacklight
4
4
  module Response
5
+ # Render a pagination widget for search results
5
6
  class PaginationComponent < ::ViewComponent::Base
7
+ # @param [Blacklight::Response] response
8
+ # @param [Hash] html html options for the pagination container
6
9
  def initialize(response:, html: {}, **pagination_args)
7
10
  @response = response
8
11
  @html_attr = { aria: { label: t('views.pagination.aria.container_label') } }.merge(html)
@@ -1,4 +1,4 @@
1
- <%= render(Blacklight::System::DropdownComponent.new(
1
+ <%= @view_context.render(Blacklight::System::DropdownComponent.new(
2
2
  param: @param,
3
3
  choices: @choices,
4
4
  id: @id,
@@ -2,18 +2,25 @@
2
2
 
3
3
  module Blacklight
4
4
  module Response
5
+ # Render spellcheck results for a search query
5
6
  class SpellcheckComponent < ViewComponent::Base
7
+ # @param [Blacklight::Response] response
8
+ # @param [Array<String>] options explicit spellcheck options to render
6
9
  def initialize(response:, options: nil)
7
10
  @response = response
8
11
  @options = options || @response&.spelling&.words
9
12
  end
10
13
 
11
14
  def link_to_query(query)
12
- @view_context.link_to_query(query)
15
+ Deprecation.silence(Blacklight::UrlHelperBehavior) do
16
+ @view_context.link_to_query(query)
17
+ end
13
18
  end
14
19
 
15
20
  def render?
16
- @options.any? && @view_context.should_show_spellcheck_suggestions?(@response)
21
+ Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
22
+ @options.any? && @view_context.should_show_spellcheck_suggestions?(@response)
23
+ end
17
24
  end
18
25
  end
19
26
  end
@@ -0,0 +1,11 @@
1
+ <div class="view-type">
2
+ <span class="sr-only"><%= t('blacklight.search.view_title') %></span>
3
+ <div class="view-type-group btn-group">
4
+ <% @views.each do |view, config| %>
5
+ <%= link_to url(view), title: label(view), class: "btn btn-outline-secondary btn-icon view-type-#{ view.to_s.parameterize } #{"active" if @selected == view}" do %>
6
+ <%= icon(view) %>
7
+ <span class="caption"><%= label(view) %></span>
8
+ <% end %>
9
+ <% end %>
10
+ </div>
11
+ </div>
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Response
5
+ # Render spellcheck results for a search query
6
+ class ViewTypeComponent < ViewComponent::Base
7
+ # @param [Blacklight::Response] response
8
+ def initialize(response:, views: {}, search_state:, selected: nil)
9
+ @response = response
10
+ @views = views
11
+ @search_state = search_state
12
+ @selected = selected
13
+ end
14
+
15
+ def render?
16
+ Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
17
+ @view_context.has_alternative_views?
18
+ end
19
+ end
20
+
21
+ def icon(view)
22
+ @view_context.render_view_type_group_icon(view)
23
+ end
24
+
25
+ def label(view)
26
+ Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
27
+ @view_context.view_label(view)
28
+ end
29
+ end
30
+
31
+ def url(view)
32
+ @view_context.url_for(@search_state.to_h.merge(view: view))
33
+ end
34
+ end
35
+ end
36
+ end
@@ -15,7 +15,7 @@
15
15
  <% end %>
16
16
 
17
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 } %>
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
19
 
20
20
  <%= content %>
21
21
 
@@ -41,5 +41,11 @@ module Blacklight
41
41
  def blacklight_config
42
42
  @view_context.blacklight_config
43
43
  end
44
+
45
+ def render_hash_as_hidden_fields(*args)
46
+ Deprecation.silence(Blacklight::HashAsHiddenFieldsHelperBehavior) do
47
+ @view_context.render_hash_as_hidden_fields(*args)
48
+ end
49
+ end
44
50
  end
45
51
  end
@@ -20,11 +20,15 @@ module Blacklight
20
20
  end
21
21
 
22
22
  def link_to_previous_document(*args)
23
- @view_context.link_to_previous_document(*args)
23
+ Deprecation.silence(Blacklight::UrlHelperBehavior) do
24
+ @view_context.link_to_previous_document(*args)
25
+ end
24
26
  end
25
27
 
26
28
  def link_to_next_document(*args)
27
- @view_context.link_to_next_document(*args)
29
+ Deprecation.silence(Blacklight::UrlHelperBehavior) do
30
+ @view_context.link_to_next_document(*args)
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -6,7 +6,7 @@
6
6
  <div class="dropdown-menu" role="menu">
7
7
  <%- @choices.each do |option| %>
8
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') %>
9
+ <%= link_to(text, @view_context.url_for(@search_state.params_for_search(@param => value)), class: 'dropdown-item', role: 'menuitem') %>
10
10
  <%- end -%>
11
11
  </div>
12
12
  <% end %>
@@ -0,0 +1,4 @@
1
+ <div class="alert <%= @classes %>">
2
+ <%= @message %>
3
+ <a class="close" data-dismiss="alert" href="#">&times;</a>
4
+ </div>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module System
5
+ class FlashMessageComponent < ViewComponent::Base
6
+ with_collection_parameter :message
7
+
8
+ def initialize(message:, type:)
9
+ @message = message
10
+ @classes = alert_class(type)
11
+ end
12
+
13
+ def alert_class(type)
14
+ case type.to_s
15
+ when 'success' then "alert-success"
16
+ when 'notice' then "alert-info"
17
+ when 'alert' then "alert-warning"
18
+ when 'error' then "alert-danger"
19
+ else "alert-#{type}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -6,6 +6,8 @@ module Blacklight::Catalog
6
6
  include Blacklight::Facet
7
7
  include Blacklight::Searchable
8
8
 
9
+ extend Deprecation
10
+
9
11
  # The following code is executed when someone includes blacklight::catalog in their
10
12
  # own controller.
11
13
  included do
@@ -85,7 +87,9 @@ module Blacklight::Catalog
85
87
 
86
88
  @response = search_service.facet_field_response(@facet.key)
87
89
  @display_facet = @response.aggregations[@facet.field]
88
- @pagination = facet_paginator(@facet, @display_facet)
90
+
91
+ @presenter = (@facet.presenter || Blacklight::FacetFieldPresenter).new(@facet, @display_facet, view_context)
92
+ @pagination = @presenter.paginator
89
93
  respond_to do |format|
90
94
  format.html do
91
95
  # Draw the partial for the "more" facet modal window:
@@ -132,6 +136,7 @@ module Blacklight::Catalog
132
136
  params[:q].present? || params[:f].present? || params[:search_field].present?
133
137
  end
134
138
 
139
+ # TODO: deprecate this constant with #facet_limit_for
135
140
  DEFAULT_FACET_LIMIT = 10
136
141
 
137
142
  # Look up facet limit for given facet_field. Will look at config, and
@@ -158,6 +163,7 @@ module Blacklight::Catalog
158
163
  facet.limit == true ? DEFAULT_FACET_LIMIT : facet.limit
159
164
  end
160
165
  end
166
+ deprecation_deprecate facet_limit_for: 'moving to private logic in Blacklight::FacetFieldPresenter'
161
167
 
162
168
  private
163
169
 
@@ -21,18 +21,21 @@ module Blacklight::Controller
21
21
 
22
22
  # extra head content
23
23
  helper_method :has_user_authentication_provider?
24
- helper_method :blacklight_config, :blacklight_configuration_context
25
- helper_method :search_action_url, :search_action_path, :search_facet_path
26
- helper_method :search_state
24
+ helper_method :blacklight_config, :blacklight_configuration_context # move to Catalog
25
+ helper_method :search_action_url, :search_action_path
26
+ helper_method :search_facet_path # move to catalog? deprecate?
27
+ helper_method :search_state # move to catalog?
27
28
  end
28
29
 
29
30
  # Which class to use for the search state. You can subclass SearchState if you
30
31
  # want to override any of the methods (e.g. SearchState#url_for_document)
32
+ # TODO: move to Searchable
31
33
  class_attribute :search_state_class
32
34
  self.search_state_class = Blacklight::SearchState
33
35
 
34
36
  # Which class to use for the search service. You can subclass SearchService if you
35
37
  # want to override any of the methods (e.g. SearchService#fetch)
38
+ # TODO: move to Searchable
36
39
  class_attribute :search_service_class
37
40
  self.search_service_class = Blacklight::SearchService
38
41
 
@@ -42,6 +45,7 @@ module Blacklight::Controller
42
45
  set_callback :logging_in_user, :before, :transfer_guest_user_actions_to_current_user
43
46
  end
44
47
 
48
+ # @private
45
49
  def default_catalog_controller
46
50
  CatalogController
47
51
  end
@@ -52,6 +56,7 @@ module Blacklight::Controller
52
56
 
53
57
  ##
54
58
  # Context in which to evaluate blacklight configuration conditionals
59
+ # TODO: move to catalog?
55
60
  def blacklight_configuration_context
56
61
  @blacklight_configuration_context ||= Blacklight::Configuration::Context.new(self)
57
62
  end
@@ -64,6 +69,7 @@ module Blacklight::Controller
64
69
  end
65
70
 
66
71
  # @return [Blacklight::SearchState] a memoized instance of the parameter state.
72
+ # TODO: move to catalog?
67
73
  def search_state
68
74
  @search_state ||= search_state_class.new(params, blacklight_config, self)
69
75
  end
@@ -84,6 +90,7 @@ module Blacklight::Controller
84
90
  search_action_url(*args)
85
91
  end
86
92
 
93
+ # TODO: move to catalog? deprecate?
87
94
  def search_facet_path(options = {})
88
95
  opts = search_state
89
96
  .to_h
@@ -94,6 +101,7 @@ module Blacklight::Controller
94
101
  end
95
102
 
96
103
  # Returns a list of Searches from the ids in the user's history.
104
+ # TODO: move to catalog? SearchHistory?
97
105
  def searches_from_history
98
106
  session[:history].blank? ? ::Search.none : ::Search.where(id: session[:history]).order("updated_at desc")
99
107
  end
@@ -124,6 +132,7 @@ module Blacklight::Controller
124
132
  def require_user_authentication_provider
125
133
  raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
126
134
  end
135
+ deprecation_deprecate require_user_authentication_provider: 'removed without replacement'
127
136
 
128
137
  ##
129
138
  # When a user logs in, transfer any saved searches or bookmarks to the current_user