blacklight 7.21.2 → 7.22.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: 689d00beb305c757d023bd04cbbe2a25c103d33bd510dbf66919157623091fea
4
- data.tar.gz: f331369f02497dffde92e2b6869fcd5db1daf7d9ceb1b1ca15faa1b42ca93e0e
3
+ metadata.gz: 100a7b0ab6394c96ba5ad5606bffe36132721d9f09c5946911845f117d8bddee
4
+ data.tar.gz: a57654c6cdb05add30658903b407d86661a8b975b0af389f84c56736bff2d56c
5
5
  SHA512:
6
- metadata.gz: 87dbb644ca803013438f197b3ad040b6f1c13c58945deae560fe8f2dfc27a5ed790ac5539c68d4121bad61da1aea7c375095cbcc504616906060bd7fc29a180d
7
- data.tar.gz: fba8f46b736beb2373e36effd81b335b3e70ef7cdba5c8888a3169fe73e15ddd877857b45f267cd6ccba47e2248b36c3f242f277c27be6eabae12370425534b3
6
+ metadata.gz: dec089984409283e902abf6d3a79c549a1785742396dd6d1e6dbd8ec5b49b1ec5ae4be46cad25eb5bdff663880fce761e023c313f71a020f989f17932492adb4
7
+ data.tar.gz: d1bb132cc0ef21f5f9c3a715bf407c47eba801f274d7d78f5e872b6f495298d5bad2720ee89e84944c733babcda22ec62f6d8eed119df9e7ded38b70fd5de1b7
@@ -9,8 +9,10 @@ RUN apk add --update --no-cache \
9
9
  libxml2-dev \
10
10
  libxslt-dev \
11
11
  nodejs \
12
+ shared-mime-info \
12
13
  sqlite-dev \
13
- tzdata
14
+ tzdata \
15
+ yarn
14
16
 
15
17
  RUN mkdir /app
16
18
  WORKDIR /app
data/.dockerignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ .internal_test_app
3
+ .solr_wrapper.yml
data/.env CHANGED
@@ -1,5 +1,5 @@
1
- ALPINE_RUBY_VERSION=2.6.5
2
- RAILS_VERSION=5.2.5
1
+ ALPINE_RUBY_VERSION=2.7.5
2
+ RAILS_VERSION=5.2.6
3
3
  SOLR_PORT=8983
4
4
  SOLR_URL=http://solr:8983/solr/blacklight-core
5
5
  SOLR_VERSION=latest
@@ -9,9 +9,10 @@ name: CI
9
9
 
10
10
  on:
11
11
  push:
12
- branches: [ main ]
12
+ branches:
13
+ - main
14
+ - 'release-*'
13
15
  pull_request:
14
- branches: [ main ]
15
16
 
16
17
  jobs:
17
18
  lint:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.21.2
1
+ 7.22.0
@@ -366,7 +366,7 @@ Blacklight.modal.onFailure = function (jqXHR, textStatus, errorThrown) {
366
366
  console.error('Server error:', this.url, jqXHR.status, errorThrown);
367
367
  var contents = '<div class="modal-header">' + '<div class="modal-title">There was a problem with your request.</div>' + '<button type="button" class="blacklight-modal-close btn-close close" data-dismiss="modal" aria-label="Close">' + ' <span aria-hidden="true">&times;</span>' + '</button></div>' + ' <div class="modal-body"><p>Expected a successful response from the server, but got an error</p>' + '<pre>' + this.type + ' ' + this.url + "\n" + jqXHR.status + ': ' + errorThrown + '</pre></div>';
368
368
  $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
369
- $(Blacklight.modal.modalSelector).modal('show');
369
+ Blacklight.modal.show();
370
370
  };
371
371
 
