blacklight 7.30.0 → 7.31.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: d3f2833ee33fe1cc1d37ef72206820efdd9bbdd4c39f14783c08bfba4c7b9dd8
4
- data.tar.gz: 3f9cbc91061f1a1b68bd25aab95c518f134c7a497566241691a8aee63cc6b752
3
+ metadata.gz: e7693f7aa372d8e623d9cb996089c4a04bff5ea462b119263efbceec482f0085
4
+ data.tar.gz: e2c3b9c56f6158c05b97685cfebbc3dc38fbdee1052cd8b5c3e432900cbec35d
5
5
  SHA512:
6
- metadata.gz: 5b6500ea3048765a8e9d78425eb6f14d7a7edcb6cd17c1ddcc91c88edc7e09353672f0aa7ff29e1e85fbe238508066f9221b652c48cacbfe947e636dbac13a27
7
- data.tar.gz: 5da051e3b7d496204d5e8752c09d346e39c0a94d917539155e60d0a2488ee3a32770bdbf205d11d9fff9da0f107c8d01b8786749ad9e9272b4b9933f46b6815e
6
+ metadata.gz: b0e155b0bf0fa6f5b8c15ef317bb05198b91e871187a8f8fc846894f182e3a2883ae07caa9c3eceaa676a1b45ce94f34bd73e9d9a4b97ce55eb2da15d5c4ab6f
7
+ data.tar.gz: 69adc6ec4c6402a555bcf2f970adfb692ea5b9a5422375050f787b494d0f62d371859198db14d45373416d10743ee1759162900c25840994481edebd618527c6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.30.0
1
+ 7.31.0
@@ -3,7 +3,7 @@
3
3
  url,
4
4
  id: @id,
5
5
  class: @link_classes,
6
- data: {}.merge(({ blacklight_modal: "trigger" } if @action.modal != false) || {}) %>
6
+ data: {}.merge(({ blacklight_modal: "trigger", turbo: false } if @action.modal != false) || {}) %>
7
7
  <% else %>
8
8
  <%= helpers.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options)) %>
9
9
  <% end %>
@@ -6,15 +6,27 @@ module Blacklight
6
6
  # You can override the default svg by setting:
7
7
  # Blacklight::Icons::ListComponent.svg = '<svg>your SVG here</svg>'
8
8
  class IconComponent < ::ViewComponent::Base
9
- def initialize(svg: nil)
9
+ # rubocop:disable Metrics/ParameterLists
10
+ def initialize(svg: nil, tag: :span, name: nil, label: nil, aria_hidden: nil, classes: nil, **options)
10
11
  self.svg = svg if svg
12
+ @classes = Array(classes) + ['blacklight-icons', "blacklight-icons-#{name}"]
13
+ @name = name
14
+ @tag = tag
15
+ @options = options.merge(aria: options.fetch(:aria, {}).reverse_merge(label: label, hidden: aria_hidden))
11
16
  end
17
+ # rubocop:enable Metrics/ParameterLists
12
18
 
13
19
  def call
14
- svg&.html_safe # rubocop:disable Rails/OutputSafety
20
+ tag.public_send(@tag, svg&.html_safe, # rubocop:disable Rails/OutputSafety
21
+ class: @classes,
22
+ **@options)
15
23
  end
16
24
 
17
25
  class_attribute :svg
26
+
27
+ def name
28
+ @name ||= self.class.name.demodulize.underscore.sub('_component', '')
29
+ end
18
30
  end
19
31
  end
20
32
  end
@@ -9,9 +9,11 @@ module Blacklight::IconHelperBehavior
9
9
  # the svg everytime.
10
10
  # @param [String, Symbol] icon_name
11
11
  # @return [String]
12
- def blacklight_icon(icon_name, options = {})
13
- Rails.cache.fetch([:blacklight_icons, icon_name, options]) do
14
- icon = Blacklight::Icon.new(icon_name, **options)
12
+ def blacklight_icon(icon_name, **kwargs)
13
+ render "Blacklight::Icons::#{icon_name.to_s.camelize}Component".constantize.new(**kwargs)
14
+ rescue NameError
15
+ Rails.cache.fetch([:blacklight_icons, icon_name, kwargs]) do
16
+ icon = Blacklight::Icon.new(icon_name, **kwargs)
15
17
  tag.span(icon.svg.html_safe, **icon.options)
16
18
  end
17
19
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SearchBuilder < Blacklight::SearchBuilder
4
+ include Blacklight::Solr::SearchBuilderBehavior
5
+ end
@@ -12,8 +12,7 @@
12
12
  <% end %>
13
13
 
14
14
  <% content_for(:container_header) do -%>
15
- <h1 class="sr-only visually-hidden top-content-title"><%= t('blacklight.search.header') %></h1>
16
-
15
+ <%= render 'search_results_header' %>
17
16
  <%= render 'constraints' %>
18
17
  <% end %>
19
18
 
@@ -0,0 +1 @@
1
+ <h1 class="sr-only visually-hidden top-content-title"><%= t('blacklight.search.header') %></h1>
data/lib/blacklight.rb CHANGED
@@ -60,11 +60,7 @@ module Blacklight
60
60
  end
