blacklight 8.6.1 → 8.7.0

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: afd3fee02b2c13951464a573d0866db0eaf380043fa25564710e30ff3b123cf5
4
- data.tar.gz: e89eaca552de439340a25da85e9cd17ced73352cabe6d739d5b8f903eb14214f
3
+ metadata.gz: 9358af81c0c58fd1a8ccae1fc02815bc703daa08fcd5b249af15c765da98c311
4
+ data.tar.gz: 3ffdf6aa8da204915f04db78d379a3c995ec85a19527c7191bf2b0e74f652259
5
5
  SHA512:
6
- metadata.gz: 6eb41e7758a828af27604f1f914b3026892dd08e1d94e9b07b17e1aeef8e8c94050f2578774bdec730a09a12522513f61c2b3c021b02a6b050892e0a8de010b5
7
- data.tar.gz: b908484c6b275c4dfffb5821b795f9ad30c1aa88e66cc5cccd343af3c2ac6fbfbc1a437ecc1b0627ea6de68c0c22780b79e9565f992caec248fc1486beebd67a
6
+ metadata.gz: 967b1417e1988538686c89ddd80caf619be22f5ec5b9cbcffdab89e56c2dc62cf64d712cf46feb8d8d3899d5fadc3f4dbf232a1c980fc136dd8ab3c086a1cfbd
7
+ data.tar.gz: 4953cfad3da4a16a170e3efaf0f5e9025a1dbb288d2b8f463f47cd3ed7a54f2dc266b2cb18db73f2aea7861cd6639c4fbc8d88a90379f6a5d207dbbb9be22b8c
@@ -43,6 +43,9 @@ jobs:
43
43
  additional_engine_cart_rails_options: [""]
44
44
  additional_name: [""]
45
45
  include:
46
+ - ruby: "3.3"
47
+ rails_version: "8.0.0"
48
+ additional_engine_cart_rails_options: --css=bootstrap
46
49
  - ruby: "3.2"
47
50
  rails_version: "6.1.7.8"
48
51
  - ruby: "3.2"
@@ -76,7 +79,7 @@ jobs:
76
79
  VIEW_COMPONENT_VERSION: ${{ matrix.view_component_version }}
77
80
  BOOTSTRAP_VERSION: ${{ matrix.bootstrap_version }}
78
81
  BLACKLIGHT_API_TEST: ${{ matrix.api }}
79
- ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
82
+ ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-kamal --skip-solid --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
80
83
  steps:
81
84
  - uses: actions/checkout@v4
82
85
  - name: Set up Ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.6.1
1
+ 8.7.0
@@ -39,16 +39,6 @@
39
39
  }
40
40
  }
41
41
 
42
- .search-input-group {
43
- width: 80%;
44
- }
45
-
46
- @media (max-width: breakpoint-max(xs)) {
47
- .search-input-group {
48
- width: auto;
49
- }
50
- }
51
-
52
42
  .modal_form {
53
43
  margin-bottom: 0;
54
44
  }
@@ -22,12 +22,12 @@
22
22
 
23
23
  <%= f.label @query_param, scoped_t('search.label'), class: 'sr-only visually-hidden' %>
24
24
  <% if autocomplete_path.present? %>
25
- <auto-complete src="<%= autocomplete_path %>" for="autocomplete-popup" class="search-autocomplete-wrapper">
26
- <%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", autofocus: @autofocus, aria: { label: scoped_t('search.label'), autocomplete: 'list', controls: 'autocomplete-popup' } %>
25
+ <auto-complete src="<%= autocomplete_path %>" for="autocomplete-popup" class="search-autocomplete-wrapper <%= rounded_border_class %>">
26
+ <%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control #{rounded_border_class}", autofocus: @autofocus, aria: { label: scoped_t('search.label'), autocomplete: 'list', controls: 'autocomplete-popup' } %>
27
27
  <ul id="autocomplete-popup" class="dropdown-menu" role="listbox" aria-label="<%= scoped_t('search.label') %>" hidden></ul>
28
28
  </auto-complete>
29
29
  <% else %>
30
- <%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", autofocus: @autofocus, aria: { label: scoped_t('search.label') } %>
30
+ <%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control #{rounded_border_class}", autofocus: @autofocus, aria: { label: scoped_t('search.label') } %>
31
31
  <% end %>
32
32
 
33
33
  <%= append %>
@@ -60,6 +60,12 @@ module Blacklight
60
60
  blacklight_config.advanced_search.enabled
61
61
  end
62
62
 
63
+ def rounded_border_class
64
+ return 'rounded-0' if search_fields.length > 1
65
+
66
+ 'rounded-left rounded-start'
67
+ end
68
+
63
69
  private
64
70
 
65
71
  def blacklight_config
@@ -3,13 +3,19 @@
3
3
  module Blacklight
