blacklight 7.12.1 → 7.13.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/VERSION +1 -1
  4. data/app/components/blacklight/constraints_component.rb +7 -5
  5. data/app/components/blacklight/document_component.html.erb +1 -0
  6. data/app/components/blacklight/document_component.rb +14 -1
  7. data/app/components/blacklight/facet_field_component.html.erb +1 -0
  8. data/app/controllers/concerns/blacklight/search_context.rb +1 -1
  9. data/app/controllers/concerns/blacklight/searchable.rb +1 -1
  10. data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -9
  11. data/app/helpers/blacklight/facets_helper_behavior.rb +8 -2
  12. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +7 -5
  13. data/app/presenters/blacklight/document_presenter.rb +4 -0
  14. data/app/presenters/blacklight/facet_item_presenter.rb +6 -2
  15. data/app/presenters/blacklight/index_presenter.rb +2 -2
  16. data/app/presenters/blacklight/rendering/link_to_facet.rb +3 -1
  17. data/app/presenters/blacklight/show_presenter.rb +0 -4
  18. data/app/services/blacklight/search_service.rb +13 -11
  19. data/app/views/catalog/_search_form.html.erb +1 -1
  20. data/app/views/catalog/index.json.jbuilder +3 -1
  21. data/lib/blacklight/configuration/facet_field.rb +7 -0
  22. data/lib/blacklight/configuration/search_field.rb +5 -0
  23. data/lib/blacklight/configuration/tool_config.rb +4 -0
  24. data/lib/blacklight/configuration/view_config.rb +12 -0
  25. data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
  26. data/lib/blacklight/search_builder.rb +13 -23
  27. data/lib/blacklight/search_state.rb +82 -70
  28. data/lib/blacklight/search_state/filter_field.rb +122 -0
  29. data/lib/blacklight/solr/search_builder_behavior.rb +71 -51
  30. data/package.json +4 -0
  31. data/spec/components/blacklight/document_component_spec.rb +15 -0
  32. data/spec/features/search_spec.rb +0 -5
  33. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +1 -2
  34. data/spec/lib/blacklight/configuration/view_config_spec.rb +15 -0
  35. data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +9 -0
  36. data/spec/lib/blacklight/search_state/filter_field_spec.rb +125 -0
  37. data/spec/lib/blacklight/search_state_spec.rb +132 -3
  38. data/spec/models/blacklight/configuration_spec.rb +8 -0
  39. data/spec/models/blacklight/solr/search_builder_spec.rb +32 -2
  40. metadata +7 -3
  41. data/.npmignore +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f595fd87d8dbfa6aec25b133ea695e0edfcf4762e8451e84fb26947b3f7b2c41
4
- data.tar.gz: adf2c0528a386885de7a656a84a0a88f2a2c419f07a6235279d9adc2dbe65f35
3
+ metadata.gz: cc85c2e67bf13d0e9c856d53d545896d372495fc242fc3b69d43fdd738681af2
4
+ data.tar.gz: 573ca993f0519fdb53560d8c14443dc5dd6f092753ba2bcee7a933595234b957
5
5
  SHA512:
6
- metadata.gz: 31e4a93e7e8b4f02ef3608743d0c3a44e9f08a1752ca4cb424b2f61b8bff9478f94a10ed2035c3090667bba4209ed2a89a19d993f16b6b03923616d044b7c122
7
- data.tar.gz: 464311223c2591897ce1e1ec74493502a11b23c3f601a955df3496e0616152241eccced5345722756fee0653ae554573b7b1b962bc68ee1e8d29fc3263209e9b
6
+ metadata.gz: d08af97a62b30095f7c66ac49f829d0085ca7e2faa1c7cd96d961834031e4fab8eaf3ffb785c8e2d30c970837a27d2fdb0c03e75258ff8ff3f8e43571697948f
7
+ data.tar.gz: a18de70871cd90a83341a55ebf039b3fb007bd2b49dd27f0786415dc68a21115ddfbcc06a72c57e6043ed7e0a62b18f7cc0913b9e9cbb7eaec7d1d54eaa89106
@@ -37,6 +37,8 @@ Metrics/BlockLength:
37
37
  Metrics/ClassLength:
