blacklight 7.15.2 → 7.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/VERSION +1 -1
- data/app/components/blacklight/advanced_search_form_component.html.erb +9 -3
- data/app/components/blacklight/advanced_search_form_component.rb +48 -35
- data/app/components/blacklight/constraints_component.html.erb +19 -3
- data/app/components/blacklight/constraints_component.rb +5 -1
- data/app/components/blacklight/content_areas_shim.rb +12 -0
- data/app/components/blacklight/document/action_component.html.erb +1 -1
- data/app/components/blacklight/document/action_component.rb +6 -1
- data/app/components/blacklight/document/actions_component.html.erb +3 -5
- data/app/components/blacklight/document/actions_component.rb +16 -2
- data/app/components/blacklight/document/thumbnail_component.html.erb +3 -3
- data/app/components/blacklight/document/thumbnail_component.rb +11 -3
- data/app/components/blacklight/document_component.html.erb +4 -7
- data/app/components/blacklight/document_component.rb +73 -73
- data/app/components/blacklight/document_metadata_component.html.erb +2 -2
- data/app/components/blacklight/document_metadata_component.rb +13 -2
- data/app/components/blacklight/document_title_component.html.erb +17 -0
- data/app/components/blacklight/document_title_component.rb +59 -0
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_component.rb +4 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -1
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_layout_component.html.erb +3 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +26 -1
- data/app/components/blacklight/response/view_type_button_component.html.erb +4 -0
- data/app/components/blacklight/response/view_type_button_component.rb +38 -0
- data/app/components/blacklight/response/view_type_component.html.erb +2 -5
- data/app/components/blacklight/response/view_type_component.rb +9 -13
- data/app/components/blacklight/search_bar_component.rb +9 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +4 -7
- data/app/components/blacklight/system/dropdown_component.rb +24 -0
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +7 -1
- data/app/components/blacklight/system/modal_component.rb +7 -1
- data/app/controllers/concerns/blacklight/catalog.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/presenters/blacklight/document_presenter.rb +8 -4
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +2 -2
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +3 -3
- data/app/views/catalog/email.html.erb +2 -2
- data/app/views/catalog/email_success.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +3 -3
- data/app/views/catalog/sms.html.erb +2 -2
- data/app/views/catalog/sms_success.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.de.yml +2 -2
- data/lib/blacklight/configuration.rb +50 -5
- data/lib/blacklight/configuration/view_config.rb +18 -5
- data/lib/blacklight/engine.rb +3 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +23 -7
- data/lib/blacklight/open_struct_with_hash_access.rb +4 -0
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/search_state.rb +2 -2
- data/lib/blacklight/solr/facet_paginator.rb +2 -0
- data/lib/blacklight/solr/request.rb +31 -0
- data/lib/blacklight/solr/response.rb +2 -16
- data/lib/blacklight/solr/response/facets.rb +76 -22
- data/lib/blacklight/solr/response/params.rb +104 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +64 -28
- data/lib/generators/blacklight/assets_generator.rb +6 -2
- data/lib/generators/blacklight/user_generator.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +3 -3
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +6 -7
- data/spec/helpers/blacklight_helper_spec.rb +2 -2
- data/spec/helpers/catalog_helper_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +12 -0
- data/spec/models/blacklight/configuration_spec.rb +64 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +4 -0
- data/spec/models/blacklight/solr/request_spec.rb +62 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +109 -0
- data/spec/models/blacklight/solr/response_spec.rb +10 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +58 -0
- data/spec/services/blacklight/search_service_spec.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +8 -9
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- metadata +10 -4
@@ -120,6 +120,16 @@ RSpec.describe Blacklight::Solr::Response, api: true do
|
|
120
120
|
expect(r.params['test']).to eq :test
|
121
121
|
end
|
122
122
|
|
123
|
+
it 'extracts json params' do
|
124
|
+
raw_response = eval(mock_query_response)
|
125
|
+
raw_response['responseHeader']['params']['test'] = 'from query'
|
126
|
+
raw_response['responseHeader']['params'].delete('rows')
|
127
|
+
raw_response['responseHeader']['params']['json'] = { limit: 5, params: { test: 'from json params' } }.to_json
|
128
|
+
r = described_class.new(raw_response, raw_response['params'])
|
129
|
+
expect(r.params['test']).to eq 'from query'
|
130
|
+
expect(r.rows).to eq 5
|
131
|
+
end
|
132
|
+
|
123
133
|
it 'provides the solr-returned params and "rows" should be 11' do
|
124
134
|
raw_response = eval(mock_query_response)
|
125
135
|
r = described_class.new(raw_response, {})
|
@@ -259,6 +259,23 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
+
describe 'with a json facet' do
|
263
|
+
let(:user_params) { { f: { json_facet: ['value'] } }.with_indifferent_access }
|
264
|
+
|
265
|
+
before do
|
266
|
+
blacklight_config.add_facet_field 'json_facet', field: 'foo', json: { bar: 'baz' }
|
267
|
+
end
|
268
|
+
|
269
|
+
it "has proper solr parameters" do
|
270
|
+
expect(subject[:fq]).to include('{!term f=foo}value')
|
271
|
+
expect(subject.dig(:json, :facet, 'json_facet')).to include(
|
272
|
+
field: 'foo',
|
273
|
+
type: 'terms',
|
274
|
+
bar: 'baz'
|
275
|
+
)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
262
279
|
describe 'with multi-valued facets' do
|
263
280
|
let(:user_params) { { f_inclusive: { format: %w[Book Movie CD] } } }
|
264
281
|
|
@@ -321,6 +338,38 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
321
338
|
end
|
322
339
|
end
|
323
340
|
|
341
|
+
describe "solr json query parameters from the fielded search" do
|
342
|
+
let(:user_params) { subject_search_params }
|
343
|
+
|
344
|
+
before do
|
345
|
+
blacklight_config.search_fields['subject'].solr_parameters = {
|
346
|
+
some: :parameter
|
347
|
+
}
|
348
|
+
|
349
|
+
blacklight_config.search_fields['subject'].clause_params = {
|
350
|
+
edismax: {
|
351
|
+
another: :parameter
|
352
|
+
}
|
353
|
+
}
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'sets solr parameters from the field' do
|
357
|
+
expect(subject[:some]).to eq :parameter
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'does not set a q parameter' do
|
361
|
+
expect(subject).not_to have_key :q
|
362
|
+
end
|
363
|
+
|
364
|
+
it 'includes the user query in the JSON query DSL request' do
|
365
|
+
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include query: 'wome'
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'includes addtional clause parameters for the field' do
|
369
|
+
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include another: :parameter
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
324
373
|
describe "overriding of qt parameter" do
|
325
374
|
let(:user_params) do
|
326
375
|
{ qt: 'overridden' }
|
@@ -751,4 +800,13 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
751
800
|
expect(subject.to_hash.with_indifferent_access.dig(:json, :query, :bool, :must, 1, :edismax, :qf)).to eq '${author_qf}'
|
752
801
|
end
|
753
802
|
end
|
803
|
+
|
804
|
+
describe '#where' do
|
805
|
+
let(:user_params) { {} }
|
806
|
+
|
807
|
+
it 'adds additional query filters on the search' do
|
808
|
+
subject.where(id: [1, 2, 3])
|
809
|
+
expect(subject.to_hash).to include q: '{!lucene}id:(1 OR 2 OR 3)'
|
810
|
+
end
|
811
|
+
end
|
754
812
|
end
|
@@ -477,7 +477,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
477
477
|
end
|
478
478
|
|
479
479
|
before do
|
480
|
-
blacklight_config.view.opensearch
|
480
|
+
blacklight_config.view.opensearch(title_field: :field)
|
481
481
|
allow(repository).to receive(:search).and_return(mock_response)
|
482
482
|
end
|
483
483
|
|
@@ -3,13 +3,9 @@
|
|
3
3
|
RSpec.describe "catalog/_view_type_group" do
|
4
4
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
5
|
let(:response) { instance_double(Blacklight::Solr::Response, empty?: false) }
|
6
|
-
let(:icon_instance) { instance_double(Blacklight::Icon) }
|
7
6
|
|
8
7
|
before do
|
9
8
|
allow(view).to receive(:view_label), &:to_s
|
10
|
-
allow(Blacklight::Icon).to receive(:new).and_return icon_instance
|
11
|
-
allow(icon_instance).to receive(:svg).and_return '<svg></svg>'
|
12
|
-
allow(icon_instance).to receive(:options).and_return({})
|
13
9
|
allow(view).to receive_messages(how_sort_and_per_page?: true, blacklight_config: blacklight_config)
|
14
10
|
controller.request.path_parameters[:action] = 'index'
|
15
11
|
assign(:response, response)
|
@@ -24,13 +20,16 @@ RSpec.describe "catalog/_view_type_group" do
|
|
24
20
|
it "displays the group" do
|
25
21
|
blacklight_config.configure do |config|
|
26
22
|
config.view.delete(:list)
|
27
|
-
config.view.a
|
28
|
-
config.view.b
|
29
|
-
config.view.c
|
23
|
+
config.view.a(icon: :list)
|
24
|
+
config.view.b(icon: :list)
|
25
|
+
config.view.c(icon: :list)
|
30
26
|
end
|
31
27
|
render partial: 'catalog/view_type_group'
|
32
28
|
expect(rendered).to have_selector('.btn-group.view-type-group')
|
33
29
|
expect(rendered).to have_selector('.view-type-a', text: 'a')
|
30
|
+
within '.view-type-a' do
|
31
|
+
expect(rendered).to have_selector 'svg'
|
32
|
+
end
|
34
33
|
expect(rendered).to have_selector('.view-type-b', text: 'b')
|
35
34
|
expect(rendered).to have_selector('.view-type-c', text: 'c')
|
36
35
|
end
|
@@ -38,8 +37,8 @@ RSpec.describe "catalog/_view_type_group" do
|
|
38
37
|
it "sets the current view to 'active'" do
|
39
38
|
blacklight_config.configure do |config|
|
40
39
|
config.view.delete(:list)
|
41
|
-
config.view.a
|
42
|
-
config.view.b
|
40
|
+
config.view.a(icon: :list)
|
41
|
+
config.view.b(icon: :list)
|
43
42
|
end
|
44
43
|
render partial: 'catalog/view_type_group'
|
45
44
|
expect(rendered).to have_selector('.active', text: 'a')
|
@@ -12,7 +12,7 @@ RSpec.describe "catalog/index" do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
let(:blacklight_config) { CatalogController.blacklight_config }
|
15
|
+
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
16
16
|
|
17
17
|
before do
|
18
18
|
@response = Blacklight::Solr::Response.new({ response: { numFound: 30 } }, start: 10, rows: 10)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2021-
|
20
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -129,14 +129,14 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 2.
|
132
|
+
version: 2.28.0
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
139
|
+
version: 2.28.0
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: rsolr
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -402,6 +402,7 @@ files:
|
|
402
402
|
- app/components/blacklight/constraint_layout_component.rb
|
403
403
|
- app/components/blacklight/constraints_component.html.erb
|
404
404
|
- app/components/blacklight/constraints_component.rb
|
405
|
+
- app/components/blacklight/content_areas_shim.rb
|
405
406
|
- app/components/blacklight/document/action_component.html.erb
|
406
407
|
- app/components/blacklight/document/action_component.rb
|
407
408
|
- app/components/blacklight/document/actions_component.html.erb
|
@@ -420,6 +421,8 @@ files:
|
|
420
421
|
- app/components/blacklight/document_component.rb
|
421
422
|
- app/components/blacklight/document_metadata_component.html.erb
|
422
423
|
- app/components/blacklight/document_metadata_component.rb
|
424
|
+
- app/components/blacklight/document_title_component.html.erb
|
425
|
+
- app/components/blacklight/document_title_component.rb
|
423
426
|
- app/components/blacklight/facet_field_checkboxes_component.html.erb
|
424
427
|
- app/components/blacklight/facet_field_checkboxes_component.rb
|
425
428
|
- app/components/blacklight/facet_field_component.html.erb
|
@@ -448,6 +451,8 @@ files:
|
|
448
451
|
- app/components/blacklight/response/sort_component.rb
|
449
452
|
- app/components/blacklight/response/spellcheck_component.html.erb
|
450
453
|
- app/components/blacklight/response/spellcheck_component.rb
|
454
|
+
- app/components/blacklight/response/view_type_button_component.html.erb
|
455
|
+
- app/components/blacklight/response/view_type_button_component.rb
|
451
456
|
- app/components/blacklight/response/view_type_component.html.erb
|
452
457
|
- app/components/blacklight/response/view_type_component.rb
|
453
458
|
- app/components/blacklight/search_bar_component.html.erb
|
@@ -691,6 +696,7 @@ files:
|
|
691
696
|
- lib/blacklight/solr/response/group_response.rb
|
692
697
|
- lib/blacklight/solr/response/more_like_this.rb
|
693
698
|
- lib/blacklight/solr/response/pagination_methods.rb
|
699
|
+
- lib/blacklight/solr/response/params.rb
|
694
700
|
- lib/blacklight/solr/response/response.rb
|
695
701
|
- lib/blacklight/solr/response/spelling.rb
|
696
702
|
- lib/blacklight/solr/search_builder_behavior.rb
|