4
4
  class SkipLinkComponent < Blacklight::Component
5
5
  def link_to_search
6
- link_to t('blacklight.skip_links.search_field'), '#search_field', class: link_classes
6
+ link_to t('blacklight.skip_links.search_field'), search_id, class: link_classes
7
7
  end
8
8
 
9
9
  def link_to_main
10
10
  link_to t('blacklight.skip_links.main_content'), '#main-container', class: link_classes
11
11
  end
12
12
 
13
+ def search_id
14
+ return '#search_field' if helpers.blacklight_config.search_fields.values.many? { |field_def| helpers.should_render_field?(field_def) }
15
+
16
+ '#q'
17
+ end
18
+
13
19
  def link_classes
14
20
  'd-inline-flex p-2 m-1'
15
21
  end
data/blacklight.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.required_ruby_version = '>= 2.7'
27
27
 
28
- s.add_dependency "rails", '>= 6.1', '< 8'
28
+ s.add_dependency "rails", '>= 6.1', '< 9'
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
@@ -49,6 +49,6 @@ Gem::Specification.new do |s|
49
49
  s.add_development_dependency "rubocop-capybara"
50
50
  s.add_development_dependency "rubocop-rspec_rails"
51
51
  s.add_development_dependency "rubocop-factory_bot"
52
- s.add_development_dependency "i18n-tasks"
52
+ s.add_development_dependency "i18n-tasks", '~> 1.0'
53
53
  s.add_development_dependency "solr_wrapper"
54
54
  end
@@ -334,7 +334,7 @@ module Blacklight::Solr
334
334
 
335
335
  ##
336
336
  # Convert a facet/value pair into a solr fq parameter
337
- # rubocop:disable Metrics/PerceivedComplexity
337
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
338
338
  def facet_value_to_fq_string(facet_field, value, use_local_params: true)
339
339
  facet_config = blacklight_config.facet_fields[facet_field]
340
340
 
@@ -353,14 +353,16 @@ module Blacklight::Solr
353
353
  end
354
354
  elsif value.is_a?(Range)
355
355
  prefix = "{!#{local_params.join(' ')}}" unless local_params.empty?
356
- "#{prefix}#{solr_field}:[#{value.first} TO #{value.last}]"
356
+ start = value.begin || '*'
357
+ finish = value.end || '*'
358
+ "#{prefix}#{solr_field}:[#{start} TO #{finish}]"
357
359
  elsif value == Blacklight::SearchState::FilterField::MISSING
358
360
  "-#{solr_field}:[* TO *]"
359
361
  else
360
362
  "{!term f=#{solr_field}#{" #{local_params.join(' ')}" unless local_params.empty?}}#{convert_to_term_value(value)}"
361
363
  end
362
364
  end
363
- # rubocop:enable Metrics/PerceivedComplexity
365
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
364
366
 
365
367
  def facet_inclusive_value_to_fq_string(facet_field, values)
366
368
  return if values.blank?
@@ -20,6 +20,8 @@ module Blacklight
20
20
  CONTENT
21
21
  end
22
22
 
23
+ return unless defined?(Sprockets)
24
+
23
25
  append_to_file 'app/assets/config/manifest.js' do
24
26
  <<~CONTENT
25
27
  //= link blacklight/manifest.js
@@ -28,9 +30,15 @@ module Blacklight
28
30
  end
29
31
 
30
32
  def append_blacklight_javascript
33
+ # This may already be present if rails new was invoked with `--css bootstrap'
34
+ append_to_file 'app/javascript/application.js' do
35
+ <<~CONTENT
36
+ import * as bootstrap from "bootstrap"
37
+ CONTENT
38
+ end
39
+
31
40
  append_to_file 'app/javascript/application.js' do
32
41
  <<~CONTENT
33
- import bootstrap from "bootstrap"
34
42
  import githubAutoCompleteElement from "@github/auto-complete-element"
35
43
  import Blacklight from "blacklight"
36
44
  CONTENT
@@ -38,13 +46,27 @@ module Blacklight
38
46
  end
39
47
 
40
48
  def add_stylesheet
41
- gem "sassc-rails", "~> 2.1" if Rails.version > '7'
49
+ if File.exist? 'app/assets/stylesheets/application.bootstrap.scss'
50
+ if ENV['CI']
51
+ run "yarn add file:#{Blacklight::Engine.root}"
52
+ else
53
+ run "yarn add blacklight-frontend@#{Blacklight::VERSION}"
54
+ end
42
55
 
