blacklight 8.0.0.beta7 → 8.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0662c318e51fa886e7bb99d4e1b92fe25475758a713f3cb294b1db20cdde838f
4
- data.tar.gz: d5478a9723172b23520d55b0550b23c8b57d7f72aa26e5844e837f13cbc43cad
3
+ metadata.gz: bf15f6dbb817f0839a3b5729997535274d21043ff834b4882cbd50af5ad37f05
4
+ data.tar.gz: 57101760654230e5c50eaae71bdaf2fc679230d2ed739ad2023a1f48cea7a2ea
5
5
  SHA512:
6
- metadata.gz: '0818d78cb403856c00378967fdad5ce88ee63fe1cfbff4c22dc09b1dd9eaf29dc04834d4575f71b52a66a0fa227a47d059f3a5c519d38f34909c5c0f8e45362d'
7
- data.tar.gz: 0566a3bc3a8ee90b05529d22819d9cca9253ff1c6ecedb300eb49b55a117c0735ffbcace049cf280f1bd13220be42ee80fd74794ec2fa402457b9bb9ec2801e5
6
+ metadata.gz: bd8d458da8677de400d1e96104fbb0d0831ba674a1d1790dbfcdf2b4e939cc270dc6b263f48d20e2ddd309f5cff7a312d003d573cb4ab5b9455ecd970c8caa99
7
+ data.tar.gz: f2f66d799ca0c97a97705fb8d9d7f71ac2f374a9d0f69ecf02e620a5223ee1a72054b3911c8025959276a26bb71d6b852d3ab196d7b151d1d5aea3964a720e93
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.0.0.beta7
1
+ 8.0.0
@@ -1,3 +1,3 @@
1
- //= link_tree ../../images
1
+ //= link_tree ../../images .png
2
2
  //= link_directory ../../stylesheets .css
3
3
  //= link_tree ../../../javascript .js
@@ -0,0 +1,12 @@
1
+ <div class="card show-tools">
2
+ <div class="card-header">
3
+ <h2 class="mb-0 h6"><%= t('blacklight.tools.title') %></h2>
4
+ </div>
5
+ <%= render Blacklight::Document::ActionsComponent.new(document: document,
6
+ tag: 'ul',
7
+ classes: 'list-group list-group-flush',
8
+ wrapping_tag: 'li',
9
+ wrapping_classes: 'list-group-item list-group-item-action',
10
+ actions: actions,
11
+ url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h)) %>
12
+ </div>
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Document
5
+ # Render the tools that display on the sidebar of the show page
6
+ class ShowToolsComponent < Blacklight::Component
7
+ # @param [Blacklight::Document] document
8
+ def initialize(document:)
9
+ @document = document
10
+ end
11
+
12
+ attr_reader :document
13
+
14
+ def render?
15
+ helpers.show_doc_actions?
16
+ end
17
+
18
+ def actions
19
+ helpers.document_actions(document)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -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
@@ -35,7 +37,7 @@ module Blacklight
35
37
 
36
38
  # The document title with some reasonable default behavior
37
39
  renders_one :title, (lambda do |*args, component: nil, **kwargs|
38
- component ||= Blacklight::DocumentTitleComponent
40
+ component ||= @presenter&.view_config&.title_component || Blacklight::DocumentTitleComponent
39
41
 
40
42
  component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
41
43
  end)
@@ -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,6 +1,6 @@
1
1
  <nav class="navbar navbar-expand-md navbar-dark bg-dark topbar" role="navigation">
2
2
  <div class="<%= container_classes %>">
3
- <%= link_to application_name, blacklight_config.logo_link, class: 'mb-0 navbar-brand navbar-logo' %>
3
+ <%= logo_link %>
4
4
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-bs-toggle="collapse" data-target="#user-util-collapse" data-bs-target="#user-util-collapse" aria-controls="user-util-collapse" aria-expanded="false" aria-label="Toggle navigation">
5
5
  <span class="navbar-toggler-icon"></span>
6
6
  </button>
