blacklight 7.29.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: 752a397403b186b177e51a6f260f7f385d9e1db6c26abdb9b37c9c25ecf2ad04
4
- data.tar.gz: f81dc90a28f7c9d9cecc35f60e119bd09ec96bd12584b8f1ffb39e51845a0588
3
+ metadata.gz: e7693f7aa372d8e623d9cb996089c4a04bff5ea462b119263efbceec482f0085
4
+ data.tar.gz: e2c3b9c56f6158c05b97685cfebbc3dc38fbdee1052cd8b5c3e432900cbec35d
5
5
  SHA512:
6
- metadata.gz: 54c453918cd5521dd2ee24df0d7d874c48705d14422f8746a10bd262681e411ed54efef1202f9785beec20169ca5ca9acd4d648e730df8a930d2aa659190d905
7
- data.tar.gz: 8014988552c75ebb9bbbd82dcad688dfcd3ea2b6126b63c4c178ab32fe034787bdd61b75a826ecdb1c9022e148a7f9911eb99e7c35090de9361d434756fb85a1
6
+ metadata.gz: b0e155b0bf0fa6f5b8c15ef317bb05198b91e871187a8f8fc846894f182e3a2883ae07caa9c3eceaa676a1b45ce94f34bd73e9d9a4b97ce55eb2da15d5c4ab6f
7
+ data.tar.gz: 69adc6ec4c6402a555bcf2f970adfb692ea5b9a5422375050f787b494d0f62d371859198db14d45373416d10743ee1759162900c25840994481edebd618527c6
@@ -23,6 +23,7 @@ jobs:
23
23
  uses: ruby/setup-ruby@v1
24
24
  with:
25
25
  ruby-version: 2.7
26
+ bundler: 'latest'
26
27
  - name: Install dependencies
27
28
  run: bundle install
28
29
  - name: Run linter
@@ -38,12 +39,13 @@ jobs:
38
39
  uses: ruby/setup-ruby@v1
39
40
  with:
40
41
  ruby-version: ${{ matrix.ruby }}
42
+ bundler: 'latest'
41
43
  - name: Install dependencies
42
44
  run: bundle install
43
45
  - name: Run tests
44
46
  run: bundle exec rake ci
45
47
  env:
46
- ENGINE_CART_RAILS_OPTIONS: '-a propshaft --skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
48
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
47
49
  test_bootstrap5:
48
50
  runs-on: ubuntu-latest
49
51
  strategy:
@@ -55,6 +57,7 @@ jobs:
55
57
  uses: ruby/setup-ruby@v1
56
58
  with:
57
59
  ruby-version: ${{ matrix.ruby }}
60
+ bundler: 'latest'
58
61
  - name: Install dependencies
59
62
  run: bundle install
60
63
  - name: Run tests
@@ -73,6 +76,7 @@ jobs:
73
76
  uses: ruby/setup-ruby@v1
74
77
  with:
75
78
  ruby-version: ${{ matrix.ruby }}
79
+ bundler: 'latest'
76
80
  - name: Install dependencies
77
81
  run: bundle install
78
82
  env:
@@ -93,6 +97,7 @@ jobs:
93
97
  uses: ruby/setup-ruby@v1
94
98
  with:
95
99
  ruby-version: ${{ matrix.ruby }}
100
+ bundler: 'latest'
96
101
  - name: Install dependencies
97
102
  run: bundle install
98
103
  env:
@@ -114,6 +119,7 @@ jobs:
114
119
  uses: ruby/setup-ruby@v1
115
120
  with:
116
121
  ruby-version: ${{ matrix.ruby }}
122
+ bundler: 'latest'
117
123
  - name: Install dependencies
118
124
  run: bundle install
119
125
  env:
@@ -133,6 +139,7 @@ jobs:
133
139
  - name: Set up Ruby
134
140
  uses: ruby/setup-ruby@v1
135
141
  with:
142
+ bundler: 'latest'
136
143
  ruby-version: ${{ matrix.ruby }}
137
144
  - name: Install dependencies
138
145
  run: bundle install
@@ -140,7 +147,7 @@ jobs:
140
147
  run: bundle exec rake ci
141
148
  env:
142
149
  BLACKLIGHT_API_TEST: true
143
- ENGINE_CART_RAILS_OPTIONS: '--api --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test'
150
+ ENGINE_CART_RAILS_OPTIONS: '-a propshaft --api --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test'
144
151
  docker_build:
145
152
  runs-on: ubuntu-latest
146
153
  steps:
data/README.md CHANGED
@@ -42,7 +42,7 @@ rails generate blacklight:install
42
42
  Code contributions are always welcome, instructions for contributing can be found at [CONTRIBUTING.md](https://github.com/projectblacklight/blacklight/blob/main/CONTRIBUTING.md).
43
43
 
44
44
  ## Configuring Apache Solr
45
- You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [README_SOLR](https://github.com/projectblacklight/blacklight/wiki/README_SOLR)
45
+ You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [Solr Configuration](https://github.com/projectblacklight/blacklight/wiki/Solr-Configuration#solr-configuration)
46
46
 
47
47
  ## Building the javascript
48
48
  The javascript is built by npm from sources in `app/javascript` into a bundle
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.29.0
1
+ 7.31.0
@@ -9,6 +9,7 @@
9
9
 
10
10
  input.tt-hint.form-control {
11
11
  width: 100%;
12
+ filter: opacity(0.33);
12
13
  }
13
14
 
14
15
  .tt-menu {
@@ -27,4 +28,10 @@
27
28
  font-size: 14px;
28
29
  padding: 5px 5px 5px 10px;
29
30
  }
31
+
32
+ .tt-suggestion:hover {
33
+ background-color: $dropdown-link-hover-bg;
34
+ color: $dropdown-link-hover-color;
35
+ cursor: pointer;
36
+ }
30
37
  }
@@ -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 %>
@@ -1,12 +1,12 @@
1
1
  <header class="documentHeader row">
2
2
  <%= content_tag @as, class: @classes do %>
3
- <% before_title.each do |t| %>
3
+ <% before_titles.each do |t| %>
4
4
  <%= t %>
5
5
  <% end %>
6
6
 
7
7
  <%= counter -%><%= title -%>
8
8
 
9
- <% after_title.each do |t| %>
9
+ <% after_titles.each do |t| %>
10
10
  <%= t %>
11
11
  <% end %>
12
12
  <% end %>
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Blacklight
4
4
  class DocumentTitleComponent < Blacklight::Component
5
- renders_many :before_title
6
- renders_many :after_title
5
+ renders_many :before_titles
6
+ renders_many :after_titles
7
7
  renders_many :actions
8
8
 
9
9
  # rubocop:disable Metrics/ParameterLists
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Icons
5
+ # This is the list icon for the search button.
6
+ # You can override the default svg by setting:
7
+ # Blacklight::Icons::ListComponent.svg = '<svg>your SVG here</svg>'
8
+ class IconComponent < ::ViewComponent::Base
9
+ # rubocop:disable Metrics/ParameterLists
10
+ def initialize(svg: nil, tag: :span, name: nil, label: nil, aria_hidden: nil, classes: nil, **options)
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))
16
+ end
17
+ # rubocop:enable Metrics/ParameterLists
18
+
19
+ def call
20
+ tag.public_send(@tag, svg&.html_safe, # rubocop:disable Rails/OutputSafety
21
+ class: @classes,
22
+ **@options)
23
+ end
24
+
25
+ class_attribute :svg
26
+
27
+ def name
28
+ @name ||= self.class.name.demodulize.underscore.sub('_component', '')
29
+ end
30
+ end
31
+ end
32
+ end
@@ -15,6 +15,9 @@ module Blacklight
15
15
  end
16
16
 
17
17
  def icon
18
+ return render(@view.icon.new) if @view.icon.is_a?(Class)
19
+ return render(@view.icon) if @view.icon.is_a?(ViewComponent::Base)
20
+
18
21
  Deprecation.silence(Blacklight::CatalogHelperBehavior) do
19
22
  helpers.render_view_type_group_icon(@view.icon || @key)
20
23
  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>
@@ -8,6 +8,8 @@ module Blacklight
8
8
  @__vc_compiler ||= EngineCompiler.new(self)
9
9
  end
10
10
  # rubocop:enable Naming/MemoizedInstanceVariableName
11
+
12
+ alias sidecar_files _sidecar_files unless ViewComponent::Base.respond_to? :sidecar_files
11
13
  end
12
14
 
13
15
  class EngineCompiler < ::ViewComponent::Compiler
@@ -23,7 +25,7 @@ module Blacklight
23
25
  @templates ||= begin
24
26
  extensions = ActionView::Template.template_handler_extensions
25
27
 
26
- component_class._sidecar_files(extensions).each_with_object([]) do |path, memo|
28
+ component_class.sidecar_files(extensions).each_with_object([]) do |path, memo|
27
29
  pieces = File.basename(path).split(".")
28
30
  app_path = "#{Rails.root}/#{path.slice(path.index(component_class.view_component_path)..-1)}"
29
31
 