38
38
  Exclude:
39
39
  - "lib/blacklight/configuration.rb"
40
+ - "lib/blacklight/search_builder.rb"
41
+ - "lib/blacklight/search_state.rb"
40
42
 
41
43
  Layout/LineLength:
42
44
  Max: 200
@@ -46,6 +48,7 @@ Layout/LineLength:
46
48
  Metrics/ModuleLength:
47
49
  Exclude:
48
50
  - 'app/controllers/concerns/blacklight/catalog.rb'
51
+ - 'lib/blacklight/solr/search_builder_behavior.rb'
49
52
 
50
53
  Naming/HeredocDelimiterNaming:
51
54
  Enabled: false
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.12.1
1
+ 7.13.0
@@ -47,13 +47,15 @@ module Blacklight
47
47
  private
48
48
 
49
49
  def facet_item_presenters
50
- @search_state.filter_params.each_pair.flat_map do |facet, values|
51
- facet_config = @view_context.facet_configuration_for_field(facet)
50
+ Deprecation.silence(Blacklight::SearchState) do
51
+ @search_state.filter_params.each_pair.flat_map do |facet, values|
52
+ facet_config = @view_context.facet_configuration_for_field(facet)
52
53
 
53
- Array(values).map do |val|
54
- next if val.blank? # skip empty string
54
+ Array(values).map do |val|
55
+ next if val.blank? # skip empty string
55
56
 
56
- facet_item_presenter(facet_config, val, facet)
57
+ facet_item_presenter(facet_config, val, facet)
58
+ end
57
59
  end
58
60
  end
59
61
  end
@@ -19,6 +19,7 @@
19
19
  <%= actions %>
20
20
  </header>
21
21
 
22
+ <%= embed %>
22
23
  <%= content %>
23
24
  <%= metadata %>
24
25
  </div>
@@ -6,7 +6,7 @@ module Blacklight
6
6
  # the accessors below.
7
7
  with_content_areas :header, :body, :footer,
8
8
  :before_title, :title, :after_title,
9
- :actions, :metadata, :thumbnail,
9
+ :actions, :embed, :metadata, :thumbnail,
10
10
  :partials
11
11
  with_collection_parameter :document
12
12
 
@@ -25,6 +25,7 @@ module Blacklight
25
25
  def initialize(document: nil, presenter: nil,
26
26
  id: nil, classes: [], component: :article, title_component: :h4,
27
27
  metadata_component: Blacklight::DocumentMetadataComponent,
28
+ embed_component: nil,
28
29
  counter: nil, document_counter: nil, counter_offset: 0,
29
30
  show: false)
30
31
  if presenter.nil? && document.nil?
@@ -39,8 +40,10 @@ module Blacklight
39
40
  @id = id || ('document' if show)
40
41
  @classes = classes
41
42
 
43
+ @embed_component = embed_component
42
44
  @metadata_component = metadata_component
43
45
 
46
+ @document_counter = document_counter
44
47
  @counter = counter
45
48
  @counter ||= document_counter + 1 + counter_offset if document_counter.present?
46
49
 
@@ -101,6 +104,16 @@ module Blacklight
101
104
  @before_title || counter
102
105
  end
103
106
 
107
+ def embed
108
+ return @embed if @embed
109
+
110
+ component = @embed_component || presenter.view_config.embed_component
111
+
112
+ return unless component
113
+
114
+ @view_context.render(component.new(document: @document, presenter: presenter, document_counter: @document_counter))
115
+ end
116
+
104
117
  private
105
118
 
106
119
  def counter
