blacklight 8.0.1 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.github/workflows/ruby.yml +17 -4
  4. data/.rubocop.yml +4 -0
  5. data/.rubocop_todo.yml +82 -73
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/blacklight/blacklight.esm.js +44 -21
  8. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.js +44 -21
  10. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  11. data/app/assets/stylesheets/blacklight/_mixins.scss +1 -1
  12. data/app/builders/blacklight/action_builder.rb +1 -1
  13. data/app/components/blacklight/advanced_search_form_component.html.erb +3 -3
  14. data/app/components/blacklight/advanced_search_form_component.rb +3 -3
  15. data/app/components/blacklight/document/bookmark_component.html.erb +1 -6
  16. data/app/components/blacklight/facet_field_component.html.erb +2 -1
  17. data/app/components/blacklight/icons/legacy_icon_component.rb +1 -1
  18. data/app/components/blacklight/response/facet_group_component.html.erb +0 -1
  19. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  20. data/app/components/blacklight/response/pagination_component.rb +6 -1
  21. data/app/components/blacklight/search_bar_component.html.erb +2 -2
  22. data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
  23. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  24. data/app/controllers/concerns/blacklight/token_based_user.rb +5 -19
  25. data/app/helpers/blacklight/url_helper_behavior.rb +3 -2
  26. data/app/javascript/blacklight/bookmark_toggle.js +1 -1
  27. data/app/javascript/blacklight/checkbox_submit.js +15 -10
  28. data/app/javascript/blacklight/index.js +10 -5
  29. data/app/javascript/blacklight/modal.js +27 -13
  30. data/app/javascript/blacklight/search_context.js +1 -0
  31. data/app/models/concerns/blacklight/document/active_model_shim.rb +10 -0
  32. data/app/models/search.rb +6 -1
  33. data/app/services/blacklight/field_retriever.rb +13 -11
  34. data/app/values/blacklight/types.rb +14 -0
  35. data/app/views/catalog/_advanced_search_form.html.erb +1 -1
  36. data/app/views/catalog/_citation.html.erb +1 -1
  37. data/app/views/catalog/_show_tools.html.erb +1 -1
  38. data/app/views/catalog/email.html.erb +2 -2
  39. data/app/views/catalog/sms.html.erb +2 -2
  40. data/app/views/kaminari/blacklight/_page.html.erb +1 -1
  41. data/blacklight.gemspec +2 -3
  42. data/config/locales/blacklight.ar.yml +0 -1
  43. data/config/locales/blacklight.ca.yml +0 -2
  44. data/config/locales/blacklight.de.yml +0 -1
  45. data/config/locales/blacklight.en.yml +1 -1
  46. data/config/locales/blacklight.es.yml +0 -1
  47. data/config/locales/blacklight.fr.yml +0 -1
  48. data/config/locales/blacklight.hu.yml +0 -1
  49. data/config/locales/blacklight.it.yml +0 -1
  50. data/config/locales/blacklight.nl.yml +0 -1
  51. data/config/locales/blacklight.pt-BR.yml +0 -1
  52. data/config/locales/blacklight.sq.yml +0 -1
  53. data/config/locales/blacklight.zh.yml +0 -1
  54. data/docker-compose.yml +0 -2
  55. data/lib/blacklight/component.rb +1 -1
  56. data/lib/blacklight/configuration.rb +7 -1
  57. data/lib/blacklight/engine.rb +12 -0
  58. data/lib/blacklight/solr/repository.rb +16 -2
  59. data/lib/blacklight/solr/response/params.rb +1 -1
  60. data/lib/blacklight/solr/search_builder_behavior.rb +3 -0
  61. data/lib/generators/blacklight/assets/importmap_generator.rb +2 -2
  62. data/lib/generators/blacklight/assets/sprockets_generator.rb +1 -1
  63. data/lib/generators/blacklight/assets_generator.rb +2 -4
  64. data/lib/generators/blacklight/install_generator.rb +1 -3
  65. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
  66. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +69 -0
  67. data/package.json +1 -1
  68. data/spec/components/blacklight/facet_component_spec.rb +11 -1
  69. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +2 -2
  70. data/spec/components/blacklight/response/pagination_component_spec.rb +53 -0
  71. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +11 -1
  72. data/spec/controllers/catalog_controller_spec.rb +2 -2
  73. data/spec/features/advanced_search_spec.rb +61 -0
  74. data/spec/features/axe_spec.rb +5 -0
  75. data/spec/features/citation_spec.rb +10 -0
  76. data/spec/features/sms_spec.rb +12 -0
  77. data/spec/helpers/blacklight_helper_spec.rb +10 -5
  78. data/spec/models/blacklight/configurable_spec.rb +1 -1
  79. data/spec/models/blacklight/solr/repository_spec.rb +27 -0
  80. data/spec/models/blacklight/solr/response_spec.rb +1 -1
  81. data/spec/models/blacklight/solr/search_builder_spec.rb +21 -0
  82. data/spec/models/solr_document_spec.rb +6 -2
  83. data/spec/services/blacklight/field_retriever_spec.rb +17 -0
  84. data/spec/spec_helper.rb +1 -2
  85. data/spec/support/view_component_test_helpers.rb +14 -0
  86. data/spec/test_app_templates/Gemfile.extra +0 -1
  87. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -0
  88. data/template.demo.rb +7 -7
  89. metadata +15 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 788296244ed7711b196967fcc206a6b7836db4b384bcbbe7e062cdf9f29d8b06
4
- data.tar.gz: 4f83e1cf3421afde9db8cd8bfb7fed298c5f3c5874de2f22f7e7a48db2fe5979
3
+ metadata.gz: 995d0162eaaf76fe9e4fe2498145be544b61f63387a5f22400c4f3f6ae66c5f7
4
+ data.tar.gz: 23730f5c2cb706d7202da4c2d4f7757fd149b194041c7e1ec655d556e7a49155
5
5
  SHA512:
6
- metadata.gz: 193f6a74d712c28cd42a7354ff0da15b7e303b94e51a3854de54401a38ef2e444bf76a1878130fcef71d5286080943cc5635d46f3f38b8bce7c539d2af6f10fe
7
- data.tar.gz: 0cf1904df3915ed93d122d54d653201b576c2b4027b182fdb88e6d02bcc9885bac69ecc9c7f6331f4dd3d9ca7f637600e869a5edcb106dad03b2c88868e77e86
6
+ metadata.gz: 0f444539b52a3e6ec539b5a0865be12d09e98a12d0c8285e3df0e6a3cebf293520d3be5365be244093bccc39d33d973075e8eb5ad26fa0b44d1181a699601d63
7
+ data.tar.gz: f676071cd8a7b98b1de39c7f34edbd641ae511883a50445121649440c5ff4133701c57ae0eb5b521c8174c09d1b6a56d60074fe7b1a16106251c44a54f0a80ac
data/.env CHANGED
@@ -1,6 +1,6 @@
1
1
  ALPINE_RUBY_VERSION=3.0.3
2
2
  RAILS_VERSION=6.1.4.6
3
- VIEW_COMPONENT_VERSION=2.6.6
3
+ VIEW_COMPONENT_VERSION=2.66.0
4
4
  SOLR_PORT=8983
5
5
  SOLR_URL=http://solr:8983/solr/blacklight-core
6
6
  SOLR_VERSION=latest
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Set up Ruby
23
23
  uses: ruby/setup-ruby@v1
24
24
  with:
25
- ruby-version: 2.7
25
+ ruby-version: 3.2
26
26
  bundler: 'latest'
27
27
  - name: Install dependencies
28
28
  run: bundle install
@@ -33,7 +33,7 @@ jobs:
33
33
  name: test (ruby ${{ matrix.ruby }} / rails ${{ matrix.rails_version }} ${{ matrix.additional_name }})
34
34
  strategy:
35
35
  matrix:
36
- ruby: [2.7, '3.0']
36
+ ruby: ['3.0']
37
37
  rails_version: ['6.1.7', '7.0.4']
38
38
  bootstrap_version: [null]
39
39
  view_component_version: ['~> 2.66']
@@ -41,8 +41,20 @@ jobs:
41
41
  additional_engine_cart_rails_options: ['']
42
42
  additional_name: ['']
43
43
  include:
44
- - ruby: '3.2.0'
44
+ - ruby: '3.3.0'
45
+ rails_version: '7.1.1'
46
+ - ruby: '3.2.2'
47
+ rails_version: '7.1.1'
48
+ - ruby: '3.2.2'
45
49
  rails_version: '7.0.4'
50
+ - ruby: '3.2.2'
51
+ rails_version: '7.0.4'
52
+ solr_version: '9.3.0'
53
+ additional_name: 'Solr 9.3.0'
54
+ - ruby: '3.2.2'
55
+ rails_version: '7.0.4'
56
+ solr_version: '8.11.2'
57
+ additional_name: 'Solr 8.11.2'
46
58
  - ruby: '3.1'
47
59
  rails_version: '7.0.4'
48
60
  - ruby: '3.1'
@@ -64,10 +76,11 @@ jobs:
64
76
  additional_name: '/ API'
65
77
  env:
66
78
  RAILS_VERSION: ${{ matrix.rails_version }}
79
+ SOLR_VERSION: ${{ matrix.solr_version || 'latest' }}
67
80
  VIEW_COMPONENT_VERSION: ${{ matrix.view_component_version }}
68
81
  BOOTSTRAP_VERSION: ${{ matrix.bootstrap_version }}
69
82
  BLACKLIGHT_API_TEST: ${{ matrix.api }}
70
- ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
83
+ ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
71
84
  steps:
72
85
  - uses: actions/checkout@v3
73
86
  - name: Set up Ruby
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  require:
2
+ - rubocop-capybara
2
3
  - rubocop-rspec
3
4
  - rubocop-rails
4
5
 
@@ -197,6 +198,9 @@ Security/IoMethods: # new in 1.22
197
198
  Enabled: true
198
199
  Style/ArgumentsForwarding: # new in 1.1
199
200
  Enabled: true
201
+ Exclude:
202
+ # This cop includes some checks specific to Ruby 3.2
203
+ - 'lib/blacklight/solr/response/group_response.rb'
200
204
  Style/CollectionCompact: # new in 1.2
201
205
  Enabled: true
202
206
  Style/DocumentDynamicEvalDefinition: # new in 1.1
data/.rubocop_todo.yml CHANGED
@@ -1,20 +1,36 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-06-27 19:52:51 UTC using RuboCop version 1.31.0.
3
+ # on 2023-12-05 17:55:17 UTC using RuboCop version 1.58.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 4
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ Capybara/CurrentPathExpectation:
12
+ Exclude:
13
+ - 'spec/features/alternate_controller_spec.rb'
14
+
15
+ # Offense count: 13
16
+ Capybara/VisibilityMatcher:
17
+ Exclude:
18
+ - 'spec/features/facets_spec.rb'
19
+ - 'spec/features/search_filters_spec.rb'
20
+ - 'spec/helpers/blacklight_helper_spec.rb'
21
+
9
22
  # Offense count: 5
10
- # Configuration parameters: AutoCorrect.
23
+ # This cop supports safe autocorrection (--autocorrect).
24
+ # Configuration parameters: EnforcedStyle.
25
+ # SupportedStyles: leading, trailing
11
26
  Layout/LineContinuationLeadingSpace:
12
27
  Exclude:
13
28
  - 'lib/generators/blacklight/controller_generator.rb'
14
29
  - 'lib/generators/blacklight/user_generator.rb'
15
30
 
16
31
  # Offense count: 1
17
- # Configuration parameters: IgnoredMethods.
32
+ # This cop supports safe autocorrection (--autocorrect).
33
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
18
34
  Lint/AmbiguousBlockAssociation:
19
35
  Exclude:
20
36
  - 'lib/blacklight/solr/search_builder_behavior.rb'
@@ -29,7 +45,7 @@ Lint/AmbiguousOperator:
29
45
  - 'spec/models/blacklight/solr/search_builder_spec.rb'
30
46
  - 'spec/services/blacklight/search_service_spec.rb'
31
47
 
32
- # Offense count: 44
48
+ # Offense count: 45
33
49
  # This cop supports safe autocorrection (--autocorrect).
34
50
  Lint/AmbiguousRegexpLiteral:
35
51
  Exclude:
@@ -75,7 +91,8 @@ Lint/EmptyFile:
75
91
  Exclude:
