blacklight 8.0.0.beta7 → 8.0.0.beta8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0662c318e51fa886e7bb99d4e1b92fe25475758a713f3cb294b1db20cdde838f
4
- data.tar.gz: d5478a9723172b23520d55b0550b23c8b57d7f72aa26e5844e837f13cbc43cad
3
+ metadata.gz: bf6f2c77b039ffcb18b23c50795dd2acd9dd410e50749422a55a2d6b7f85d9aa
4
+ data.tar.gz: f5edad3ff59994077cbe368027d5af44ed1284cad8d561b8dba46e12a82a0688
5
5
  SHA512:
6
- metadata.gz: '0818d78cb403856c00378967fdad5ce88ee63fe1cfbff4c22dc09b1dd9eaf29dc04834d4575f71b52a66a0fa227a47d059f3a5c519d38f34909c5c0f8e45362d'
7
- data.tar.gz: 0566a3bc3a8ee90b05529d22819d9cca9253ff1c6ecedb300eb49b55a117c0735ffbcace049cf280f1bd13220be42ee80fd74794ec2fa402457b9bb9ec2801e5
6
+ metadata.gz: 4f8630de40970d3cd1422168e292445057172b55942eebd6fccbda3ca6be8141c89b9981ee459880b8185482d4c37d957803bcc610b87afa612876760085439d
7
+ data.tar.gz: 90e98ba147b335d833ca80b139776b89c622c18184a59e8c19083fa0b651983206ab209aa3b0429a673b34781a9cdfcc53dc6b12bafeaf74e4da575a00cd2151
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.0.0.beta7
1
+ 8.0.0.beta8
@@ -6,15 +6,17 @@ module Blacklight
6
6
  ##
7
7
  # A component for rendering a single document
8
8
  #
9
- # @note when subclassing this component, you must explicitly specify the collection parameter
10
- # as `document` and handle the `document` parameter in your initializer.
9
+ # @note when subclassing this component, if you override the initializer,
10
+ # you must explicitly specify the counter variable `document_counter` even if you don't use it.
11
+ # Otherwise view_component will not provide the count value when calling the component.
12
+ #
13
+ # @see https://viewcomponent.org/guide/collections.html#collection-counter
11
14
  #
12
15
  # @example
13
16
  # class MyDocumentComponent < Blacklight::DocumentComponent
14
- # with_collection_parameter :document
15
- #
16
- # def initialize(document:, **kwargs)
17
- # super(document: document, **kwargs)
17
+ # def initialize(document_counter: nil, **kwargs)
18
+ # super
19
+ # ... custom code ...
18
20
  # end
19
21
  # end
20
22
  class DocumentComponent < Blacklight::Component
@@ -54,7 +56,7 @@ module Blacklight
54
56
  renders_one :metadata, (lambda do |static_content = nil, *args, component: nil, fields: nil, **kwargs|
55
57
  next static_content if static_content.present?
56
58
 
57
- component ||= Blacklight::DocumentMetadataComponent
59
+ component ||= @presenter&.view_config&.metadata_component || Blacklight::DocumentMetadataComponent
58
60
 
59
61
  component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
60
62
  end)
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'shellwords'
4
+
3
5
  module Blacklight
4
6
  class AssetsGenerator < Rails::Generators::Base
5
7
  class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.1'), desc: "Set the generated app's bootstrap version"
6
8
 
7
9
  def run_asset_pipeline_specific_generator
8
- generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
10
+ generated_options = "--bootstrap-version='#{Shellwords.escape(options[:'bootstrap-version'])}'" if options[:'bootstrap-version']
9
11
 
10
12
  generator = if defined?(Propshaft)
11
13
  'blacklight:assets:propshaft'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'shellwords'
4
+
3
5
  module Blacklight
4
6
  class Install < Rails::Generators::Base
5
7
  source_root File.expand_path('../templates', __FILE__)
@@ -35,7 +37,7 @@ module Blacklight
35
37
  # Call external generator in AssetsGenerator, so we can
36
38
  # leave that callable seperately too.
37
39
  def copy_public_assets
38
- generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
40
+ generated_options = "--bootstrap-version='#{Shellwords.escape(options[:'bootstrap-version'])}'" if options[:'bootstrap-version']
39
41
 