@@ -1,6 +1,7 @@
1
1
  <div class="card facet-limit blacklight-<%= @facet_field.key %> <%= 'facet-limit-active' if @facet_field.active? %>">
2
2
  <h3 class="card-header p-0 facet-field-heading" id="<%= @facet_field.html_id %>-header">
3
3
  <button
4
+ type="button"
4
5
  class="btn btn-block p-2 text-left collapse-toggle <%= "collapsed" if @facet_field.collapsed? %>"
5
6
  data-toggle="collapse"
6
7
  data-target="#<%= @facet_field.html_id %>"
@@ -111,7 +111,7 @@ module Blacklight::SearchContext
111
111
  def setup_next_and_previous_documents
112
112
  if search_session['counter'] && current_search_session
113
113
  index = search_session['counter'].to_i - 1
114
- response, documents = search_service.previous_and_next_documents_for_search index, search_state.reset(current_search_session.query_params).to_hash
114
+ response, documents = search_service.previous_and_next_documents_for_search index, search_state.reset(current_search_session.query_params)
115
115
 
116
116
  search_session['total'] = response.total
117
117
  { prev: documents.first, next: documents.last }
@@ -13,7 +13,7 @@
13
13
  module Blacklight::Searchable
14
14
  # @return [Blacklight::SearchService]
15
15
  def search_service
16
- search_service_class.new(config: blacklight_config, user_params: search_state.to_h, **search_service_context)
16
+ search_service_class.new(config: blacklight_config, search_state: search_state, user_params: search_state.to_h, **search_service_context)
17
17
  end
18
18
 
19
19
  # @return [Hash] a hash of context information to pass through to the search service
@@ -103,15 +103,9 @@ module Blacklight::ConfigurationHelperBehavior
103
103
  # @return [String]
104
104
  def view_label view
105
105
  view_config = blacklight_config.view[view]
106
- field_label(
107
- :"blacklight.search.view_title.#{view}",
108
- :"blacklight.search.view.#{view}",
109
- view_config.label,
110
- view_config.title,
111
- view.to_s.humanize
112
- )
113
- end
114
- deprecation_deprecate view_label: 'Moving to Blacklight::Response::ViewTypeComponent'
106
+ view_config.display_label(view)
107
+ end
108
+ deprecation_deprecate view_label: 'Moving to ViewConfig#display_label and Blacklight::Response::ViewTypeComponent'
115
109
 
116
110
  # Shortcut for commonly needed operation, look up display
117
111
  # label for the key specified.
@@ -254,7 +254,10 @@ module Blacklight::FacetsHelperBehavior
254
254
  # @return [Boolean]
255
255
  def facet_field_in_params? field
256
256
  config = facet_configuration_for_field(field)
257
- search_state.has_facet? config
257
+
258
+ Deprecation.silence(Blacklight::SearchState) do
259
+ search_state.has_facet? config
260
+ end
258
261
  end
259
262
  # Left undeprecated for the sake of temporary backwards compatibility
260
263
  # deprecation_deprecate :facet_field_in_params?
@@ -269,7 +272,10 @@ module Blacklight::FacetsHelperBehavior
269
272
  # @return [Boolean]
270
273
  def facet_in_params?(field, item)
271
274
  config = facet_configuration_for_field(field)
272
- search_state.has_facet? config, value: facet_value_for_facet_item(item)
275
+
276
+ Deprecation.silence(Blacklight::SearchState) do
277
+ search_state.has_facet? config, value: facet_value_for_facet_item(item)
278
+ end
273
279
  end
274
280
  deprecation_deprecate :facet_in_params?
275
281
 
@@ -84,12 +84,14 @@ module Blacklight::RenderConstraintsHelperBehavior
84
84
  Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'render_constraints_filters is deprecated')
85
85
  search_state = convert_to_search_state(params_or_search_state)
86
86
 
