blacklight 6.5.0 → 6.6.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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +114 -213
- data/{.solr_wrapper → .solr_wrapper.yml} +0 -0
- data/.yardopts +3 -1
- data/Gemfile +0 -3
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/Vagrantfile +0 -2
- data/app/controllers/bookmarks_controller.rb +0 -2
- data/app/controllers/catalog_controller.rb +0 -2
- data/app/controllers/concerns/blacklight/base.rb +0 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +7 -11
- data/app/controllers/concerns/blacklight/controller.rb +11 -7
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +24 -37
- data/app/controllers/concerns/blacklight/facet.rb +2 -11
- data/app/controllers/concerns/blacklight/request_builders.rb +1 -3
- data/app/controllers/concerns/blacklight/search_context.rb +0 -1
- data/app/controllers/concerns/blacklight/search_fields.rb +2 -2
- data/app/controllers/concerns/blacklight/search_helper.rb +14 -24
- data/app/controllers/concerns/blacklight/token_based_user.rb +0 -2
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +27 -28
- data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -15
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -5
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -3
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +21 -25
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -2
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +8 -9
- data/app/helpers/blacklight/render_partials_helper.rb +14 -13
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -4
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/blacklight/facet_paginator.rb +2 -2
- data/app/models/concerns/blacklight/document.rb +1 -6
- data/app/models/concerns/blacklight/document/active_model_shim.rb +0 -1
- data/app/models/concerns/blacklight/document/cache_key.rb +3 -3
- data/app/models/concerns/blacklight/document/dublin_core.rb +0 -1
- data/app/models/concerns/blacklight/document/email.rb +0 -2
- data/app/models/concerns/blacklight/document/export.rb +1 -2
- data/app/models/concerns/blacklight/document/schema_org.rb +0 -2
- data/app/models/concerns/blacklight/document/sms.rb +0 -2
- data/app/models/concerns/blacklight/solr/document.rb +0 -1
- data/app/models/record_mailer.rb +0 -1
- data/app/models/solr_document.rb +0 -2
- data/app/presenters/blacklight/document_presenter.rb +14 -11
- data/app/presenters/blacklight/index_presenter.rb +5 -5
- data/app/presenters/blacklight/json_presenter.rb +0 -1
- data/app/presenters/blacklight/rendering/abstract_step.rb +0 -1
- data/app/presenters/blacklight/rendering/helper_method.rb +5 -5
- data/app/presenters/blacklight/rendering/link_to_facet.rb +1 -1
- data/app/presenters/blacklight/show_presenter.rb +4 -5
- data/app/services/blacklight/field_retriever.rb +8 -9
- data/app/views/catalog/_facet_limit.html.erb +1 -1
- data/blacklight.gemspec +4 -0
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/abstract_repository.rb +4 -3
- data/lib/blacklight/configuration.rb +57 -92
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/fields.rb +24 -7
- data/lib/blacklight/exceptions.rb +0 -2
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/search_builder.rb +92 -96
- data/lib/blacklight/search_state.rb +2 -1
- data/lib/blacklight/solr/repository.rb +3 -4
- data/lib/blacklight/solr/request.rb +0 -2
- data/lib/blacklight/solr/response/facets.rb +23 -28
- data/lib/blacklight/solr/response/group.rb +0 -1
- data/lib/blacklight/solr/response/group_response.rb +1 -5
- data/lib/blacklight/solr/response/pagination_methods.rb +0 -1
- data/lib/blacklight/solr/response/response.rb +1 -1
- data/lib/blacklight/solr/response/spelling.rb +0 -4
- data/lib/blacklight/solr/search_builder_behavior.rb +29 -41
- data/lib/blacklight/utils.rb +10 -7
- data/lib/generators/blacklight/assets_generator.rb +0 -1
- data/lib/generators/blacklight/document_generator.rb +0 -1
- data/lib/generators/blacklight/install_generator.rb +2 -6
- data/lib/generators/blacklight/models_generator.rb +0 -3
- data/lib/generators/blacklight/search_builder_generator.rb +0 -1
- data/lib/generators/blacklight/solr4_generator.rb +0 -2
- data/lib/generators/blacklight/solr5_generator.rb +15 -1
- data/lib/generators/blacklight/test_support_generator.rb +0 -1
- data/lib/railties/blacklight.rake +3 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -4
- data/spec/controllers/blacklight/search_helper_spec.rb +5 -7
- data/spec/controllers/blacklight/suggest_search_spec.rb +2 -2
- data/spec/controllers/bookmarks_controller_spec.rb +2 -2
- data/spec/controllers/catalog_controller_spec.rb +6 -6
- data/spec/features/search_context_spec.rb +4 -5
- data/spec/features/search_formats_spec.rb +0 -6
- data/spec/helpers/blacklight_helper_spec.rb +7 -7
- data/spec/helpers/catalog_helper_spec.rb +10 -10
- data/spec/helpers/configuration_helper_spec.rb +3 -3
- data/spec/helpers/facets_helper_spec.rb +1 -2
- data/spec/helpers/render_constraints_helper_spec.rb +8 -0
- data/spec/integration/generators/blacklight/solr5_generator_spec.rb +60 -0
- data/spec/models/blacklight/document_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +5 -4
- data/spec/models/blacklight/solr/search_builder_spec.rb +12 -18
- data/spec/presenters/pipeline_spec.rb +1 -1
- data/spec/spec_helper.rb +43 -0
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -1
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
- data/tasks/blacklight.rake +3 -0
- metadata +61 -3
|
@@ -11,10 +11,10 @@ module Blacklight
|
|
|
11
11
|
##
|
|
12
12
|
# Evaluate conditionals for a configuration with if/unless attributes
|
|
13
13
|
#
|
|
14
|
-
# @param
|
|
14
|
+
# @param [#if,#unless] config an object that responds to if/unless
|
|
15
15
|
# @return [Boolean]
|
|
16
16
|
def evaluate_if_unless_configuration(config, *args)
|
|
17
|
-
return config if config
|
|
17
|
+
return config if config == true or config == false
|
|
18
18
|
|
|
19
19
|
if_value = !config.respond_to?(:if) ||
|
|
20
20
|
config.if.nil? ||
|
|
@@ -32,7 +32,7 @@ module Blacklight
|
|
|
32
32
|
when Symbol
|
|
33
33
|
arity = context.method(proc_helper_or_boolean).arity
|
|
34
34
|
|
|
35
|
-
if arity
|
|
35
|
+
if arity.zero?
|
|
36
36
|
context.send(proc_helper_or_boolean)
|
|
37
37
|
else
|
|
38
38
|
context.send(proc_helper_or_boolean, *args_for_procs_and_methods)
|
|
@@ -7,7 +7,6 @@ module Blacklight
|
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
8
|
|
|
9
9
|
module ClassMethods
|
|
10
|
-
|
|
11
10
|
# Add a configuration block for a collection of solr fields
|
|
12
11
|
def define_field_access(key, options = {})
|
|
13
12
|
key = key.to_s if respond_to? :to_s
|
|
@@ -39,12 +38,20 @@ module Blacklight
|
|
|
39
38
|
#
|
|
40
39
|
# * a field name and block format:
|
|
41
40
|
#
|
|
41
|
+
# @overload add_blacklight_field(config_key, field_key)
|
|
42
|
+
# @param [Symbol] config_key
|
|
43
|
+
# @param [Symbol,String] field_key
|
|
44
|
+
#
|
|
45
|
+
#
|
|
42
46
|
# add_blacklight_field :index_field, 'format' do |field|
|
|
43
47
|
# field.label = 'Format'
|
|
44
48
|
# end
|
|
45
49
|
#
|
|
46
50
|
# * a plain block:
|
|
47
51
|
#
|
|
52
|
+
# @overload add_blacklight_field(config_key)
|
|
53
|
+
# @param [Symbol] config_key
|
|
54
|
+
#
|
|
48
55
|
# add_blacklight_field :index_field do |field|
|
|
49
56
|
# field.field = 'format'
|
|
50
57
|
# field.label = 'Format'
|
|
@@ -52,20 +59,28 @@ module Blacklight
|
|
|
52
59
|
#
|
|
53
60
|
# * a configuration hash:
|
|
54
61
|
#
|
|
62
|
+
# @overload add_blacklight_field(config_key, options)
|
|
63
|
+
# @param [Symbol] config_key
|
|
64
|
+
# @param [Hash] options
|
|
65
|
+
#
|
|
55
66
|
# add_blacklight_field :index_field, :field => 'format', :label => 'Format'
|
|
56
67
|
#
|
|
57
68
|
# * a Field instance:
|
|
58
69
|
#
|
|
70
|
+
# @overload add_blacklight_field(config_key, field)
|
|
71
|
+
# @param [Symbol] config_key
|
|
72
|
+
# @param [Blacklight::Configuration::Field] field
|
|
73
|
+
#
|
|
74
|
+
#
|
|
59
75
|
# add_blacklight_field :index_field, IndexField.new(:field => 'format', :label => 'Format')
|
|
60
76
|
#
|
|
61
77
|
# * an array of hashes:
|
|
62
78
|
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
79
|
+
# @overload add_blacklight_field(config_key, fields)
|
|
80
|
+
# @param [Symbol] config_key
|
|
81
|
+
# @param [Array<Blacklight::Configuration::Field, Hash>] fields
|
|
65
82
|
#
|
|
66
|
-
#
|
|
67
|
-
# @param Array *args
|
|
68
|
-
# @para
|
|
83
|
+
# add_blacklight_field :index_field, [{ :field => 'format', :label => 'Format' }, IndexField.new(:field => 'date', :label => 'Date')]
|
|
69
84
|
#
|
|
70
85
|
def add_blacklight_field config_key, *args, &block
|
|
71
86
|
field_config = case args.first
|
|
@@ -121,8 +136,9 @@ module Blacklight
|
|
|
121
136
|
end
|
|
122
137
|
|
|
123
138
|
protected
|
|
139
|
+
|
|
124
140
|
def luke_fields
|
|
125
|
-
if @table[:luke_fields]
|
|
141
|
+
if @table[:luke_fields] == false
|
|
126
142
|
return nil
|
|
127
143
|
end
|
|
128
144
|
|
|
@@ -179,6 +195,7 @@ module Blacklight
|
|
|
179
195
|
end
|
|
180
196
|
|
|
181
197
|
private
|
|
198
|
+
|
|
182
199
|
# convert a config key to the appropriate Field class
|
|
183
200
|
def field_class_from_key key
|
|
184
201
|
"Blacklight::Configuration::#{key.camelcase}".constantize
|
|
@@ -4,7 +4,7 @@ module Blacklight
|
|
|
4
4
|
##
|
|
5
5
|
# Sanitize the search parameters by removing unnecessary parameters
|
|
6
6
|
# from the provided parameters.
|
|
7
|
-
# @param [Hash]
|
|
7
|
+
# @param [Hash] params parameters
|
|
8
8
|
def self.sanitize params
|
|
9
9
|
params.reject { |k,v| v.nil? }
|
|
10
10
|
.except(:action, :controller, :id, :commit, :utf8)
|
|
@@ -11,14 +11,18 @@ module Blacklight
|
|
|
11
11
|
|
|
12
12
|
attr_reader :processor_chain, :blacklight_params
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
# @
|
|
14
|
+
|
|
15
|
+
# @overload initialize(scope)
|
|
16
|
+
# @param [Object] scope scope the scope where the filter methods reside in.
|
|
17
|
+
# @overload initialize(processor_chain, scope)
|
|
18
|
+
# @param [List<Symbol>,TrueClass] processor_chain options a list of filter methods to run or true, to use the default methods
|
|
19
|
+
# @param [Object] scope scope the scope where the filter methods reside in.
|
|
16
20
|
def initialize(*options)
|
|
17
21
|
@scope = case options.size
|
|
18
22
|
when 1
|
|
19
23
|
options.first
|
|
20
24
|
when 2
|
|
21
|
-
if options.first
|
|
25
|
+
if options.first == true
|
|
22
26
|
Deprecation.warn Blacklight::SearchBuilder, "SearchBuilder#initialize now takes only one parameter, the scope. Passing `true' will be removed in Blacklight 7"
|
|
23
27
|
else
|
|
24
28
|
@processor_chain = options.first
|
|
@@ -36,7 +40,7 @@ module Blacklight
|
|
|
36
40
|
|
|
37
41
|
##
|
|
38
42
|
# Set the parameters to pass through the processor chain
|
|
39
|
-
def with
|
|
43
|
+
def with(blacklight_params = {})
|
|
40
44
|
params_will_change!
|
|
41
45
|
@blacklight_params = blacklight_params.dup
|
|
42
46
|
self
|
|
@@ -44,7 +48,7 @@ module Blacklight
|
|
|
44
48
|
|
|
45
49
|
##
|
|
46
50
|
# Update the :q (query) parameter
|
|
47
|
-
def where
|
|
51
|
+
def where(conditions)
|
|
48
52
|
params_will_change!
|
|
49
53
|
@blacklight_params[:q] = conditions
|
|
50
54
|
self
|
|
@@ -52,55 +56,53 @@ module Blacklight
|
|
|
52
56
|
|
|
53
57
|
##
|
|
54
58
|
# Append additional processor chain directives
|
|
55
|
-
def append
|
|
59
|
+
def append(*addl_processor_chain)
|
|
56
60
|
params_will_change!
|
|
57
61
|
builder = self.class.new(processor_chain + addl_processor_chain, scope)
|
|
58
62
|
.with(blacklight_params)
|
|
59
63
|
.merge(@merged_params)
|
|
60
64
|
.reverse_merge(@reverse_merged_params)
|
|
61
65
|
|
|
62
|
-
builder.start
|
|
63
|
-
builder.rows
|
|
64
|
-
builder.page
|
|
65
|
-
builder.facet
|
|
66
|
-
|
|
66
|
+
builder.start = @start if @start
|
|
67
|
+
builder.rows = @rows if @rows
|
|
68
|
+
builder.page = @page if @page
|
|
69
|
+
builder.facet = @facet if @facet
|
|
67
70
|
builder
|
|
68
71
|
end
|
|
69
72
|
|
|
70
73
|
##
|
|
71
74
|
# Converse to append, remove processor chain directives,
|
|
72
75
|
# returning a new builder that's a copy of receiver with
|
|
73
|
-
# specified change.
|
|
76
|
+
# specified change.
|
|
74
77
|
#
|
|
75
78
|
# Methods in argument that aren't currently in processor
|
|
76
|
-
# chain are ignored as no-ops, rather than raising.
|
|
77
|
-
def except
|
|
79
|
+
# chain are ignored as no-ops, rather than raising.
|
|
80
|
+
def except(*except_processor_chain)
|
|
78
81
|
builder = self.class.new(processor_chain - except_processor_chain, scope)
|
|
79
82
|
.with(blacklight_params)
|
|
80
83
|
.merge(@merged_params)
|
|
81
84
|
.reverse_merge(@reverse_merged_params)
|
|
82
85
|
|
|
83
|
-
builder.start
|
|
84
|
-
builder.rows
|
|
85
|
-
builder.page
|
|
86
|
-
builder.facet
|
|
87
|
-
|
|
86
|
+
builder.start = @start if @start
|
|
87
|
+
builder.rows = @rows if @rows
|
|
88
|
+
builder.page = @page if @page
|
|
89
|
+
builder.facet = @facet if @facet
|
|
88
90
|
builder
|
|
89
91
|
end
|
|
90
92
|
|
|
91
93
|
##
|
|
92
94
|
# Merge additional, repository-specific parameters
|
|
93
|
-
def merge
|
|
95
|
+
def merge(extra_params, &block)
|
|
94
96
|
if extra_params
|
|
95
97
|
params_will_change!
|
|
96
98
|
@merged_params.merge!(extra_params.to_hash, &block)
|
|
97
99
|
end
|
|
98
100
|
self
|
|
99
101
|
end
|
|
100
|
-
|
|
102
|
+
|
|
101
103
|
##
|
|
102
104
|
# "Reverse merge" additional, repository-specific parameters
|
|
103
|
-
def reverse_merge
|
|
105
|
+
def reverse_merge(extra_params, &block)
|
|
104
106
|
if extra_params
|
|
105
107
|
params_will_change!
|
|
106
108
|
@reverse_merged_params.reverse_merge!(extra_params.to_hash, &block)
|
|
@@ -111,23 +113,18 @@ module Blacklight
|
|
|
111
113
|
delegate :[], :key?, to: :to_hash
|
|
112
114
|
|
|
113
115
|
# a solr query method
|
|
114
|
-
# @param [Hash] extra_controller_params (nil) extra parameters to add to the search
|
|
115
116
|
# @return [Blacklight::Solr::Response] the solr response object
|
|
116
117
|
def to_hash
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
else
|
|
123
|
-
@params
|
|
124
|
-
end
|
|
118
|
+
return @params unless params_need_update?
|
|
119
|
+
@params = processed_parameters.
|
|
120
|
+
reverse_merge(@reverse_merged_params).
|
|
121
|
+
merge(@merged_params).
|
|
122
|
+
tap { self.clear_changes }
|
|
125
123
|
end
|
|
126
124
|
|
|
127
125
|
alias_method :query, :to_hash
|
|
128
126
|
alias_method :to_h, :to_hash
|
|
129
127
|
|
|
130
|
-
# @returns a params hash for searching solr.
|
|
131
128
|
# The CatalogController #index action uses this.
|
|
132
129
|
# Solr parameters can come from a number of places. From lowest
|
|
133
130
|
# precedence to highest:
|
|
@@ -142,6 +139,8 @@ module Blacklight
|
|
|
142
139
|
# specified otherwise.
|
|
143
140
|
#
|
|
144
141
|
# Incoming parameter :f is mapped to :fq solr parameter.
|
|
142
|
+
#
|
|
143
|
+
# @return a params hash for searching solr.
|
|
145
144
|
def processed_parameters
|
|
146
145
|
request.tap do |request_parameters|
|
|
147
146
|
processor_chain.each do |method_name|
|
|
@@ -150,80 +149,90 @@ module Blacklight
|
|
|
150
149
|
end
|
|
151
150
|
end
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
scope.blacklight_config
|
|
155
|
-
end
|
|
152
|
+
delegate :blacklight_config, to: :scope
|
|
156
153
|
|
|
157
|
-
def start
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
self
|
|
162
|
-
else
|
|
163
|
-
@start ||= (page - 1) * (rows || 10)
|
|
154
|
+
def start=(value)
|
|
155
|
+
params_will_change!
|
|
156
|
+
@start = value.to_i
|
|
157
|
+
end
|
|
164
158
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
# @param [#to_i] value
|
|
160
|
+
def start(value = nil)
|
|
161
|
+
if value
|
|
162
|
+
self.start = value
|
|
163
|
+
return self
|
|
168
164
|
end
|
|
165
|
+
@start ||= (page - 1) * (rows || 10)
|
|
166
|
+
val = @start || 0
|
|
167
|
+
val = 0 if @start < 0
|
|
168
|
+
val
|
|
169
169
|
end
|
|
170
170
|
alias_method :padding, :start
|
|
171
171
|
|
|
172
|
-
def page
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@page = 1 if @page < 1
|
|
177
|
-
self
|
|
178
|
-
else
|
|
179
|
-
@page ||= begin
|
|
180
|
-
page = if blacklight_params[:page].blank?
|
|
181
|
-
1
|
|
182
|
-
else
|
|
183
|
-
blacklight_params[:page].to_i
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
page
|
|
187
|
-
end
|
|
188
|
-
end
|
|
172
|
+
def page=(value)
|
|
173
|
+
params_will_change!
|
|
174
|
+
@page = value.to_i
|
|
175
|
+
@page = 1 if @page < 1
|
|
189
176
|
end
|
|
190
177
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
rows = blacklight_config.default_per_page
|
|
200
|
-
|
|
201
|
-
# user-provided parameters should override any default row
|
|
202
|
-
rows = blacklight_params[:rows].to_i unless blacklight_params[:rows].blank?
|
|
203
|
-
rows = blacklight_params[:per_page].to_i unless blacklight_params[:per_page].blank?
|
|
178
|
+
# @param [#to_i] value
|
|
179
|
+
def page(value = nil)
|
|
180
|
+
if value
|
|
181
|
+
self.page = value
|
|
182
|
+
return self
|
|
183
|
+
end
|
|
184
|
+
@page ||= blacklight_params[:page].blank? ? 1 : blacklight_params[:page].to_i
|
|
185
|
+
end
|
|
204
186
|
|
|
205
|
-
|
|
206
|
-
|
|
187
|
+
def rows=(value)
|
|
188
|
+
params_will_change!
|
|
189
|
+
@rows = [value, blacklight_config.max_per_page].map(&:to_i).min
|
|
190
|
+
end
|
|
207
191
|
|
|
208
|
-
|
|
209
|
-
|
|
192
|
+
# @param [#to_i] value
|
|
193
|
+
def rows(value = nil)
|
|
194
|
+
if value
|
|
195
|
+
self.rows = value
|
|
196
|
+
return self
|
|
197
|
+
end
|
|
198
|
+
@rows ||= begin
|
|
199
|
+
# user-provided parameters should override any default row
|
|
200
|
+
r = [:rows, :per_page].map {|k| blacklight_params[k] }.reject(&:blank?).first
|
|
201
|
+
r ||= blacklight_config.default_per_page
|
|
202
|
+
# ensure we don't excede the max page size
|
|
203
|
+
r.nil? ? nil : [r, blacklight_config.max_per_page].map(&:to_i).min
|
|
210
204
|
end
|
|
211
205
|
end
|
|
212
206
|
|
|
213
207
|
alias per rows
|
|
214
208
|
|
|
209
|
+
# sets the facet that this query pertains to, for the purpose of facet pagination
|
|
210
|
+
def facet=(value)
|
|
211
|
+
params_will_change!
|
|
212
|
+
@facet = value
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# @param [Object] value
|
|
216
|
+
def facet(value = nil)
|
|
217
|
+
if value
|
|
218
|
+
self.facet = value
|
|
219
|
+
return self
|
|
220
|
+
end
|
|
221
|
+
@facet
|
|
222
|
+
end
|
|
223
|
+
|
|
215
224
|
def sort
|
|
216
225
|
sort_field = if blacklight_params[:sort].blank?
|
|
217
226
|
# no sort param provided, use default
|
|
218
227
|
blacklight_config.default_sort_field
|
|
219
228
|
else
|
|
220
|
-
# check for sort field key
|
|
229
|
+
# check for sort field key
|
|
221
230
|
blacklight_config.sort_fields[blacklight_params[:sort]]
|
|
222
231
|
end
|
|
223
232
|
|
|
224
233
|
field = if sort_field.present?
|
|
225
234
|
sort_field.sort
|
|
226
|
-
else
|
|
235
|
+
else
|
|
227
236
|
# just pass the key through
|
|
228
237
|
blacklight_params[:sort]
|
|
229
238
|
end
|
|
@@ -231,23 +240,12 @@ module Blacklight
|
|
|
231
240
|
field unless field.blank?
|
|
232
241
|
end
|
|
233
242
|
|
|
234
|
-
# sets the facet that this query pertains to, if it is for the purpose of
|
|
235
|
-
# facet pagination
|
|
236
|
-
def facet(facet = nil)
|
|
237
|
-
if facet
|
|
238
|
-
params_will_change!
|
|
239
|
-
@facet = facet
|
|
240
|
-
self
|
|
241
|
-
else
|
|
242
|
-
@facet
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
|
|
246
243
|
def search_field
|
|
247
244
|
blacklight_config.search_fields[blacklight_params[:search_field]]
|
|
248
245
|
end
|
|
249
246
|
|
|
250
247
|
protected
|
|
248
|
+
|
|
251
249
|
def request
|
|
252
250
|
Blacklight::Solr::Request.new
|
|
253
251
|
end
|
|
@@ -256,9 +254,7 @@ module Blacklight
|
|
|
256
254
|
field.include_in_request || (field.include_in_request.nil? && blacklight_config.add_field_configuration_to_solr_request)
|
|
257
255
|
end
|
|
258
256
|
|
|
259
|
-
|
|
260
|
-
@scope
|
|
261
|
-
end
|
|
257
|
+
attr_reader :scope
|
|
262
258
|
|
|
263
259
|
def params_will_change!
|
|
264
260
|
@dirty = true
|
|
@@ -3,10 +3,11 @@ module Blacklight
|
|
|
3
3
|
# This class encapsulates the search state as represented by the query
|
|
4
4
|
# parameters namely: :f, :q, :page, :per_page and, :sort
|
|
5
5
|
class SearchState
|
|
6
|
-
include Blacklight::Facet
|
|
7
6
|
attr_reader :blacklight_config # Must be called blacklight_config, because Blacklight::Facet calls blacklight_config.
|
|
8
7
|
attr_reader :params
|
|
9
8
|
|
|
9
|
+
delegate :facet_configuration_for_field, to: :blacklight_config
|
|
10
|
+
|
|
10
11
|
# @param [ActionController::Parameters] params
|
|
11
12
|
# @param [Blacklight::Config] blacklight_config
|
|
12
13
|
def initialize(params, blacklight_config)
|