@@ -9,5 +9,9 @@ module Blacklight
9
9
  attr_reader :blacklight_config
10
10
 
11
11
  delegate :application_name, :container_classes, to: :helpers
12
+
13
+ def logo_link(title: application_name)
14
+ link_to title, blacklight_config.logo_link, class: 'mb-0 navbar-brand navbar-logo'
15
+ end
12
16
  end
13
17
  end
@@ -59,6 +59,7 @@ render document_component.new(presenter: document_presenter(document), component
59
59
  if template
60
60
  template.render(self, locals.merge(document: doc))
61
61
  else
62
+ logger.warn("No template was found for base_name: '#{base_name}', view_type: '#{view_type}' in render_document_partial")
62
63
  ''
63
64
  end
64
65
  end
@@ -1,14 +1 @@
1
- <% if show_doc_actions? %>
2
- <div class="card show-tools">
3
- <div class="card-header">
4
- <h2 class="mb-0 h6"><%= t('blacklight.tools.title') %></h2>
5
- </div>
6
- <%= render Blacklight::Document::ActionsComponent.new(document: document,
7
- tag: 'ul',
8
- classes: 'list-group list-group-flush',
9
- wrapping_tag: 'li',
10
- wrapping_classes: 'list-group-item list-group-item-action',
11
- actions: document_actions(document),
12
- url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h)) %>
13
- </div>
14
- <% end %>
1
+ <%= render Blacklight::Document::ShowToolsComponent.new(document: document) %>
@@ -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",
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,46 @@ 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
184
+
185
+ context 'with configured title component' do
186
+ let(:custom_component_class) do
187
+ Class.new(Blacklight::DocumentTitleComponent) do
188
+ # Override component rendering with our own value
189
+ def call
190
+ 'Titleriffic'
191
+ end
192
+ end
193
+ end
194
+
195
+ before do
196
+ stub_const('MyTitleComponent', custom_component_class)
197
+ blacklight_config.show.title_component = MyTitleComponent
198
+ end
199
+
200
+ it 'renders custom component' do
201
+ expect(rendered).to have_text 'Titleriffic'
202
+ end
203
+ end
158
204
  end
159
205
 
160
206
  it 'renders partials' do
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Blacklight::HeaderComponent, type: :component do
4
+ before do
5
+ with_controller_class(CatalogController) do
6
+ allow(controller).to receive(:current_user).and_return(nil)
7
+ allow(controller).to receive(:search_action_url).and_return('/search')
8
+ render
9
+ end
10
+ end
11
+
12
+ context 'with no slots' do
13
+ let(:render) { render_inline(described_class.new(blacklight_config: CatalogController.blacklight_config)) }
14
+
15
+ it 'draws the topbar' do
16
+ expect(page).to have_css 'nav.topbar'
17
+ expect(page).to have_link 'Blacklight', href: '/'
18
+ end
19
+ end
20
+ end
@@ -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,
@@ -158,7 +158,7 @@ RSpec.describe CatalogController, api: true do
158
158
 
159
159
  format = facets.find { |x| x['id'] == 'format' }
160
160
 
161
- expect(format['attributes']['items'].pluck('attributes')).to match_array([{ "value" => "Book", "hits" => 30, "label" => "Book" }])
161
+ expect(format['attributes']['items'].pluck('attributes')).to contain_exactly({ "value" => "Book", "hits" => 30, "label" => "Book" })
162
162
  expect(format['links']['self']).to eq facet_catalog_url(format: :json, id: 'format')
163
163
  expect(format['attributes']['items'].first['links']['self']).to eq search_catalog_url(format: :json, f: { format: ['Book'] })
164
164
  end
@@ -76,7 +76,7 @@ RSpec.describe Blacklight::OpenStructWithHashAccess do
76
76
 
77
77
  it "sorts the underlying hash" do
78
78
  sorted = subject.sort_by { |_k, v| v }
79
- expect(sorted.keys).to match_array [:b, :a, :c]
79
+ expect(sorted.keys).to contain_exactly(:b, :a, :c)
80
80
  end