76
92
  - 'spec/components/blacklight/document_metadata_component_spec.rb'
77
93
 
78
- # Offense count: 38
94
+ # Offense count: 46
95
+ # Configuration parameters: AllowedParentClasses.
79
96
  Lint/MissingSuper:
80
97
  Enabled: false
81
98
 
@@ -94,14 +111,14 @@ Lint/ShadowingOuterLocalVariable:
94
111
  Exclude:
95
112
  - 'spec/models/blacklight/configuration_spec.rb'
96
113
 
97
- # Offense count: 74
98
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
114
+ # Offense count: 81
115
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
99
116
  Metrics/AbcSize:
100
117
  Max: 46
101
118
 
102
119
  # Offense count: 1
103
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods, inherit_mode.
104
- # IgnoredMethods: refine
120
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
121
+ # AllowedMethods: refine
105
122
  Metrics/BlockLength:
106
123
  Max: 26
107
124
 
@@ -110,32 +127,33 @@ Metrics/BlockLength:
110
127
  Metrics/BlockNesting:
111
128
  Max: 4
112
129
 
113
- # Offense count: 43
114
- # Configuration parameters: IgnoredMethods.
130
+ # Offense count: 42
131
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
115
132
  Metrics/CyclomaticComplexity:
116
133
  Max: 14
117
134
 
118
- # Offense count: 69
119
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
135
+ # Offense count: 77
136
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
120
137
  Metrics/MethodLength:
121
138
  Max: 29
122
139
 
123
- # Offense count: 3
140
+ # Offense count: 4
124
141
  # Configuration parameters: CountComments, CountAsOne.
125
142
  Metrics/ModuleLength:
126
- Max: 126
143
+ Max: 124
127
144
 
128
145
  # Offense count: 8
129
146
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
130
147
  Metrics/ParameterLists:
131
148
  Max: 6
132
149
 
133
- # Offense count: 36
134
- # Configuration parameters: IgnoredMethods.
150
+ # Offense count: 37
151
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
135
152
  Metrics/PerceivedComplexity:
136
153
  Max: 14
137
154
 
138
155
  # Offense count: 3
156
+ # This cop supports unsafe autocorrection (--autocorrect-all).
139
157
  # Configuration parameters: EnforcedStyleForLeadingUnderscores.
140
158
  # SupportedStylesForLeadingUnderscores: disallowed, required, optional
141
159
  Naming/MemoizedInstanceVariableName:
@@ -146,7 +164,7 @@ Naming/MemoizedInstanceVariableName:
146
164
 
147
165
  # Offense count: 9
148
166
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
149
- # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
167
+ # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
150
168
  Naming/MethodParameterName:
151
169
  Exclude:
152
170
  - 'app/models/concerns/blacklight/document.rb'
@@ -158,47 +176,33 @@ Naming/MethodParameterName:
158
176
  # Offense count: 9
159
177
  # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
160
178
  # SupportedStyles: snake_case, normalcase, non_integer
161
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
179
+ # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
162
180
  Naming/VariableNumber:
163
181
  Exclude:
164
182
  - 'spec/lib/blacklight/search_state_spec.rb'
165
183
  - 'spec/models/blacklight/search_builder_spec.rb'
166
184
 
167
- # Offense count: 7
185
+ # Offense count: 5
168
186
  RSpec/BeforeAfterAll:
169
187
  Exclude:
170
188
  - 'spec/controllers/search_history_controller_spec.rb'
171
189
  - 'spec/models/blacklight/configurable_spec.rb'
172
190
  - 'spec/models/blacklight/document/dublin_core_spec.rb'
173
- - 'spec/models/blacklight/document/email_spec.rb'
174
- - 'spec/models/blacklight/document/sms_spec.rb'
175
191
  - 'spec/models/blacklight/solr/document_spec.rb'
176
192
 