372
372
  Blacklight.modal.receiveAjax = function (contents) {
@@ -385,7 +385,7 @@ Blacklight.modal.receiveAjax = function (contents) {
385
385
  $(Blacklight.modal.modalSelector).trigger(e); // if they did preventDefault, don't show the dialog
386
386
 
387
387
  if (e.isDefaultPrevented()) return;
388
- $(Blacklight.modal.modalSelector).modal('show');
388
+ Blacklight.modal.show();
389
389
  };
390
390
 
391
391
  Blacklight.modal.modalAjaxLinkClick = function (e) {
@@ -432,7 +432,7 @@ Blacklight.modal.setupModal = function () {
432
432
  Blacklight.modal.checkCloseModal = function (event) {
433
433
  if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) {
434
434
  var modalFlashes = $(this).find('.flash_messages');
435
- $(event.target).modal('hide');
435
+ Blacklight.modal.hide(event.target);
436
436
  event.preventDefault();
437
437
  var mainFlashes = $('#main-flashes');
438
438
  mainFlashes.append(modalFlashes);
@@ -440,6 +440,22 @@ Blacklight.modal.checkCloseModal = function (event) {
440
440
  }
441
441
  };
442
442
 
443
+ Blacklight.modal.hide = function (el) {
444
+ if (bootstrap.Modal.VERSION >= "5") {
445
+ bootstrap.Modal.getOrCreateInstance(el).hide();
446
+ } else {
447
+ $(el || Blacklight.modal.modalSelector).modal('hide');
448
+ }
449
+ };
450
+
451
+ Blacklight.modal.show = function (el) {
452
+ if (bootstrap.Modal.VERSION >= "5") {
453
+ bootstrap.Modal.getOrCreateInstance(el).show();
454
+ } else {
455
+ $(el || Blacklight.modal.modalSelector).modal('show');
456
+ }
457
+ };
458
+
443
459
  Blacklight.onLoad(function () {
444
460
  Blacklight.modal.setupModal();
445
461
  });
@@ -1,6 +1,8 @@
1
1
  .constraints-container {
2
2
  @extend .mb-2;
3
3
  display: flex;
4
+ flex-wrap: wrap;
5
+ gap: 0.5rem 0.25rem;
4
6
  }
5
7
 
6
8
  .applied-filter {
@@ -86,7 +86,7 @@ module Blacklight
86
86
  end
87
87
 
88
88
  def facet_item_presenter(facet_config, facet_item, facet_field)
89
- Blacklight::FacetItemPresenter.new(facet_item, facet_config, @view_context, facet_field)
89
+ (facet_config.item_presenter || Blacklight::FacetItemPresenter).new(facet_item, facet_config, @view_context, facet_field)
90
90
  end
91
91
 
92
92
  def inclusive_facet_item_presenter(facet_config, facet_item, facet_field)
@@ -17,7 +17,7 @@ module Blacklight
17
17
  return to_enum(:presenters) unless block_given?
18
18
 
19
19
  @facet_field.paginator.items.each do |item|
20
- yield Blacklight::FacetItemPresenter.new(item, @facet_field.facet_field, @view_context, @facet_field.key, @facet_field.search_state)
20
+ yield (@facet_field.facet_field.item_presenter || Blacklight::FacetItemPresenter).new(item, @facet_field.facet_field, @view_context, @facet_field.key, @facet_field.search_state)
21
21
  end
22
22
  end
23
23
  end
@@ -78,7 +78,7 @@ module Blacklight
78
78
  end
79
79
 
80
80
  def facet_item_presenter(facet_item)
81
- Blacklight::FacetItemPresenter.new(facet_item, @facet_item.facet_config, @view_context, @facet_item.facet_field, @facet_item.search_state)
81
+ (@facet_item.facet_config.item_presenter || Blacklight::FacetItemPresenter).new(facet_item, @facet_item.facet_config, @view_context, @facet_item.facet_field, @facet_item.search_state)
82
82
  end
83
83
  end
84
84
  end
@@ -319,7 +319,7 @@ module Blacklight::FacetsHelperBehavior
319
319
  end
320
320
 
321
321
  def facet_item_presenter(facet_config, facet_item, facet_field)
322
- Blacklight::FacetItemPresenter.new(facet_item, facet_config, self, facet_field)
322
+ (facet_config.item_presenter || Blacklight::FacetItemPresenter).new(facet_item, facet_config, self, facet_field)
323
323
  end
324
324
 
325
325
  def facet_item_component(facet_config, facet_item, facet_field, **args)
@@ -114,7 +114,7 @@ Blacklight.modal.onFailure = function(jqXHR, textStatus, errorThrown) {
114
114
  this.type + ' ' + this.url + "\n" + jqXHR.status + ': ' + errorThrown +
115
115
  '</pre></div>';
116
116
  $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
117
- $(Blacklight.modal.modalSelector).modal('show');
117
+ Blacklight.modal.show();
118
118
  }
119
119
 
120
120
  Blacklight.modal.receiveAjax = function (contents) {
@@ -135,7 +135,7 @@ Blacklight.modal.receiveAjax = function (contents) {
135
135
  // if they did preventDefault, don't show the dialog
136
136
  if (e.isDefaultPrevented()) return;
137
137
 
138
- $(Blacklight.modal.modalSelector).modal('show');
138
+ Blacklight.modal.show();
139
139
  };
140
140
 
141
141
 
@@ -196,7 +196,7 @@ Blacklight.modal.checkCloseModal = function(event) {
196
196
  if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) {
197
197
  var modalFlashes = $(this).find('.flash_messages');
198
198
 
199
- $(event.target).modal('hide');
199
+ Blacklight.modal.hide(event.target);
200
200
  event.preventDefault();
201
201
 
202
202
  var mainFlashes = $('#main-flashes');
@@ -205,6 +205,22 @@ Blacklight.modal.checkCloseModal = function(event) {
205
205
  }
206
206
  }
207
207
 
208
+ Blacklight.modal.hide = function(el) {
209
+ if (bootstrap.Modal.VERSION >= "5") {
210
+ bootstrap.Modal.getOrCreateInstance(el).hide();
211
+ } else {
212
+ $(el || Blacklight.modal.modalSelector).modal('hide');
213
+ }
214
+ }
215
+
216
+ Blacklight.modal.show = function(el) {
217
+ if (bootstrap.Modal.VERSION >= "5") {
218
+ bootstrap.Modal.getOrCreateInstance(el).show();
219
+ } else {
220
+ $(el || Blacklight.modal.modalSelector).modal('show');
221
+ }
222
+ }
223
+
208
224
  Blacklight.onLoad(function() {
209
225
  Blacklight.modal.setupModal();
210
226
  });
data/docker-compose.yml CHANGED
@@ -7,8 +7,9 @@ services:
7
7
  dockerfile: .docker/app/Dockerfile
8
8
  args:
9
9
  - ALPINE_RUBY_VERSION
10
- volumes:
11
- - .:/app
10
+ # mounting . is causing seg-fault on macosx
11
+ #volumes:
12
+ #- .:/app
12
13
  depends_on:
13
14
  - solr
14
15
  ports:
@@ -16,6 +17,8 @@ services:
16
17
  environment:
17
18
  - SOLR_URL # Set via environment variable or use default defined in .env file
18
19
  - RAILS_VERSION # Set via environment variable or use default defined in .env file
20
+ - SOLR_ENV=docker-compose
21
+ - ENGINE_CART_RAILS_OPTIONS=--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test --skip-solr
19
22
 
20
23
  solr:
21
24
  environment:
@@ -58,6 +58,8 @@ module Blacklight
58
58
  # Rendering:
59
59
  # @!attribute presenter
60
60
  # @return [Blacklight::FacetFieldPresenter]
61
+ # @!attribute item_presenter
62
+ # @return [Blacklight::FacetItemPresenter]
61
63
  # @!attribute component
62
64
  # @return [Blacklight::FacetFieldListComponent]
63
65
  # @!attribute item_component
@@ -61,6 +61,10 @@ module Blacklight::Solr::Response::Facets
61
61
  @options[:data] || {}
62
62
  end
63
63
 
64
+ def response
65
+ @options[:response]
66
+ end
67
+
64
68
  def index?
65
69
  sort == 'index'
66
70
  end
@@ -180,7 +184,7 @@ module Blacklight::Solr::Response::Facets
180
184
  end
181
185
 
182
186
  options = facet_field_aggregation_options(facet_field_name)
183
- facet_field = FacetField.new(facet_field_name, items, options)
187
+ facet_field = FacetField.new(facet_field_name, items, options.merge(response: self))
184
188
 
185
189
  if values[nil]
186
190
  facet_field.missing = items.find(&:missing)
@@ -213,7 +217,9 @@ module Blacklight::Solr::Response::Facets
213
217
 
214
218
  items = items.sort_by(&:hits).reverse if facet_field.sort && facet_field.sort.to_sym == :count
215
219
 
216
- hash[field_name] = Blacklight::Solr::Response::Facets::FacetField.new field_name, items
220
+ facet_field = Blacklight::Solr::Response::Facets::FacetField.new field_name, items, response: response
221
+
222
+ hash[field_name] = facet_field
217
223
  end
218
224
  end
219
225
 
@@ -244,7 +250,9 @@ module Blacklight::Solr::Response::Facets
244
250
 
245
251
  # alias all the possible blacklight config names..
246
252
  blacklight_config.facet_fields.select { |_k, v| v.pivot && v.pivot.join(",") == field_name }.each_key do |key|
247
- hash[key] = Blacklight::Solr::Response::Facets::FacetField.new key, items
253
+ facet_field = Blacklight::Solr::Response::Facets::FacetField.new key, items, response: self
254
+
255
+ hash[key] = facet_field
248
256
  end
249
257
  end
250
258
  end
@@ -288,7 +296,7 @@ module Blacklight::Solr::Response::Facets
288
296
  i
289
297
  end
290
298
 
291
- options = facet_field_aggregation_options(facet_field_name).merge(data: data)
299
+ options = facet_field_aggregation_options(facet_field_name).merge(data: data, response: self)
292
300
  facet_field = FacetField.new(facet_field_name, items, options)
293
301
 
294
302
  facet_field.missing = Blacklight::Solr::Response::Facets::FacetItem.new(
@@ -305,7 +305,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
305
305
  let(:search_state) { double(has_facet?: false, add_facet_params_and_redirect: { controller: 'catalog' }) }
306
306
 
307
307
  before do
308
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: nil))
308
+ allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: nil, item_presenter: nil))
309
309
  allow(helper).to receive(:facet_display_value).and_return('Z')
310
310
  allow(helper).to receive(:search_state).and_return(search_state)
311
311
  allow(helper).to receive(:search_action_path) do |*args|
@@ -326,7 +326,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
326
326
  let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/blabla">Z</a></span><span class="facet-count">10</span>' }
327
327
 
328
328
  it "uses that method" do
329
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method))
329
+ allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method, item_presenter: nil))
330
330
  allow(helper).to receive(:test_method).with('simple_field', item).and_return('/blabla')