81
81
  end
82
82
 
@@ -85,7 +85,7 @@ RSpec.describe Blacklight::OpenStructWithHashAccess do
85
85
 
86
86
  it "sorts the underlying hash" do
87
87
  subject.sort_by! { |_k, v| v }
88
- expect(subject.keys).to match_array [:b, :a, :c]
88
+ expect(subject.keys).to contain_exactly(:b, :a, :c)
89
89
  end
90
90
  end
91
91
 
@@ -172,8 +172,8 @@ RSpec.describe "Blacklight::Configuration", api: true do
172
172
 
173
173
  expect(config.a[:value]).to eq 1
174
174
  expect(config_copy.a[:value]).to eq 2
175
- expect(config.b).to match_array [1, 2, 3]
176
- expect(config_copy.b).to match_array [1, 2, 3, 5]
175
+ expect(config.b).to contain_exactly(1, 2, 3)
176
+ expect(config_copy.b).to contain_exactly(1, 2, 3, 5)
177
177
  expect(config.c.value).to match_array %w[a b]
178
178
  expect(config_copy.c.value).to match_array %w[a b c]
179
179
  end
@@ -45,7 +45,7 @@ RSpec.describe Blacklight::SearchBuilder, api: true do
45
45
 
46
46
  it "is mutable" do
47
47
  subject.processor_chain.insert(-1, :d)
48
- expect(subject.processor_chain).to match_array [:a, :b, :c, :d]
48
+ expect(subject.processor_chain).to contain_exactly(:a, :b, :c, :d)
49
49
  end
50
50
  end
51
51
 
@@ -56,7 +56,7 @@ RSpec.describe Blacklight::SearchBuilder, api: true do
56
56
  builder = subject.append(:d, :e)
57
57
  expect(subject.processor_chain).to eq processor_chain
58
58
  expect(builder.processor_chain).not_to eq subject.processor_chain
59
- expect(builder.processor_chain).to match_array [:a, :b, :c, :d, :e]
59
+ expect(builder.processor_chain).to contain_exactly(:a, :b, :c, :d, :e)
60
60
  end
61
61
  end
62
62
 
@@ -68,7 +68,7 @@ RSpec.describe Blacklight::SearchBuilder, api: true do
68
68
  expect(builder).not_to equal(subject)
69
69
  expect(subject.processor_chain).to eq processor_chain
70
70
  expect(builder.processor_chain).not_to eq subject.processor_chain
71
- expect(builder.processor_chain).to match_array [:a, :c, :e]
71
+ expect(builder.processor_chain).to contain_exactly(:a, :c, :e)
72
72
  end
73
73
  end
74
74
 
@@ -45,7 +45,7 @@ RSpec.describe Blacklight::Solr::Request, api: true do
45
45
  subject.append_query 'this is my query'
46
46
  subject.append_query 'another:query'
47
47
  expect(subject).not_to have_key 'q'
48
- expect(subject.dig('json', 'query', 'bool', 'must')).to match_array ['this is my query', 'another:query']
48
+ expect(subject.dig('json', 'query', 'bool', 'must')).to contain_exactly('this is my query', 'another:query')
49
49
  end
50
50
  end
51
51
 
@@ -62,7 +62,7 @@ RSpec.describe Blacklight::Solr::Request, api: true do
62
62
  subject['q'] = 'some query'
63
63
  subject.append_boolean_query :must, 'also required'
64
64
 
65
- expect(subject.dig('json', 'query', 'bool', 'must')).to match_array ['some query', 'also required']
65
+ expect(subject.dig('json', 'query', 'bool', 'must')).to contain_exactly('some query', 'also required')
66
66
  end
67
67
  end
68
68
  end
@@ -14,7 +14,7 @@ module ViewComponentTestHelpers
14
14
  return super if defined?(super)
15
15
 
16
16
  # ViewComponent 3.x