177
- # Offense count: 4
178
- # This cop supports safe autocorrection (--autocorrect).
179
- RSpec/Capybara/CurrentPathExpectation:
180
- Exclude:
181
- - 'spec/features/alternate_controller_spec.rb'
182
-
183
- # Offense count: 13
184
- RSpec/Capybara/VisibilityMatcher:
185
- Exclude:
186
- - 'spec/features/facets_spec.rb'
187
- - 'spec/features/search_filters_spec.rb'
188
- - 'spec/helpers/blacklight_helper_spec.rb'
189
-
190
- # Offense count: 98
191
- # Configuration parameters: Prefixes.
193
+ # Offense count: 104
194
+ # Configuration parameters: Prefixes, AllowedPatterns.
192
195
  # Prefixes: when, with, without
193
196
  RSpec/ContextWording:
194
197
  Enabled: false
195
198
 
196
199
  # Offense count: 1
200
+ # This cop supports unsafe autocorrection (--autocorrect-all).
197
201
  RSpec/EmptyExampleGroup:
198
202
  Exclude:
199
203
  - 'spec/models/blacklight/solr/search_builder_spec.rb'
200
204
 
201
- # Offense count: 128
205
+ # Offense count: 135
202
206
  # Configuration parameters: CountAsOne.
203
207
  RSpec/ExampleLength:
204
208
  Max: 33
@@ -208,18 +212,17 @@ RSpec/ExpectInHook:
208
212
  Exclude:
209
213
  - 'spec/controllers/catalog_controller_spec.rb'
210
214
 
211
- # Offense count: 5
215
+ # Offense count: 4
212
216
  # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
213
217
  # Include: **/*_spec*rb*, **/spec/**/*
214
218
  RSpec/FilePath:
215
219
  Exclude:
216
220
  - 'spec/controllers/blacklight/catalog/component_configuration_spec.rb'
217
- - 'spec/features/sitelinks_search_box.rb'
218
221
  - 'spec/models/blacklight/solr/search_builder_spec.rb'
219
222
  - 'spec/presenters/pipeline_spec.rb'
220
223
  - 'spec/presenters/thumbnail_presenter_spec.rb'
221
224
 
222
- # Offense count: 128
225
+ # Offense count: 108
223
226
  # Configuration parameters: AssignmentOnly.
224
227
  RSpec/InstanceVariable:
225
228
  Exclude:
@@ -232,7 +235,6 @@ RSpec/InstanceVariable:
232
235
  - 'spec/models/blacklight/document/dublin_core_spec.rb'
233
236
  - 'spec/models/blacklight/solr/document_spec.rb'
234
237
  - 'spec/models/record_mailer_spec.rb'
235
- - 'spec/models/search_spec.rb'
236
238
  - 'spec/services/blacklight/search_service_spec.rb'
237
239
  - 'spec/views/catalog/index.atom.builder_spec.rb'
238
240
 
@@ -276,21 +278,23 @@ RSpec/MessageSpies:
276
278
  - 'spec/presenters/blacklight/field_presenter_spec.rb'
277
279
  - 'spec/presenters/thumbnail_presenter_spec.rb'
278
280
 
279
- # Offense count: 364
281
+ # Offense count: 382
280
282
  RSpec/MultipleExpectations:
281
283
  Max: 16
282
284
 
283
- # Offense count: 258
285
+ # Offense count: 282
284
286
  # Configuration parameters: AllowSubject.
285
287
  RSpec/MultipleMemoizedHelpers:
286
288
  Max: 14
287
289
 
288
- # Offense count: 388
289
- # Configuration parameters: IgnoreSharedExamples.
290
+ # Offense count: 394
291
+ # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
292
+ # SupportedStyles: always, named_only
290
293
  RSpec/NamedSubject:
291
294
  Enabled: false
292
295
 
293
- # Offense count: 55
296
+ # Offense count: 59
297
+ # Configuration parameters: AllowedGroups.
294
298
  RSpec/NestedGroups:
295
299
  Max: 5
296
300
 
@@ -345,34 +349,27 @@ RSpec/SubjectStub:
345
349
  - 'spec/presenters/blacklight/document_presenter_spec.rb'
346
350
  - 'spec/services/blacklight/search_service_spec.rb'
347
351
 
348
- # Offense count: 77
352
+ # Offense count: 79
349
353
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
350
354
  RSpec/VerifiedDoubles:
351
355
  Enabled: false
352
356
 
353
357
  # Offense count: 4
358
+ # This cop supports unsafe autocorrection (--autocorrect-all).
354
359
  # Configuration parameters: EnforcedStyle, AllowToTime.