43
- create_file 'app/assets/stylesheets/blacklight.scss' do
44
- <<~CONTENT
45
- @import 'bootstrap';
46
- @import 'blacklight/blacklight';
47
- CONTENT
56
+ append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do
57
+ <<~CONTENT
58
+ @import "blacklight-frontend/app/assets/stylesheets/blacklight/blacklight";
59
+ CONTENT
60
+ end
61
+ else
62
+ gem "sassc-rails", "~> 2.1"
63
+
64
+ create_file 'app/assets/stylesheets/blacklight.scss' do
65
+ <<~CONTENT
66
+ @import 'bootstrap';
67
+ @import 'blacklight/blacklight';
68
+ CONTENT
69
+ end
48
70
  end
49
71
  end
50
72
 
@@ -7,10 +7,10 @@ module Blacklight
7
7
  def run_asset_pipeline_specific_generator
8
8
  generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
9
9
 
10
- generator = if defined?(Propshaft)
11
- 'blacklight:assets:propshaft'
12
- elsif defined?(Importmap)
10
+ generator = if defined?(Importmap)
13
11
  'blacklight:assets:importmap'
12
+ elsif defined?(Propshaft)
13
+ 'blacklight:assets:propshaft'
14
14
  elsif defined?(Sprockets)
15
15
  'blacklight:assets:sprockets'
16
16
  end
@@ -31,7 +31,7 @@ module Blacklight
31
31
  route <<-EOF
32
32
  concern :searchable, Blacklight::Routes::Searchable.new
33
33
 
34
- resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
34
+ resource :catalog, only: [], as: 'catalog', path: '/catalog', controller: 'catalog' do
35
35
  concerns :searchable
36
36
  end
37
37
  EOF
@@ -18,7 +18,7 @@ module Blacklight
18
18
  copy_file "alternate_controller.rb", "app/controllers/alternate_controller.rb"
19
19
 
20
20
  routing_code = <<-EOF
21
- resource :alternate, controller: 'alternate', only: [:index] do
21
+ resource :alternate, controller: 'alternate', only: [] do
22
22
  concerns :searchable
23
23
  end
24
24
  EOF
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "8.6.1",
3
+ "version": "8.7.0",
4
4
  "description": "The frontend code and styles for Blacklight",
5
5
  "main": "app/assets/javascripts/blacklight",
6
6
  "type": "module",
@@ -10,6 +10,7 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
10
10
  let(:blacklight_config) do
11
11
  Blacklight::Configuration.new.configure do |config|
12
12
  config.view = { list: nil, abc: nil }
13
+ config.add_search_field('test_field', label: 'Test Field')
13
14
  end
14
15
  end
15
16
 
@@ -79,4 +80,28 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
79
80
  expect(render.css("input[name='bar']")).to be_present
80
81
  end
81
82
  end
83
+
84
+ context 'with one search field' do
85
+ subject(:render) { render_inline(instance) }
86
+
87
+ it 'sets the rounded border class' do
88
+ expect(render.css('.rounded-left.rounded-start')).to be_present
89
+ end
90
+ end
91
+
92
+ context 'with multiple search fields' do
93
+ subject(:render) { render_inline(instance) }
94
+
95
+ let(:blacklight_config) do
96
+ Blacklight::Configuration.new.configure do |config|
97
+ config.view = { list: nil, abc: nil }
98
+ config.add_search_field('test_field', label: 'Test Field')
99
+ config.add_search_field('another_field', label: 'Another Field')
100
+ end
101
+ end
102
+
103
+ it 'sets the rounded border class' do
104
+ expect(render.css('.rounded-0')).to be_present
105
+ end
106
+ end
82
107
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::SkipLinkComponent, type: :component do
6
+ subject(:rendered) do
7
+ render_inline_to_capybara_node(described_class.new)
8
+ end
9
+
10
+ before do
11
+ allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
12
+ end
13
+
14
+ context 'with no search fields' do
15
+ let(:blacklight_config) do
16
+ Blacklight::Configuration.new.configure do |config|
17
+ config.search_fields = {}
18
+ end
19
+ end
20
+
21
+ it 'renders skip links with correct link to search' do
22
+ expect(rendered).to have_link("Skip to main content", href: '#main-container')
23
+ expect(rendered).to have_link("Skip to search", href: "#q")
24
+ end
25
+ end
26
+
27
+ context 'with one search field' do
28
+ let(:blacklight_config) do
29
+ Blacklight::Configuration.new.configure do |config|
30
+ config.search_fields = { "all_fields" => "" }
31
+ end
32
+ end
33
+
34
+ it 'renders skip links with correct link to search' do
35
+ expect(rendered).to have_link("Skip to main content", href: "#main-container")
36
+ expect(rendered).to have_link("Skip to search", href: "#q")
37
+ end
38
+ end
39
+
40
+ context 'with two search field' do
41
+ let(:blacklight_config) do
42
+ Blacklight::Configuration.new.configure do |config|
43
+ config.search_fields = { "all_fields" => "", "title_field" => "" }
44
+ end
45
+ end
46
+
47
+ it 'renders skip links with correct link to search' do
48
+ expect(rendered).to have_link("Skip to main content", href: "#main-container")
49
+ expect(rendered).to have_link("Skip to search", href: "#search_field")
50
+ end
51
+ end
52
+ end
@@ -575,6 +575,9 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, :api do
575
575
 
