blacklight 7.17.2 → 7.18.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/VERSION +1 -1
- 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.rb +1 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +23 -7
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +7 -1
- 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/models/blacklight/solr/search_builder_spec.rb +9 -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 +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60b0a39be3483ff0a8968a73c07ad6e7fcd576c7249020606d602454401e3e81
|
4
|
+
data.tar.gz: 46aa7df118c340444ec95e045cd1006a62017595160adcfd953d99bafb1222db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02715a196cc746c2e3b23a453edcf4f7e50c43077a670ee2ec0975362969a36f71a299ad881d688d97207d25d75ddccedf460d14ed8c877347e3f626b9d43971
|
7
|
+
data.tar.gz: da5835cdb464f59d5b0715c0808e08ac81484e70271443b15baad6076f5266ed0000e5cad2d73cd9638796ec1532f891f57c0b3e4b87a85ea136e50ed38a0e13
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.18.0
|
@@ -1,12 +1,12 @@
|
|
1
|
-
<% value =
|
1
|
+
<% value = use_thumbnail_tag_behavior? ? presenter.thumbnail.thumbnail_tag(@image_options, 'aria-hidden': true, tabindex: -1, counter: @counter) : presenter.thumbnail.render(@image_options) %>
|
2
2
|
|
3
3
|
<% if value %>
|
4
4
|
<div class="document-thumbnail">
|
5
|
-
<% if
|
5
|
+
<% if use_thumbnail_tag_behavior? %>
|
6
6
|
<% warn_about_deprecated_behavior %>
|
7
7
|
<%= value %>
|
8
8
|
<% else %>
|
9
|
-
<%= helpers.link_to_document(
|
9
|
+
<%= helpers.link_to_document(presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
|
10
10
|
<% end %>
|
11
11
|
</div>
|
12
12
|
<% end %>
|
@@ -9,20 +9,28 @@ module Blacklight
|
|
9
9
|
# @param [Blacklight::DocumentPresenter] presenter
|
10
10
|
# @param [Integer] counter
|
11
11
|
# @param [Hash] image_options options for the thumbnail presenter's image tag
|
12
|
-
def initialize(presenter
|
12
|
+
def initialize(presenter: nil, document: nil, counter:, image_options: {})
|
13
13
|
@presenter = presenter
|
14
|
+
@document = presenter&.document || document
|
14
15
|
@counter = counter
|
15
16
|
@image_options = { alt: '' }.merge(image_options)
|
16
|
-
@use_thumbnail_tag = !@presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
|
17
17
|
end
|
18
18
|
|
19
19
|
def render?
|
20
|
-
|
20
|
+
presenter.thumbnail.exists?
|
21
|
+
end
|
22
|
+
|
23
|
+
def use_thumbnail_tag_behavior?
|
24
|
+
!presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
|
21
25
|
end
|
22
26
|
|
23
27
|
def warn_about_deprecated_behavior
|
24
28
|
Deprecation.warn(Blacklight::Document::ThumbnailComponent, 'Detected as custom thumbnail presenter; make sure it has a #render method that returns just the thumbnail image tag')
|
25
29
|
end
|
30
|
+
|
31
|
+
def presenter
|
32
|
+
@presenter ||= @view_context.document_presenter(@document)
|
33
|
+
end
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
@@ -50,7 +50,7 @@ module Blacklight
|
|
50
50
|
component ||= @presenter&.view_config&.thumbnail_component || Blacklight::Document::ThumbnailComponent
|
51
51
|
Deprecation.warn('Pass the presenter to the DocumentComponent') if !component && @presenter.nil?
|
52
52
|
|
53
|
-
component.new(*args, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
|
53
|
+
component.new(*args, document: @document, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
|
54
54
|
end)
|
55
55
|
|
56
56
|
# A container for partials rendered using the view config partials configuration. Its use is discouraged, but necessary until
|
@@ -5,6 +5,9 @@ module Blacklight
|
|
5
5
|
# An OpenStruct refinement that converts any hash-keys into
|
6
6
|
# additional instances of NestedOpenStructWithHashAccess
|
7
7
|
class NestedOpenStructWithHashAccess < OpenStructWithHashAccess
|
8
|
+
extend Deprecation
|
9
|
+
self.deprecation_horizon = 'blacklight 8.0'
|
10
|
+
|
8
11
|
attr_reader :nested_class
|
9
12
|
|
10
13
|
delegate :default_proc=, to: :to_h
|
@@ -86,15 +89,28 @@ module Blacklight
|
|
86
89
|
##
|
87
90
|
# Override #method_missing from OpenStruct to ensure the default_proc logic
|
88
91
|
# gets triggered.
|
89
|
-
def method_missing(mid, *args)
|
92
|
+
def method_missing(mid, *args, **kwargs, &block)
|
90
93
|
len = args.length
|
91
94
|
|
92
|
-
if
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
res = if mid.to_s.ends_with?('!')
|
96
|
+
m = mid[0...-1]
|
97
|
+
new_ostruct_member!(m)
|
98
|
+
@table[m]
|
99
|
+
elsif mid.to_s.ends_with?('=')
|
100
|
+
m = mid[0...-1]
|
101
|
+
new_ostruct_member!(m)
|
102
|
+
@table[m] = args.first
|
103
|
+
elsif len.zero? && kwargs.blank? && !block
|
104
|
+
Deprecation.warn("Initializing a #{nested_class} implicitly (by calling #{mid}) is deprecated. Call it as #{mid}! or pass initialize arguments")
|
105
|
+
@table[mid]
|
106
|
+
else
|
107
|
+
new_ostruct_member!(mid)
|
108
|
+
@table[mid] = nested_class.new(*args, **kwargs)
|
109
|
+
end
|
110
|
+
|
111
|
+
block&.call(res)
|
112
|
+
|
113
|
+
res
|
98
114
|
end
|
99
115
|
|
100
116
|
private
|
@@ -45,6 +45,7 @@ module Blacklight
|
|
45
45
|
##
|
46
46
|
# Update the :q (query) parameter
|
47
47
|
def where(conditions)
|
48
|
+
Deprecation.warn("SearchBuilder#where must be called with a hash, received #{conditions.inspect}.") unless conditions.is_a? Hash
|
48
49
|
params_will_change!
|
49
50
|
@search_state = @search_state.reset(@search_state.params.merge(q: conditions))
|
50
51
|
@blacklight_params = @search_state.params.dup
|
@@ -32,6 +32,7 @@ module Blacklight::Solr
|
|
32
32
|
# Take the user-entered query, and put it in the solr params,
|
33
33
|
# including config's "search field" params for current search field.
|
34
34
|
# also include setting spellcheck.q.
|
35
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
35
36
|
def add_query_to_solr(solr_parameters)
|
36
37
|
###
|
37
38
|
# legacy behavior of user param :qt is passed through, but over-ridden
|
@@ -64,11 +65,15 @@ module Blacklight::Solr
|
|
64
65
|
elsif search_field&.solr_local_parameters.present?
|
65
66
|
add_search_field_with_local_parameters(solr_parameters)
|
66
67
|
elsif search_state.query_param.is_a? Hash
|
67
|
-
|
68
|
+
if search_state.query_param == @additional_filters && !processor_chain.include?(:add_additional_filters)
|
69
|
+
Deprecation.warn('Expecting to see the processor step add_additional_filters; falling back to legacy query handling')
|
70
|
+
add_additional_filters(solr_parameters, search_state.query_param)
|
71
|
+
end
|
68
72
|
elsif search_state.query_param
|
69
73
|
solr_parameters.append_query search_state.query_param
|
70
74
|
end
|
71
75
|
end
|
76
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
72
77
|
|
73
78
|
def add_additional_filters(solr_parameters, additional_filters = nil)
|
74
79
|
q = additional_filters || @additional_filters
|
@@ -322,6 +327,7 @@ module Blacklight::Solr
|
|
322
327
|
# around the term unless it's a bare-word. Escape internal quotes
|
323
328
|
# if needed.
|
324
329
|
def solr_param_quote(val, options = {})
|
330
|
+
val = val.to_s
|
325
331
|
options[:quote] ||= '"'
|
326
332
|
unless val =~ /^[a-zA-Z0-9$_\-\^]+$/
|
327
333
|
val = options[:quote] +
|
@@ -33,9 +33,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
33
33
|
|
34
34
|
describe "#default_document_index_view_type" do
|
35
35
|
it "uses the first view with default set to true" do
|
36
|
-
blacklight_config.view.a
|
37
|
-
blacklight_config.view.b
|
38
|
-
blacklight_config.view.b.default = true
|
36
|
+
blacklight_config.view.a({})
|
37
|
+
blacklight_config.view.b(default: true)
|
39
38
|
expect(helper.default_document_index_view_type).to eq :b
|
40
39
|
end
|
41
40
|
|
@@ -48,8 +47,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
48
47
|
describe "#document_index_views" do
|
49
48
|
before do
|
50
49
|
blacklight_config.view.abc = false
|
51
|
-
blacklight_config.view.def
|
52
|
-
blacklight_config.view.xyz
|
50
|
+
blacklight_config.view.def(if: false)
|
51
|
+
blacklight_config.view.xyz(unless: true)
|
53
52
|
end
|
54
53
|
|
55
54
|
it "filters views using :if/:unless configuration" do
|
@@ -62,8 +61,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
62
61
|
|
63
62
|
describe '#document_index_view_controls' do
|
64
63
|
before do
|
65
|
-
blacklight_config.view.a
|
66
|
-
blacklight_config.view.b
|
64
|
+
blacklight_config.view.a({})
|
65
|
+
blacklight_config.view.b(display_control: false)
|
67
66
|
end
|
68
67
|
|
69
68
|
it "filters index views to those set to display controls" do
|
@@ -127,7 +127,7 @@ RSpec.describe BlacklightHelper do
|
|
127
127
|
|
128
128
|
it "renders view type specific actions" do
|
129
129
|
allow(helper).to receive(:document_index_view_type).and_return(:custom)
|
130
|
-
config.view.custom
|
130
|
+
config.view.custom(document_actions: [])
|
131
131
|
expect(helper.render_index_doc_actions(document)).to be_blank
|
132
132
|
end
|
133
133
|
end
|
@@ -315,7 +315,7 @@ RSpec.describe BlacklightHelper do
|
|
315
315
|
end
|
316
316
|
|
317
317
|
it "ignores missing templates" do
|
318
|
-
blacklight_config.view.view_type
|
318
|
+
blacklight_config.view.view_type(partials: %w[index_header a b])
|
319
319
|
|
320
320
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
321
321
|
expect(response).to have_selector "div#documents"
|
@@ -323,7 +323,7 @@ RSpec.describe CatalogHelper do
|
|
323
323
|
|
324
324
|
it "supports view-specific field configuration" do
|
325
325
|
allow(helper).to receive(:document_index_view_type).and_return(:some_view_type)
|
326
|
-
blacklight_config.view.some_view_type
|
326
|
+
blacklight_config.view.some_view_type(display_type_field: :other_type)
|
327
327
|
doc = { other_type: "document" }
|
328
328
|
expect(helper.render_document_class(doc)).to eq "blacklight-document"
|
329
329
|
end
|
@@ -800,4 +800,13 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
800
800
|
expect(subject.to_hash.with_indifferent_access.dig(:json, :query, :bool, :must, 1, :edismax, :qf)).to eq '${author_qf}'
|
801
801
|
end
|
802
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
|
803
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
|
|
@@ -20,9 +20,9 @@ RSpec.describe "catalog/_view_type_group" do
|
|
20
20
|
it "displays the group" do
|
21
21
|
blacklight_config.configure do |config|
|
22
22
|
config.view.delete(:list)
|
23
|
-
config.view.a
|
24
|
-
config.view.b
|
25
|
-
config.view.c
|
23
|
+
config.view.a(icon: :list)
|
24
|
+
config.view.b(icon: :list)
|
25
|
+
config.view.c(icon: :list)
|
26
26
|
end
|
27
27
|
render partial: 'catalog/view_type_group'
|
28
28
|
expect(rendered).to have_selector('.btn-group.view-type-group')
|
@@ -37,8 +37,8 @@ RSpec.describe "catalog/_view_type_group" do
|
|
37
37
|
it "sets the current view to 'active'" do
|
38
38
|
blacklight_config.configure do |config|
|
39
39
|
config.view.delete(:list)
|
40
|
-
config.view.a
|
41
|
-
config.view.b
|
40
|
+
config.view.a(icon: :list)
|
41
|
+
config.view.b(icon: :list)
|
42
42
|
end
|
43
43
|
render partial: 'catalog/view_type_group'
|
44
44
|
expect(rendered).to have_selector('.active', text: 'a')
|
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-04-
|
20
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|