355
360
  # SupportedStyles: strict, flexible
356
361
  Rails/Date:
357
362
  Exclude:
358
363
  - 'spec/models/search_spec.rb'
359
364
 
360
- # Offense count: 1
361
- # Configuration parameters: EnforcedStyle.
362
- # SupportedStyles: slashes, arguments
363
- Rails/FilePath:
364
- Exclude:
365
- - 'lib/railties/blacklight.rake'
366
-
367
365
  # Offense count: 20
368
366
  # Configuration parameters: Include.
369
367
  # Include: app/helpers/**/*.rb
370
368
  Rails/HelperInstanceVariable:
371
369
  Exclude:
372
- - 'app/helpers/blacklight/blacklight_helper_behavior.rb'
373
370
  - 'app/helpers/blacklight/catalog_helper_behavior.rb'
374
- - 'app/helpers/blacklight/document_helper_behavior.rb'
375
371
  - 'app/helpers/blacklight/component_helper_behavior.rb'
372
+ - 'app/helpers/blacklight/document_helper_behavior.rb'
376
373
  - 'app/helpers/blacklight/layout_helper_behavior.rb'
377
374
  - 'app/helpers/blacklight/render_partials_helper_behavior.rb'
378
375
 
@@ -383,12 +380,9 @@ Rails/I18nLocaleAssignment:
383
380
  Exclude:
384
381
  - 'spec/helpers/blacklight_helper_spec.rb'
385
382
 
386
- # Offense count: 10
383
+ # Offense count: 1
387
384
  Rails/OutputSafety:
388
385
  Exclude:
389
- - 'app/components/blacklight/search_context/server_item_pagination_component.rb'
390
- - 'app/helpers/blacklight/catalog_helper_behavior.rb'
391
- - 'app/helpers/blacklight/configuration_helper_behavior.rb'
392
386
  - 'app/presenters/blacklight/rendering/join.rb'
393
387
 
394
388
  # Offense count: 14
@@ -411,11 +405,11 @@ Style/Alias:
411
405
 
412
406
  # Offense count: 3
413
407
  # This cop supports safe autocorrection (--autocorrect).
414
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
408
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
415
409
  # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
416
410
  # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
417
411
  # FunctionalMethods: let, let!, subject, watch
418
- # IgnoredMethods: lambda, proc, it
412
+ # AllowedMethods: lambda, proc, it
419
413
  Style/BlockDelimiters:
420
414
  Exclude:
421
415
  - 'app/views/catalog/index.rss.builder'
@@ -449,17 +443,16 @@ Style/DocumentDynamicEvalDefinition:
449
443
  - 'app/builders/blacklight/action_builder.rb'
450
444
  - 'lib/blacklight/configuration/fields.rb'
451
445
 
452
- # Offense count: 105
446
+ # Offense count: 128
453
447
  # Configuration parameters: AllowedConstants.
454
448
  Style/Documentation:
455
449
  Enabled: false
456
450
 
457
- # Offense count: 10
451
+ # Offense count: 9
458
452
  # This cop supports safe autocorrection (--autocorrect).
459
453
  Style/ExpandPathArguments:
460
454
  Exclude:
461
455
  - 'Gemfile'
462
- - 'lib/generators/blacklight/assets_generator.rb'
463
456
  - 'lib/generators/blacklight/controller_generator.rb'
464
457
  - 'lib/generators/blacklight/document_generator.rb'
465
458
  - 'lib/generators/blacklight/install_generator.rb'
@@ -471,12 +464,14 @@ Style/ExpandPathArguments:
471
464
 
472
465
  # Offense count: 16
473
466
  # This cop supports safe autocorrection (--autocorrect).
474
- # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
467
+ # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
475
468
  # SupportedStyles: annotated, template, unannotated
469
+ # AllowedMethods: redirect
476
470
  Style/FormatStringToken:
477
471
  EnforcedStyle: template
478
472
 
479
473
  # Offense count: 6
474
+ # This cop supports safe autocorrection (--autocorrect).
480
475
  # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
481
476
  Style/GuardClause:
482
477
  Exclude:
@@ -486,7 +481,7 @@ Style/GuardClause:
486
481
  - 'app/helpers/blacklight/catalog_helper_behavior.rb'