576
576
  it "handles range requests" do
577
577
  expect(subject.send(:facet_value_to_fq_string, "facet_name", 1..5)).to eq "facet_name:[1 TO 5]"
578
+ expect(subject.send(:facet_value_to_fq_string, "facet_name", 1..nil)).to eq "facet_name:[1 TO *]"
579
+ expect(subject.send(:facet_value_to_fq_string, "facet_name", nil..5)).to eq "facet_name:[* TO 5]"
580
+ expect(subject.send(:facet_value_to_fq_string, "facet_name", nil..nil)).to eq "facet_name:[* TO *]"
578
581
  end
579
582
 
580
583
  it "adds tag local parameters" do
@@ -1,4 +1,5 @@
1
1
  gem 'rails-controller-testing'
2
+ gem 'rails-i18n', github: 'Shopify/rails-i18n', branch: 'schwad_rails_8'
2
3
 
3
4
  unless ENV['VIEW_COMPONENT_VERSION'].to_s == ""
4
5
  gem 'view_component', ENV.fetch('VIEW_COMPONENT_VERSION')
@@ -29,12 +29,6 @@ class TestAppGenerator < Rails::Generators::Base
29
29
  generate(:'blacklight:test_support')
30
30
  end
31
31
 
32
- def add_local_assets_for_propshaft
33
- return unless defined?(Propshaft)
34
-
35
- run "yarn add #{Blacklight::Engine.root}"
36
- end
37
-
38
32
  def add_component_template_override
39
33
  src_template = File.join(Blacklight::Engine.root, 'app', 'components', 'blacklight', 'top_navbar_component.html.erb')
40
34
  target_template = File.join('app', 'components', 'blacklight', 'top_navbar_component.html.erb')
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.6.1
4
+ version: 8.7.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-10-25 00:00:00.000000000 Z
20
+ date: 2024-12-04 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: '6.1'
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
- version: '8'
31
+ version: '9'
32
32
  type: :runtime
33
33
  prerelease: false
34
34
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,7 +38,7 @@ dependencies:
38
38
  version: '6.1'
39
39
  - - "<"
40
40
  - !ruby/object:Gem::Version
41
- version: '8'
41
+ version: '9'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: globalid
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -369,16 +369,16 @@ dependencies:
369
369
  name: i18n-tasks
370
370
  requirement: !ruby/object:Gem::Requirement
371
371
  requirements:
372
- - - ">="
372
+ - - "~>"
373
373
  - !ruby/object:Gem::Version
374
- version: '0'
374
+ version: '1.0'
375
375
  type: :development
376
376
  prerelease: false
377
377
  version_requirements: !ruby/object:Gem::Requirement
378
378
  requirements:
379
- - - ">="
379
+ - - "~>"
380
380
  - !ruby/object:Gem::Version
381
- version: '0'
381
+ version: '1.0'
382
382
  - !ruby/object:Gem::Dependency
383
383
  name: solr_wrapper
384
384
  requirement: !ruby/object:Gem::Requirement
@@ -848,6 +848,7 @@ files:
848
848
  - spec/components/blacklight/search_bar_component_spec.rb
849
849
  - spec/components/blacklight/search_context/server_applied_params_component_spec.rb
850
850
  - spec/components/blacklight/search_context/server_item_pagination_component_spec.rb
851
+ - spec/components/blacklight/skip_link_component_spec.rb
851
852
  - spec/components/blacklight/start_over_button_component_spec.rb
852
853
  - spec/components/blacklight/system/flash_message_component_spec.rb
853
854
  - spec/controllers/alternate_controller_spec.rb
@@ -1000,7 +1001,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1000
1001
  - !ruby/object:Gem::Version
1001
1002
  version: '0'
1002
1003
  requirements: []
1003
- rubygems_version: 3.5.9
1004
+ rubygems_version: 3.5.22
1004
1005
  signing_key:
1005
1006
  specification_version: 4
1006
1007
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -1030,6 +1031,7 @@ test_files:
1030
1031
  - spec/components/blacklight/search_bar_component_spec.rb
1031
1032
  - spec/components/blacklight/search_context/server_applied_params_component_spec.rb
1032
1033
  - spec/components/blacklight/search_context/server_item_pagination_component_spec.rb
1034
+ - spec/components/blacklight/skip_link_component_spec.rb
1033
1035
  - spec/components/blacklight/start_over_button_component_spec.rb
1034
1036
  - spec/components/blacklight/system/flash_message_component_spec.rb
1035
1037
  - spec/controllers/alternate_controller_spec.rb