blacklight 7.31.0 → 7.32.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: e7693f7aa372d8e623d9cb996089c4a04bff5ea462b119263efbceec482f0085
4
- data.tar.gz: e2c3b9c56f6158c05b97685cfebbc3dc38fbdee1052cd8b5c3e432900cbec35d
3
+ metadata.gz: 17b8b14189b4ced9faa60d183fa887eb6962dba4d55f3718fee11ff4bed59388
4
+ data.tar.gz: dd1f5ea853080c0732313b3ab64de8d310634786cfbcfe5ddde6691bc2137820
5
5
  SHA512:
6
- metadata.gz: b0e155b0bf0fa6f5b8c15ef317bb05198b91e871187a8f8fc846894f182e3a2883ae07caa9c3eceaa676a1b45ce94f34bd73e9d9a4b97ce55eb2da15d5c4ab6f
7
- data.tar.gz: 69adc6ec4c6402a555bcf2f970adfb692ea5b9a5422375050f787b494d0f62d371859198db14d45373416d10743ee1759162900c25840994481edebd618527c6
6
+ metadata.gz: d481b3b290ca1030fcc593fad5ef8fdbe3e5a42091c4138af3efaaa58b45322f32d8e4956e6d92d01d305e762d4e2a3886f9caa193ba4197920d18d989184308
7
+ data.tar.gz: f6010fc1c00b31fddce8d2e73794655dbe3c1c690e65bedace78c693a4c36a884f5ac0589681717e3852bf9e1ff41109a7d5de2c2d4957e835c59afd53cfcfcb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.31.0
1
+ 7.32.0
@@ -12,19 +12,16 @@
12
12
  .navbar-logo { /* The main logo image for the Blacklight instance */
13
13
  @if $logo-image {
14
14
  background: transparent $logo-image no-repeat top left;
15
+ background-size: $logo-width $logo-height;
15
16
  }
16
-
17
17
  display: inline-block;
18
- flex: 0 0 150px;
19
- height: 50px;
20
- margin-right:20px;
18
+ height: $logo-height;
19
+ margin-right: 20px;
21
20
  margin-top: -0.4rem;
22
21
  overflow: hidden;
23
- padding-left: 0;
24
- padding-right: 0;
25
22
  text-indent: 100%;
26
23
  white-space: nowrap;
27
- width: 150px;
24
+ width: $logo-width;
28
25
  }
29
26
 
30
27
  .navbar-search {
@@ -1,6 +1,8 @@
1
1
  /* Warning! If you want to change these, just copy them into your own theme css. But you want to remove the !default, which only will set them if not already set. */
2
2
 
3
3
  $logo-image: image_url('blacklight/logo.png') !default;
4
+ $logo-width: 150px !default;
5
+ $logo-height: 50px !default;
4
6
 
5
7
  /* label (field names) */
6
8
  $field_name_color: $text-muted !default;
@@ -1,5 +1,5 @@
1
1
  <%= render(@layout.new(
2
2
  classes: (Array(@classes) + ["filter-#{@facet_item_presenter.key.parameterize}"]).join(' '),
3
3
  label: @facet_item_presenter.field_label,
4
- value: @facet_item_presenter.label,
4
+ value: @facet_item_presenter.constraint_label,
5
5
  remove_path: @facet_item_presenter.remove_href)) %>
@@ -1,8 +1,11 @@
1
- <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => scoped_t('submit') do %>
1
+ <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', aria: { label: scoped_t('submit') }, **@form_options do %>
2
2
  <%= render_hash_as_hidden_fields(@params) %>
3
3
  <% if search_fields.length > 1 %>
4
4
  <label for="search_field" class="sr-only visually-hidden"><%= scoped_t('search_field.label') %></label>
5
5
  <% end %>
6
+ <% before_input_groups.each do |input_group| %>
7
+ <%= input_group %>
8
+ <% end %>
6
9
  <div class="input-group">
7
10
  <%= prepend %>
8
11
 
@@ -17,15 +20,11 @@
17
20
  <% end %>
18
21
 
19
22
  <label for="<%= @prefix %><%= @query_param %>" class="sr-only visually-hidden"><%= scoped_t('search.label') %></label>
20
- <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %>
23
+ <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, aria: { label: scoped_t('search.label') }, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %>
21
24
 
22
25
  <span class="input-group-append">
23
26
  <%= append %>
24
-
25
- <button type="submit" class="btn btn-primary search-btn" id="<%= @prefix %>search">
26
- <span class="submit-search-text"><%= scoped_t('submit') %></span>
27
- <%= blacklight_icon :search, aria_hidden: true %>
28
- </button>
27
+ <%= search_button || render(Blacklight::SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))) %>
29
28
  </span>
30
29
  </div>
31
30
  <% end %>
@@ -6,6 +6,8 @@ module Blacklight
6
6
 
7
7
  renders_one :append
8
8
  renders_one :prepend
9
+ renders_one :search_button
10
+ renders_many :before_input_groups
9
11
 
10
12
  # rubocop:disable Metrics/ParameterLists
11
13
  def initialize(
@@ -14,7 +16,8 @@ module Blacklight
14
16
  classes: ['search-query-form'], prefix: nil,
15
17
  method: 'GET', q: nil, query_param: :q,
16
18
  search_field: nil, search_fields: nil, autocomplete_path: nil,
17
- autofocus: nil, i18n: { scope: 'blacklight.search.form' }
19
+ autofocus: nil, i18n: { scope: 'blacklight.search.form' },
20
+ form_options: {}
18
21
  )
19
22
  @url = url
20
23
  @advanced_search_url = advanced_search_url
@@ -29,6 +32,8 @@ module Blacklight
29
32
  @autofocus = autofocus
30
33
  @search_fields = search_fields
31
34
  @i18n = i18n
35
+ @form_options = form_options
36
+
32
37
  return if presenter.nil?
33
38
 
34
39
  Deprecation.warn(self, 'SearchBarComponent no longer uses a SearchBarPresenter, the presenter: param will be removed in 8.0. ' \
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class SearchButtonComponent < ::ViewComponent::Base
5
+ def initialize(text:, id:)
6
+ @text = text
7
+ @id = id
8
+ end
9
+
10
+ def call
11
+ tag.button(class: 'btn btn-primary search-btn', type: 'submit', id: @id) do
12
+ tag.span(@text, class: "submit-search-text") +
13
+ blacklight_icon(:search, aria_hidden: true)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -38,28 +38,26 @@ module Blacklight
38
38
  # (normally renders next to title in the list view)
39
39
  #
40
40
  # @param [SolrDocument] document
41
- # @param [Hash] options
42
- # @option options [String] :wrapping_class
41
+ # @param [String] wrapping_class ("index-document-functions")
42
+ # @param [Class] component (Blacklight::Document::ActionsComponent)
43
43
  # @return [String]
44
- def render_index_doc_actions(document, options = {})
45
- actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options)).map { |_k, v| v }
46
- wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
44
+ def render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent)
45
+ actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }).map { |_k, v| v }
47
46
 
48
- render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: options, classes: wrapping_class))
47
+ render(component.new(document: document, actions: actions, classes: wrapping_class))
49
48
  end
50
49
 
51
50
  ##
52
51
  # Render "collection actions" area for search results view
53
52
  # (normally renders next to pagination at the top of the result set)
54
53
  #
55
- # @param [Hash] options
56
- # @option options [String] :wrapping_class
54
+ # @param [String] wrapping_class ("search-widgets")
55
+ # @param [Class] component (Blacklight::Document::ActionsComponent)
57
56
  # @return [String]
58
- def render_results_collection_tools(options = {})
59
- actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options).map { |_k, v| v }
60
- wrapping_class = options.delete(:wrapping_class) || "search-widgets"
57
+ def render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent)
58
+ actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, {}).map { |_k, v| v }
61
59
 
62
- render(Blacklight::Document::ActionsComponent.new(actions: actions, options: options, classes: wrapping_class))
60
+ render(component.new(actions: actions, classes: wrapping_class))
63
61
  end
64
62
 
65
63
  ##
@@ -26,6 +26,8 @@ module Blacklight::Document
26
26
  extend ActiveModel::Naming
27
27
  include Blacklight::Document::Extensions
28
28
  include GlobalID::Identification
29
+
30
+ class_attribute :inspector_fields, default: [:_source]
29
31
  end
30
32
 
31
33
  attr_reader :response, :_source
@@ -82,6 +84,11 @@ module Blacklight::Document
82
84
  Array(self[key]).first
83
85
  end
84
86
 
87
+ def inspect
88
+ fields = inspector_fields.map { |field| "#{field}: #{public_send(field)}" }.join(", ")
89
+ "#<#{self.class.name}:#{object_id} #{fields}>"
90
+ end
91
+
85
92
  def to_partial_path
86
93
  'catalog/document'
87
94
  end
@@ -24,6 +24,10 @@ module Blacklight
24
24
  user_parameters[:query]
25
25
  end
26
26
 
27
+ def constraint_label
28
+ label
29
+ end
30
+
27
31
  def remove_href(path = search_state)
28
32
  view_context.search_action_path(path.reset_search(clause: path.clause_params.except(key)).to_h)
29
33
  end
@@ -125,6 +125,11 @@ module Blacklight
125
125
  configuration.view_config(:show)
126
126
  end
127
127
 
128
+ def inspect
129
+ fields = "document:#{document.inspect}"
130
+ "#<#{self.class.name}:#{object_id} #{fields}>"
131
+ end
132
+
128
133
  private
129
134
 
130
135
  def render_field?(field_config)
@@ -66,6 +66,14 @@ module Blacklight
66
66
  end
67
67
  end
68
68
 
69
+ # Get the displayable version of the facet's value for use
70
+ # in e.g. the constraints widget
71
+ #
72
+ # @return [String]
73
+ def constraint_label
74
+ label
75
+ end
76
+
69
77
  def value
70
78
  if facet_item.respond_to? :value
71
79
  facet_item.value
data/blacklight.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency "deprecation"
33
33
  s.add_dependency "i18n", '>= 1.7.0' # added named parameters
34
34
  s.add_dependency "ostruct", '>= 0.3.2'
35
- s.add_dependency "view_component", '~> 2.43'
35
+ s.add_dependency "view_component", '~> 2.66'
36
36
  s.add_dependency 'hashdiff'
37
37
 
38
38
  s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
@@ -3,6 +3,11 @@
3
3
  module Blacklight
4
4
  class Component < ViewComponent::Base
5
5
  class << self
6
+ # Workaround for https://github.com/ViewComponent/view_component/issues/1565
7
+ def config
8
+ @config ||= ViewComponent::Config.defaults.merge(ViewComponent::Base.config)
9
+ end
10
+
6
11
  # rubocop:disable Naming/MemoizedInstanceVariableName
7
12
  def compiler
8
13
  @__vc_compiler ||= EngineCompiler.new(self)
@@ -12,6 +17,21 @@ module Blacklight
12
17
  alias sidecar_files _sidecar_files unless ViewComponent::Base.respond_to? :sidecar_files
13
18
  end
14
19
 
20
+ EXCLUDE_VARIABLES = [
21
+ :@lookup_context, :@view_renderer, :@view_flow, :@view_context,
22
+ :@tag_builder, :@current_template,
23
+ :@__vc_set_slots, :@__vc_original_view_context,
24
+ :@__vc_variant, :@__vc_content_evaluated,
25
+ :@__vc_render_in_block, :@__vc_content, :@__vc_helpers
26
+ ].freeze
27
+
28
+ def inspect
29
+ # Exclude variables added by render_in
30
+ render_variables = instance_variables - EXCLUDE_VARIABLES
31
+ fields = render_variables.map { |ivar| "#{ivar}:#{instance_variable_get(ivar).inspect}" }.join(', ')
32
+ "#<#{self.class.name}:#{object_id} #{fields}>"
33
+ end
34
+
15
35
  class EngineCompiler < ::ViewComponent::Compiler
