blacklight 7.34.0 → 7.35.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/controllers/concerns/blacklight/bookmarks.rb +5 -1
- data/app/controllers/concerns/blacklight/catalog.rb +10 -2
- data/app/models/concerns/blacklight/document/active_model_shim.rb +10 -0
- data/app/models/search.rb +6 -1
- data/app/services/blacklight/field_retriever.rb +13 -11
- data/blacklight.gemspec +2 -2
- data/lib/blacklight/engine.rb +11 -0
- data/spec/components/blacklight/facet_component_spec.rb +11 -1
- data/spec/helpers/blacklight_helper_spec.rb +10 -5
- data/spec/services/blacklight/field_retriever_spec.rb +17 -0
- data/spec/spec_helper.rb +28 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841946108f3216c1dfc66f10787069b43fdcca041e9cc3e114524bf0a5cf6aa1
|
4
|
+
data.tar.gz: 621f2d5648013ab85fa3c3c99a001824e49b24be263cd1eda45a7f5ed9e22daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ae81c46a04f928701d7e16c227bf33ae9ed0ae214e6ef94bbf96bc0b33aa22ff889e286a1235d6c6a225e11597fe3e832db2c5242cc71a533229ee75dc2b407
|
7
|
+
data.tar.gz: 2005c22b35ac7a9f4c3fb065f412a6369bcf903f918bc46770d23999a509bae45d855c83b14a0e167f3acbafd900ae63f6fe4cfe30de98f8d97bb17980a64c49
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.35.0
|
@@ -42,7 +42,11 @@ module Blacklight::Bookmarks
|
|
42
42
|
@bookmarks = token_or_current_or_guest_user.bookmarks
|
43
43
|
bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }
|
44
44
|
@response, deprecated_document_list = search_service.fetch(bookmark_ids)
|
45
|
-
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
45
|
+
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
46
|
+
deprecated_document_list,
|
47
|
+
"The @document_list instance variable is now deprecated",
|
48
|
+
ActiveSupport::Deprecation.new("8.0", "blacklight")
|
49
|
+
)
|
46
50
|
|
47
51
|
respond_to do |format|
|
48
52
|
format.html {}
|
@@ -34,7 +34,11 @@ module Blacklight::Catalog
|
|
34
34
|
def index
|
35
35
|
(@response, deprecated_document_list) = search_service.search_results
|
36
36
|
|
37
|
-
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
37
|
+
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
38
|
+
deprecated_document_list,
|
39
|
+
'The @document_list instance variable is deprecated; use @response.documents instead.',
|
40
|
+
ActiveSupport::Deprecation.new("8.0", "blacklight")
|
41
|
+
)
|
38
42
|
|
39
43
|
respond_to do |format|
|
40
44
|
format.html { store_preferred_view }
|
@@ -53,7 +57,11 @@ module Blacklight::Catalog
|
|
53
57
|
# to add responses for formats other than html or json see _Blacklight::Document::Export_
|
54
58
|
def show
|
55
59
|
deprecated_response, @document = search_service.fetch(params[:id])
|
56
|
-
@response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
60
|
+
@response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
61
|
+
deprecated_response,
|
62
|
+
'The @response instance variable is deprecated; use @document.response instead.',
|
63
|
+
ActiveSupport::Deprecation.new("8.0", "blacklight")
|
64
|
+
)
|
57
65
|
|
58
66
|
respond_to do |format|
|
59
67
|
format.html { @search_context = setup_next_and_previous_documents }
|
@@ -28,6 +28,16 @@ module Blacklight::Document
|
|
28
28
|
def find id
|
29
29
|
repository.find(id).documents.first
|
30
30
|
end
|
31
|
+
|
32
|
+
# In Rails 7.1+, needs this method
|
33
|
+
def composite_primary_key?
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
# In Rails 7.1+, needs this method
|
38
|
+
def has_query_constraints?
|
39
|
+
false
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
##
|
data/app/models/search.rb
CHANGED
@@ -4,7 +4,12 @@ class Search < ApplicationRecord
|
|
4
4
|
belongs_to :user, optional: true
|
5
5
|
|
6
6
|
# use a backwards-compatible serializer until the Rails API stabilizes and we can evaluate for major-revision compatibility
|
7
|
-
|
7
|
+
if ::Rails.version.to_f >= 7.1
|
8
|
+
# non-deprecated coder: keyword arg for Rails 7.1+
|
9
|
+
serialize :query_params, coder: Blacklight::SearchParamsYamlCoder
|
10
|
+
else
|
11
|
+
serialize :query_params, Blacklight::SearchParamsYamlCoder
|
12
|
+
end
|
8
13
|
|
9
14
|
# A Search instance is considered a saved search if it has a user_id.
|
10
15
|
def saved?
|
@@ -22,17 +22,19 @@ module Blacklight
|
|
22
22
|
|
23
23
|
# @return [Array]
|
24
24
|
def fetch
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
if field_config.highlight
|
26
|
+
value = retrieve_highlight
|
27
|
+
end
|
28
|
+
if value.blank?
|
29
|
+
value = if field_config.accessor
|
30
|
+
retieve_using_accessor
|
31
|
+
elsif field_config.values
|
32
|
+
retrieve_values
|
33
|
+
else
|
34
|
+
retrieve_simple
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Array.wrap(value)
|
36
38
|
end
|
37
39
|
|
38
40
|
private
|
data/blacklight.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
|
26
26
|
s.required_ruby_version = '>= 2.5'
|
27
27
|
|
28
|
-
s.add_dependency "rails", '>= 5.1', '< 7.
|
28
|
+
s.add_dependency "rails", '>= 5.1', '< 7.2'
|
29
29
|
s.add_dependency "globalid"
|
30
30
|
s.add_dependency "jbuilder", '~> 2.7'
|
31
31
|
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_dependency 'hashdiff'
|
37
37
|
|
38
38
|
s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
|
39
|
-
s.add_development_dependency "rspec-rails", "
|
39
|
+
s.add_development_dependency "rspec-rails", ">= 5.0" # some versions tested need >= 6.0
|
40
40
|
s.add_development_dependency "rspec-collection_matchers", ">= 1.0"
|
41
41
|
s.add_development_dependency 'axe-core-rspec'
|
42
42
|
s.add_development_dependency "capybara", '~> 3'
|
data/lib/blacklight/engine.rb
CHANGED
@@ -6,6 +6,17 @@ module Blacklight
|
|
6
6
|
class Engine < Rails::Engine
|
7
7
|
engine_name "blacklight"
|
8
8
|
|
9
|
+
config.before_configuration do
|
10
|
+
# see https://github.com/fxn/zeitwerk#for_gem
|
11
|
+
# Blacklight puts a generator into LOCAL APP lib/generators, so tell
|
12
|
+
# zeitwerk to ignore the whole directory? If we're using zeitwerk
|
13
|
+
#
|
14
|
+
# https://github.com/cbeer/engine_cart/issues/117
|
15
|
+
if Rails.try(:autoloaders).try(:main).respond_to?(:ignore)
|
16
|
+
Rails.autoloaders.main.ignore(Rails.root.join('lib/generators'))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
9
20
|
# BlacklightHelper is needed by all helpers, so we inject it
|
10
21
|
# into action view base here.
|
11
22
|
initializer 'blacklight.helpers' do
|
@@ -51,7 +51,17 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
before do
|
54
|
-
|
54
|
+
# Not sure why we need to re-implement rspec's stub_template, but
|
55
|
+
# we already were, and need a Rails 7.1+ safe alternate too
|
56
|
+
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
57
|
+
# https://github.com/rspec/rspec-rails/issues/2696
|
58
|
+
|
59
|
+
replace_hash = { 'catalog/_facet_partial.html.erb' => 'facet partial' }
|
60
|
+
if ::Rails.version.to_f >= 7.1
|
61
|
+
controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
62
|
+
else
|
63
|
+
controller.view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
64
|
+
end
|
55
65
|
end
|
56
66
|
|
57
67
|
it 'renders the partial' do
|
@@ -331,12 +331,17 @@ RSpec.describe BlacklightHelper do
|
|
331
331
|
blacklight_config.view.gallery(template: '/my/partial')
|
332
332
|
end
|
333
333
|
|
334
|
-
def stub_template(hash)
|
335
|
-
view.view_paths.unshift(ActionView::FixtureResolver.new(hash))
|
336
|
-
end
|
337
|
-
|
338
334
|
it 'renders that template' do
|
339
|
-
|
335
|
+
# Not sure why we need to re-implement rspec's stub_template, but
|
336
|
+
# we already were, and need a Rails 7.1+ safe alternate too
|
337
|
+
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
338
|
+
# https://github.com/rspec/rspec-rails/issues/2696
|
339
|
+
replace_hash = { 'my/_partial.html.erb' => 'some content' }
|
340
|
+
if ::Rails.version.to_f >= 7.1
|
341
|
+
controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
342
|
+
else
|
343
|
+
view.view_paths.unshift(ActionView::FixtureResolver.new(replace_hash))
|
344
|
+
end
|
340
345
|
|
341
346
|
response = helper.render_document_index_with_view :gallery, [obj1, obj1]
|
342
347
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Blacklight::FieldRetriever, api: true do
|
4
|
+
let(:service) { described_class.new(document, blacklight_field_config) }
|
5
|
+
|
6
|
+
let(:blacklight_field_config) { Blacklight::Configuration::Field.new(field: 'author_field', highlight: true) }
|
7
|
+
let(:document) { SolrDocument.new({ 'id' => 'doc1', 'title_field' => 'doc1 title', 'author_field' => 'author_someone' }, 'highlighting' => { 'doc1' => { 'title_tsimext' => ['doc <em>1</em>'] } }) }
|
8
|
+
let(:view_context) { {} }
|
9
|
+
|
10
|
+
context "highlighting" do
|
11
|
+
describe '#fetch' do
|
12
|
+
it "retrieves an author even if it's not highlighted" do
|
13
|
+
expect(service.fetch).to eq(['author_someone'])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -117,3 +117,31 @@ RSpec.configure do |config|
|
|
117
117
|
# as the one that triggered the failure.
|
118
118
|
Kernel.srand config.seed
|
119
119
|
end
|
120
|
+
|
121
|
+
# RSpec's stub_template method needs a differnet implementation for Rails 7.1, that
|
122
|
+
# isn't yet in an rspec-rails release.
|
123
|
+
#
|
124
|
+
# First rspec-rails tried this:
|
125
|
+
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
126
|
+
#
|
127
|
+
# But it was subject to this problem:
|
128
|
+
# https://github.com/rspec/rspec-rails/issues/2696
|
129
|
+
#
|
130
|
+
# Below implementation appears to work for our purposes here, so we will patch it in
|
131
|
+
# if we are on Rails 7.1+, and not yet rspec-rails 6.1 which we expect to have it.
|
132
|
+
|
133
|
+
if ::Rails.version.to_f >= 7.1 && Gem.loaded_specs["rspec-rails"].version.release < Gem::Version.new('6.1')
|
134
|
+
|
135
|
+
module RSpec
|
136
|
+
module Rails
|
137
|
+
module ViewExampleGroup
|
138
|
+
module ExampleMethods
|
139
|
+
def stub_template(hash)
|
140
|
+
controller.prepend_view_path(StubResolverCache.resolver_for(hash))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
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.35.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: 2023-
|
20
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
version: '5.1'
|
29
29
|
- - "<"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '7.
|
31
|
+
version: '7.2'
|
32
32
|
type: :runtime
|
33
33
|
prerelease: false
|
34
34
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
version: '5.1'
|
39
39
|
- - "<"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '7.
|
41
|
+
version: '7.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: globalid
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,14 +181,14 @@ dependencies:
|
|
181
181
|
name: rspec-rails
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
|
-
- - "
|
184
|
+
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '5.0'
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
189
|
version_requirements: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
|
-
- - "
|
191
|
+
- - ">="
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '5.0'
|
194
194
|
- !ruby/object:Gem::Dependency
|
@@ -894,6 +894,7 @@ files:
|
|
894
894
|
- spec/presenters/thumbnail_presenter_spec.rb
|
895
895
|
- spec/routing/catalog_routing_spec.rb
|
896
896
|
- spec/routing/search_history_spec.rb
|
897
|
+
- spec/services/blacklight/field_retriever_spec.rb
|
897
898
|
- spec/services/blacklight/search_service_spec.rb
|
898
899
|
- spec/spec_helper.rb
|
899
900
|
- spec/support/controller_level_helpers.rb
|
@@ -954,7 +955,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
954
955
|
- !ruby/object:Gem::Version
|
955
956
|
version: '0'
|
956
957
|
requirements: []
|
957
|
-
rubygems_version: 3.4.
|
958
|
+
rubygems_version: 3.4.21
|
958
959
|
signing_key:
|
959
960
|
specification_version: 4
|
960
961
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
@@ -1077,6 +1078,7 @@ test_files:
|
|
1077
1078
|
- spec/presenters/thumbnail_presenter_spec.rb
|
1078
1079
|
- spec/routing/catalog_routing_spec.rb
|
1079
1080
|
- spec/routing/search_history_spec.rb
|
1081
|
+
- spec/services/blacklight/field_retriever_spec.rb
|
1080
1082
|
- spec/services/blacklight/search_service_spec.rb
|
1081
1083
|
- spec/spec_helper.rb
|
1082
1084
|
- spec/support/controller_level_helpers.rb
|