61
61
 
62
62
  def self.connection_config
63
- Blacklight::RuntimeRegistry.connection_config ||= begin
64
- raise "The #{::Rails.env} environment settings were not found in the blacklight.yml config" unless blacklight_yml[::Rails.env]
65
-
66
- blacklight_yml[::Rails.env].symbolize_keys
67
- end
63
+ Blacklight::RuntimeRegistry.connection_config ||= blacklight_yml[::Rails.env]&.symbolize_keys if blacklight_yml?
68
64
  end
69
65
 
70
66
  def self.connection_config=(value)
@@ -86,7 +82,7 @@ module Blacklight
86
82
  require 'yaml'
87
83
 
88
84
  return @blacklight_yml if @blacklight_yml
89
- unless File.exist?(blacklight_config_file)
85
+ unless blacklight_yml?
90
86
  raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
91
87
  end
92
88
 
@@ -113,6 +109,10 @@ module Blacklight
113
109
  @blacklight_yml
114
110
  end
115
111
 
112
+ def self.blacklight_yml?
113
+ File.exist?(blacklight_config_file)
114
+ end
115
+
116
116
  def self.logger
117
117
  @logger ||= begin
118
118
  ::Rails.logger if defined? Rails && Rails.respond_to?(:logger)
@@ -15,8 +15,6 @@ module Blacklight
15
15
  return unless Rails.version > '7'
16
16
 
17
17
  gem "sassc-rails", "~> 2.1"
18
-
19
- remove_file 'app/javascript/application.js'
20
18
  end
21
19
 
22
20
  # Add sprockets javascript if needed
@@ -37,7 +35,7 @@ module Blacklight
37
35
  # Remove the empty generated app/assets/images directory. Without doing this,
38
36
  # the default Sprockets 4 manifest will raise an exception.
39
37
  def appease_sprockets4
40
- return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4'
38
+ return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4' || using_importmap?
41
39
 
42
40
  append_to_file 'app/assets/config/manifest.js', "\n//= link application.js"
43
41
  empty_directory 'app/assets/images'
@@ -74,6 +72,14 @@ module Blacklight
74
72
 
75
73
  private
76
74
 
75
+ def root
76
+ @root ||= Pathname(destination_root)
77
+ end
78
+
79
+ def using_importmap?
80
+ @using_importmap ||= root.join('config/importmap.rb').exist?
81
+ end
82
+
77
83
  def turbolinks?
78
84
  @turbolinks ||= application_js.include?('turbolinks')
79
85
  end
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # Blacklight controller that handles searches and document requests
2
4
  class <%= controller_name.classify %>Controller < ApplicationController
3
5
 
4
6
  include Blacklight::Catalog
@@ -17,7 +17,7 @@
17
17
  </updateHandler>
18
18
 
19
19
  <!-- solr lib dirs -->
20
- <lib dir="${solr.install.dir:../../../..}/contrib/modules/lib" />
20
+ <lib dir="${solr.install.dir:../../../..}/modules/analysis-extras/lib" />
21
21
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" />
22
22
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" />
23
23
 
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # Represent a single document returned from Solr
2
4
  class <%= model_name.classify %>
3
5
  include Blacklight::Solr::Document
4
6
 
@@ -2,9 +2,14 @@
2
2
 
3
3
  RSpec.describe Blacklight::IconHelperBehavior do
4
4
  describe '#blacklight_icon' do
5
- it 'wraps the svg in a span with classes' do
6
- expect(helper.blacklight_icon(:search))
7
- .to have_css 'span.blacklight-icons svg'
5
+ subject(:icon) { helper.blacklight_icon(:search, classes: 'custom-class') }
6
+
7
+ it 'returns the svg' do
8
+ expect(icon).to have_css '.blacklight-icons svg'
9
+ end
10
+
11
+ it 'adds classes to the wrappering element' do
12
+ expect(icon).to have_css '.custom-class svg'
8
13
  end
9
14
  end
10
15
  end
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.30.0
4
+ version: 7.31.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: 2022-10-03 00:00:00.000000000 Z
20
+ date: 2022-10-18 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -555,6 +555,7 @@ files:
555
555
  - app/models/concerns/blacklight/user.rb
556
556
  - app/models/record_mailer.rb
557
557
  - app/models/search.rb
558
+ - app/models/search_builder.rb
558
559
  - app/models/solr_document.rb
559
560
  - app/presenters/blacklight/clause_presenter.rb
560
561
  - app/presenters/blacklight/document_presenter.rb
@@ -620,6 +621,7 @@ files:
620
621
  - app/views/catalog/_search_form.html.erb
621
622
  - app/views/catalog/_search_header.html.erb
622
623
  - app/views/catalog/_search_results.html.erb
624
+ - app/views/catalog/_search_results_header.html.erb
623
625
  - app/views/catalog/_search_sidebar.html.erb
624
626
  - app/views/catalog/_show.html.erb
625
627
  - app/views/catalog/_show_header.html.erb