87
- return "".html_safe if search_state.filter_params.blank?
87
+ Deprecation.silence(Blacklight::SearchState) do
88
+ return "".html_safe if search_state.filter_params.blank?
88
89
 
89
- Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
90
- safe_join(search_state.filter_params.each_pair.map do |facet, values|
91
- render_filter_element(facet, values, search_state)
92
- end, "\n")
90
+ Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
91
+ safe_join(search_state.filter_params.each_pair.map do |facet, values|
92
+ render_filter_element(facet, values, search_state)
93
+ end, "\n")
94
+ end
93
95
  end
94
96
  end
95
97
 
@@ -113,6 +113,10 @@ module Blacklight
113
113
  LinkAlternatePresenter.new(view_context, document, options).render
114
114
  end
115
115
 
116
+ def view_config
117
+ @view_config ||= configuration.view_config(:show)
118
+ end
119
+
116
120
  private
117
121
 
118
122
  def render_field?(field_config)
@@ -18,7 +18,9 @@ module Blacklight
18
18
  # Check if the query parameters have the given facet field with the
19
19
  # given value.
20
20
  def selected?
21
- search_state.has_facet? facet_config, value: facet_value
21
+ Deprecation.silence(Blacklight::SearchState) do
22
+ search_state.has_facet? facet_config, value: facet_value
23
+ end
22
24
  end
23
25
 
24
26
  def field_label
@@ -60,7 +62,9 @@ module Blacklight
60
62
 
61
63
  # @private
62
64
  def remove_href(path = search_state)
63
- view_context.search_action_path(path.remove_facet_params(facet_config.key, facet_item))
65
+ Deprecation.silence(Blacklight::SearchState) do
66
+ view_context.search_action_path(path.remove_facet_params(facet_config.key, facet_item))
67
+ end
64
68
  end
65
69
 
66
70
  # @private
@@ -29,12 +29,12 @@ module Blacklight
29
29
 
30
30
  deprecation_deprecate label: 'Use #heading'
31
31
 
32
- private
33
-
34
32
  def view_config
35
33
  @view_config ||= configuration.view_config(view_context.document_index_view_type)
36
34
  end
37
35
 
36
+ private
37
+
38
38
  # @return [Hash<String,Configuration::Field>] all the fields for this index view
39
39
  def fields
40
40
  configuration.index_fields_for(display_type)
@@ -32,7 +32,9 @@ module Blacklight
32
32
  end
33
33
 
34
34
  def facet_params(field, v)
35
- context.search_state.reset.add_facet_params(field, v)
35
+ Deprecation.silence(Blacklight::SearchState) do
36
+ context.search_state.reset.add_facet_params(field, v)
37
+ end
36
38
  end
37
39
  end
38
40
  end
@@ -8,10 +8,6 @@ module Blacklight
8
8
  configuration.show_fields_for(display_type)
9
9
  end
10
10
 
11
- def view_config
12
- configuration.view_config(:show)
13
- end
14
-
15
11
  def field_config(field)
16
12
  configuration.show_fields.fetch(field) { Configuration::NullField.new(field) }
17
13
  end
@@ -2,9 +2,10 @@
2
2
  # SearchService returns search results from the repository
3
3
  module Blacklight
4
4
  class SearchService
5
- def initialize(config:, user_params: {}, search_builder_class: config.search_builder_class, **context)
5
+ def initialize(config:, search_state: nil, user_params: nil, search_builder_class: config.search_builder_class, **context)
6
6
  @blacklight_config = config
7
- @user_params = user_params
7
+ @search_state = search_state || Blacklight::SearchState.new(user_params || {}, config)
8
+ @user_params = @search_state.params
8
9
  @search_builder_class = search_builder_class
9
10
  @context = context
10
11
  end
@@ -20,9 +21,9 @@ module Blacklight
20
21
  # @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.
21
22
  # @return [Blacklight::Solr::Response] the solr response object