40
42
  generate "blacklight:assets", generated_options unless options[:'skip-assets']
41
43
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "8.0.0-beta.7",
3
+ "version": "8.0.0-beta.8",
4
4
  "description": "[![Build Status](https://travis-ci.com/projectblacklight/blacklight.png?branch=main)](https://travis-ci.com/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Coverage Status](https://coveralls.io/repos/github/projectblacklight/blacklight/badge.svg?branch=main)](https://coveralls.io/github/projectblacklight/blacklight?branch=main)",
5
5
  "main": "app/assets/javascripts/blacklight",
6
6
  "module": "app/assets/javascripts/blacklight/blacklight.esm.js",
@@ -76,6 +76,10 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
76
76
  end
77
77
 
78
78
  context 'index view' do
79
+ before do
80
+ controller.action_name = "index"
81
+ end
82
+
79
83
  let(:attr) { { counter: 5 } }
80
84
 
81
85
  it 'has data properties' do
@@ -111,13 +115,22 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
111
115
  it 'renders a thumbnail' do
112
116
  expect(rendered).to have_selector 'a[href="/catalog/x"] img[src="http://example.com/image.jpg"]'
113
117
  end
118
+
119
+ context 'with default metadata component' do
120
+ it 'renders metadata' do
121
+ expect(rendered).to have_selector 'dl.document-metadata'
122
+ expect(rendered).to have_selector 'dt', text: 'Title:'
123
+ expect(rendered).to have_selector 'dd', text: 'Title'
124
+ expect(rendered).not_to have_selector 'dt', text: 'ISBN:'
125
+ end
126
+ end
114
127
  end
115
128
 
116
129
  context 'show view' do
117
130
  let(:attr) { { title_component: :h1, show: true } }
118
131
 
119
132
  before do
120
- allow(view_context).to receive(:action_name).and_return('show')
133
+ controller.action_name = "show"
121
134
  end
122
135
 
123
136
  it 'renders with an id' do
@@ -148,13 +161,26 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
148
161
  blacklight_config.show.embed_component = StubComponent
149
162
  expect(rendered).to have_content 'embed'
150
163
  end
151
- end
152
164
 
153
- it 'renders metadata' do
154
- expect(rendered).to have_selector 'dl.document-metadata'
155
- expect(rendered).to have_selector 'dt', text: 'Title:'
156
- expect(rendered).to have_selector 'dd', text: 'Title'
157
- expect(rendered).not_to have_selector 'dt', text: 'ISBN:'
165
+ context 'with configured metadata component' do
166
+ let(:custom_component_class) do
167
+ Class.new(Blacklight::DocumentMetadataComponent) do
168
+ # Override component rendering with our own value
169
+ def call
170
+ 'blah'
171
+ end
172
+ end
173
+ end
174
+
175
+ before do
176
+ stub_const('MyMetadataComponent', custom_component_class)
177
+ blacklight_config.show.metadata_component = MyMetadataComponent
178
+ end
179
+
180
+ it 'renders custom component' do
181
+ expect(rendered).to have_text 'blah'
182
+ end
183
+ end
158
184
  end
159
185
 
160
186
  it 'renders partials' do
@@ -11,7 +11,24 @@ RSpec.describe Blacklight::Response::ViewTypeComponent, type: :component do
11
11
  let(:search_state) { instance_double(Blacklight::SearchState, to_h: { controller: 'catalog', action: 'index' }) }
12
12
  let(:view_config) { Blacklight::Configuration::ViewConfig.new }
13
13
 
14
+ let(:custom_component_class) do
15
+ Class.new(Blacklight::Icons::IconComponent) do
16
+ # Override component rendering with our own value
17
+ def call
18
+ 'blah'
19
+ end
20
+ end
21
+ end
22
+
23
+ before do
24
+ stub_const('Blacklight::Icons::DefComponent', custom_component_class)
25
+ end
26
+
14
27
  describe "when some views exist" do
28
+ before do
29
+ stub_const('Blacklight::Icons::AbcComponent', custom_component_class)
30
+ end
31
+
15
32
  let(:views) do
16
33
  {
17
34
  abc: view_config,
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: 8.0.0.beta7
4
+ version: 8.0.0.beta8
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-02-23 00:00:00.000000000 Z
20
+ date: 2023-02-27 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails