blacklight 8.0.0 → 8.0.1

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: bf15f6dbb817f0839a3b5729997535274d21043ff834b4882cbd50af5ad37f05
4
- data.tar.gz: 57101760654230e5c50eaae71bdaf2fc679230d2ed739ad2023a1f48cea7a2ea
3
+ metadata.gz: 788296244ed7711b196967fcc206a6b7836db4b384bcbbe7e062cdf9f29d8b06
4
+ data.tar.gz: 4f83e1cf3421afde9db8cd8bfb7fed298c5f3c5874de2f22f7e7a48db2fe5979
5
5
  SHA512:
6
- metadata.gz: bd8d458da8677de400d1e96104fbb0d0831ba674a1d1790dbfcdf2b4e939cc270dc6b263f48d20e2ddd309f5cff7a312d003d573cb4ab5b9455ecd970c8caa99
7
- data.tar.gz: f2f66d799ca0c97a97705fb8d9d7f71ac2f374a9d0f69ecf02e620a5223ee1a72054b3911c8025959276a26bb71d6b852d3ab196d7b151d1d5aea3964a720e93
6
+ metadata.gz: 193f6a74d712c28cd42a7354ff0da15b7e303b94e51a3854de54401a38ef2e444bf76a1878130fcef71d5286080943cc5635d46f3f38b8bce7c539d2af6f10fe
7
+ data.tar.gz: 0cf1904df3915ed93d122d54d653201b576c2b4027b182fdb88e6d02bcc9885bac69ecc9c7f6331f4dd3d9ca7f637600e869a5edcb106dad03b2c88868e77e86
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.0.0
1
+ 8.0.1
@@ -1,2 +1,2 @@
1
- <%= render 'show_tools', document: document %>
1
+ <%= render_show_tools %>
2
2
  <%= render(Blacklight::Document::MoreLikeThisComponent.new(document: document)) %>
@@ -11,6 +11,18 @@ module Blacklight
11
11
  end
12
12
 
13
13
  attr_reader :document
14
+
15
+ delegate :blacklight_config, to: :helpers
16
+
17
+ private
18
+
19
+ def render_show_tools
20
+ blacklight_config.view_config(:show).show_tools_component&.tap do |show_tools_component_class|
21
+ return render show_tools_component_class.new(document: document)
22
+ end
23
+
24
+ render 'show_tools', document: document, silence_deprecation: helpers.partial_from_blacklight?('show_tools')
25
+ end
14
26
  end
15
27
  end
16
28
  end
@@ -1,3 +1,3 @@
1
- <%= content_tag :section, class: 'pagination', **@html_attr do %>
1
+ <%= content_tag :section, class: 'pagination', **html_attr do %>
2
2
  <%= pagination %>
3
3
  <% end %>
@@ -8,10 +8,14 @@ module Blacklight
8
8
  # @param [Hash] html html options for the pagination container
9
9
  def initialize(response:, html: {}, **pagination_args)
10
10
  @response = response
11
- @html_attr = { aria: { label: t('views.pagination.aria.container_label') } }.merge(html)
11
+ @html = html
12
12
  @pagination_args = pagination_args
13
13
  end
14
14
 
15
+ def html_attr
16
+ { aria: { label: t('views.pagination.aria.container_label') } }.merge(@html)
17
+ end
18
+
15
19
  def pagination
16
20
  helpers.paginate @response, **Blacklight::Engine.config.blacklight.default_pagination_options, **@pagination_args
17
21
  end
@@ -37,4 +37,14 @@ module Blacklight::BlacklightHelperBehavior
37
37
  self.formats = old_formats
38
38
  nil
39
39
  end
40
+
41
+ def self.blacklight_gem_path
42
+ @blacklight_gem_path ||= Gem.loaded_specs["blacklight"].full_gem_path
43
+ end
44
+
45
+ def partial_from_blacklight?(partial)
46
+ path = lookup_context.find_all(partial, lookup_context.prefixes + [""], true).first&.identifier
47
+
48
+ path.nil? ? false : path.starts_with?(Blacklight::BlacklightHelperBehavior.blacklight_gem_path)
49
+ end
40
50
  end
@@ -1 +1,2 @@
1
+ <% Blacklight.deprecation.warn('The partial _show_tools.html.erb will be removed in 9.0. Configure blacklight_config.show.show_tools_component instead (default Blacklight::Document::ShowToolsComponent).') unless local_assigns[:silence_deprecation] %>
1
2
  <%= render Blacklight::Document::ShowToolsComponent.new(document: document) %>
@@ -5,9 +5,6 @@
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
7
 
8
- <!-- Internet Explorer use the highest version available -->
9
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
10
-
11
8
  <title><%= render_page_title %></title>
12
9
  <script>
13
10
  document.querySelector('html').classList.remove('no-js');
@@ -181,6 +181,9 @@ module Blacklight
181
181
  # document presenter class used by helpers and views
182
182
  document_presenter_class: nil,
183
183
  document_component: Blacklight::DocumentComponent,
184
+ # in Blacklight 9, the default show_tools_component configuration will
185
+ # be Blacklight::Document::ShowToolsComponent
186
+ show_tools_component: nil,
184
187
  sidebar_component: Blacklight::Document::SidebarComponent,
185
188
  display_type_field: nil,
186
189
  # the "field access" key to use to look up the document display fields
@@ -40,7 +40,7 @@ namespace :blacklight do
40
40
  exit 1
41
41
  end
42
42
  rescue => e
43
- puts e.to_s
43
+ puts e
44
44
  exit 1
45
45
  end
46
46
 
@@ -70,7 +70,7 @@ namespace :blacklight do
70
70
  end
71
71
  rescue => e
72
72
  errors += 1
73
- puts e.to_s
73
+ puts e
74
74
  end
75
75
 
76
76
  print " - search_results: "
@@ -92,7 +92,7 @@ namespace :blacklight do
92
92
  end
93
93
  rescue => e
94
94
  errors += 1
95
- puts e.to_s
95
+ puts e
96
96
  end
97
97
 
98
98
  print " - fetch: "
@@ -112,7 +112,7 @@ namespace :blacklight do
112
112
  end
113
113
  rescue => e
114
114
  errors += 1
115
- puts e.to_s
115
+ puts e
116
116
  end
117
117
 
118
118
  exit 1 if errors > 0
data/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "8.0.0",
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)",
3
+ "version": "8.0.1",
4
+ "description": "The frontend code and styles for Blacklight",
5
5
  "main": "app/assets/javascripts/blacklight",
6
6
  "module": "app/assets/javascripts/blacklight/blacklight.esm.js",