22
23
  def search_results
23
- builder = search_builder.with(user_params)
24
- builder.page = user_params[:page] if user_params[:page]
25
- builder.rows = (user_params[:per_page] || user_params[:rows]) if user_params[:per_page] || user_params[:rows]
24
+ builder = search_builder.with(search_state)
25
+ builder.page = search_state.page
26
+ builder.rows = search_state.per_page
26
27
 
27
28
  builder = yield(builder) if block_given?
28
29
  response = repository.search(builder)
@@ -51,7 +52,7 @@ module Blacklight
51
52
  # Get the solr response when retrieving only a single facet field
52
53
  # @return [Blacklight::Solr::Response] the solr response
53
54
  def facet_field_response(facet_field, extra_controller_params = {})
54
- query = search_builder.with(user_params).facet(facet_field)
55
+ query = search_builder.with(search_state).facet(facet_field)
55
56
  repository.search(query.merge(extra_controller_params))
56
57
  end
57
58
 
@@ -59,7 +60,8 @@ module Blacklight
59
60
  # @return [Blacklight::Solr::Response, Array<Blacklight::SolrDocument>] the solr response and a list of the first and last document
60
61
  def previous_and_next_documents_for_search(index, request_params, extra_controller_params = {})
61
62
  p = previous_and_next_document_params(index)
62
- query = search_builder.with(request_params).start(p.delete(:start)).rows(p.delete(:rows)).merge(extra_controller_params).merge(p)
63
+ new_state = request_params.is_a?(Blacklight::SearchState) ? request_params : Blacklight::SearchState.new(request_params, blacklight_config)
64
+ query = search_builder.with(new_state).start(p.delete(:start)).rows(p.delete(:rows)).merge(extra_controller_params).merge(p)
63
65
  response = repository.search(query)
64
66
  document_list = response.documents
65
67
 
@@ -78,15 +80,15 @@ module Blacklight
78
80
  def opensearch_response(field = nil, extra_controller_params = {})
79
81
  field ||= blacklight_config.view_config(:opensearch).title_field
80
82
 
81
- query = search_builder.with(user_params).merge(solr_opensearch_params(field)).merge(extra_controller_params)
83
+ query = search_builder.with(search_state).merge(solr_opensearch_params(field)).merge(extra_controller_params)
82
84
  response = repository.search(query)
83
85
 
84
- [user_params[:q], response.documents.flat_map { |doc| doc[field] }.uniq]
86
+ [search_state.query_param, response.documents.flat_map { |doc| doc[field] }.uniq]
85
87
  end
86
88
 
87
89
  private
88
90
 
89
- attr_reader :search_builder_class, :user_params
91
+ attr_reader :search_builder_class, :user_params, :search_state
90
92
 
91
93
  delegate :repository, to: :blacklight_config
92
94
 
@@ -135,7 +137,7 @@ module Blacklight
135
137
  extra_controller_params ||= {}
136
138
 
137
139
  query = search_builder
138
- .with(user_params)
140
+ .with(search_state)
139
141
  .where(blacklight_config.document_model.unique_key => ids)
140
142
  .merge(blacklight_config.fetch_many_document_params)
141
143
  .merge(extra_controller_params)
@@ -1,6 +1,6 @@
1
1
  <%= render(Blacklight::SearchBarComponent.new(
2
2
  url: search_action_url,
3
3
  params: search_state.params_for_search.except(:qt),
4
- search_fields: search_fields,
4
+ search_fields: Deprecation.silence(Blacklight::ConfigurationHelperBehavior) { search_fields },
5
5
  presenter: presenter,
6
6
  autocomplete_path: search_action_path(action: :suggest))) %>
@@ -51,7 +51,9 @@ json.included do
51
51
  json.links do
52
52
  Deprecation.silence(Blacklight::FacetsHelperBehavior) do
53
53
  if facet_in_params?(facet.name, item.value)