16
36
  # ViewComponent::Compiler locates and caches templates from sidecar files to the component source file.
17
37
  # While this is sensible in a Rails application, it prevents component templates defined in an Engine
data/package.json CHANGED
@@ -28,7 +28,6 @@
28
28
  },
29
29
  "browserslist": "> 0.25%, not dead",
30
30
  "dependencies": {
31
- "bloodhound-js": "^1.2.3",
32
31
  "bootstrap": ">=4.3.1 <6.0.0",
33
32
  "jquery": "^3.5.1",
34
33
  "typeahead.js": "^0.11.1"
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::SearchBarComponent, type: :component do
6
+ let(:instance) { described_class.new(url: search_action_url, params: params_for_search) }
7
+
8
+ let(:search_action_url) { '/catalog' }
9
+ let(:params_for_search) { { q: 'testParamValue' } }
10
+ let(:blacklight_config) do
11
+ Blacklight::Configuration.new.configure do |config|
12
+ config.view = { list: nil, abc: nil }
13
+ end
14
+ end
15
+
16
+ before do
17
+ allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
18
+ end
19
+
20
+ context 'with the default button' do
21
+ subject(:render) { render_inline(instance) }
22
+
23
+ it 'renders the search field and a button' do
24
+ expect(render.css("input[aria-label='#{I18n.t('blacklight.search.form.search.label')}']")).to be_present
25
+ expect(render.css("button#search")).to be_present
26
+ end
27
+ end
28
+
29
+ context 'when a button is passed in' do
30
+ subject(:render) do
31
+ render_inline(instance) do |c|
32
+ c.search_button do
33
+ controller.view_context.tag.button "hello", id: 'custom_search'
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'renders the search field and a button' do
39
+ expect(render.css("input[aria-label='#{I18n.t('blacklight.search.form.search.label')}']")).to be_present
40
+ expect(render.css("button#search")).not_to be_present
41
+ expect(render.css("button#custom_search")).to be_present
42
+ end
43
+ end
44
+
45
+ context 'with prepend' do
46
+ subject(:render) do
47
+ render_inline(instance) do |c|
48
+ c.with_prepend { 'stuff before' }
49
+ end
50
+ end
51
+
52
+ it 'renders the prepended value' do
53
+ expect(render.to_html).to include 'stuff before'
54
+ end
55
+ end
56
+
57
+ context 'with append' do
58
+ subject(:render) do
59
+ render_inline(instance) do |c|
60
+ c.with_append { 'stuff after' }
61
+ end
62
+ end
63
+
64
+ it 'renders the appended value' do
65
+ expect(render.to_html).to include 'stuff after'
66
+ end
67
+ end
68
+
69
+ context 'with extra inputs' do
70
+ subject(:render) do
71
+ render_inline(instance) do |c|
72
+ c.with_before_input_group { controller.view_context.tag.input name: 'foo' }
73
+ c.with_before_input_group { controller.view_context.tag.input name: 'bar' }
74
+ end
75
+ end
76
+
77
+ it 'renders the extra inputs' do
78
+ expect(render.css("input[name='foo']")).to be_present
79
+ expect(render.css("input[name='bar']")).to be_present
80
+ end
81
+ end
82
+ end
@@ -243,7 +243,7 @@ RSpec.describe CatalogHelper do
243
243
  end
244
244
 
245
245
  it "calls thumbnail presenter with provided values" do
246
- expect(thumbnail_presenter).to receive(:thumbnail_tag).with({}, suppress_link: true)
246
+ expect(thumbnail_presenter).to receive(:thumbnail_tag).with({}, { suppress_link: true })
247
247
  helper.render_thumbnail_tag document, {}, suppress_link: true
248
248
  end
249
249
  end
@@ -8,7 +8,7 @@ RSpec.describe Blacklight::SuggestSearch, api: true do
8
8
 
9
9
  describe '#suggestions' do
10
10
  it 'delegates to the repository' do
11
- expect(repository).to receive(:suggestions).with(q: 'test').and_return(response)
11
+ expect(repository).to receive(:suggestions).with({ q: 'test' }).and_return(response)
12
12
  expect(suggest_search.suggestions).to eq response
13
13
  end
14
14
  end
@@ -29,6 +29,17 @@ RSpec.describe SolrDocument, api: true do
29
29
  end
30
30
  end
31
31
 
32
+ describe '.inspect' do
33
+ subject(:inspect) { document.inspect }
34
+
35
+ let(:document) do
36
+ described_class.new(id: '123',
37
+ title_tesim: ['Good Omens'])
38
+ end
39
+
40
+ it { is_expected.to end_with "_source: {\"id\"=>\"123\", \"title_tesim\"=>[\"Good Omens\"]}>" }
41
+ end
42
+
32
43
  describe '.attribute' do
33
44
  subject(:title) { document.title }
34
45
 
@@ -60,4 +60,10 @@ RSpec.describe Blacklight::DocumentPresenter do
60
60
  expect(presenter.thumbnail).to be_a_kind_of custom_presenter_class
61
61
  end
62
62
  end
63
+
64
+ describe '#inspect' do
65
+ subject(:inspect) { presenter.inspect }
66
+
67
+ it { is_expected.to start_with '#<Blacklight::DocumentPresenter:' }
68
+ end
63
69
  end
@@ -55,6 +55,13 @@ RSpec.describe Blacklight::FacetItemPresenter, type: :presenter do
55
55
  end
56
56
  end
57
57
 
58
+ describe '#constraint_label' do
59
+ it 'provides the label for the constraint' do
60
+ allow(facet_config).to receive_messages(query: nil, date: nil, helper_method: nil, url_method: nil)
61
+ expect(presenter.constraint_label).to eq presenter.label
62
+ end
63
+ end
64
+
58
65
  describe '#href' do
59
66
  before do
60
67
  allow(search_state).to receive(:has_facet?).and_return(false)
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.31.0
4
+ version: 7.32.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-18 00:00:00.000000000 Z
20
+ date: 2022-11-16 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -129,14 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '2.43'
132
+ version: '2.66'
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '2.43'
139
+ version: '2.66'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: hashdiff
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -489,6 +489,7 @@ files:
489
489
  - app/components/blacklight/response/view_type_component.rb
490
490
  - app/components/blacklight/search_bar_component.html.erb
491
491
  - app/components/blacklight/search_bar_component.rb
492
+ - app/components/blacklight/search_button_component.rb
492
493
  - app/components/blacklight/search_context_component.html.erb
493
494
  - app/components/blacklight/search_context_component.rb
494
495
  - app/components/blacklight/search_history_constraint_layout_component.rb
@@ -792,6 +793,7 @@ files:
792
793
  - spec/components/blacklight/hidden_search_state_component_spec.rb
793
794
  - spec/components/blacklight/metadata_field_component_spec.rb
794
795
  - spec/components/blacklight/response/spellcheck_component_spec.rb
796
+ - spec/components/blacklight/search_bar_component_spec.rb
795
797
  - spec/components/blacklight/start_over_button_component_spec.rb
796
798
  - spec/components/blacklight/system/flash_message_component_spec.rb
797
799
  - spec/controllers/alternate_controller_spec.rb
@@ -952,7 +954,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
952
954
  - !ruby/object:Gem::Version
953
955
  version: '0'
954
956
  requirements: []
955
- rubygems_version: 3.2.32
957
+ rubygems_version: 3.3.7
956
958
  signing_key:
957
959
  specification_version: 4
958
960
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -973,6 +975,7 @@ test_files:
973
975
  - spec/components/blacklight/hidden_search_state_component_spec.rb
974
976
  - spec/components/blacklight/metadata_field_component_spec.rb
975
977
  - spec/components/blacklight/response/spellcheck_component_spec.rb
978
+ - spec/components/blacklight/search_bar_component_spec.rb
976
979
  - spec/components/blacklight/start_over_button_component_spec.rb
977
980
  - spec/components/blacklight/system/flash_message_component_spec.rb
978
981
  - spec/controllers/alternate_controller_spec.rb