17
- return __vc_test_helpers_controller if defined?(__vc_test_helpers_controller)
17
+ return vc_test_controller if defined?(vc_test_controller)
18
18
 
19
19
  ApplicationController.new.extend(Rails.application.routes.url_helpers)
20
20
  end
@@ -3,10 +3,10 @@
3
3
  RSpec.describe "catalog/_show_tools.html.erb" do
4
4
  let(:document) { SolrDocument.new id: 'xyz', format: 'a' }
5
5
  let(:blacklight_config) { Blacklight::Configuration.new }
6
- let(:component) { instance_double(Blacklight::Document::ActionsComponent) }
6
+ let(:component) { instance_double(Blacklight::Document::ShowToolsComponent) }
7
7
 
8
8
  before do
9
- allow(Blacklight::Document::ActionsComponent).to receive(:new).and_return(component)
9
+ allow(Blacklight::Document::ShowToolsComponent).to receive(:new).and_return(component)
10
10
  allow(view).to receive(:render).with(component)
11
11
  allow(view).to receive(:render).with('catalog/show_tools', { document: document }).and_call_original
12
12
  allow(view).to receive(:blacklight_config).and_return blacklight_config
@@ -93,7 +93,7 @@ RSpec.describe "catalog/index.json", api: true do
93
93
  expect(facets.pluck('id')).to include 'format'
94
94
  expect(format['links']).to include self: 'http://test.host/some/facet/url'
95
95
  expect(format['attributes']['label']).to eq 'Format'
96
- expect(format_item_attributes).to match_array [{ value: 'Book', hits: 30, label: 'Book' }]
96
+ expect(format_item_attributes).to contain_exactly({ value: 'Book', hits: 30, label: 'Book' })
97
97
  end
98
98
  end
99
99
 
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
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-03-16 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -423,6 +423,8 @@ files:
423
423
  - app/components/blacklight/document/group_component.rb
424
424
  - app/components/blacklight/document/more_like_this_component.html.erb
425
425
  - app/components/blacklight/document/more_like_this_component.rb
426
+ - app/components/blacklight/document/show_tools_component.html.erb
427
+ - app/components/blacklight/document/show_tools_component.rb
426
428
  - app/components/blacklight/document/sidebar_component.html.erb
427
429
  - app/components/blacklight/document/sidebar_component.rb
428
430
  - app/components/blacklight/document/thumbnail_component.html.erb
@@ -776,6 +778,7 @@ files:
776
778
  - spec/components/blacklight/facet_field_list_component_spec.rb
777
779
  - spec/components/blacklight/facet_item_component_spec.rb
778
780
  - spec/components/blacklight/facet_item_pivot_component_spec.rb
781
+ - spec/components/blacklight/header_component_spec.rb
779
782
  - spec/components/blacklight/hidden_search_state_component_spec.rb
780
783
  - spec/components/blacklight/metadata_field_component_spec.rb
781
784
  - spec/components/blacklight/response/spellcheck_component_spec.rb
@@ -927,11 +930,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
927
930
  version: '2.7'
928
931
  required_rubygems_version: !ruby/object:Gem::Requirement
929
932
  requirements:
930
- - - ">"
933
+ - - ">="
931
934
  - !ruby/object:Gem::Version
932
- version: 1.3.1
935
+ version: '0'
933
936
  requirements: []
934
- rubygems_version: 3.3.26
937
+ rubygems_version: 3.1.6
935
938
  signing_key:
936
939
  specification_version: 4
937
940
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -949,6 +952,7 @@ test_files:
949
952
  - spec/components/blacklight/facet_field_list_component_spec.rb
950
953
  - spec/components/blacklight/facet_item_component_spec.rb
951
954
  - spec/components/blacklight/facet_item_pivot_component_spec.rb
955
+ - spec/components/blacklight/header_component_spec.rb
952
956
  - spec/components/blacklight/hidden_search_state_component_spec.rb
953
957
  - spec/components/blacklight/metadata_field_component_spec.rb
954
958
  - spec/components/blacklight/response/spellcheck_component_spec.rb