331
331
  result = helper.render_facet_value('simple_field', item)
332
332
  expect(result).to be_equivalent_to(expected_html).respecting_element_order
@@ -345,28 +345,28 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
345
345
 
346
346
  describe "#facet_display_value" do
347
347
  it "justs be the facet value for an ordinary facet" do
348
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(query: nil, date: nil, helper_method: nil, url_method: nil))
348
+ allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(query: nil, date: nil, helper_method: nil, url_method: nil, item_presenter: nil))
349
349
  expect(helper.facet_display_value('simple_field', 'asdf')).to eq 'asdf'
350
350
  end
351
351
 
352
352
  it "allows you to pass in a :helper_method argument to the configuration" do
353
- allow(helper).to receive(:facet_configuration_for_field).with('helper_field').and_return(double(query: nil, date: nil, url_method: nil, helper_method: :my_facet_value_renderer))
353
+ allow(helper).to receive(:facet_configuration_for_field).with('helper_field').and_return(double(query: nil, date: nil, url_method: nil, helper_method: :my_facet_value_renderer, item_presenter: nil))
354
354
  allow(helper).to receive(:my_facet_value_renderer).with('qwerty').and_return('abc')
355
355
  expect(helper.facet_display_value('helper_field', 'qwerty')).to eq 'abc'
