blacklight 7.36.1 → 7.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f765559b5df84d243537823f81c5b6d9fccca157bf7cc17a1c857067f76c4a79
4
- data.tar.gz: d0de6aa0209d19691e48569b9aa33011f13259755502997082add198ad6e21de
3
+ metadata.gz: a363d5e420f14ec8b9bc11825cfa98fd31e0be3b7e45da9fb1a60895d8d7e491
4
+ data.tar.gz: 928f51bf66d44b4dbb2243e845f978176a78720e50f386340c1f247c542fc7f2
5
5
  SHA512:
6
- metadata.gz: d241feeec8c93d23cfbe7a8b9b8600e2cd10ccfe52ddd26e8706b721173311033b31d9378226929008fa8d9326828c9e9363646d67a48f74359fda7479b1a468
7
- data.tar.gz: bc1df26425a9e43efb3b01bbdcdf31e4b9fd3ad2ee9e6215780e485bf1c7f62d6b625a5c554549f183c1ce104503bba175e0830349cdadc981c7d895d0c440c8
6
+ metadata.gz: ec45d9d2d4e513eecc80ed7de3c47d083bb0b0a43f52863f1cdf28504be9688d0568a61ba1ab739da100a85b503b9f185346ea7fdd8519d35d9a736023e5a879
7
+ data.tar.gz: d73ec607a44211851883e93a49d40a2eebb31f55e4967a9347866b891499f8ea49444cd2faa1352124e8482a38abc84ad0891485e2c4dfd6cb4a685ea726b30a
@@ -47,7 +47,7 @@ jobs:
47
47
  - name: Run tests
48
48
  run: bundle exec rake ci
49
49
  env:
50
- ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
50
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test'
51
51
  test_bootstrap5:
52
52
  runs-on: ubuntu-latest
53
53
  strategy:
@@ -68,7 +68,7 @@ jobs:
68
68
  run: bundle exec rake ci
69
69
  env:
70
70
  BOOTSTRAP_VERSION: '~> 5.0'
71
- ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
71
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test'
72
72
  test_rails6_0:
73
73
  runs-on: ubuntu-latest
74
74
  strategy:
@@ -151,7 +151,7 @@ jobs:
151
151
  - name: Run tests
152
152
  run: bundle exec rake ci
153
153
  env:
154
- ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
154
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test'
155
155
  api_test:
156
156
  runs-on: ubuntu-latest
157
157
  strategy:
data/Gemfile CHANGED
@@ -48,29 +48,3 @@ end
48
48
  # END ENGINE_CART BLOCK
49
49
 
50
50
  eval_gemfile File.expand_path("spec/test_app_templates/Gemfile.extra", File.dirname(__FILE__))
51
-
52
- gem "rubocop", "~> 1.60"
53
-
54
- gem "rubocop-capybara", "~> 2.20"
55
-
56
- gem "rubocop-rspec", "~> 2.26"
57
-
58
- gem "rubocop-rails", "~> 2.23"
59
-
60
- gem "rspec", "~> 3.12"
61
-
62
- gem "simplecov", "~> 0.22.0"
63
-
64
- gem "engine_cart", "~> 2.6"
65
-
66
- gem "rspec-rails", "~> 6.1"
67
-
68
- gem "rspec-collection_matchers", "~> 1.2"
69
-
70
- gem "capybara", "~> 3.39"
71
-
72
- gem "selenium-webdriver", "~> 4.16"
73
-
74
- gem "equivalent-xml", "~> 0.6.0"
75
-
76
- gem "axe-core-rspec", "~> 4.8"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.36.1
1
+ 7.37.0
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
 
