blacklight 7.39.0 → 7.40.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.github/workflows/ruby.yml +2 -2
- data/.rubocop.yml +1 -0
- data/VERSION +1 -1
- data/app/presenters/blacklight/document_presenter.rb +29 -10
- data/app/presenters/blacklight/index_presenter.rb +1 -1
- data/blacklight.gemspec +1 -1
- data/lib/blacklight/component.rb +10 -47
- data/package.json +1 -1
- data/spec/lib/blacklight/component_spec.rb +32 -27
- data/spec/presenters/blacklight/document_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e1a5889b0f9dee50b64165ffe292482619e54780bac24b14af00b3b1cba2fdd
|
4
|
+
data.tar.gz: 0ed718e93da4bca43bb242e5a97c6ced3546aa8ec9f17d18ce00a444dca95d93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee5a1dc4ddb014510defa98a6c36a3d0e3ef9913c5cce5195878c688d062f7b95e3b30b376558adbc300ce4586f894e2e2af75dac933bc621c5401e2f7cf1eff
|
7
|
+
data.tar.gz: 0cd9ec1e44e68aeae47dbc86f95e18f1402831579b94d942c6ed4e9b264eab2b1f698bbe776616f962b4f6f28b4fe0fedb1e8e6d37aeb4b5be376425cd7d795d
|
data/.env
CHANGED
data/.github/workflows/ruby.yml
CHANGED
@@ -109,14 +109,14 @@ jobs:
|
|
109
109
|
run: bundle exec rake ci
|
110
110
|
env:
|
111
111
|
ENGINE_CART_RAILS_OPTIONS: '--skip-keeps --skip-test'
|
112
|
-
|
112
|
+
test_vc2:
|
113
113
|
runs-on: ubuntu-latest
|
114
114
|
strategy:
|
115
115
|
matrix:
|
116
116
|
ruby: ['3.2']
|
117
117
|
env:
|
118
118
|
RAILS_VERSION: 7.0.8
|
119
|
-
VIEW_COMPONENT_VERSION:
|
119
|
+
VIEW_COMPONENT_VERSION: "~> 2.74"
|
120
120
|
steps:
|
121
121
|
- uses: actions/checkout@v2
|
122
122
|
- name: Set up Ruby
|
data/.rubocop.yml
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.40.0
|
@@ -11,18 +11,26 @@ module Blacklight
|
|
11
11
|
# @param [SolrDocument] document
|
12
12
|
# @param [ActionView::Base] view_context scope for linking and generating urls
|
13
13
|
# @param [Blacklight::Configuration] configuration
|
14
|
-
def initialize(document, view_context, configuration = view_context.blacklight_config)
|
14
|
+
def initialize(document, view_context, configuration = view_context.blacklight_config, view_config: nil, field_presenter_options: {})
|
15
15
|
@document = document
|
16
16
|
@view_context = view_context
|
17
17
|
@configuration = configuration
|
18
|
+
@view_config = view_config
|
19
|
+
@field_presenter_options = field_presenter_options
|
18
20
|
end
|
19
21
|
|
20
22
|
# @return [Hash<String,Configuration::Field>] all the fields for this index view that should be rendered
|
21
|
-
def fields_to_render
|
22
|
-
|
23
|
+
def fields_to_render(document_fields = fields, **kwargs)
|
24
|
+
unless block_given?
|
25
|
+
return to_enum(:fields_to_render, document_fields, **kwargs) unless method(:fields_to_render).arity.zero?
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
Deprecation.warn(self.class, 'In Blacklight 8, Blacklight::DocumentPresenter#fields_to_render accepts additional arguments')
|
28
|
+
|
29
|
+
return to_enum(:fields_to_render)
|
30
|
+
end
|
31
|
+
|
32
|
+
document_fields.each do |name, field_config|
|
33
|
+
field_presenter = field_presenter(field_config, kwargs)
|
26
34
|
|
27
35
|
next unless field_presenter.render_field? && field_presenter.any?
|
28
36
|
|
@@ -30,10 +38,21 @@ module Blacklight
|
|
30
38
|
end
|
31
39
|
end
|
32
40
|
|
33
|
-
def field_presenters
|
34
|
-
|
41
|
+
def field_presenters(document_fields = fields, **kwargs)
|
42
|
+
unless block_given?
|
43
|
+
return to_enum(:field_presenters, document_fields, **kwargs) unless method(:field_presenters).arity.zero?
|
44
|
+
|
45
|
+
Deprecation.warn(self.class, 'In Blacklight 8, Blacklight::DocumentPresenter#field_presenters accepts additional arguments')
|
35
46
|
|
36
|
-
|
47
|
+
return to_enum(:field_presenters)
|
48
|
+
end
|
49
|
+
|
50
|
+
if method(:fields_to_render).arity.zero?
|
51
|
+
Deprecation.warn(self.class, 'In Blacklight 8, Blacklight::DocumentPresenter#fields_to_render accept additional arguments')
|
52
|
+
fields_to_render.each { |_, _, config| yield config }
|
53
|
+
else
|
54
|
+
fields_to_render(document_fields, **kwargs).each { |_, _, config| yield config }
|
55
|
+
end
|
37
56
|
end
|
38
57
|
|
39
58
|
##
|
@@ -122,7 +141,7 @@ module Blacklight
|
|
122
141
|
end
|
123
142
|
|
124
143
|
def show_view_config
|
125
|
-
configuration.view_config(:show)
|
144
|
+
configuration.view_config(:show, action_name: view_context.action_name)
|
126
145
|
end
|
127
146
|
|
128
147
|
def inspect
|
@@ -158,7 +177,7 @@ module Blacklight
|
|
158
177
|
end
|
159
178
|
|
160
179
|
def field_presenter_options
|
161
|
-
{}
|
180
|
+
@field_presenter_options ||= {}
|
162
181
|
end
|
163
182
|
end
|
164
183
|
end
|
@@ -30,7 +30,7 @@ module Blacklight
|
|
30
30
|
deprecation_deprecate label: 'Use #heading'
|
31
31
|
|
32
32
|
def view_config
|
33
|
-
@view_config ||= configuration.view_config(view_context.document_index_view_type)
|
33
|
+
@view_config ||= configuration.view_config(view_context.document_index_view_type, action_name: view_context.action_name)
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
data/blacklight.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_dependency "deprecation"
|
33
33
|
s.add_dependency "i18n", '>= 1.7.0' # added named parameters
|
34
34
|
s.add_dependency "ostruct", '>= 0.3.2'
|
35
|
-
s.add_dependency "view_component", '>= 2.
|
35
|
+
s.add_dependency "view_component", '>= 2.74', '< 4'
|
36
36
|
s.add_dependency 'hashdiff'
|
37
37
|
s.add_dependency "zeitwerk"
|
38
38
|
|
data/lib/blacklight/component.rb
CHANGED
@@ -3,57 +3,20 @@
|
|
3
3
|
module Blacklight
|
4
4
|
class Component < ViewComponent::Base
|
5
5
|
class << self
|
6
|
-
|
7
|
-
def config
|
8
|
-
@config ||= ViewComponent::Config.defaults.merge(ViewComponent::Base.config)
|
9
|
-
end
|
6
|
+
alias upstream_sidecar_files sidecar_files
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
@__vc_compiler ||= EngineCompiler.new(self)
|
8
|
+
def reset_compiler!
|
9
|
+
@__vc_compiler = nil
|
14
10
|
end
|
15
|
-
# rubocop:enable Naming/MemoizedInstanceVariableName
|
16
|
-
|
17
|
-
alias sidecar_files _sidecar_files unless ViewComponent::Base.respond_to? :sidecar_files
|
18
|
-
end
|
19
|
-
|
20
|
-
EXCLUDE_VARIABLES = [
|
21
|
-
:@lookup_context, :@view_renderer, :@view_flow, :@view_context,
|
22
|
-
:@tag_builder, :@current_template,
|
23
|
-
:@__vc_set_slots, :@__vc_original_view_context,
|
24
|
-
:@__vc_variant, :@__vc_content_evaluated,
|
25
|
-
:@__vc_render_in_block, :@__vc_content, :@__vc_helpers
|
26
|
-
].freeze
|
27
|
-
|
28
|
-
def inspect
|
29
|
-
# Exclude variables added by render_in
|
30
|
-
render_variables = instance_variables - EXCLUDE_VARIABLES
|
31
|
-
fields = render_variables.map { |ivar| "#{ivar}:#{instance_variable_get(ivar).inspect}" }.join(', ')
|
32
|
-
"#<#{self.class.name}:#{object_id} #{fields}>"
|
33
|
-
end
|
34
|
-
|
35
|
-
class EngineCompiler < ::ViewComponent::Compiler
|
36
|
-
# ViewComponent::Compiler locates and caches templates from sidecar files to the component source file.
|
37
|
-
# While this is sensible in a Rails application, it prevents component templates defined in an Engine
|
38
|
-
# from being overridden by an installing application without subclassing the component, which may also
|
39
|
-
# require modifying any partials rendering the component. This subclass of compiler overrides the template
|
40
|
-
# location algorithm to take the sidecar file names from the Engine, but look to see if a file of the
|
41
|
-
# same name existing in the installing application (ie, under Rails.root). If the latter exists, this
|
42
|
-
# compiler will cache that template instead of the engine-defined file; if not, the compiler will fall
|
43
|
-
# back to the engine-defined file.
|
44
|
-
def templates
|
45
|
-
@templates ||= begin
|
46
|
-
extensions = ActionView::Template.template_handler_extensions
|
47
11
|
|
48
|
-
|
49
|
-
|
50
|
-
|
12
|
+
def sidecar_files(*args, **kwargs)
|
13
|
+
upstream_sidecar_files(*args, **kwargs).map do |path|
|
14
|
+
app_path = Rails.root.join(path.slice(path.index(view_component_path)..-1).to_s).to_s
|
51
15
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
16
|
+
if File.exist?(app_path)
|
17
|
+
app_path
|
18
|
+
else
|
19
|
+
path
|
57
20
|
end
|
58
21
|
end
|
59
22
|
end
|
data/package.json
CHANGED
@@ -1,43 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::Component do
|
4
|
-
let(:component_class) { Blacklight::
|
3
|
+
RSpec.describe Blacklight::Component, type: :component do
|
4
|
+
let(:component_class) { Blacklight::System::ModalComponent }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
before do
|
7
|
+
component_class.reset_compiler!
|
8
|
+
ViewComponent::CompileCache.invalidate!
|
9
|
+
|
10
|
+
component_class.class_eval do
|
11
|
+
undef :call if method_defined?(:call)
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
after do
|
16
|
+
component_class.reset_compiler!
|
17
|
+
ViewComponent::CompileCache.invalidate!
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
component_class.class_eval do
|
20
|
+
undef :call if method_defined?(:call)
|
21
|
+
end
|
22
|
+
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
24
|
+
context "without overrides" do
|
25
|
+
it "renders the engine template" do
|
26
|
+
render_inline(component_class.new)
|
27
|
+
expect(page).to have_css('.modal-header')
|
25
28
|
end
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
context "with overrides" do
|
32
|
+
around do |ex|
|
33
|
+
FileUtils.mkdir_p(Rails.root.join('app/components/blacklight/system'))
|
34
|
+
Rails.root.join("app/components/blacklight/system/modal_component.html.erb").open("w") do |f|
|
35
|
+
f.puts '<div class="custom-modal">Overridden</div>'
|
30
36
|
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
ex.run
|
39
|
+
ensure
|
40
|
+
Rails.root.join('app/components/blacklight/system/modal_component.html.erb').unlink
|
41
|
+
end
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
43
|
+
it "renders to application template" do
|
44
|
+
render_inline(component_class.new)
|
45
|
+
expect(page).to have_css('.custom-modal')
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -22,6 +22,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
|
|
22
22
|
|
23
23
|
before do
|
24
24
|
allow(request_context).to receive(:search_state).and_return(search_state)
|
25
|
+
allow(request_context).to receive(:action_name).and_return(:show)
|
25
26
|
end
|
26
27
|
|
27
28
|
describe "link_rel_alternates" do
|
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.40.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: 2024-
|
20
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -129,7 +129,7 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '2.
|
132
|
+
version: '2.74'
|
133
133
|
- - "<"
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '4'
|
@@ -139,7 +139,7 @@ dependencies:
|
|
139
139
|
requirements:
|
140
140
|
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: '2.
|
142
|
+
version: '2.74'
|
143
143
|
- - "<"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '4'
|