54
- json.remove search_action_path(search_state.remove_facet_params(facet.name, item.value))
54
+ Deprecation.silence(Blacklight::SearchState) do
55
+ json.remove search_action_path(search_state.remove_facet_params(facet.name, item.value))
56
+ end
55
57
  else
56
58
  json.self path_for_facet(facet.name, item.value, only_path: false)
57
59
  end
@@ -46,6 +46,13 @@ module Blacklight
46
46
  # are a hash containing: label (a label to show the user in the facet interface), fq (a string passed into solr as an fq (when selected) or a facet.query)
47
47
  # @!attribute pivot
48
48
  # @return []
49
+ # @!attribute filter_query_builder
50
+ # @return [nil, #call] a Proc (or other object responding to #call) that receives as parameters: 1) the search builder, 2) this facet config
51
+ # and 3) the solr parameters hash. The Proc returns a string suitable for e.g. Solr's fq parameter, or a 2-element array of the string and a hash of additional
52
+ # parameters to include with the query (i.e. for referenced subqueries); note that implementations are responsible for ensuring
53
+ # the additional parameter keys are unique.
54
+ # @!attribute filter_class
55
+ # @ return [nil, Blacklight::SearchState::FilterField] a class that implements the `FilterField`'s' API to manage URL parameters for a facet
49
56
 
50
57
  ##
51
58
  # Rendering:
@@ -3,6 +3,11 @@ module Blacklight
3
3
  class Configuration::SearchField < Blacklight::Configuration::Field
4
4
  # @!attribute include_in_simple_select
5
5
  # @!attribute qt
6
+ # @!attribute query_builder
7
+ # @return [nil, #call] a Proc (or other object responding to #call) that receives as parameters: 1) the search builder, 2) this search field,
8
+ # and 3) the solr_parameters hash. The Proc returns a string suitable for e.g. Solr's q parameter, or a 2-element array of the
9
+ # string and a hash of additional parameters to include with the query (i.e. for referenced subqueries); note that
10
+ # implementations are responsible for ensuring the additional parameter keys are unique.
6
11
 
7
12
  def normalize! blacklight_config = nil
8
13
  self.if = include_in_simple_select if self.if.nil?
@@ -2,5 +2,9 @@
2
2
  module Blacklight
3
3
  class Configuration::ToolConfig < OpenStructWithHashAccess
4
4
  # @!attribute partial
5
+
6
+ def name
7
+ super || key
8
+ end
5
9
  end
6
10
  end
@@ -17,6 +17,18 @@ class Blacklight::Configuration
17
17
  super || Blacklight::SearchBarPresenter
18
18
  end
19
19
 
20
+ def display_label(key)
21
+ I18n.t(
22
+ :"blacklight.search.view_title.#{key}",
23
+ default: [
24
+ :"blacklight.search.view.#{key}",
25
+ label,
26
+ title,
27
+ key.to_s.humanize
28
+ ]
29
+ )
30
+ end
31
+
20
32
  class Show < ViewConfig
21
33
  # @!attribute route
22
34
  # @return [Hash] Default route parameters for 'show' requests.
@@ -101,7 +101,7 @@ module Blacklight
101
101
 
102
102
  def set_default_proc!
103
103
  self.default_proc = lambda do |hash, key|
104
- hash[key] = nested_class.new
104
+ hash[key] = nested_class.new(key: key)
105
105
  end
106
106
  end
107
107
  end
@@ -8,7 +8,7 @@ module Blacklight
8
8
  class_attribute :default_processor_chain
9
9
  self.default_processor_chain = []
10
10
 
11
- attr_reader :processor_chain, :blacklight_params
11
+ attr_reader :processor_chain, :search_state, :blacklight_params
12
12
 
13
13
  # @overload initialize(scope)
14
14
  # @param [Object] scope scope the scope where the filter methods reside in.
