blacklight_range_limit 9.0.0.beta2 → 9.1.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 +4 -4
- data/.github/workflows/ruby.yml +32 -15
- data/README.md +4 -2
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/app/components/blacklight_range_limit/range_facet_component.rb +11 -2
- data/app/components/blacklight_range_limit/range_segments_component.rb +5 -2
- data/blacklight_range_limit.gemspec +1 -1
- data/lib/blacklight_range_limit/range_limit_builder.rb +9 -0
- data/lib/blacklight_range_limit/routes/range_searchable.rb +0 -1
- data/package.json +1 -1
- data/spec/controllers/range_limit_action_method_spec.rb +61 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/presenter_test_helpers.rb +3 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +7 -3
- metadata +7 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eb86d2b4a964fa439b38733a97efb61faa03e3db7a4a51a0ffa4daea379fe9d
|
4
|
+
data.tar.gz: 2444a4e758791ecb567d8f2f3aa0ee16a14a8cd20e3b4652a4b1b565a9511f0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 423928f6a8c0b71b04a8ac60a4bff7b2581aacb0a398bb4d7c933ba6c87e4b92540871e9709870e8342f7471830995552ba465e2c19357d0fa4b5637b80c5d10
|
7
|
+
data.tar.gz: 9799b189b778c9a34ca56fcb794143f328cbac9cb9ce7df829c18c23146842b6f8c961ac866c7692cc9eef31923dc0d0a012171afe658fe5778e91a5cdd18651
|
data/.github/workflows/ruby.yml
CHANGED
@@ -12,6 +12,8 @@ on:
|
|
12
12
|
branches: [main]
|
13
13
|
pull_request:
|
14
14
|
branches: ['**']
|
15
|
+
schedule:
|
16
|
+
- cron: "0 2 * * TUE"
|
15
17
|
|
16
18
|
jobs:
|
17
19
|
test:
|
@@ -24,8 +26,8 @@ jobs:
|
|
24
26
|
#
|
25
27
|
# * Blacklight: 7, 8, or 9
|
26
28
|
# * Rails: 7 or 8
|
27
|
-
# * sprockets or propshaft(with cssbundling-rails sass)
|
28
|
-
# * importmap-rails or esbuild
|
29
|
+
# * sprockets or propshaft (with cssbundling-rails sass)
|
30
|
+
# * importmap-rails or esbuild (each with sprockets or importmaps)
|
29
31
|
#
|
30
32
|
# We should work with almost every combo of these (even though BL itself
|
31
33
|
# doesn't officially support every one), but we don't test with every one,
|
@@ -42,29 +44,53 @@ jobs:
|
|
42
44
|
ruby: "3.3"
|
43
45
|
additional_name: "/ importmap-rails"
|
44
46
|
additional_engine_cart_rails_options: "--css=bootstrap"
|
47
|
+
|
45
48
|
- rails_version: "~> 8.0.0"
|
46
49
|
blacklight_version: '{ "git": "https://github.com/projectblacklight/blacklight.git" }'
|
47
50
|
ruby: "3.3"
|
48
51
|
additional_name: "/ esbuild"
|
49
52
|
additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
|
50
53
|
|
54
|
+
# BLACKLIGHT 9, with beta cause that's all that's out as we write this
|
55
|
+
# and with Rails 8.0 only for simplicity
|
56
|
+
#
|
57
|
+
|
58
|
+
- rails_version: "~> 8.0.0"
|
59
|
+
blacklight_version: '~> 9.0.0.beta'
|
60
|
+
ruby: "3.4"
|
61
|
+
additional_name: "/ importmap-rails"
|
62
|
+
additional_engine_cart_rails_options: "--css=bootstrap"
|
63
|
+
|
64
|
+
- rails_version: "~> 8.0.0"
|
65
|
+
blacklight_version: '~> 9.0.0.beta'
|
66
|
+
ruby: "3.4"
|
67
|
+
additional_name: "/ esbuild"
|
68
|
+
additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
|
51
69
|
|
52
70
|
|
53
71
|
# BLACKLIGHT 8, can test with use importmaps and esbuild
|
54
72
|
#
|
55
73
|
|
74
|
+
- rails_version: "~> 8.0.0"
|
75
|
+
blacklight_version: "~> 8.0"
|
76
|
+
ruby: "3.3"
|
77
|
+
additional_name: "/ importmap-rails, propshaft"
|
78
|
+
additional_engine_cart_rails_options: "-a propshaft --css=bootstrap"
|
79
|
+
|
56
80
|
- rails_version: "7.2.1"
|
57
81
|
blacklight_version: "~> 8.0"
|
58
82
|
ruby: "3.3"
|
59
83
|
additional_name: "/ importmap-rails, sprockets"
|
84
|
+
|
60
85
|
- rails_version: "7.2.1"
|
61
86
|
blacklight_version: "~> 8.0"
|
62
87
|
ruby: "3.3"
|
63
88
|
additional_name: "/ importmap-rails, propshaft"
|
64
89
|
additional_engine_cart_rails_options: "-a propshaft --css=bootstrap"
|
90
|
+
|
65
91
|
- rails_version: "7.2.1"
|
66
92
|
blacklight_version: "~> 8.0"
|
67
|
-
ruby: 3.3
|
93
|
+
ruby: "3.3"
|
68
94
|
additional_engine_cart_rails_options: "-a propshaft --javascript=esbuild --css=bootstrap"
|
69
95
|
additional_name: "/ esbuild, propshaft"
|
70
96
|
|
@@ -73,12 +99,11 @@ jobs:
|
|
73
99
|
# * Blacklight 8 can't easily generate an app with Rails 7 and sprockets and esbuild
|
74
100
|
# (the default layout won't be right), although I think it should work fine.
|
75
101
|
#
|
76
|
-
# * Can't test with
|
77
|
-
# npm package
|
102
|
+
# * Can't test with unreleased Blacklight main and esbuild because the blacklight-frontend
|
103
|
+
# npm package doesn't work from git checkout. So currently can't test with Rails 8
|
78
104
|
# and esbuild.
|
79
105
|
|
80
106
|
|
81
|
-
|
82
107
|
# BLACKLIGHT 7, only test with esbuild, not sure if it supports importmaps, it won't generate it
|
83
108
|
|
84
109
|
- rails_version: "7.2.1"
|
@@ -86,6 +111,7 @@ jobs:
|
|
86
111
|
ruby: "3.3"
|
87
112
|
additional_engine_cart_rails_options: "--javascript=esbuild"
|
88
113
|
additional_name: "/ esbuild, sprockets"
|
114
|
+
|
89
115
|
- rails_version: "7.2.1"
|
90
116
|
blacklight_version: "~> 7.0"
|
91
117
|
ruby: "3.3"
|
@@ -98,15 +124,6 @@ jobs:
|
|
98
124
|
additional_engine_cart_rails_options: "--javascript=esbuild"
|
99
125
|
additional_name: "/ esbuild, sprockets"
|
100
126
|
|
101
|
-
- rails_version: "7.0.8.4"
|
102
|
-
blacklight_version: "~> 7.0"
|
103
|
-
ruby: "3.1"
|
104
|
-
additional_engine_cart_rails_options: "--javascript=esbuild"
|
105
|
-
additional_name: "/ esbuild, sprockets"
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
127
|
|
111
128
|
env:
|
112
129
|
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version || '~> 8.0' }}
|
data/README.md
CHANGED
@@ -173,6 +173,8 @@ bundle exec rspec spec/features/blacklight_range_limit_spec.rb
|
|
173
173
|
|
174
174
|
Once you are done iterating on your test you will need to stop the application server with `Ctrl-C`.
|
175
175
|
|
176
|
-
#
|
176
|
+
# Release process
|
177
177
|
|
178
|
-
|
178
|
+
Make sure you adjust version to match in both `VERSION` *and* `package.json` file.
|
179
|
+
|
180
|
+
Release rubygem with `bundle exec rake release` and also be sure to release npm package by running `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit
|
data/Rakefile
CHANGED
@@ -32,10 +32,11 @@ task :guard_version_match do
|
|
32
32
|
|
33
33
|
# 9.0.0.beta1 in gem becomes 9.0.0-beta1 in npm
|
34
34
|
gem_version_parts = gem_version.split(".")
|
35
|
+
|
35
36
|
npm_version_required = [
|
36
37
|
gem_version_parts.slice(0, 3).join("."),
|
37
38
|
gem_version_parts.slice(3, gem_version_parts.length).join(".")
|
38
|
-
].join("-")
|
39
|
+
].collect {|s| s if s && !s.empty? }.compact.join("-")
|
39
40
|
|
40
41
|
if npm_version != npm_version_required
|
41
42
|
raise <<~EOS
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
9.
|
1
|
+
9.1.0
|
@@ -6,7 +6,16 @@ module BlacklightRangeLimit
|
|
6
6
|
|
7
7
|
def initialize(facet_field:, layout: nil, classes: BlacklightRangeLimit.classes)
|
8
8
|
@facet_field = facet_field
|
9
|
-
@layout = layout == false
|
9
|
+
@layout = if layout == false
|
10
|
+
Blacklight::FacetFieldNoLayoutComponent
|
11
|
+
elsif layout
|
12
|
+
layout
|
13
|
+
elsif defined?(Blacklight::Facets::FacetFieldComponent)
|
14
|
+
Blacklight::Facets::FacetFieldComponent # Blacklight 9
|
15
|
+
else
|
16
|
+
Blacklight::FacetFieldComponent # Blacklight < 9
|
17
|
+
end
|
18
|
+
|
10
19
|
@classes = classes
|
11
20
|
end
|
12
21
|
|
@@ -39,7 +48,7 @@ module BlacklightRangeLimit
|
|
39
48
|
min = @facet_field.selected_range_facet_item&.value&.begin || @facet_field.min
|
40
49
|
max = @facet_field.selected_range_facet_item&.value&.end || @facet_field.max
|
41
50
|
|
42
|
-
return nil unless
|
51
|
+
return nil unless min && max
|
43
52
|
|
44
53
|
range_limit_url(range_start: min, range_end: max)
|
45
54
|
end
|
@@ -3,11 +3,14 @@
|
|
3
3
|
module BlacklightRangeLimit
|
4
4
|
class RangeSegmentsComponent < Blacklight::Component
|
5
5
|
def initialize(facet_field:, facet_items: nil, item_component: nil, classes: [])
|
6
|
-
super
|
6
|
+
super()
|
7
7
|
|
8
8
|
@facet_field = facet_field
|
9
9
|
@facet_items = facet_items || facet_field.try(:range_queries) || []
|
10
|
-
|
10
|
+
# newer versions of BL9 want Blacklight::Facets::ItemComponent -- the older one is supposed
|
11
|
+
# to be deprecated, but in fact may not work so we use newer if avail.
|
12
|
+
@item_component = facet_field.facet_field.item_component ||
|
13
|
+
(defined?(Blacklight::Facets::ItemComponent) ? Blacklight::Facets::ItemComponent : Blacklight::FacetItemComponent)
|
11
14
|
@classes = classes
|
12
15
|
end
|
13
16
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.license = 'Apache 2.0'
|
19
19
|
|
20
20
|
s.add_dependency 'blacklight', '>= 7.25.2', '< 9'
|
21
|
-
s.add_dependency 'view_component', ">= 2.54", "<
|
21
|
+
s.add_dependency 'view_component', ">= 2.54", "< 5"
|
22
22
|
|
23
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
24
24
|
s.add_development_dependency 'rspec-rails'
|
@@ -48,6 +48,12 @@ module BlacklightRangeLimit
|
|
48
48
|
# range_field, range_start, range_end
|
49
49
|
def fetch_specific_range_limit(solr_params)
|
50
50
|
field_key = blacklight_params[:range_field] # what field to fetch for
|
51
|
+
|
52
|
+
unless blacklight_params[:range_start].present? && blacklight_params[:range_start].kind_of?(String) &&
|
53
|
+
blacklight_params[:range_end].present? && blacklight_params[:range_end].kind_of?(String)
|
54
|
+
raise BlacklightRangeLimit::InvalidRange
|
55
|
+
end
|
56
|
+
|
51
57
|
start = blacklight_params[:range_start].to_i
|
52
58
|
finish = blacklight_params[:range_end].to_i
|
53
59
|
|
@@ -61,6 +67,9 @@ module BlacklightRangeLimit
|
|
61
67
|
solr_params[:rows] = 0
|
62
68
|
|
63
69
|
return solr_params
|
70
|
+
rescue BlacklightRangeLimit::InvalidRange
|
71
|
+
# This will make Rails return a 400
|
72
|
+
raise ActionController::BadRequest, "invalid range_start (#{blacklight_params[:range_start]}) or range_end (#{blacklight_params[:range_end]})"
|
64
73
|
end
|
65
74
|
|
66
75
|
# hacky polyfill for new Blacklight behavior we need, if we don't have it yet
|
data/package.json
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe CatalogController, type: :controller do
|
4
|
+
# Note that ActionController::BadRequest is caught by rails and turned into a 400
|
5
|
+
# response, and ActionController::RoutingError is caught by raisl and turned into 404
|
6
|
+
describe "bad params" do
|
7
|
+
let (:facet_field) { "pub_date_si" }
|
8
|
+
|
9
|
+
it "without start param present raise BadRequest " do
|
10
|
+
expect {
|
11
|
+
get :range_limit, params: {
|
12
|
+
"range_field"=> facet_field,
|
13
|
+
"range_start"=>"1931"
|
14
|
+
}
|
15
|
+
}.to raise_error(ActionController::BadRequest)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "without end param raise BadRequest " do
|
19
|
+
expect {
|
20
|
+
get :range_limit, params: {
|
21
|
+
"range_field"=> facet_field,
|
22
|
+
"range_start"=>"1931"
|
23
|
+
}
|
24
|
+
}.to raise_error(ActionController::BadRequest)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "without either boundary raise BadRequest" do
|
28
|
+
expect {
|
29
|
+
get :range_limit, params: {
|
30
|
+
"range_field"=> facet_field,
|
31
|
+
}
|
32
|
+
}.to raise_error(ActionController::BadRequest)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "without a range_field raise RoutingError" do
|
36
|
+
expect {
|
37
|
+
get :range_limit, params: {}
|
38
|
+
}.to raise_error(ActionController::RoutingError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "with params out of order raise BadRequest" do
|
42
|
+
expect {
|
43
|
+
get :range_limit, params: {
|
44
|
+
"range_field"=> facet_field,
|
45
|
+
"range_start"=>"1940",
|
46
|
+
"range_end"=>"1930"
|
47
|
+
}
|
48
|
+
}.to raise_error(ActionController::BadRequest)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "with one of the params is an array raise BadRequest" do
|
52
|
+
expect {
|
53
|
+
get :range_limit, params: {
|
54
|
+
"range_field"=> facet_field,
|
55
|
+
"range_start"=>"1931",
|
56
|
+
"range_end"=>["1940"]
|
57
|
+
}
|
58
|
+
}.to raise_error(ActionController::BadRequest)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -44,8 +44,8 @@ RSpec.configure do |config|
|
|
44
44
|
config.infer_spec_type_from_file_location!
|
45
45
|
|
46
46
|
config.include PresenterTestHelpers, type: :presenter
|
47
|
+
config.include ViewComponent::TestHelpers, type: :presenter
|
47
48
|
config.include ViewComponent::TestHelpers, type: :component
|
48
49
|
|
49
50
|
config.example_status_persistence_file_path = 'spec/examples.txt'
|
50
|
-
|
51
51
|
end
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
module PresenterTestHelpers
|
4
4
|
def controller
|
5
|
-
|
5
|
+
# view_component 3+ should be just `vc_test_controller_class` when we drop VC 2 support we can
|
6
|
+
# just use that.
|
7
|
+
@controller ||= (respond_to?(:vc_test_controller_class) ? vc_test_controller_class : ApplicationController).new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
|
6
8
|
end
|
7
9
|
|
8
10
|
def request
|
@@ -13,9 +13,13 @@ class TestAppGenerator < Rails::Generators::Base
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run_bl8_jsbundling_fixup
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
16
|
+
# BL 8.7.0 doesn't seem to need anything, but BL8 before that the automatic BL
|
17
|
+
# install process doesn't do everything we need.
|
18
|
+
#
|
19
|
+
# By manually triggering the BL8 assets:propshaft generator, we can get what we need
|
20
|
+
# for jsbundling, even though it's named confusingly for that, it works in these
|
21
|
+
# versions.
|
22
|
+
if File.exist?("package.json") && Gem::Requirement.create("~> 8.0", "< 8.7.0").satisfied_by?(Gem::Version.new(Blacklight::VERSION))
|
19
23
|
generate "blacklight:assets:propshaft"
|
20
24
|
end
|
21
25
|
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_range_limit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
- Chris Beer
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: blacklight
|
@@ -40,7 +39,7 @@ dependencies:
|
|
40
39
|
version: '2.54'
|
41
40
|
- - "<"
|
42
41
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
42
|
+
version: '5'
|
44
43
|
type: :runtime
|
45
44
|
prerelease: false
|
46
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,7 +49,7 @@ dependencies:
|
|
50
49
|
version: '2.54'
|
51
50
|
- - "<"
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
52
|
+
version: '5'
|
54
53
|
- !ruby/object:Gem::Dependency
|
55
54
|
name: rspec
|
56
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +176,6 @@ dependencies:
|
|
177
176
|
- - ">="
|
178
177
|
- !ruby/object:Gem::Version
|
179
178
|
version: 3.13.1
|
180
|
-
description:
|
181
179
|
email:
|
182
180
|
- blacklight-development@googlegroups.com
|
183
181
|
executables: []
|
@@ -250,6 +248,7 @@ files:
|
|
250
248
|
- spec/components/range_facet_component_spec.rb
|
251
249
|
- spec/components/range_form_component_spec.rb
|
252
250
|
- spec/components/range_segments_component_spec.rb
|
251
|
+
- spec/controllers/range_limit_action_method_spec.rb
|
253
252
|
- spec/features/blacklight_range_limit_spec.rb
|
254
253
|
- spec/features/run_through_spec.rb
|
255
254
|
- spec/fixtures/solr_documents/unknown_year.yml
|
@@ -267,7 +266,6 @@ homepage: https://github.com/projectblacklight/blacklight_range_limit
|
|
267
266
|
licenses:
|
268
267
|
- Apache 2.0
|
269
268
|
metadata: {}
|
270
|
-
post_install_message:
|
271
269
|
rdoc_options: []
|
272
270
|
require_paths:
|
273
271
|
- lib
|
@@ -282,14 +280,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
280
|
- !ruby/object:Gem::Version
|
283
281
|
version: '0'
|
284
282
|
requirements: []
|
285
|
-
rubygems_version: 3.
|
286
|
-
signing_key:
|
283
|
+
rubygems_version: 3.6.9
|
287
284
|
specification_version: 4
|
288
285
|
summary: Blacklight Range Limit plugin
|
289
286
|
test_files:
|
290
287
|
- spec/components/range_facet_component_spec.rb
|
291
288
|
- spec/components/range_form_component_spec.rb
|
292
289
|
- spec/components/range_segments_component_spec.rb
|
290
|
+
- spec/controllers/range_limit_action_method_spec.rb
|
293
291
|
- spec/features/blacklight_range_limit_spec.rb
|
294
292
|
- spec/features/run_through_spec.rb
|
295
293
|
- spec/fixtures/solr_documents/unknown_year.yml
|