blacklight 9.2.1 → 9.3.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/.github/matrix.json +4 -4
- data/.github/workflows/build.yml +3 -0
- data/.github/workflows/lint.yml +17 -2
- data/.github/workflows/main.yml +3 -0
- data/.github/workflows/release_7_x_scheduled.yml +3 -0
- data/.github/workflows/release_8_x_scheduled.yml +3 -0
- data/.github/workflows/test.yml +3 -2
- data/.gitignore +0 -1
- data/.prettierignore +5 -0
- data/.prettierrc.json +4 -0
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +0 -143
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +39 -9
- data/app/assets/javascripts/blacklight/blacklight.esm.js +207 -125
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +207 -125
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_search_results.scss +24 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +18 -3
- data/app/components/blacklight/constraints_component.rb +2 -1
- data/app/components/blacklight/facet_field_component.rb +1 -1
- data/app/components/blacklight/open_graph_metadata_component.rb +33 -0
- data/app/components/blacklight/search/sidebar_component.html.erb +2 -2
- data/app/components/blacklight/search/sidebar_component.rb +3 -2
- data/app/controllers/concerns/blacklight/catalog.rb +3 -5
- data/app/controllers/concerns/blacklight/controller.rb +2 -6
- data/app/controllers/concerns/blacklight/search_context.rb +2 -7
- data/app/controllers/concerns/blacklight/token_based_user.rb +2 -6
- data/app/helpers/blacklight/catalog_helper_behavior.rb +9 -9
- data/app/helpers/blacklight/url_helper_behavior.rb +2 -7
- data/app/javascript/blacklight-frontend/bookmark_toggle.js +10 -8
- data/app/javascript/blacklight-frontend/checkbox_submit.js +42 -33
- data/app/javascript/blacklight-frontend/color_theme_switcher.js +47 -16
- data/app/javascript/blacklight-frontend/core.js +18 -19
- data/app/javascript/blacklight-frontend/debounce.js +7 -5
- data/app/javascript/blacklight-frontend/facet_suggest.js +27 -25
- data/app/javascript/blacklight-frontend/index.js +1 -1
- data/app/javascript/blacklight-frontend/modal.js +69 -52
- data/app/javascript/blacklight-frontend/search_context.js +36 -17
- data/app/models/blacklight/facet_paginator.rb +1 -3
- data/app/presenters/blacklight/document_presenter.rb +10 -1
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -3
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +0 -8
- data/app/presenters/blacklight/json_presenter.rb +1 -3
- data/app/presenters/blacklight/open_graph_presenter.rb +34 -0
- data/app/presenters/blacklight/thumbnail_presenter.rb +24 -1
- data/app/services/blacklight/field_retriever.rb +1 -3
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/catalog/_document.atom.builder +3 -5
- data/app/views/catalog/_show_main_content.html.erb +1 -0
- data/app/views/catalog/index.atom.builder +8 -4
- data/app/views/layouts/blacklight/base.html.erb +7 -1
- data/config/i18n-tasks.yml +1 -1
- data/config/locales/blacklight.ja.yml +256 -0
- data/lib/blacklight/configuration/context.rb +1 -1
- data/lib/blacklight/configuration/fields.rb +3 -9
- data/lib/blacklight/configuration/view_config.rb +16 -0
- data/lib/blacklight/configuration.rb +6 -2
- data/lib/blacklight/engine.rb +2 -4
- data/lib/blacklight/search_builder.rb +4 -4
- data/lib/blacklight/search_state/filter_field.rb +0 -1
- data/lib/blacklight/search_state.rb +2 -6
- data/lib/blacklight/solr/facet_paginator.rb +1 -1
- data/lib/blacklight/solr/repository.rb +1 -3
- data/lib/blacklight/solr/response/facets.rb +11 -9
- data/lib/blacklight/solr/response/spelling.rb +51 -47
- data/lib/blacklight/solr/search_builder_behavior.rb +14 -15
- data/lib/blacklight.rb +3 -9
- data/lib/generators/blacklight/assets/importmap_generator.rb +3 -3
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/railties/blacklight.rake +3 -5
- data/package-lock.json +1054 -0
- data/package.json +7 -4
- data/rollup.config.js +5 -7
- data/spec/components/blacklight/constraints_component_spec.rb +23 -1
- data/spec/components/blacklight/document/page_header_component_spec.rb +4 -4
- data/spec/components/blacklight/document_component_spec.rb +16 -3
- data/spec/components/blacklight/metadata_field_component_spec.rb +2 -2
- data/spec/components/blacklight/response/spellcheck_component_spec.rb +2 -2
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +1 -1
- data/spec/components/blacklight/system/dropdown_component_spec.rb +1 -2
- data/spec/controllers/bookmarks_controller_spec.rb +3 -9
- data/spec/controllers/catalog_controller_spec.rb +56 -26
- data/spec/features/dark_mode_spec.rb +30 -0
- data/spec/features/did_you_mean_spec.rb +1 -1
- data/spec/features/facet_missing_spec.rb +3 -3
- data/spec/features/modal_spec.rb +2 -2
- data/spec/features/open_graph_spec.rb +43 -0
- data/spec/features/search_context_spec.rb +1 -1
- data/spec/fixtures/sample_solr_documents.yml +6 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +11 -8
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +5 -5
- data/spec/helpers/blacklight_helper_spec.rb +6 -4
- data/spec/helpers/catalog_helper_spec.rb +34 -8
- data/spec/lib/blacklight/configuration/session_tracking_config_spec.rb +2 -2
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +2 -2
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +1 -1
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +1 -1
- data/spec/lib/blacklight/search_state_spec.rb +14 -19
- data/spec/lib/blacklight_spec.rb +5 -5
- data/spec/models/blacklight/configuration_spec.rb +1 -1
- data/spec/models/blacklight/document/cache_key_spec.rb +32 -12
- data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
- data/spec/models/blacklight/icon_spec.rb +3 -3
- data/spec/models/blacklight/search_builder_spec.rb +21 -16
- data/spec/models/blacklight/solr/default_filter_query_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/document_spec.rb +8 -8
- data/spec/models/blacklight/solr/response/facets_spec.rb +5 -5
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -1
- data/spec/models/blacklight/solr/response_spec.rb +18 -3
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +46 -7
- data/spec/models/blacklight/suggest_search_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/models/search_spec.rb +7 -7
- data/spec/presenters/blacklight/document_presenter_spec.rb +19 -6
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +4 -4
- data/spec/presenters/blacklight/field_presenter_spec.rb +12 -9
- data/spec/presenters/blacklight/open_graph_presenter_spec.rb +56 -0
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +3 -3
- data/spec/presenters/blacklight/thumbnail_presenter_spec.rb +129 -13
- data/spec/routing/catalog_routing_spec.rb +1 -1
- data/spec/services/blacklight/field_retriever_spec.rb +1 -1
- data/spec/services/blacklight/search_service_spec.rb +8 -8
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -3
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +16 -20
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +1 -1
- metadata +12 -2
|
@@ -6,6 +6,20 @@ class Blacklight::Configuration
|
|
|
6
6
|
# @return [String] partial to render around the documents
|
|
7
7
|
# @!attribute document_presenter_class
|
|
8
8
|
# @return [Class] document presenter class used by helpers and views
|
|
9
|
+
# @!attribute thumbnail_presenter
|
|
10
|
+
# @return [Class] thumbnail presenter class used by the document presenter; defaults to Blacklight::ThumbnailPresenter
|
|
11
|
+
# @!attribute open_graph_presenter
|
|
12
|
+
# @return [Class] presenter class used to derive Open Graph <meta> properties for a document;
|
|
13
|
+
# defaults to Blacklight::OpenGraphPresenter
|
|
14
|
+
# @!attribute thumbnail_field
|
|
15
|
+
# @return [String, Symbol, Blacklight::Configuration::Field, Array] solr field(s) containing a thumbnail url;
|
|
16
|
+
# the first field with a value is used. Only this source provides a url for og:image.
|
|
17
|
+
# @!attribute thumbnail_method
|
|
18
|
+
# @return [Symbol] helper method that renders a thumbnail; called with the document and image options.
|
|
19
|
+
# Takes precedence over thumbnail_field when rendering a thumbnail.
|
|
20
|
+
# @!attribute default_thumbnail
|
|
21
|
+
# @return [String, Symbol, Proc] thumbnail to render when the document has none: an image asset path,
|
|
22
|
+
# a helper method name, or a proc; methods and procs are called with the document and image options
|
|
9
23
|
# @!attribute document_component
|
|
10
24
|
# @return [Class] component class used to render a document; defaults to Blacklight::DocumentComponent
|
|
11
25
|
# @!attribute document_title_component
|
|
@@ -14,6 +28,8 @@ class Blacklight::Configuration
|
|
|
14
28
|
# @return [Class] component class used to render the document metadata
|
|
15
29
|
# @!attribute document_thumbnail_component
|
|
16
30
|
# @return [Class] component class used to render a document thumbnail
|
|
31
|
+
# @!attribute default_thumbnail
|
|
32
|
+
# @return [String, Symbol, Proc] image asset, helper method, or lambda rendering a default thumbnail
|
|
17
33
|
# @!attribute document_embed_component
|
|
18
34
|
# @return [Class] component class used to render a document embed
|
|
19
35
|
# @!attribute title_field
|
|
@@ -35,8 +35,11 @@ module Blacklight
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
BASIC_SEARCH_PARAMETERS = [
|
|
39
|
-
|
|
38
|
+
BASIC_SEARCH_PARAMETERS = [
|
|
39
|
+
:q, :qt, :page, :per_page, :search_field, :sort, :controller, :action,
|
|
40
|
+
:'facet.page', :'facet.prefix', :'facet.sort', :rows, :format, :view, :id,
|
|
41
|
+
:facet_id, :query_fragment, :only_values
|
|
42
|
+
].freeze
|
|
40
43
|
ADVANCED_SEARCH_PARAMETERS = [{ clause: {} }, :op].freeze
|
|
41
44
|
|
|
42
45
|
# rubocop:disable Metrics/BlockLength
|
|
@@ -45,6 +48,7 @@ module Blacklight
|
|
|
45
48
|
property :skip_link_component, default: Blacklight::SkipLinkComponent
|
|
46
49
|
property :skip_link_item_component, default: Blacklight::SkipLinkItemComponent
|
|
47
50
|
property :header_component, default: Blacklight::HeaderComponent
|
|
51
|
+
property :open_graph_component, default: Blacklight::OpenGraphMetadataComponent
|
|
48
52
|
property :full_width_layout, default: false
|
|
49
53
|
|
|
50
54
|
# @!attribute dark_mode_support
|
data/lib/blacklight/engine.rb
CHANGED
|
@@ -13,9 +13,7 @@ module Blacklight
|
|
|
13
13
|
# enough version of Rails to have zeitwerk config
|
|
14
14
|
#
|
|
15
15
|
# See: https://github.com/cbeer/engine_cart/issues/117
|
|
16
|
-
if Rails.try(:autoloaders).try(:main).respond_to?(:ignore)
|
|
17
|
-
Rails.autoloaders.main.ignore(Rails.root.join('lib/generators'))
|
|
18
|
-
end
|
|
16
|
+
Rails.autoloaders.main.ignore(Rails.root.join('lib/generators')) if Rails.try(:autoloaders).try(:main).respond_to?(:ignore)
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
config.after_initialize do
|
|
@@ -40,7 +38,7 @@ module Blacklight
|
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
PRECOMPILE_ASSETS = %w
|
|
41
|
+
PRECOMPILE_ASSETS = %w[favicon.ico blacklight/blacklight.js blacklight/blacklight.js.map blacklight/blacklight.esm.js blacklight/blacklight.esm.js.map].freeze
|
|
44
42
|
|
|
45
43
|
initializer "blacklight.assets.precompile" do |app|
|
|
46
44
|
# When Rails has been generated in API mode, it does not have sprockets available
|
|
@@ -12,10 +12,10 @@ module Blacklight
|
|
|
12
12
|
attr_reader :processor_chain, :blacklight_config
|
|
13
13
|
|
|
14
14
|
# @overload initialize(scope)
|
|
15
|
-
# @param [
|
|
15
|
+
# @param [Blacklight::SearchService] 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
|
-
# @param [
|
|
18
|
+
# @param [Blacklight::SearchService] scope the scope where the filter methods reside in.
|
|
19
19
|
def initialize(*options, blacklight_config: nil)
|
|
20
20
|
case options.size
|
|
21
21
|
when 1
|
|
@@ -175,7 +175,7 @@ module Blacklight
|
|
|
175
175
|
merge(document_pagination_params)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
-
if index
|
|
178
|
+
if index.positive?
|
|
179
179
|
self.start = [index - window, 0].max
|
|
180
180
|
self.rows = (2 * window) + 1
|
|
181
181
|
else
|
|
@@ -204,7 +204,7 @@ module Blacklight
|
|
|
204
204
|
end
|
|
205
205
|
@start ||= (page - 1) * (rows || 10)
|
|
206
206
|
val = @start || 0
|
|
207
|
-
val = 0 if @start
|
|
207
|
+
val = 0 if @start.negative?
|
|
208
208
|
val
|
|
209
209
|
end
|
|
210
210
|
alias padding start
|
|
@@ -127,13 +127,9 @@ module Blacklight
|
|
|
127
127
|
# params hash we'll return
|
|
128
128
|
my_params = to_h.merge(self.class.new(params_to_merge, blacklight_config, controller))
|
|
129
129
|
|
|
130
|
-
if block_given?
|
|
131
|
-
yield my_params
|
|
132
|
-
end
|
|
130
|
+
yield my_params if block_given?
|
|
133
131
|
|
|
134
|
-
if my_params[:page] && (my_params[:per_page] != params[:per_page] || my_params[:sort] != params[:sort])
|
|
135
|
-
my_params[:page] = 1
|
|
136
|
-
end
|
|
132
|
+
my_params[:page] = 1 if my_params[:page] && (my_params[:per_page] != params[:per_page] || my_params[:sort] != params[:sort])
|
|
137
133
|
|
|
138
134
|
Parameters.sanitize(my_params)
|
|
139
135
|
end
|
|
@@ -26,9 +26,7 @@ module Blacklight::Solr
|
|
|
26
26
|
# @param [Hash,Blacklight::SearchBuilder] params solr query parameters
|
|
27
27
|
# @param [String] path solr request handler path
|
|
28
28
|
def search pos_params = nil, path: nil, params: nil, **kwargs
|
|
29
|
-
if pos_params
|
|
30
|
-
Blacklight.deprecation.warn("Passing positional arguments to search() is deprecated. Use the params kwarg instead.")
|
|
31
|
-
end
|
|
29
|
+
Blacklight.deprecation.warn("Passing positional arguments to search() is deprecated. Use the params kwarg instead.") if pos_params
|
|
32
30
|
|
|
33
31
|
request_params = (params || pos_params || {}).reverse_merge(kwargs).reverse_merge({ qt: blacklight_config.qt })
|
|
34
32
|
|
|
@@ -83,7 +83,7 @@ module Blacklight::Solr::Response::Facets
|
|
|
83
83
|
|
|
84
84
|
# Per https://wiki.apache.org/solr/SimpleFacetParameters#facet.sort
|
|
85
85
|
def solr_default_sort
|
|
86
|
-
if limit
|
|
86
|
+
if limit.positive?
|
|
87
87
|
'count'
|
|
88
88
|
else
|
|
89
89
|
'index'
|
|
@@ -208,16 +208,16 @@ module Blacklight::Solr::Response::Facets
|
|
|
208
208
|
options = facet_field_aggregation_options(facet_field_name)
|
|
209
209
|
facet_field = FacetField.new(facet_field_name, items, options.merge(response: self))
|
|
210
210
|
|
|
211
|
-
if values[nil]
|
|
212
|
-
facet_field.missing = items.find(&:missing)
|
|
213
|
-
end
|
|
211
|
+
facet_field.missing = items.find(&:missing) if values[nil]
|
|
214
212
|
|
|
215
213
|
hash[facet_field_name] = facet_field
|
|
216
214
|
|
|
217
215
|
# alias all the possible blacklight config names..
|
|
216
|
+
next unless blacklight_config && !blacklight_config.facet_fields[facet_field_name]
|
|
217
|
+
|
|
218
218
|
blacklight_config.facet_fields.select { |_k, v| v.field == facet_field_name }.each_key do |key|
|
|
219
219
|
hash[key] = hash[facet_field_name]
|
|
220
|
-
end
|
|
220
|
+
end
|
|
221
221
|
end
|
|
222
222
|
end
|
|
223
223
|
|
|
@@ -321,10 +321,12 @@ module Blacklight::Solr::Response::Facets
|
|
|
321
321
|
options = facet_field_aggregation_options(facet_field_name).merge(data: data, response: self)
|
|
322
322
|
facet_field = FacetField.new(facet_field_name, items, options)
|
|
323
323
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
if data['missing']
|
|
325
|
+
facet_field.missing = Blacklight::Solr::Response::Facets::FacetItem.new(
|
|
326
|
+
hits: data.dig('missing', 'count'),
|
|
327
|
+
data: data['missing']
|
|
328
|
+
)
|
|
329
|
+
end
|
|
328
330
|
|
|
329
331
|
hash[facet_field_name] = facet_field
|
|
330
332
|
end
|
|
@@ -23,64 +23,68 @@ module Blacklight::Solr::Response::Spelling
|
|
|
23
23
|
# combination of words may not have results.
|
|
24
24
|
# Thanks to Naomi Dushay!
|
|
25
25
|
def words
|
|
26
|
-
@words ||=
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# (hash of term info and term suggestion)
|
|
39
|
-
# 'correctlySpelled'
|
|
40
|
-
# true/false
|
|
41
|
-
# collation
|
|
42
|
-
# (suggestion for collation)
|
|
43
|
-
# We turn it into a hash here so that it is the same format as in solr 6.5 and later
|
|
44
|
-
suggestions = Hash[*suggestions].except('correctlySpelled', 'collation')
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
suggestions.each_value do |term_info|
|
|
48
|
-
# term_info is a hash:
|
|
49
|
-
# numFound =>
|
|
50
|
-
# startOffset =>
|
|
51
|
-
# endOffset =>
|
|
52
|
-
# origFreq =>
|
|
53
|
-
# suggestion => [{ frequency =>, word => }] # for extended results
|
|
54
|
-
# suggestion => ['word'] # for non-extended results
|
|
55
|
-
orig_freq = term_info['origFreq']
|
|
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
|
-
end
|
|
26
|
+
@words ||= term_suggestions.map do |term_info|
|
|
27
|
+
# term_info is a hash:
|
|
28
|
+
# numFound =>
|
|
29
|
+
# startOffset =>
|
|
30
|
+
# endOffset =>
|
|
31
|
+
# origFreq =>
|
|
32
|
+
# suggestion => [{ frequency =>, word => }] # for extended results
|
|
33
|
+
# suggestion => ['word'] # for non-extended results
|
|
34
|
+
orig_freq = term_info['origFreq']
|
|
35
|
+
if term_info['suggestion'].first.is_a?(Hash)
|
|
36
|
+
term_info['suggestion'].map do |suggestion|
|
|
37
|
+
suggestion['word'] if suggestion['freq'] > orig_freq
|
|
65
38
|
end
|
|
39
|
+
else
|
|
40
|
+
# only extended suggestions have frequency so we just return all suggestions
|
|
41
|
+
term_info['suggestion']
|
|
66
42
|
end
|
|
67
|
-
|
|
68
|
-
end
|
|
43
|
+
end.flatten.compact.uniq
|
|
69
44
|
end
|
|
70
45
|
|
|
71
46
|
def collation
|
|
72
|
-
|
|
73
|
-
spellcheck = response[:spellcheck]
|
|
74
|
-
return unless spellcheck && spellcheck[:suggestions]
|
|
75
|
-
|
|
76
|
-
suggestions = spellcheck[:suggestions]
|
|
47
|
+
return unless suggestions
|
|
77
48
|
|
|
78
49
|
if suggestions.is_a?(Array) && suggestions.index("collation")
|
|
79
50
|
# solr < 5 response
|
|
80
51
|
suggestions[suggestions.index("collation") + 1]
|
|
81
52
|
elsif spellcheck.key?("collations")
|
|
82
53
|
# solr 5+ response
|
|
83
|
-
spellcheck['collations'].last
|
|
54
|
+
spellcheck['collations'].last
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def spellcheck
|
|
61
|
+
response[:spellcheck]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @return [Array, Hash, nil] the raw suggestions from the spellcheck component
|
|
65
|
+
def suggestions
|
|
66
|
+
spellcheck[:suggestions] if spellcheck
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @return [Array<Hash>] the term info for each suggested query term
|
|
70
|
+
def term_suggestions
|
|
71
|
+
return [] unless suggestions
|
|
72
|
+
|
|
73
|
+
if suggestions.is_a?(Array)
|
|
74
|
+
# Before solr 6.5 suggestions is an array with the following format:
|
|
75
|
+
# (query term)
|
|
76
|
+
# (hash of term info and term suggestion)
|
|
77
|
+
# ...
|
|
78
|
+
# (query term)
|
|
79
|
+
# (hash of term info and term suggestion)
|
|
80
|
+
# 'correctlySpelled'
|
|
81
|
+
# true/false
|
|
82
|
+
# collation
|
|
83
|
+
# (suggestion for collation)
|
|
84
|
+
# We turn it into a hash here so that it is the same format as in solr 6.5 and later
|
|
85
|
+
Hash[*suggestions].except('correctlySpelled', 'collation').values
|
|
86
|
+
else
|
|
87
|
+
suggestions.values
|
|
84
88
|
end
|
|
85
89
|
end
|
|
86
90
|
end
|
|
@@ -102,7 +102,15 @@ 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?
|
|
106
|
+
|
|
107
|
+
defaults = { must: [], must_not: [], should: [] }
|
|
108
|
+
default_op = search_state.query_boolean_operator&.to_sym || :must
|
|
109
|
+
|
|
110
|
+
# Clauses with a blank query or an unconfigured search field are ignored
|
|
111
|
+
clauses = search_state.clause_params.values.filter_map { |clause| adv_search_clause(clause, default_op) }
|
|
112
|
+
.select { |op, _query| defaults.key?(op) }
|
|
113
|
+
return if clauses.empty?
|
|
106
114
|
|
|
107
115
|
# We need to specify lucene as the top-level defType when using JSON Query DSL in Solr versions
|
|
108
116
|
# between 7.2.0 & 9.4.0. After 9.4.0 this is no longer necessary, but also not harmful to include.
|
|
@@ -111,14 +119,9 @@ module Blacklight::Solr
|
|
|
111
119
|
# Disable spellcheck, which doesn't work when using JSON Query DSL
|
|
112
120
|
solr_parameters[:spellcheck] = 'false'
|
|
113
121
|
|
|
114
|
-
defaults = { must: [], must_not: [], should: [] }
|
|
115
|
-
default_op = search_state.query_boolean_operator&.to_sym || :must
|
|
116
122
|
solr_parameters[:mm] = 1 if default_op == :should && search_state.clause_params.values.any? { |clause| }
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
op, query = adv_search_clause(clause, default_op)
|
|
120
|
-
next unless defaults.key?(op)
|
|
121
|
-
|
|
124
|
+
clauses.each do |op, query|
|
|
122
125
|
solr_parameters.append_boolean_query(op, query)
|
|
123
126
|
end
|
|
124
127
|
end
|
|
@@ -148,9 +151,7 @@ module Blacklight::Solr
|
|
|
148
151
|
# as :f, to solr as appropriate :fq query.
|
|
149
152
|
def add_facet_fq_to_solr(solr_parameters)
|
|
150
153
|
# convert a String value into an Array
|
|
151
|
-
if solr_parameters[:fq].is_a? String
|
|
152
|
-
solr_parameters[:fq] = [solr_parameters[:fq]]
|
|
153
|
-
end
|
|
154
|
+
solr_parameters[:fq] = [solr_parameters[:fq]] if solr_parameters[:fq].is_a? String
|
|
154
155
|
|
|
155
156
|
search_state.filters.each do |filter|
|
|
156
157
|
filter_query_builder_class_or_proc = filter.config.filter_query_builder || DefaultFilterQueryBuilder
|
|
@@ -205,9 +206,7 @@ module Blacklight::Solr
|
|
|
205
206
|
solr_parameters.append_facet_fields with_ex_local_param(facet.ex, facet.field)
|
|
206
207
|
end
|
|
207
208
|
|
|
208
|
-
if facet.sort
|
|
209
|
-
solr_parameters[:"f.#{facet.field}.facet.sort"] = facet.sort
|
|
210
|
-
end
|
|
209
|
+
solr_parameters[:"f.#{facet.field}.facet.sort"] = facet.sort if facet.sort
|
|
211
210
|
|
|
212
211
|
facet.solr_params&.each do |k, v|
|
|
213
212
|
solr_parameters[:"f.#{facet.field}.#{k}"] = v
|
|
@@ -276,7 +275,7 @@ module Blacklight::Solr
|
|
|
276
275
|
offset = (page - 1) * limit
|
|
277
276
|
|
|
278
277
|
if facet_config.json
|
|
279
|
-
add_solr_facet_json_params(
|
|
278
|
+
add_solr_facet_json_params(solr_params, facet, facet_config, limit: limit + 1, offset: offset, sort: sort, prefix: prefix)
|
|
280
279
|
return
|
|
281
280
|
end
|
|
282
281
|
|
|
@@ -330,7 +329,7 @@ module Blacklight::Solr
|
|
|
330
329
|
|
|
331
330
|
return if limit.nil?
|
|
332
331
|
|
|
333
|
-
if limit
|
|
332
|
+
if limit.positive?
|
|
334
333
|
limit + 1
|
|
335
334
|
else
|
|
336
335
|
limit
|
data/lib/blacklight.rb
CHANGED
|
@@ -29,9 +29,7 @@ module Blacklight
|
|
|
29
29
|
# the class Blacklight::(name of the adapter)::Repository, e.g.
|
|
30
30
|
# elastic_search => Blacklight::ElasticSearch::Repository
|
|
31
31
|
def self.repository_class
|
|
32
|
-
if connection_config && !connection_config.key?(:adapter)
|
|
33
|
-
raise "The value for :adapter was not found in the blacklight.yml config"
|
|
34
|
-
end
|
|
32
|
+
raise "The value for :adapter was not found in the blacklight.yml config" if connection_config && !connection_config.key?(:adapter)
|
|
35
33
|
|
|
36
34
|
case connection_config&.fetch(:adapter) || 'solr'
|
|
37
35
|
when 'solr'
|
|
@@ -69,9 +67,7 @@ module Blacklight
|
|
|
69
67
|
require 'yaml'
|
|
70
68
|
|
|
71
69
|
return @blacklight_yml if @blacklight_yml
|
|
72
|
-
unless blacklight_yml?
|
|
73
|
-
raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
|
|
74
|
-
end
|
|
70
|
+
raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?" unless blacklight_yml?
|
|
75
71
|
|
|
76
72
|
begin
|
|
77
73
|
blacklight_erb = ERB.new(File.read(blacklight_config_file)).result(binding)
|
|
@@ -89,9 +85,7 @@ module Blacklight
|
|
|
89
85
|
raise("#{blacklight_config_file} was found, but could not be parsed.\n#{e.inspect}")
|
|
90
86
|
end
|
|
91
87
|
|
|
92
|
-
if @blacklight_yml.nil? || !@blacklight_yml.is_a?(Hash)
|
|
93
|
-
raise("#{blacklight_config_file} was found, but was blank or malformed.\n")
|
|
94
|
-
end
|
|
88
|
+
raise("#{blacklight_config_file} was found, but was blank or malformed.\n") if @blacklight_yml.nil? || !@blacklight_yml.is_a?(Hash)
|
|
95
89
|
|
|
96
90
|
@blacklight_yml
|
|
97
91
|
end
|
|
@@ -9,8 +9,8 @@ module Blacklight
|
|
|
9
9
|
append_to_file 'config/importmap.rb' do
|
|
10
10
|
<<~CONTENT
|
|
11
11
|
pin "@github/auto-complete-element", to: "https://cdn.jsdelivr.net/npm/@github/auto-complete-element@3.8.0/+esm"
|
|
12
|
-
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.
|
|
13
|
-
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.
|
|
12
|
+
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.8/dist/umd/popper.min.js"
|
|
13
|
+
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.9'}/dist/js/bootstrap.js"
|
|
14
14
|
CONTENT
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -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.9/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.9'), 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']
|
|
@@ -20,7 +20,7 @@ namespace :blacklight do
|
|
|
20
20
|
require 'yaml'
|
|
21
21
|
|
|
22
22
|
app_file = Rails.root && "#{Rails.root}spec/fixtures/sample_solr_documents.yml"
|
|
23
|
-
file = ENV.fetch('FILE') {
|
|
23
|
+
file = ENV.fetch('FILE') { app_file && File.exist?(app_file) && app_file } ||
|
|
24
24
|
File.join(Blacklight.root, 'spec', 'fixtures', 'sample_solr_documents.yml')
|
|
25
25
|
docs = YAML.safe_load(File.open(file))
|
|
26
26
|
conn = Blacklight.default_index.connection
|
|
@@ -107,15 +107,13 @@ namespace :blacklight do
|
|
|
107
107
|
errors += 1
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
if verbose
|
|
111
|
-
puts "\tstatus: #{response.header['status']}"
|
|
112
|
-
end
|
|
110
|
+
puts "\tstatus: #{response.header['status']}" if verbose
|
|
113
111
|
rescue StandardError => e
|
|
114
112
|
errors += 1
|
|
115
113
|
puts e
|
|
116
114
|
end
|
|
117
115
|
|
|
118
|
-
exit 1 if errors
|
|
116
|
+
exit 1 if errors.positive?
|
|
119
117
|
end
|
|
120
118
|
end
|
|
121
119
|
end
|