@@ -27,15 +27,17 @@ module Blacklight
27
27
  end
28
28
 
29
29
  @blacklight_params = {}
30
+ @search_state = Blacklight::SearchState.new(@blacklight_params, @scope&.blacklight_config, @scope)
30
31
  @merged_params = {}
31
32
  @reverse_merged_params = {}
32
33
  end
33
34
 
34
35
  ##
35
36
  # Set the parameters to pass through the processor chain
36
- def with(blacklight_params = {})
37
+ def with(blacklight_params_or_search_state = {})
37
38
  params_will_change!
38
- @blacklight_params = blacklight_params.dup
39
+ @search_state = blacklight_params_or_search_state.is_a?(Blacklight::SearchState) ? blacklight_params_or_search_state : @search_state.reset(blacklight_params_or_search_state)
40
+ @blacklight_params = @search_state.params.dup
39
41
  self
40
42
  end
41
43
 
@@ -43,7 +45,8 @@ module Blacklight
43
45
  # Update the :q (query) parameter
44
46
  def where(conditions)
45
47
  params_will_change!
46
- @blacklight_params[:q] = conditions
48
+ @search_state = @search_state.reset(@search_state.params.merge(q: conditions))
49
+ @blacklight_params = @search_state.params.dup
47
50
  self
48
51
  end
49
52
 
@@ -52,7 +55,7 @@ module Blacklight
52
55
  def append(*addl_processor_chain)
53
56
  params_will_change!
54
57
  builder = self.class.new(processor_chain + addl_processor_chain, scope)
55
- .with(blacklight_params)
58
+ .with(search_state)
56
59
  .merge(@merged_params)
57
60
  .reverse_merge(@reverse_merged_params)
58
61
 
@@ -72,7 +75,7 @@ module Blacklight
72
75
  # chain are ignored as no-ops, rather than raising.
73
76
  def except(*except_processor_chain)
74
77
  builder = self.class.new(processor_chain - except_processor_chain, scope)
75
- .with(blacklight_params)
78
+ .with(search_state)
76
79
  .merge(@merged_params)
77
80
  .reverse_merge(@reverse_merged_params)
78
81
 
@@ -175,7 +178,7 @@ module Blacklight
175
178
  self.page = value
176
179
  return self
177
180
  end
178
- @page ||= blacklight_params[:page].blank? ? 1 : blacklight_params[:page].to_i
181
+ @page ||= search_state.page
179
182
  end
180
183
 
181
184
  def rows=(value)
@@ -191,8 +194,7 @@ module Blacklight
191
194
  end
192
195
  @rows ||= begin
193
196
  # user-provided parameters should override any default row
194
- r = [:rows, :per_page].map { |k| blacklight_params[k] }.reject(&:blank?).first
195
- r ||= blacklight_config.default_per_page
197
+ r = search_state.per_page
196
198
  # ensure we don't excede the max page size
197
199
  r.nil? ? nil : [r, blacklight_config.max_per_page].map(&:to_i).min
198
200
  end
@@ -220,22 +222,10 @@ module Blacklight
220
222
  # configured search values are passed through to the search.
221
223
  # @return [String] the field/fields to sort by
222
224
  def sort
223
- sort_field = if blacklight_params[:sort].blank?
224
- # no sort param provided, use default
225
- blacklight_config.default_sort_field
226
- else
227
- # check for sort field key
228
- blacklight_config.sort_fields[blacklight_params[:sort]]
229
- end
230
- return sort_field.sort if sort_field.present?
231
-
232
- Blacklight.logger.warn "Invalid sort field: '#{blacklight_params[:sort]}' was provided."
233
- nil
225
+ search_state.sort_field&.sort
234
226
  end
235
227
 
236
- def search_field
237
- blacklight_config.search_fields[blacklight_params[:search_field]]
238
- end
228
+ delegate :search_field, to: :search_state
239
229
 
240
230
  private
241
231