blacklight 9.0.0 → 9.1.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/.env +3 -3
- data/.github/matrix.json +12 -18
- data/.github/workflows/lint.yml +1 -1
- data/.github/workflows/test.yml +4 -3
- data/.rubocop.yml +72 -7
- data/.rubocop_todo.yml +142 -268
- data/Gemfile +1 -1
- data/README.md +2 -9
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +37 -23
- data/app/assets/images/blacklight/logo-dark.svg +184 -0
- data/app/assets/images/blacklight/logo.svg +184 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js +128 -45
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +128 -45
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +17 -0
- data/app/assets/stylesheets/blacklight/_constraints.scss +2 -2
- data/app/assets/stylesheets/blacklight/_facets.scss +14 -10
- data/app/assets/stylesheets/blacklight/_header.scss +0 -4
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -9
- data/app/components/blacklight/facets/inclusive_constraint_component.html.erb +1 -1
- data/app/components/blacklight/icons/checkmark_component.rb +16 -0
- data/app/components/blacklight/icons/circle_half_component.rb +16 -0
- data/app/components/blacklight/icons/moon_stars_component.rb +17 -0
- data/app/components/blacklight/icons/sun_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.rb +1 -1
- data/app/components/blacklight/search_navbar_component.html.erb +1 -1
- data/app/components/blacklight/theme_switcher_component.html.erb +31 -0
- data/app/components/blacklight/theme_switcher_component.rb +6 -0
- data/app/components/blacklight/top_navbar_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +8 -14
- data/app/controllers/concerns/blacklight/catalog.rb +9 -10
- data/app/controllers/concerns/blacklight/controller.rb +54 -11
- data/app/controllers/concerns/blacklight/guest_user.rb +51 -0
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/controllers/concerns/blacklight/search_history.rb +3 -1
- data/app/controllers/concerns/blacklight/searchable.rb +18 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +7 -0
- data/app/javascript/blacklight-frontend/color_theme_switcher.js +85 -0
- data/app/javascript/blacklight-frontend/index.js +2 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +2 -2
- data/app/models/concerns/blacklight/document.rb +1 -1
- data/app/models/concerns/blacklight/user.rb +36 -0
- data/app/presenters/blacklight/field_presenter.rb +1 -1
- data/app/presenters/blacklight/rendering/microdata.rb +1 -0
- data/app/services/blacklight/bookmarks_search_builder.rb +4 -4
- data/app/services/blacklight/search_service.rb +46 -33
- data/app/values/blacklight/types.rb +1 -1
- data/app/views/catalog/_email_form.html.erb +3 -3
- data/app/views/catalog/_home_text.html.erb +1 -1
- data/app/views/catalog/_sms_form.html.erb +4 -4
- data/app/views/catalog/index.rss.builder +4 -4
- data/app/views/catalog/opensearch.json.jbuilder +3 -0
- data/app/views/catalog/opensearch.xml.builder +2 -2
- data/app/views/layouts/blacklight/base.html.erb +13 -1
- data/app/views/shared/_user_util_links.html.erb +18 -5
- data/blacklight.gemspec +3 -3
- data/config/locales/blacklight.ar.yml +5 -0
- data/config/locales/blacklight.ca.yml +5 -0
- data/config/locales/blacklight.de.yml +6 -2
- data/config/locales/blacklight.en.yml +5 -0
- data/config/locales/blacklight.es.yml +5 -0
- data/config/locales/blacklight.fr.yml +5 -0
- data/config/locales/blacklight.hu.yml +5 -0
- data/config/locales/blacklight.it.yml +6 -2
- data/config/locales/blacklight.nl.yml +5 -0
- data/config/locales/blacklight.pt-BR.yml +6 -2
- data/config/locales/blacklight.sq.yml +5 -0
- data/config/locales/blacklight.zh.yml +5 -0
- data/lib/blacklight/component.rb +1 -1
- data/lib/blacklight/configuration/action_config_map_entry.rb +31 -0
- data/lib/blacklight/configuration/display_field.rb +1 -0
- data/lib/blacklight/configuration/field.rb +6 -6
- data/lib/blacklight/configuration/fields.rb +1 -1
- data/lib/blacklight/configuration/sort_field.rb +2 -2
- data/lib/blacklight/configuration.rb +30 -19
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/search_builder.rb +58 -19
- data/lib/blacklight/search_state.rb +4 -0
- data/lib/blacklight/solr/request.rb +8 -1
- data/lib/blacklight/solr/response/group_response.rb +1 -1
- data/lib/blacklight/solr/response/spelling.rb +8 -8
- data/lib/blacklight/solr/response.rb +2 -21
- data/lib/blacklight/solr/search_builder_behavior.rb +3 -9
- data/lib/blacklight.rb +2 -2
- data/lib/generators/blacklight/assets/importmap_generator.rb +2 -2
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/generators/blacklight/controller_generator.rb +1 -1
- data/lib/generators/blacklight/document_generator.rb +1 -1
- data/lib/generators/blacklight/install_generator.rb +6 -4
- data/lib/generators/blacklight/models_generator.rb +1 -1
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/solr_generator.rb +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +20 -1
- data/lib/generators/blacklight/templates/solr/conf/schema.xml +264 -178
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +6 -14
- data/lib/generators/blacklight/test_support_generator.rb +1 -1
- data/lib/generators/blacklight/user_generator.rb +66 -5
- data/lib/railties/blacklight.rake +4 -4
- data/package.json +2 -2
- data/spec/components/blacklight/document/action_component_spec.rb +1 -1
- data/spec/components/blacklight/document/group_component_spec.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +9 -9
- data/spec/components/blacklight/facet_component_spec.rb +2 -2
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +1 -2
- data/spec/components/blacklight/facets/list_component_spec.rb +1 -1
- data/spec/components/blacklight/facets/suggest_component_spec.rb +1 -2
- data/spec/components/blacklight/metadata_field_component_spec.rb +26 -0
- data/spec/components/blacklight/skip_link_component_spec.rb +2 -2
- data/spec/controllers/application_controller_spec.rb +71 -0
- data/spec/controllers/bookmarks_controller_spec.rb +18 -5
- data/spec/controllers/catalog_controller_spec.rb +7 -5
- data/spec/features/advanced_search_spec.rb +29 -16
- data/spec/features/alternate_controller_spec.rb +4 -4
- data/spec/features/axe_spec.rb +34 -22
- data/spec/features/bookmarks_spec.rb +13 -13
- data/spec/features/dark_mode_spec.rb +42 -0
- data/spec/features/did_you_mean_spec.rb +27 -27
- data/spec/features/facet_missing_spec.rb +3 -3
- data/spec/features/record_view_spec.rb +14 -14
- data/spec/features/search_context_spec.rb +8 -8
- data/spec/features/search_filters_spec.rb +16 -16
- data/spec/features/search_formats_spec.rb +2 -2
- data/spec/features/search_history_spec.rb +11 -11
- data/spec/features/search_pagination_spec.rb +17 -17
- data/spec/features/search_results_spec.rb +3 -3
- data/spec/features/search_sort_spec.rb +4 -4
- data/spec/features/search_spec.rb +20 -20
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +15 -15
- data/spec/helpers/blacklight_helper_spec.rb +1 -1
- data/spec/helpers/catalog_helper_spec.rb +7 -7
- data/spec/integration/generators/blacklight/user_generator_spec.rb +60 -0
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +1 -1
- data/spec/models/blacklight/configurable_spec.rb +1 -1
- data/spec/models/blacklight/configuration_spec.rb +0 -19
- data/spec/models/blacklight/document/dublin_core_spec.rb +2 -2
- data/spec/models/blacklight/facet_paginator_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +15 -3
- data/spec/models/blacklight/solr/repository_spec.rb +10 -2
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +3 -5
- data/spec/models/blacklight/user_spec.rb +32 -5
- data/spec/models/bookmark_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +8 -8
- data/spec/models/search_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +4 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +1 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/thumbnail_presenter_spec.rb +1 -0
- data/spec/services/blacklight/search_service_spec.rb +7 -7
- data/spec/spec_helper.rb +3 -12
- data/spec/support/features/session_helpers.rb +13 -4
- data/spec/support/features/turbo_helpers.rb +13 -0
- data/spec/support/features.rb +2 -0
- data/spec/support/user_helpers.rb +24 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +5 -5
- data/spec/views/catalog/index.html.erb_spec.rb +2 -2
- data/spec/views/catalog/show.html.erb_spec.rb +3 -4
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +56 -0
- data/template.demo.rb +2 -1
- metadata +30 -22
- data/.hound.yml +0 -4
- data/.jshintrc +0 -22
- data/app/assets/images/blacklight/logo.png +0 -0
|
@@ -9,14 +9,14 @@ module Blacklight
|
|
|
9
9
|
class_attribute :default_processor_chain
|
|
10
10
|
self.default_processor_chain = []
|
|
11
11
|
|
|
12
|
-
attr_reader :processor_chain, :
|
|
12
|
+
attr_reader :processor_chain, :blacklight_config
|
|
13
13
|
|
|
14
14
|
# @overload initialize(scope)
|
|
15
15
|
# @param [Object] scope the scope where the filter methods reside in.
|
|
16
16
|
# @overload initialize(processor_chain, scope)
|
|
17
17
|
# @param [List<Symbol>,TrueClass] processor_chain options a list of filter methods to run or true, to use the default methods
|
|
18
18
|
# @param [Object] scope the scope where the filter methods reside in.
|
|
19
|
-
def initialize(*options)
|
|
19
|
+
def initialize(*options, blacklight_config: nil)
|
|
20
20
|
case options.size
|
|
21
21
|
when 1
|
|
22
22
|
@processor_chain = default_processor_chain.dup
|
|
@@ -27,20 +27,29 @@ module Blacklight
|
|
|
27
27
|
raise ArgumentError, "wrong number of arguments. (#{options.size} for 1..2)"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
@
|
|
31
|
-
search_state_class = @scope.try(:search_state_class) || Blacklight::SearchState
|
|
32
|
-
@search_state = search_state_class.new(@blacklight_params, @scope&.blacklight_config, @scope)
|
|
30
|
+
@blacklight_config = blacklight_config || @scope&.blacklight_config
|
|
33
31
|
@additional_filters = {}
|
|
34
32
|
@merged_params = {}
|
|
35
33
|
@reverse_merged_params = {}
|
|
36
34
|
end
|
|
37
35
|
|
|
36
|
+
def search_state
|
|
37
|
+
@search_state ||= begin
|
|
38
|
+
search_state_class = @scope.try(:search_state_class) || Blacklight::SearchState
|
|
39
|
+
@search_state = search_state_class.new({}, blacklight_config, @scope)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def blacklight_params
|
|
44
|
+
search_state.params
|
|
45
|
+
end
|
|
46
|
+
Blacklight.deprecation.deprecate_methods(self, blacklight_params: 'Use search_state.params instead of blacklight_params directly')
|
|
47
|
+
|
|
38
48
|
##
|
|
39
49
|
# Set the parameters to pass through the processor chain
|
|
40
50
|
def with(blacklight_params_or_search_state = {})
|
|
41
51
|
params_will_change!
|
|
42
|
-
@search_state = blacklight_params_or_search_state.is_a?(Blacklight::SearchState) ? blacklight_params_or_search_state :
|
|
43
|
-
@blacklight_params = @search_state.params.dup
|
|
52
|
+
@search_state = blacklight_params_or_search_state.is_a?(Blacklight::SearchState) ? blacklight_params_or_search_state : search_state.reset(blacklight_params_or_search_state)
|
|
44
53
|
self
|
|
45
54
|
end
|
|
46
55
|
|
|
@@ -51,8 +60,7 @@ module Blacklight
|
|
|
51
60
|
# search_builder.where(id: [1,2,3]) # produces: q:"{!lucene}id:(1 OR 2 OR 3)"
|
|
52
61
|
def where(conditions)
|
|
53
62
|
params_will_change!
|
|
54
|
-
@search_state =
|
|
55
|
-
@blacklight_params = @search_state.params
|
|
63
|
+
@search_state = search_state.reset(search_state.params.merge(q: conditions))
|
|
56
64
|
@additional_filters = conditions
|
|
57
65
|
self
|
|
58
66
|
end
|
|
@@ -127,8 +135,8 @@ module Blacklight
|
|
|
127
135
|
.tap { clear_changes }
|
|
128
136
|
end
|
|
129
137
|
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
alias query to_hash
|
|
139
|
+
alias to_h to_hash
|
|
132
140
|
|
|
133
141
|
# The CatalogController #index action uses this.
|
|
134
142
|
# Solr parameters can come from a number of places. From lowest
|
|
@@ -154,16 +162,43 @@ module Blacklight
|
|
|
154
162
|
end
|
|
155
163
|
end
|
|
156
164
|
|
|
157
|
-
|
|
165
|
+
def default_document_pagination_params
|
|
166
|
+
{ fl: blacklight_config.document_model.unique_key }
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def for_previous_and_next_documents(index, window = 1)
|
|
170
|
+
document_pagination_params = blacklight_config.document_pagination_params.dup
|
|
171
|
+
|
|
172
|
+
if document_pagination_params.empty?
|
|
173
|
+
merge(default_document_pagination_params)
|
|
174
|
+
else
|
|
175
|
+
merge(document_pagination_params)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
if index > 0
|
|
179
|
+
self.start = [index - window, 0].max
|
|
180
|
+
self.rows = (2 * window) + 1
|
|
181
|
+
else
|
|
182
|
+
self.start = 0
|
|
183
|
+
self.rows = 2 * window
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
self
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# An undefined value that can be used to detect if a parameter was passed in or not, since nil and false may be valid values for some parameters.
|
|
190
|
+
UNDEFINED = Object.new.freeze
|
|
158
191
|
|
|
159
192
|
def start=(value)
|
|
193
|
+
return if value.nil?
|
|
194
|
+
|
|
160
195
|
params_will_change!
|
|
161
196
|
@start = value.to_i
|
|
162
197
|
end
|
|
163
198
|
|
|
164
199
|
# @param [#to_i] value
|
|
165
|
-
def start(value =
|
|
166
|
-
if value
|
|
200
|
+
def start(value = Blacklight::SearchBuilder::UNDEFINED)
|
|
201
|
+
if value != Blacklight::SearchBuilder::UNDEFINED
|
|
167
202
|
self.start = value
|
|
168
203
|
return self
|
|
169
204
|
end
|
|
@@ -172,17 +207,19 @@ module Blacklight
|
|
|
172
207
|
val = 0 if @start < 0
|
|
173
208
|
val
|
|
174
209
|
end
|
|
175
|
-
|
|
210
|
+
alias padding start
|
|
176
211
|
|
|
177
212
|
def page=(value)
|
|
213
|
+
return if value.nil?
|
|
214
|
+
|
|
178
215
|
params_will_change!
|
|
179
216
|
@page = value.to_i
|
|
180
217
|
@page = 1 if @page < 1
|
|
181
218
|
end
|
|
182
219
|
|
|
183
220
|
# @param [#to_i] value
|
|
184
|
-
def page(value =
|
|
185
|
-
if value
|
|
221
|
+
def page(value = Blacklight::SearchBuilder::UNDEFINED)
|
|
222
|
+
if value != Blacklight::SearchBuilder::UNDEFINED
|
|
186
223
|
self.page = value
|
|
187
224
|
return self
|
|
188
225
|
end
|
|
@@ -190,13 +227,15 @@ module Blacklight
|
|
|
190
227
|
end
|
|
191
228
|
|
|
192
229
|
def rows=(value)
|
|
230
|
+
return if value.nil?
|
|
231
|
+
|
|
193
232
|
params_will_change!
|
|
194
233
|
@rows = [value, blacklight_config.max_per_page].map(&:to_i).min
|
|
195
234
|
end
|
|
196
235
|
|
|
197
236
|
# @param [#to_i] value
|
|
198
|
-
def rows(value =
|
|
199
|
-
if value
|
|
237
|
+
def rows(value = Blacklight::SearchBuilder::UNDEFINED)
|
|
238
|
+
if value != Blacklight::SearchBuilder::UNDEFINED
|
|
200
239
|
self.rows = value
|
|
201
240
|
return self
|
|
202
241
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
class Blacklight::Solr::InvalidParameter < ArgumentError; end
|
|
4
4
|
|
|
5
|
-
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
|
5
|
+
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess # rubocop:disable Style/OneClassPerFile
|
|
6
6
|
def initialize(constructor = {})
|
|
7
7
|
if constructor.is_a?(Hash)
|
|
8
8
|
super()
|
|
@@ -52,6 +52,13 @@ class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
|
|
52
52
|
self['fq'] << query
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# Filter the results to a specific set of values in the given field.
|
|
56
|
+
# @param [String] field
|
|
57
|
+
# @param [Array<String>] values
|
|
58
|
+
def append_ids_filter(field, values)
|
|
59
|
+
append_filter_query("{!terms f=#{field}}#{Array(values).join(',')}")
|
|
60
|
+
end
|
|
61
|
+
|
|
55
62
|
def append_facet_fields(values)
|
|
56
63
|
self['facet.field'] ||= []
|
|
57
64
|
self['facet.field'] += Array(values)
|
|
@@ -53,14 +53,14 @@ module Blacklight::Solr::Response::Spelling
|
|
|
53
53
|
# suggestion => [{ frequency =>, word => }] # for extended results
|
|
54
54
|
# suggestion => ['word'] # for non-extended results
|
|
55
55
|
orig_freq = term_info['origFreq']
|
|
56
|
-
if term_info['suggestion'].first.is_a?(Hash)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
word_suggestions << if term_info['suggestion'].first.is_a?(Hash)
|
|
57
|
+
term_info['suggestion'].map do |suggestion|
|
|
58
|
+
suggestion['word'] if suggestion['freq'] > orig_freq
|
|
59
|
+
end
|
|
60
|
+
else
|
|
61
|
+
# only extended suggestions have frequency so we just return all suggestions
|
|
62
|
+
term_info['suggestion']
|
|
63
|
+
end
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -18,7 +18,7 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
18
18
|
def initialize(data, request_params, options = {})
|
|
19
19
|
@search_builder = request_params if request_params.is_a?(Blacklight::SearchBuilder)
|
|
20
20
|
|
|
21
|
-
super(
|
|
21
|
+
super(ActiveSupport::HashWithIndifferentAccess.new(data))
|
|
22
22
|
@request_params = ActiveSupport::HashWithIndifferentAccess.new(request_params)
|
|
23
23
|
self.blacklight_config = options[:blacklight_config]
|
|
24
24
|
self.options = options
|
|
@@ -31,7 +31,7 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
31
31
|
def documents
|
|
32
32
|
@documents ||= (response['docs'] || []).collect { |doc| document_factory.build(doc, self, options) }
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
alias docs documents
|
|
35
35
|
|
|
36
36
|
def grouped
|
|
37
37
|
@groups ||= self["grouped"].map do |field, group|
|
|
@@ -61,23 +61,4 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
61
61
|
def export_formats
|
|
62
62
|
documents.map { |x| x.export_formats.keys }.flatten.uniq
|
|
63
63
|
end
|
|
64
|
-
|
|
65
|
-
private
|
|
66
|
-
|
|
67
|
-
def force_to_utf8(value)
|
|
68
|
-
case value
|
|
69
|
-
when Hash
|
|
70
|
-
value.each { |k, v| value[k] = force_to_utf8(v) }
|
|
71
|
-
when Array
|
|
72
|
-
value.each { |v| force_to_utf8(v) }
|
|
73
|
-
when String
|
|
74
|
-
if value.encoding == Encoding::UTF_8
|
|
75
|
-
value
|
|
76
|
-
else
|
|
77
|
-
Blacklight.logger&.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
|
|
78
|
-
value.dup.force_encoding('UTF-8')
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
value
|
|
82
|
-
end
|
|
83
64
|
end
|
|
@@ -102,7 +102,7 @@ module Blacklight::Solr
|
|
|
102
102
|
|
|
103
103
|
# Transform "clause" parameters into the Solr JSON Query DSL
|
|
104
104
|
def add_adv_search_clauses(solr_parameters)
|
|
105
|
-
return if search_state.clause_params.blank?
|
|
105
|
+
return if search_state.clause_params.blank? || search_state.clause_params.all? { |_k, v| v[:query].blank? }
|
|
106
106
|
|
|
107
107
|
# We need to specify lucene as the top-level defType when using JSON Query DSL in Solr versions
|
|
108
108
|
# between 7.2.0 & 9.4.0. After 9.4.0 this is no longer necessary, but also not harmful to include.
|
|
@@ -112,7 +112,7 @@ module Blacklight::Solr
|
|
|
112
112
|
solr_parameters[:spellcheck] = 'false'
|
|
113
113
|
|
|
114
114
|
defaults = { must: [], must_not: [], should: [] }
|
|
115
|
-
default_op =
|
|
115
|
+
default_op = search_state.query_boolean_operator&.to_sym || :must
|
|
116
116
|
solr_parameters[:mm] = 1 if default_op == :should && search_state.clause_params.values.any? { |clause| }
|
|
117
117
|
|
|
118
118
|
search_state.clause_params.each_value do |clause|
|
|
@@ -200,7 +200,7 @@ module Blacklight::Solr
|
|
|
200
200
|
if facet.pivot
|
|
201
201
|
solr_parameters.append_facet_pivot with_ex_local_param(facet.ex, facet.pivot.join(","))
|
|
202
202
|
elsif facet.query
|
|
203
|
-
solr_parameters.append_facet_query
|
|
203
|
+
solr_parameters.append_facet_query(facet.query.values.map { |x| with_ex_local_param(facet.ex, x[:fq]) })
|
|
204
204
|
else
|
|
205
205
|
solr_parameters.append_facet_fields with_ex_local_param(facet.ex, facet.field)
|
|
206
206
|
end
|
|
@@ -367,12 +367,6 @@ module Blacklight::Solr
|
|
|
367
367
|
end
|
|
368
368
|
end
|
|
369
369
|
|
|
370
|
-
def search_state
|
|
371
|
-
return super if defined?(super)
|
|
372
|
-
|
|
373
|
-
@search_state ||= Blacklight::SearchState.new(blacklight_params, blacklight_config)
|
|
374
|
-
end
|
|
375
|
-
|
|
376
370
|
def add_search_field_query_builder_params(solr_parameters)
|
|
377
371
|
q, additional_parameters = search_field.query_builder.call(self, search_field, solr_parameters)
|
|
378
372
|
|
data/lib/blacklight.rb
CHANGED
|
@@ -85,7 +85,7 @@ module Blacklight
|
|
|
85
85
|
else
|
|
86
86
|
YAML.safe_load(blacklight_erb, [], [], true)
|
|
87
87
|
end
|
|
88
|
-
rescue => e
|
|
88
|
+
rescue StandardError => e
|
|
89
89
|
raise("#{blacklight_config_file} was found, but could not be parsed.\n#{e.inspect}")
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -122,6 +122,6 @@ module Blacklight
|
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
def self.deprecation
|
|
125
|
-
@deprecation ||= ActiveSupport::Deprecation.new('
|
|
125
|
+
@deprecation ||= ActiveSupport::Deprecation.new('10.0', 'Blacklight')
|
|
126
126
|
end
|
|
127
127
|
end
|
|
@@ -8,7 +8,7 @@ module Blacklight
|
|
|
8
8
|
def import_javascript_assets
|
|
9
9
|
append_to_file 'config/importmap.rb' do
|
|
10
10
|
<<~CONTENT
|
|
11
|
-
pin "@github/auto-complete-element", to: "https://cdn.
|
|
11
|
+
pin "@github/auto-complete-element", to: "https://cdn.jsdelivr.net/npm/@github/auto-complete-element@3.8.0/+esm"
|
|
12
12
|
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js"
|
|
13
13
|
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.5'}/dist/js/bootstrap.js"
|
|
14
14
|
CONTENT
|
|
@@ -49,7 +49,7 @@ module Blacklight
|
|
|
49
49
|
else
|
|
50
50
|
append_to_file 'app/assets/stylesheets/application.css' do
|
|
51
51
|
<<~CONTENT
|
|
52
|
-
@import url(https://cdn.jsdelivr.net/npm/bootstrap@5.3.
|
|
52
|
+
@import url(https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css);
|
|
53
53
|
@import url("blacklight.css");
|
|
54
54
|
CONTENT
|
|
55
55
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Blacklight
|
|
4
4
|
class AssetsGenerator < Rails::Generators::Base
|
|
5
|
-
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '5.3.
|
|
5
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '5.3.8'), desc: "Set the generated app's bootstrap version"
|
|
6
6
|
|
|
7
7
|
def run_asset_pipeline_specific_generator
|
|
8
8
|
generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
|
|
@@ -6,7 +6,7 @@ module Blacklight
|
|
|
6
6
|
class DocumentGenerator < Rails::Generators::Base
|
|
7
7
|
include Rails::Generators::Migration
|
|
8
8
|
|
|
9
|
-
source_root File.expand_path('
|
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
|
10
10
|
|
|
11
11
|
argument :model_name, type: :string, default: "solr_document"
|
|
12
12
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Blacklight
|
|
4
4
|
class Install < Rails::Generators::Base
|
|
5
|
-
source_root File.expand_path('
|
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
|
6
6
|
|
|
7
7
|
argument :model_name, type: :string, default: "user"
|
|
8
8
|
argument :controller_name, type: :string, default: "catalog"
|
|
@@ -10,6 +10,7 @@ module Blacklight
|
|
|
10
10
|
argument :search_builder_name, type: :string, default: "search_builder"
|
|
11
11
|
|
|
12
12
|
class_option :devise, type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic."
|
|
13
|
+
class_option :authentication, type: :boolean, default: false, desc: "Use Rails' built-in authentication generator."
|
|
13
14
|
class_option :marc, type: :boolean, default: false, aliases: "-m", desc: "Generate MARC-based demo."
|
|
14
15
|
class_option :'bootstrap-version', type: :string, default: nil, desc: "Set the generated app's bootstrap version"
|
|
15
16
|
class_option :'skip-assets', type: :boolean, default: false, desc: "Skip generating javascript and css assets into the application"
|
|
@@ -62,9 +63,10 @@ module Blacklight
|
|
|
62
63
|
|
|
63
64
|
def generate_blacklight_user
|
|
64
65
|
generator_args = [model_name]
|
|
65
|
-
if options[:devise]
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
raise Thor::Error, "Choose either --devise or --authentication, not both." if options[:devise] && options[:authentication]
|
|
67
|
+
|
|
68
|
+
generator_args << "--devise" if options[:devise]
|
|
69
|
+
generator_args << "--authentication" if options[:authentication]
|
|
68
70
|
|
|
69
71
|
generate 'blacklight:user', generator_args.join(" ")
|
|
70
72
|
end
|
|
@@ -8,7 +8,7 @@ module Blacklight
|
|
|
8
8
|
class ModelsGenerator < Rails::Generators::Base
|
|
9
9
|
include Rails::Generators::Migration
|
|
10
10
|
|
|
11
|
-
source_root File.expand_path('
|
|
11
|
+
source_root File.expand_path('templates', __dir__)
|
|
12
12
|
|
|
13
13
|
desc <<-EOS
|
|
14
14
|
This generator makes the following changes to your application:
|
|
@@ -6,7 +6,7 @@ module Blacklight
|
|
|
6
6
|
class SearchBuilderGenerator < Rails::Generators::Base
|
|
7
7
|
include Rails::Generators::Migration
|
|
8
8
|
|
|
9
|
-
source_root File.expand_path('
|
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
|
10
10
|
|
|
11
11
|
argument :model_name, type: :string, default: "search_builder"
|
|
12
12
|
|
|
@@ -4,7 +4,7 @@ require 'rails/generators'
|
|
|
4
4
|
|
|
5
5
|
module Blacklight
|
|
6
6
|
class SolrGenerator < Rails::Generators::Base
|
|
7
|
-
source_root ::File.expand_path('
|
|
7
|
+
source_root ::File.expand_path('templates', __dir__)
|
|
8
8
|
|
|
9
9
|
desc <<-EOF
|
|
10
10
|
This generator makes the following changes to your application:
|
|
@@ -15,6 +15,9 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
15
15
|
## Specify the style of markup to be generated
|
|
16
16
|
# config.bootstrap_version = 5
|
|
17
17
|
#
|
|
18
|
+
## Show or hide the light/dark mode theme switcher component
|
|
19
|
+
# config.dark_mode_support = true
|
|
20
|
+
#
|
|
18
21
|
## Class for sending and receiving requests from a search index
|
|
19
22
|
# config.repository_class = Blacklight::Solr::Repository
|
|
20
23
|
#
|
|
@@ -36,12 +39,20 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
36
39
|
## Optional fine-tuning for advanced search, e.g., set different limits for
|
|
37
40
|
## different facets.
|
|
38
41
|
# config.advanced_search.form_solr_parameters = {}
|
|
39
|
-
|
|
42
|
+
#
|
|
43
|
+
## What type of HTTP request to make to solr. Use `:post' to support requests longer than the URI length limit.
|
|
44
|
+
## (default is `:get')
|
|
45
|
+
# config.http_method = :post
|
|
46
|
+
#
|
|
40
47
|
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
|
|
41
48
|
config.default_solr_params = {
|
|
42
49
|
rows: 10
|
|
43
50
|
}
|
|
44
51
|
|
|
52
|
+
# If you add any inputs to the search form, you must specify them so that they are not stripped out as unpermitted.
|
|
53
|
+
# By default this includes the fields required for basic search and advanced search.
|
|
54
|
+
# config.search_state_fields += [:search_type]
|
|
55
|
+
|
|
45
56
|
# solr path which will be added to solr base url before the other solr params.
|
|
46
57
|
#config.solr_path = 'select'
|
|
47
58
|
#config.document_solr_path = 'get'
|
|
@@ -164,6 +175,14 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
164
175
|
|
|
165
176
|
# solr fields to be displayed in the show (single result) view
|
|
166
177
|
# The ordering of the field names is the order of the display
|
|
178
|
+
# You can configure some components related to the show field:
|
|
179
|
+
# - component: should have a similar API to
|
|
180
|
+
# Blacklight::MetadataFieldComponent, and describes how
|
|
181
|
+
# the values should be displayed
|
|
182
|
+
# - layout_component: should have a similar API to
|
|
183
|
+
# Blacklight::MetadataFieldLayoutComponent, and describes
|
|
184
|
+
# how the overall layout of the field (both label and
|
|
185
|
+
# values) should be displayed
|
|
167
186
|
config.add_show_field 'title_tsim', label: 'Title'
|
|
168
187
|
config.add_show_field 'title_vern_ssim', label: 'Title'
|
|
169
188
|
config.add_show_field 'subtitle_tsim', label: 'Subtitle'
|