@@ -13,7 +13,7 @@ module Blacklight
13
13
  def define_field_access(key, base_class_name = nil, class: nil)
14
14
  key = key.to_s if respond_to? :to_s
15
15
 
16
- default_values[key.pluralize.to_sym] = ActiveSupport::OrderedHash.new
16
+ default_values[key.pluralize.to_sym] = ActiveSupport::HashWithIndifferentAccess.new
17
17
 
18
18
  @field_type_for_class ||= {}
19
19
  @field_type_for_class[key] = binding.local_variable_get(:class) || base_class_name
@@ -14,7 +14,7 @@ class Blacklight::Configuration
14
14
  # @!attribute display_type_field
15
15
  # @return [String, Symbol] solr field to use to render format-specific partials
16
16
  # @!attribute icon
17
- # @return [String, Symbol] icon file to use in the view picker
17
+ # @return [String, Symbol, Blacklight::Icons::IconComponent] icon file to use in the view picker
18
18
  # @!attribute document_actions
19
19
  # @return [NestedOpenStructWithHashAccess{Symbol => Blacklight::Configuration::ToolConfig}] 'tools' to render for each document
20
20
  # @!attribute facet_group_component
@@ -45,6 +45,9 @@ module Blacklight
45
45
 
46
46
  ##
47
47
  # Update the :q (query) parameter
48
+ # @param [Hash<Symbol,Object>] conditions the field and values to query on
49
+ # @example
50
+ # search_builder.where(id: [1,2,3]) # produces: q:"{!lucene}id:(1 OR 2 OR 3)"
48
51
  def where(conditions)
49
52
  Deprecation.warn(Blacklight::SearchBuilder, "SearchBuilder#where must be called with a hash, received #{conditions.inspect}.") unless conditions.is_a? Hash
50
53
  params_will_change!
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
 
@@ -166,4 +166,18 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
166
166
  expect(rendered).to have_content 'Thumb!'
167
167
  end
168
168
  end
169
+
170
+ context 'with before_title' do
171
+ let(:render) do
172
+ component.render_in(view_context) do
173
+ component.title do |c|
174
+ c.before_title { 'Prefix!' }
175
+ end
176
+ end
177
+ end
178
+
179
+ it 'shows the prefix' do
180
+ expect(rendered).to have_content "Prefix!"
181
+ end
182
+ end
169
183
  end
@@ -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
@@ -39,13 +39,13 @@ RSpec.describe "Blacklight::Configuration", api: true do
39
39
  end
40
40
 
41
41
  it "has ordered hashes for field configuration" do
42
- expect(config.facet_fields).to be_a_kind_of ActiveSupport::OrderedHash
43
- expect(config.index_fields).to be_a_kind_of ActiveSupport::OrderedHash
44
- expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
45
- expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
46
- expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
47
- expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
48
- expect(config.sort_fields).to be_a_kind_of ActiveSupport::OrderedHash
42
+ expect(config.facet_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
43
+ expect(config.index_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
44
+ expect(config.show_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
45
+ expect(config.search_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
46
+ expect(config.show_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
47
+ expect(config.search_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
48
+ expect(config.sort_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
49
49
  end
50
50
  end
51
51
 
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.29.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-07-26 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
@@ -470,6 +470,7 @@ files:
470
470
  - app/components/blacklight/facet_item_component.rb
471
471
  - app/components/blacklight/facet_item_pivot_component.rb
472
472
  - app/components/blacklight/hidden_search_state_component.rb
473
+ - app/components/blacklight/icons/icon_component.rb
473
474
  - app/components/blacklight/metadata_field_component.html.erb
474
475
  - app/components/blacklight/metadata_field_component.rb
475
476
  - app/components/blacklight/metadata_field_layout_component.html.erb
@@ -554,6 +555,7 @@ files:
554
555
  - app/models/concerns/blacklight/user.rb
555
556
  - app/models/record_mailer.rb
556
557
  - app/models/search.rb
558
+ - app/models/search_builder.rb
557
559
  - app/models/solr_document.rb
558
560
  - app/presenters/blacklight/clause_presenter.rb
559
561
  - app/presenters/blacklight/document_presenter.rb
@@ -619,6 +621,7 @@ files:
619
621
  - app/views/catalog/_search_form.html.erb
620
622
  - app/views/catalog/_search_header.html.erb
621
623
  - app/views/catalog/_search_results.html.erb
624
+ - app/views/catalog/_search_results_header.html.erb
622
625
  - app/views/catalog/_search_sidebar.html.erb
623
626
  - app/views/catalog/_show.html.erb
624
627
  - app/views/catalog/_show_header.html.erb