3
- var Blacklight = function () {
3
+ const Blacklight = function () {
4
4
  var buffer = new Array();
5
5
  return {
6
- onLoad: function onLoad(func) {
6
+ onLoad: function (func) {
7
7
  buffer.push(func);
8
8
  },
9
- activate: function activate() {
9
+ activate: function () {
10
10
  for (var i = 0; i < buffer.length; i++) {
11
11
  buffer[i].call();
12
12
  }
13
13
  },
14
- listeners: function listeners() {
14
+ listeners: function () {
15
15
  var listeners = [];
16
16
  if (typeof Turbo !== 'undefined') {
17
17
  listeners.push('turbo:load');
@@ -39,7 +39,7 @@ Blacklight.listeners().forEach(function (listener) {
39
39
  });
40
40
  });
41
41
  Blacklight.onLoad(function () {
42
- var elem = document.querySelector('.no-js');
42
+ const elem = document.querySelector('.no-js');
43
43
 
44
44
  // The "no-js" class may already have been removed because this function is
45
45
  // run on every turbo:load event, in that case, it won't find an element.
@@ -47,6 +47,14 @@ Blacklight.onLoad(function () {
47
47
  elem.classList.remove('no-js');
48
48
  elem.classList.add('js');
49
49
  });
50
+ Blacklight.csrfToken = () => {
51
+ var _document$querySelect;
52
+ return (_document$querySelect = document.querySelector('meta[name=csrf-token]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.content;
53
+ };
54
+ Blacklight.csrfParam = () => {
55
+ var _document$querySelect2;
56
+ return (_document$querySelect2 = document.querySelector('meta[name=csrf-param]')) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.content;
57
+ };
50
58
  window.Blacklight = Blacklight;
51
59
  /*global Bloodhound */
52
60
 
@@ -89,7 +97,7 @@ Blacklight.onLoad(function () {
89
97
  $(Blacklight.doBookmarkToggleBehavior.selector).blCheckboxSubmit({
90
98
  // cssClass is added to elements added, plus used for id base
91
99
  cssClass: 'toggle-bookmark',
92
- success: function success(checked, response) {
100
+ success: function (checked, response) {
93
101
  if (response.bookmarks) {
94
102
  $('[data-role=bookmark-counter]').text(response.bookmarks.count);
95
103
  }
@@ -105,8 +113,8 @@ Blacklight.onLoad(function () {
105
113
  // Button clicks should change focus. As of 10/3/19, Firefox for Mac and
106
114
  // Safari both do not set focus to a button on button click.
107
115
  // See https://zellwk.com/blog/inconsistent-button-behavior/ for background information
108
- document.querySelectorAll('button.collapse-toggle').forEach(function (button) {
109
- button.addEventListener('click', function () {
116
+ document.querySelectorAll('button.collapse-toggle').forEach(button => {
117
+ button.addEventListener('click', () => {
110
118
  event.target.focus();
111
119
  });
112
120
  });
@@ -187,15 +195,18 @@ Blacklight.onLoad(function () {
187
195
  checkbox.attr('disabled', 'disabled');
188
196
  $.ajax({
189
197
  url: form.attr('action'),
198
+ beforeSend: function (xhr) {
199
+ xhr.setRequestHeader('X-CSRF-Token', Blacklight.csrfToken());
200
+ },
190
201
  dataType: 'json',
191
202
  type: form.attr('method').toUpperCase(),
192
203
  data: form.serialize(),
193
- error: function error() {
204
+ error: function () {
194
205
  label.removeAttr('disabled');
195
206
  checkbox.removeAttr('disabled');
196
207
  options.error.call();
197
208
  },
198
- success: function success(data, status, xhr) {
209
+ success: function (data, status, xhr) {
199
210
  //if app isn't running at all, xhr annoyingly
200
211
  //reports success with status 0.
201
212
  if (xhr.status != 0) {
@@ -219,10 +230,10 @@ Blacklight.onLoad(function () {
219
230
  $.fn.blCheckboxSubmit.defaults = {
220
231
  //cssClass is added to elements added, plus used for id base
221
232
  cssClass: 'blCheckboxSubmit',
222
- error: function error() {
233
+ error: function () {
223
234
  alert("Error");
224
235
  },
225
- success: function success() {} //callback
236
+ success: function () {} //callback
226
237
  };
227
238
  })(jQuery);
228
239
  /*global Blacklight */
@@ -234,11 +245,11 @@ Blacklight.doResizeFacetLabelsAndCounts = function () {
234
245
  return b.textContent.length - a.textContent.length;
235
246
  }
236
247
  document.querySelectorAll('.facet-values, .pivot-facet').forEach(function (elem) {
237
- var nodes = elem.querySelectorAll('.facet-count');
248
+ const nodes = elem.querySelectorAll('.facet-count');
238
249
  // TODO: when we drop ie11 support, this can become the spread operator:
239
- var longest = Array.from(nodes).sort(longer)[0];
250
+ const longest = Array.from(nodes).sort(longer)[0];
240
251
  if (longest && longest.textContent) {
241
- var width = longest.textContent.length + 1 + 'ch';
252
+ const width = longest.textContent.length + 1 + 'ch';
242
253
  elem.querySelector('.facet-count').style.width = width;
243
254
  }
244
255
  });
@@ -443,23 +454,15 @@ Blacklight.doSearchContextBehavior = function () {
443
454
  console.warn("do_search_context_behavior is deprecated. Use doSearchContextBehavior instead.");
444
455
  return Blacklight.do_search_context_behavior();
445
456
  }
446
- var elements = document.querySelectorAll('a[data-context-href]');
457
+ const elements = document.querySelectorAll('a[data-context-href]');
447
458
  // Equivalent to Array.from(), but supports ie11
448
- var nodes = Array.prototype.slice.call(elements);
459
+ const nodes = Array.prototype.slice.call(elements);
449
460
  nodes.forEach(function (element) {
450
461
  element.addEventListener('click', function (e) {
451
462
  Blacklight.handleSearchContextMethod.call(e.currentTarget, e);
452
463
  });
453
464
  });
454
465
  };
455
- Blacklight.csrfToken = function () {
456
- var _document$querySelect;
457
- return (_document$querySelect = document.querySelector('meta[name=csrf-token]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.content;
458
- };
459
- Blacklight.csrfParam = function () {
460
- var _document$querySelect2;
461
- return (_document$querySelect2 = document.querySelector('meta[name=csrf-param]')) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.content;
462
- };
463
466
 
464
467
  // this is the Rails.handleMethod with a couple adjustments, described inline:
465
468
  // first, we're attaching this directly to the event handler, so we can check for meta-keys
@@ -471,17 +474,18 @@ Blacklight.handleSearchContextMethod = function (event) {
471
474
  var link = this;
472
475
 
473
476
  // instead of using the normal href, we need to use the context href instead
474
- var href = link.getAttribute('data-context-href');
475
- var target = link.getAttribute('target');
476
- var csrfToken = Blacklight.csrfToken();
477
- var csrfParam = Blacklight.csrfParam();
478
- var form = document.createElement('form');
477
+ let href = link.getAttribute('data-context-href');
478
+ let target = link.getAttribute('target');
479
+ let csrfToken = Blacklight.csrfToken();
480
+ let csrfParam = Blacklight.csrfParam();
481
+ let form = document.createElement('form');
479
482
  form.method = 'post';
480
483
  form.action = href;
481
- var formContent = "<input name=\"_method\" value=\"post\" type=\"hidden\" />\n <input name=\"redirect\" value=\"".concat(link.getAttribute('href'), "\" type=\"hidden\" />");
484
+ let formContent = "<input name=\"_method\" value=\"post\" type=\"hidden\" />\n <input name=\"redirect\" value=\"".concat(link.getAttribute('href'), "\" type=\"hidden\" />");
482
485
 
483
486
  // check for meta keys.. if set, we should open in a new tab
484
487
  if (event.metaKey || event.ctrlKey) {
488
+ form.dataset.turbo = "false";
485
489
  target = '_blank';
486
490
  }
487
491
  if (csrfParam !== undefined && csrfToken !== undefined) {
@@ -8,11 +8,12 @@
8
8
  data-target="#<%= @facet_field.html_id %>"
9
9
  data-bs-target="#<%= @facet_field.html_id %>"
10
10
  aria-expanded="<%= @facet_field.collapsed? ? 'false' : 'true' %>"
11
+ arial-controls="<%= @facet_field.html_id %>"
11
12
  >
12
13
  <%= label %>
13
14
  </button>
14
15
  </h3>
15
- <div id="<%= @facet_field.html_id %>" aria-labelledby="<%= @facet_field.html_id %>-header" class="panel-collapse facet-content collapse <%= "show" unless @facet_field.collapsed? %>">
16
+ <div id="<%= @facet_field.html_id %>" role="region" aria-labelledby="<%= @facet_field.html_id %>-header" class="panel-collapse facet-content collapse <%= "show" unless @facet_field.collapsed? %>">
16
17
  <div class="card-body">
17
18
  <%= body %>
18
19
 
@@ -48,18 +48,7 @@ module Blacklight::TokenBasedUser
48
48
  end
49
49
 
50
50
  def secret_key_generator
51
- @secret_key_generator ||= begin
52
- app = Rails.application
53
-
54
- secret_key_base = if app.respond_to?(:credentials)
55
- # Rails 5.2+
56
- app.credentials.secret_key_base
57
- else
58
- # Rails <= 5.1
59
- app.secrets.secret_key_base
60
- end
61
- ActiveSupport::KeyGenerator.new(secret_key_base)
62
- end
51
+ @secret_key_generator ||= ActiveSupport::KeyGenerator.new(Rails.application.secret_key_base)
63
52
  end
64
53
 
65
54
  def message_encryptor
@@ -90,6 +90,7 @@
90
90
 
91
91
  $.ajax({
92
92
  url: form.attr('action'),
93
+ beforeSend: function(xhr) { xhr.setRequestHeader('X-CSRF-Token', Blacklight.csrfToken()) },
93
94
  dataType: 'json',
94
95
  type: form.attr('method').toUpperCase(),
95
96
  data: form.serialize(),
@@ -51,4 +51,7 @@ Blacklight.onLoad(function () {
51
51
  elem.classList.add('js')
52
52
  })
53
53
 
54
+ Blacklight.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content
55
+ Blacklight.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content
56
+
54
57
  window.Blacklight = Blacklight
@@ -15,9 +15,6 @@ Blacklight.doSearchContextBehavior = function() {
15
15
  })
16
16
  };
17
17
 
18
- Blacklight.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content
19
- Blacklight.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content
20
-
21
18
  // this is the Rails.handleMethod with a couple adjustments, described inline:
22
19
  // first, we're attaching this directly to the event handler, so we can check for meta-keys
23
20
  Blacklight.handleSearchContextMethod = function(event) {
@@ -42,6 +39,7 @@ Blacklight.handleSearchContextMethod = function(event) {
42
39
 
43
40
  // check for meta keys.. if set, we should open in a new tab
44
41
  if(event.metaKey || event.ctrlKey) {
42
+ form.dataset.turbo = "false";
45
43
  target = '_blank';
46
44
  }
47
45
 
@@ -69,6 +69,19 @@ module Blacklight
69
69
  end
70
70
  end
71
71
 
72
+ class Time < Value
73
+ def cast(input)
74
+ value = super
75
+ return if value.blank?
76
+
77
+ begin
78
+ ::Time.parse(value.to_s) # rubocop:disable Rails/TimeZone
79
+ rescue ArgumentError
80
+ Rails.logger&.info "Unable to parse time: #{value.inspect}"
81
+ end
82
+ end
83
+ end
84
+
72
85
  class Boolean < Value
73
86
  def cast(input)
74
87
  ActiveModel::Type::Boolean.new.cast(super)
@@ -110,6 +123,7 @@ module Blacklight
110
123
  register :boolean, Boolean
111
124
  register :string, String
112
125
  register :date, Date
126
+ register :time, Time
113
127
  register :array, Array
114
128
  register :json, JsonValue
115
129
  register :html, Html
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "7.33.1",
3
+ "version": "7.37.0",
4
4
  "description": "The frontend code and styles for Blacklight",
5
5
  "main": "app/assets/javascripts/blacklight",
6
6
  "scripts": {
@@ -49,6 +49,7 @@ RSpec.describe SolrDocument, api: true do
49
49
  attribute :author, :array, 'author_tesim', of: :string
50
50
  attribute :first_author, :select, 'author_tesim', by: :min
51
51
  attribute :date, :date, field: 'date_dtsi'
52
+ attribute :time, :time, field: 'date_dtsi'
52
53
  attribute :whatever, :string, default: ->(*) { 'default_value' }
53
54
  end
54
55
  end
@@ -56,14 +57,17 @@ RSpec.describe SolrDocument, api: true do
56
57
  doc_class.new(id: '123',
57
58
  title_tesim: ['Good Omens'],
58
59
  author_tesim: ['Neil Gaiman', 'Terry Pratchett'],
59
- date_dtsi: '1990-01-01T00:00:00Z')
60
+ date_dtsi: '1990-01-01T17:23:13Z')
60
61
  end
61
62
 
62
63
  it "casts the attributes" do
63
64
  expect(document.title).to eq 'Good Omens'
64
65
  expect(document.author).to eq ['Neil Gaiman', 'Terry Pratchett']
65
66
  expect(document.first_author).to eq 'Neil Gaiman'
66
- expect(document.date).to eq Date.new(1990)
67
+ expect(document.date).to be_a Date
68
+ expect(document.date.to_s).to eq '1990-01-01'
69
+ expect(document.time).to be_a Time
70
+ expect(document.time.to_s).to eq '1990-01-01 17:23:13 UTC'
67
71
  expect(document.whatever).to eq 'default_value'
68
72
  end
69
73
 
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.36.1
4
+ version: 7.37.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-01-18 00:00:00.000000000 Z
20
+ date: 2024-02-22 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -957,7 +957,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
957
957
  - !ruby/object:Gem::Version
958
958
  version: '0'
959
959
  requirements: []
960
- rubygems_version: 3.5.3
960
+ rubygems_version: 3.5.4
961
961
  signing_key:
962
962
  specification_version: 4
963
963
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)