356
356
  end
357
357
 
358
358
  it "extracts the configuration label for a query facet" do
359
- allow(helper).to receive(:facet_configuration_for_field).with('query_facet').and_return(double(query: { 'query_key' => { label: 'XYZ' } }, date: nil, helper_method: nil, url_method: nil))
359
+ allow(helper).to receive(:facet_configuration_for_field).with('query_facet').and_return(double(query: { 'query_key' => { label: 'XYZ' } }, date: nil, helper_method: nil, url_method: nil, item_presenter: nil))
360
360
  expect(helper.facet_display_value('query_facet', 'query_key')).to eq 'XYZ'
361
361
  end
362
362
 
363
363
  it "localizes the label for date-type facets" do
364
- allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil, :url_method => nil))
364
+ allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil, :url_method => nil, :item_presenter => nil))
365
365
  expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq 'Sun, 01 Jan 2012 00:00:00 +0000'
366
366
  end
367
367
 
368
368
  it "localizes the label for date-type facets with the supplied localization options" do
369
- allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { format: :short }, :query => nil, :helper_method => nil, :url_method => nil))
369
+ allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { format: :short }, :query => nil, :helper_method => nil, :url_method => nil, :item_presenter => nil))
370
370
  expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq '01 Jan 00:00'