7
7
  "scripts": {
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::Document::SidebarComponent, type: :component do
6
+ subject(:component) { described_class.new(presenter: document) }
7
+
8
+ let(:view_context) { controller.view_context }
9
+ let(:render) do
10
+ component.render_in(view_context)
11
+ end
12
+
13
+ let(:rendered) do
14
+ Capybara::Node::Simple.new(render)
15
+ end
16
+
17
+ let(:document) { view_context.document_presenter(presented_document) }
18
+
19
+ let(:presented_document) { SolrDocument.new(id: 'x', title_tsim: 'Title') }
20
+
21
+ let(:blacklight_config) do
22
+ CatalogController.blacklight_config.deep_copy
23
+ end
24
+
25
+ let(:expected_html) { "<div class=\"expected-show_tools\">Expected Content</div>".html_safe }
26
+
27
+ before do
28
+ # Every call to view_context returns a different object. This ensures it stays stable.
29
+ allow(controller).to receive(:view_context).and_return(view_context)
30
+ allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
31
+ end
32
+
33
+ describe '#render_show_tools' do
34
+ # rubocop:disable RSpec/SubjectStub
35
+ before do
36
+ allow(component).to receive(:render).with(an_instance_of(Blacklight::Document::MoreLikeThisComponent)).and_return("")
37
+ end
38
+
39
+ context "without a configured ShowTools component" do
40
+ before do
41
+ allow(component).to receive(:render).with('show_tools', document: presented_document, silence_deprecation: false).and_return(expected_html)
42
+ end
43
+
44
+ it 'renders show_tools partial' do
45
+ expect(rendered).to have_selector 'div[@class="expected-show_tools"]'
46
+ end
47
+ end
48
+
49
+ context "with a configured ShowTools component" do
50
+ let(:show_tools_component) { Class.new(Blacklight::Document::ShowToolsComponent) }
51
+
52
+ before do
53
+ blacklight_config.show.show_tools_component = show_tools_component
54
+ allow(component).to receive(:render).with(an_instance_of(show_tools_component)).and_return(expected_html)
55
+ end
56
+
57
+ it 'renders configured show_tools component' do
58
+ expect(rendered).to have_selector 'div[@class="expected-show_tools"]'
59
+ end
60
+ end
61
+ # rubocop:enable RSpec/SubjectStub
62
+ end
63
+ end
@@ -50,10 +50,6 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
50
50
 
51
51
  MockDocument.use_extension(MockExtension)
52
52
 
53
- def mock_document_app_helper_url *args
54
- solr_document_url(*args)
55
- end
56
-
57
53
  allow(request_context).to receive(:polymorphic_url) do |_, opts|
58
54
  "url.#{opts[:format]}"
59
55
  end
@@ -68,12 +64,10 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
68
64
  tmp_value = Capybara.ignore_hidden_elements
69
65
  Capybara.ignore_hidden_elements = false
70
66
  document.export_formats.each_pair do |format, _spec|
71
- expect(subject).to have_selector("link[href$='.#{format}']") do |matches|
72
- expect(matches).to have(1).match
73
- tag = matches[0]
74
- expect(tag.attributes["rel"].value).to eq "alternate"
75
- expect(tag.attributes["title"].value).to eq format.to_s
76
- expect(tag.attributes["href"].value).to eq mock_document_app_helper_url(document, format: format)
67
+ expect(subject).to have_selector("link[href$='.#{format}']", count: 1) do |tag|
68
+ expect(tag["rel"]).to eq "alternate"
69
+ expect(tag["title"]).to eq format.to_s
70
+ expect(tag["href"]).to eq "url.#{format}"
77
71
  end
78
72
  end
79
73
  Capybara.ignore_hidden_elements = tmp_value
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
4
+ version: 8.0.1
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-03-16 00:00:00.000000000 Z
20
+ date: 2023-05-01 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -771,6 +771,7 @@ files:
771
771
  - spec/components/blacklight/constraints_component_spec.rb
772
772
  - spec/components/blacklight/document/action_component_spec.rb
773
773
  - spec/components/blacklight/document/group_component_spec.rb
774
+ - spec/components/blacklight/document/sidebar_component_spec.rb
774
775
  - spec/components/blacklight/document_component_spec.rb
775
776
  - spec/components/blacklight/document_metadata_component_spec.rb
776
777
  - spec/components/blacklight/facet_component_spec.rb
@@ -934,7 +935,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
934
935
  - !ruby/object:Gem::Version
935
936
  version: '0'
936
937
  requirements: []
937
- rubygems_version: 3.1.6
938
+ rubygems_version: 3.4.12
938
939
  signing_key:
939
940
  specification_version: 4
940
941
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -945,6 +946,7 @@ test_files:
945
946
  - spec/components/blacklight/constraints_component_spec.rb
946
947
  - spec/components/blacklight/document/action_component_spec.rb
947
948
  - spec/components/blacklight/document/group_component_spec.rb
949
+ - spec/components/blacklight/document/sidebar_component_spec.rb
948
950
  - spec/components/blacklight/document_component_spec.rb
949
951
  - spec/components/blacklight/document_metadata_component_spec.rb
950
952
  - spec/components/blacklight/facet_component_spec.rb