487
482
  - 'lib/blacklight/solr/search_builder_behavior.rb'
488
483
 
489
- # Offense count: 30
484
+ # Offense count: 29
490
485
  # This cop supports safe autocorrection (--autocorrect).
491
486
  Style/IfUnlessModifier:
492
487
  Enabled: false
@@ -501,7 +496,7 @@ Style/MultilineIfModifier:
501
496
 
502
497
  # Offense count: 1
503
498
  # This cop supports safe autocorrection (--autocorrect).
504
- # Configuration parameters: AllowMethodComparison.
499
+ # Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
505
500
  Style/MultipleComparison:
506
501
  Exclude:
507
502
  - 'lib/blacklight/configuration/context.rb'
@@ -516,7 +511,7 @@ Style/MutableConstant:
516
511
 
517
512
  # Offense count: 9
518
513
  # This cop supports unsafe autocorrection (--autocorrect-all).
519
- # Configuration parameters: EnforcedStyle, IgnoredMethods.
514
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
520
515
  # SupportedStyles: predicate, comparison
521
516
  Style/NumericPredicate:
522
517
  Exclude:
@@ -554,13 +549,27 @@ Style/PercentLiteralDelimiters:
554
549
  - 'lib/blacklight/engine.rb'
555
550
  - 'lib/blacklight/solr/request.rb'
556
551
 
557
- # Offense count: 7
552
+ # Offense count: 15
553
+ # This cop supports safe autocorrection (--autocorrect).
554
+ Style/RedundantParentheses:
555
+ Exclude:
556
+ - 'app/components/blacklight/advanced_search_form_component.rb'
557
+ - 'app/components/blacklight/document/actions_component.rb'
558
+ - 'app/components/blacklight/document_component.rb'
559
+ - 'app/components/blacklight/document_metadata_component.rb'
560
+ - 'app/components/blacklight/metadata_field_layout_component.rb'
561
+ - 'app/components/blacklight/system/dropdown_component.rb'
562
+ - 'app/views/catalog/_document.atom.builder'
563
+ - 'lib/blacklight/search_state/pivot_filter_field.rb'
564
+ - 'lib/railties/blacklight.rake'
565
+ - 'spec/models/blacklight/solr/search_builder_spec.rb'
566
+
567
+ # Offense count: 6
558
568
  # This cop supports safe autocorrection (--autocorrect).
559
569
  # Configuration parameters: EnforcedStyle.
560
570
  # SupportedStyles: implicit, explicit
561
571
  Style/RescueStandardError:
562
572
  Exclude:
563
- - 'app/models/record_mailer.rb'
564
573
  - 'lib/blacklight.rb'
565
574
  - 'lib/blacklight/configuration/fields.rb'
566
575
  - 'lib/railties/blacklight.rake'
@@ -594,7 +603,7 @@ Style/SoleNestedConditional:
594
603
  Exclude:
595
604
  - 'app/controllers/concerns/blacklight/controller.rb'
596
605
 
597
- # Offense count: 34
606
+ # Offense count: 30
598
607
  # This cop supports safe autocorrection (--autocorrect).
599
608
  # Configuration parameters: MinSize.
600
609
  # SupportedStyles: percent, brackets
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.0.1
1
+ 8.2.0
@@ -18,11 +18,11 @@ class CheckboxSubmit {
18
18
  this.form = form;
19
19
  }
20
20
 