371
371
  end
372
372
  end
@@ -102,6 +102,12 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
102
102
  expect(subject.aggregations['my_field'].prefix).to be_nil
103
103
  end
104
104
  end
105
+
106
+ describe '#response' do
107
+ it 'provides access to the full solr response' do
108
+ expect(subject.aggregations['my_field'].response).to eq subject
109
+ end
110
+ end
105
111
  end
106
112
 
107
113
  describe "#merge_facet" do
@@ -21,7 +21,11 @@ def system_with_error_handling(*args)
21
21
  end
22
22
 
23
23
  def with_solr
24
- if system('docker-compose -v')
24
+ # We're being invoked by the app entrypoint script and solr is already up via docker-compose
25
+ if ENV['SOLR_ENV'] == 'docker-compose'
26
+ yield
27
+ elsif system('docker-compose -v')
28
+ # We're not running docker-compose up but still want to use a docker instance of solr.
25
29
  begin
26
30
  puts "Starting Solr"
27
31
  system_with_error_handling "docker-compose up -d solr"
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.21.2
4
+ version: 7.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -14,10 +14,10 @@ authors:
14
14
  - Dan Funk
15
15
  - Naomi Dushay
16
16
  - Justin Coyne
17
- autorequire:
17
+ autorequire:
18
18
  bindir: exe
19
19
  cert_chain: []
20
- date: 2021-11-23 00:00:00.000000000 Z
20
+ date: 2021-12-03 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -381,6 +381,7 @@ files:
381
381
  - ".babelrc"
382
382
  - ".docker/app/Dockerfile"
383
383
  - ".docker/app/entrypoint.sh"
384
+ - ".dockerignore"
384
385
  - ".env"
385
386
  - ".github/workflows/ruby.yml"
386
387
  - ".gitignore"
@@ -919,7 +920,7 @@ homepage: http://projectblacklight.org/
919
920
  licenses:
920
921
  - Apache 2.0
921
922
  metadata: {}
922
- post_install_message:
923
+ post_install_message:
923
924
  rdoc_options: []
924
925
  require_paths:
925
926
  - lib
@@ -934,8 +935,8 @@ 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.4
938
- signing_key:
938
+ rubygems_version: 3.2.15
939
+ signing_key:
939
940
  specification_version: 4
940
941
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
941
942
  index.