21
- async clicked(evt) {
21
+ clicked(evt) {
22
22
  this.spanTarget.innerHTML = this.form.getAttribute('data-inprogress');
23
23
  this.labelTarget.setAttribute('disabled', 'disabled');
24
24
  this.checkboxTarget.setAttribute('disabled', 'disabled');
25
- const response = await fetch(this.formTarget.getAttribute('action'), {
25
+ fetch(this.formTarget.getAttribute('action'), {
26
26
  body: new FormData(this.formTarget),
27
27
  method: this.formTarget.getAttribute('method').toUpperCase(),
28
28
  headers: {
@@ -30,16 +30,17 @@ class CheckboxSubmit {
30
30
  'X-Requested-With': 'XMLHttpRequest',
31
31
  'X-CSRF-Token': document.querySelector('meta[name=csrf-token]')?.content
32
32
  }
33
- });
34
- this.labelTarget.removeAttribute('disabled');
35
- this.checkboxTarget.removeAttribute('disabled');
36
- if (response.ok) {
37
- const json = await response.json();
33
+ }).then((response) => {
34
+ if (response.ok) return response.json();
35
+ return Promise.reject('response was not ok')
36
+ }).then((json) => {
37
+ this.labelTarget.removeAttribute('disabled');
38
+ this.checkboxTarget.removeAttribute('disabled');
38
39
  this.updateStateFor(!this.checked);
39
40
  document.querySelector('[data-role=bookmark-counter]').innerHTML = json.bookmarks.count;
40
- } else {
41
- alert('Error');
42
- }
41
+ }).catch((error) => {
42
+ this.handleError(error);
43
+ });
43
44
  }
44
45
 
45
46
  get checked() {
@@ -62,6 +63,10 @@ class CheckboxSubmit {
62
63
  return this.form.querySelector('[data-checkboxsubmit-target="span"]')
63
64
  }
64
65
 
66
+ handleError() {
67
+ alert("Unable to save the bookmark at this time.");
68
+ }
69
+
65
70
  updateStateFor(state) {
66
71
  this.checkboxTarget.checked = state;
67
72
 
@@ -197,21 +202,35 @@ const Modal = (() => {
197
202
  };
198
203
 
199
204
  // Add the passed in contents to the modal and display it.
205
+ // We have specific handling so that scripts returned from the ajax call are executed.
206
+ // This enables adding a script like recaptcha to prevent bots from sending emails.
200
207
  modal.receiveAjax = function (contents) {
201
- const domparser = new DOMParser();
202
- const dom = domparser.parseFromString(contents, "text/html");
203
- // If there is a containerSelector on the document, use its children.
204
- let elements = dom.querySelectorAll(`${modal.containerSelector} > *`);
205
- if (elements.length == 0) {
206
- // If the containerSelector wasn't found, use the whole document
207
- elements = dom.body.childNodes;
208
- }
209
-
210
- document.querySelector(`${modal.modalSelector} .modal-content`).replaceChildren(...elements);
208
+ const domparser = new DOMParser();
209
+ const dom = domparser.parseFromString(contents, "text/html");
210
+ // If there is a containerSelector on the document, use its children.
211
+ let elements = dom.querySelectorAll(`${modal.containerSelector} > *`);
212
+ const frag = document.createDocumentFragment();
213
+ if (elements.length == 0) {
214
+ // If the containerSelector wasn't found, use the whole document
215
+ elements = dom.body.childNodes;
216
+ }
217
+ elements.forEach((el) => frag.appendChild(el));
218
+ modal.activateScripts(frag);
219
+
220
+ document.querySelector(`${modal.modalSelector} .modal-content`).replaceChildren(frag);
211
221
 
212
- modal.show();
222
+ modal.show();
213
223
  };
214
224
 
225
+ // DOMParser doesn't allow scripts to be executed. This fixes that.
226
+ modal.activateScripts = function (frag) {
227
+ frag.querySelectorAll('script').forEach((script) => {
228
+ const fixedScript = document.createElement('script');
229
+ fixedScript.src = script.src;
230
+ fixedScript.async = false;
231
+ script.parentNode.replaceChild(fixedScript, script);
232
+ });
233
+ };
215
234
 
216
235
  modal.modalAjaxLinkClick = function(e) {
217
236
  e.preventDefault();
@@ -287,6 +306,7 @@ SearchContext.handleSearchContextMethod = function(event) {
287
306
 
288
307
  // check for meta keys.. if set, we should open in a new tab
289
308
  if(event.metaKey || event.ctrlKey) {
309
+ form.dataset.turbo = "false";
290
310
  target = '_blank';
291
311
  }
292
312
 
@@ -363,6 +383,9 @@ Blacklight.onLoad(function () {
363
383
  elem.classList.add('js');
364
384
  });
365
385
 
386
+ // ALL imports in this dir, including in files imported, should be RELATIVE
387
+
388
+
366
389
  const index = {
367
390
  BookmarkToggle,
368
391
  ButtonFocus,