blacklight_range_limit 9.1.0 → 9.3.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 +49 -13
- data/.solr_wrapper.yml +3 -1
- data/Gemfile +2 -18
- data/README.md +2 -1
- data/VERSION +1 -1
- data/app/components/blacklight_range_limit/range_form_component.html.erb +14 -18
- data/app/components/blacklight_range_limit/range_input_component.html.erb +10 -0
- data/app/components/blacklight_range_limit/range_input_component.rb +14 -0
- data/blacklight_range_limit.gemspec +1 -1
- data/lib/blacklight_range_limit/controller_override.rb +14 -7
- data/lib/blacklight_range_limit/range_limit_builder.rb +22 -7
- data/lib/blacklight_range_limit/segment_calculation.rb +48 -50
- data/lib/generators/blacklight_range_limit/assets_generator.rb +2 -2
- data/package.json +1 -1
- data/solr/conf/schema.xml +32 -18
- data/spec/test_app_templates/Gemfile.extra +7 -4
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 795e8e6e2b3472dd8978285eabc633113251c2f14b9c59f506b13f9c3f0c402c
|
|
4
|
+
data.tar.gz: 53f4cc96793fea0579a7ebf85b44610d70dc9845594282cbd3f7034e7b6a9b60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca5b95998473a58142dfe87743ce359e18cc8272fb5e9fedf8ebddf0dab32ad673a1de5f5f0acbb01e85d9cfa9538b65f08ded53daddf0b3a7e0fabb95ed8095
|
|
7
|
+
data.tar.gz: 19c4558b8fded3636ef41e8f7bdfa1d2f31ddd553e85b9cb555172feb02bd6bc33c1096549513767ff75bdb015f0c8cfb42c65e78b71acc10f526536b690cbab
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -34,42 +34,68 @@ jobs:
|
|
|
34
34
|
# that'd be too much. Plus BL can't *generate* every one even though it
|
|
35
35
|
# can be made to work with every one. We test with some good significant
|
|
36
36
|
# representative samples.
|
|
37
|
+
#
|
|
38
|
+
# If 'blacklight_version' includes `://`, will be understood as github url,
|
|
39
|
+
# used for testing off blacklight main.
|
|
37
40
|
|
|
38
41
|
include:
|
|
39
|
-
# BLACKLIGHT EDGE, can test with
|
|
42
|
+
# BLACKLIGHT EDGE, can test with latest rails, importmap and esbuild
|
|
40
43
|
#
|
|
41
44
|
|
|
42
|
-
- rails_version: "~> 8.
|
|
43
|
-
blacklight_version: '
|
|
45
|
+
- rails_version: "~> 8.1.0"
|
|
46
|
+
blacklight_version: 'https://github.com/projectblacklight/blacklight.git'
|
|
44
47
|
ruby: "3.3"
|
|
45
48
|
additional_name: "/ importmap-rails"
|
|
46
49
|
additional_engine_cart_rails_options: "--css=bootstrap"
|
|
47
50
|
|
|
48
|
-
- rails_version: "~> 8.
|
|
49
|
-
blacklight_version: '
|
|
51
|
+
- rails_version: "~> 8.1.0"
|
|
52
|
+
blacklight_version: 'https://github.com/projectblacklight/blacklight.git'
|
|
50
53
|
ruby: "3.3"
|
|
51
54
|
additional_name: "/ esbuild"
|
|
52
55
|
additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
|
|
53
56
|
|
|
54
|
-
# BLACKLIGHT 9
|
|
55
|
-
# and with Rails 8.0 only for simplicity
|
|
57
|
+
# BLACKLIGHT 9 and with Rails 8 and 8.1
|
|
56
58
|
#
|
|
57
59
|
|
|
60
|
+
- rails_version: "~> 8.1.0"
|
|
61
|
+
blacklight_version: '~> 9.0'
|
|
62
|
+
ruby: "3.4"
|
|
63
|
+
additional_name: "/ importmap-rails"
|
|
64
|
+
additional_engine_cart_rails_options: "--css=bootstrap"
|
|
65
|
+
|
|
66
|
+
- rails_version: "~> 8.1.0"
|
|
67
|
+
blacklight_version: '~> 9.0'
|
|
68
|
+
ruby: "3.4"
|
|
69
|
+
additional_name: "/ esbuild"
|
|
70
|
+
additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
|
|
71
|
+
|
|
58
72
|
- rails_version: "~> 8.0.0"
|
|
59
|
-
blacklight_version: '~> 9.0
|
|
73
|
+
blacklight_version: '~> 9.0'
|
|
60
74
|
ruby: "3.4"
|
|
61
75
|
additional_name: "/ importmap-rails"
|
|
62
76
|
additional_engine_cart_rails_options: "--css=bootstrap"
|
|
63
77
|
|
|
64
78
|
- rails_version: "~> 8.0.0"
|
|
65
|
-
blacklight_version: '~> 9.0
|
|
79
|
+
blacklight_version: '~> 9.0'
|
|
66
80
|
ruby: "3.4"
|
|
67
81
|
additional_name: "/ esbuild"
|
|
68
82
|
additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
|
|
69
83
|
|
|
70
84
|
|
|
71
|
-
# BLACKLIGHT 8, can test with use importmaps and esbuild
|
|
72
|
-
#
|
|
85
|
+
# BLACKLIGHT 8, can test with use importmaps and esbuild, also rails 8 and 8.1
|
|
86
|
+
# and a bit of 7.2
|
|
87
|
+
|
|
88
|
+
- rails_version: "~> 8.1.0"
|
|
89
|
+
blacklight_version: "~> 8.0"
|
|
90
|
+
ruby: "3.3"
|
|
91
|
+
additional_name: "/ importmap-rails, propshaft"
|
|
92
|
+
additional_engine_cart_rails_options: "-a propshaft --css=bootstrap"
|
|
93
|
+
|
|
94
|
+
- rails_version: "~> 8.1.0"
|
|
95
|
+
blacklight_version: "~> 8.0"
|
|
96
|
+
ruby: "3.3"
|
|
97
|
+
additional_engine_cart_rails_options: "-a propshaft --javascript=esbuild --css=bootstrap"
|
|
98
|
+
additional_name: "/ esbuild, propshaft"
|
|
73
99
|
|
|
74
100
|
- rails_version: "~> 8.0.0"
|
|
75
101
|
blacklight_version: "~> 8.0"
|
|
@@ -105,24 +131,31 @@ jobs:
|
|
|
105
131
|
|
|
106
132
|
|
|
107
133
|
# BLACKLIGHT 7, only test with esbuild, not sure if it supports importmaps, it won't generate it
|
|
134
|
+
# Blacklight 7 generator uses old `Bundler.with_clean_env`, so needs a bundler < 4. (there is no
|
|
135
|
+
# bundler 3!)
|
|
108
136
|
|
|
109
137
|
- rails_version: "7.2.1"
|
|
110
138
|
blacklight_version: "~> 7.0"
|
|
111
139
|
ruby: "3.3"
|
|
112
140
|
additional_engine_cart_rails_options: "--javascript=esbuild"
|
|
113
141
|
additional_name: "/ esbuild, sprockets"
|
|
142
|
+
bundler: "2.7.2"
|
|
114
143
|
|
|
144
|
+
# This combo failed on BL 7.42.0, and we didn't have the capacity to fix/support.
|
|
145
|
+
# https://github.com/projectblacklight/blacklight_range_limit/issues/339
|
|
115
146
|
- rails_version: "7.2.1"
|
|
116
|
-
blacklight_version: "
|
|
147
|
+
blacklight_version: "7.41.0"
|
|
117
148
|
ruby: "3.3"
|
|
118
149
|
additional_engine_cart_rails_options: "--javascript=esbuild --css=bootstrap -a propshaft"
|
|
119
150
|
additional_name: "/ esbuild, propshaft"
|
|
151
|
+
bundler: "2.7.2"
|
|
120
152
|
|
|
121
153
|
- rails_version: "7.1.4"
|
|
122
154
|
blacklight_version: "~> 7.0"
|
|
123
155
|
ruby: "3.2"
|
|
124
156
|
additional_engine_cart_rails_options: "--javascript=esbuild"
|
|
125
157
|
additional_name: "/ esbuild, sprockets"
|
|
158
|
+
bundler: "2.7.2"
|
|
126
159
|
|
|
127
160
|
|
|
128
161
|
env:
|
|
@@ -135,7 +168,10 @@ jobs:
|
|
|
135
168
|
uses: ruby/setup-ruby@v1
|
|
136
169
|
with:
|
|
137
170
|
ruby-version: ${{ matrix.ruby }}
|
|
138
|
-
bundler:
|
|
171
|
+
#bundler: ${{ matrix.bundler != '' && matrix.bundler || 'latest' }}
|
|
172
|
+
# Bundler locked to <4, see https://github.com/projectblacklight/blacklight_range_limit/pull/328
|
|
173
|
+
bundler: ${{ matrix.bundler != '' && matrix.bundler || '2.7.2' }}
|
|
174
|
+
|
|
139
175
|
|
|
140
176
|
- name: Install dependencies
|
|
141
177
|
run: bundle install
|
data/.solr_wrapper.yml
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
port: 8983
|
|
8
8
|
verbose: true
|
|
9
|
-
version: 9.
|
|
9
|
+
version: 9.10.1
|
|
10
10
|
<% ENV['CI'] && FileUtils.mkdir_p('ci_dl_solr_dist') %>
|
|
11
11
|
download_dir: <%= 'ci_dl_solr_dist' if ENV['CI'] %>
|
|
12
12
|
collection:
|
|
13
13
|
dir: solr/conf/
|
|
14
14
|
name: blacklight-core
|
|
15
|
+
env:
|
|
16
|
+
SOLR_OPTS: "-Dsolr.config.lib.enabled=true"
|
data/Gemfile
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require 'json'
|
|
3
2
|
|
|
4
3
|
source 'https://rubygems.org'
|
|
5
4
|
|
|
@@ -10,14 +9,9 @@ group :test do
|
|
|
10
9
|
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
# While gemspec allows BL8 and some people are using BL8... the build
|
|
14
|
-
# has never actually passed on BL8 yet. We may choose to run tests on
|
|
15
|
-
# a blacklight version other than the latest allowed by gemspec, to get
|
|
16
|
-
# tests to pass, or to test on older BL still supported here.
|
|
17
12
|
if ENV['BLACKLIGHT_VERSION']
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
gem "blacklight", **JSON.parse(ENV['BLACKLIGHT_VERSION'])
|
|
13
|
+
if ENV['BLACKLIGHT_VERSION'].include?("://")
|
|
14
|
+
gem "blacklight", git: ENV['BLACKLIGHT_VERSION']
|
|
21
15
|
else
|
|
22
16
|
gem "blacklight", ENV['BLACKLIGHT_VERSION']
|
|
23
17
|
end
|
|
@@ -45,16 +39,6 @@ else
|
|
|
45
39
|
else
|
|
46
40
|
gem 'rails', ENV['RAILS_VERSION']
|
|
47
41
|
end
|
|
48
|
-
|
|
49
|
-
case ENV['RAILS_VERSION']
|
|
50
|
-
when /^6.0/
|
|
51
|
-
gem 'sass-rails', '>= 6'
|
|
52
|
-
gem 'webpacker', '~> 4.0'
|
|
53
|
-
when /^5.[12]/
|
|
54
|
-
gem 'sass-rails', '~> 5.0'
|
|
55
|
-
gem 'sprockets', '~> 3.7'
|
|
56
|
-
gem 'thor', '~> 0.20'
|
|
57
|
-
end
|
|
58
42
|
end
|
|
59
43
|
end
|
|
60
44
|
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
|
@@ -19,7 +19,8 @@ Decimal numbers and Dates are NOT supported; they theoretically could be in the
|
|
|
19
19
|
|
|
20
20
|
* Javascript requires you to be using either rails-importmaps or a package.json-based builder like jsbundling-rails or vite-ruby. Legacy "sprockets-only" is not supported, however propshaft or sprockets can be used as your base asset pipeline.
|
|
21
21
|
|
|
22
|
-
* Blacklight 7.0+. Rails 7.0
|
|
22
|
+
* Blacklight 7.0+. Rails 7.0+.
|
|
23
|
+
* Note blacklight 7.x >= 7.42.0 are no longer tested in CI, see https://github.com/projectblacklight/blacklight_range_limit/issues/339. They might still work.
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
# Installation
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
9.
|
|
1
|
+
9.3.0
|
|
@@ -3,25 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
<div class="range-limit-input-group">
|
|
5
5
|
<div class="d-flex justify-content-between align-items-end">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
%>
|
|
14
|
-
</div>
|
|
6
|
+
<%= render BlacklightRangeLimit::RangeInputComponent.new(
|
|
7
|
+
input_name: begin_input_name,
|
|
8
|
+
input_value: begin_value_default,
|
|
9
|
+
label_text: t("blacklight.range_limit.range_begin_short"),
|
|
10
|
+
min_value: range_config[:min_value],
|
|
11
|
+
max_value: range_config[:max_value],
|
|
12
|
+
css_class: "range_begin") %>
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
%>
|
|
24
|
-
</div>
|
|
14
|
+
<%= render BlacklightRangeLimit::RangeInputComponent.new(
|
|
15
|
+
input_name: end_input_name,
|
|
16
|
+
input_value: end_value_default,
|
|
17
|
+
label_text: t("blacklight.range_limit.range_end_short"),
|
|
18
|
+
min_value: range_config[:min_value],
|
|
19
|
+
max_value: range_config[:max_value],
|
|
20
|
+
css_class: "range_end") %>
|
|
25
21
|
</div>
|
|
26
22
|
<div class="d-flex justify-content-end mt-2">
|
|
27
23
|
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: @classes[:submit], name: nil %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<div class="d-flex flex-column mr-1 me-1">
|
|
2
|
+
<%= label_tag @input_name, @label_text, class: 'text-muted small mb-1' %>
|
|
3
|
+
<%= number_field_tag @input_name,
|
|
4
|
+
@input_value,
|
|
5
|
+
min: @min_value,
|
|
6
|
+
max: @max_value,
|
|
7
|
+
inputmode: 'numeric',
|
|
8
|
+
class: "form-control form-control-sm #{@css_class}" %>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BlacklightRangeLimit
|
|
4
|
+
class RangeInputComponent < Blacklight::Component
|
|
5
|
+
def initialize(input_name:, input_value:, label_text:, min_value:, max_value:, css_class:)
|
|
6
|
+
@input_name = input_name
|
|
7
|
+
@input_value = input_value
|
|
8
|
+
@label_text = label_text
|
|
9
|
+
@min_value = min_value
|
|
10
|
+
@max_value = max_value
|
|
11
|
+
@css_class = css_class
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
|
17
17
|
|
|
18
18
|
s.license = 'Apache 2.0'
|
|
19
19
|
|
|
20
|
-
s.add_dependency 'blacklight', '>= 7.25.2', '<
|
|
20
|
+
s.add_dependency 'blacklight', '>= 7.25.2', '< 10'
|
|
21
21
|
s.add_dependency 'view_component', ">= 2.54", "< 5"
|
|
22
22
|
|
|
23
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
|
@@ -8,18 +8,17 @@ module BlacklightRangeLimit
|
|
|
8
8
|
|
|
9
9
|
RANGE_LIMIT_FIELDS = [:range_end, :range_field, :range_start].freeze
|
|
10
10
|
|
|
11
|
+
included do
|
|
12
|
+
# have to do this in before_action so it's done before any application level
|
|
13
|
+
# before_actions, that might do something that needs it
|
|
14
|
+
before_action :_range_limit_add_search_state_fields, only: :range_limit
|
|
15
|
+
end
|
|
16
|
+
|
|
11
17
|
# Action method of our own!
|
|
12
18
|
# Delivers a _partial_ that's a display of a single fields range facets.
|
|
13
19
|
# Used when we need a second Solr query to get range facets, after the
|
|
14
20
|
# first found min/max from result set.
|
|
15
21
|
def range_limit
|
|
16
|
-
# The builder in this action will need our special range_limit fields, so we
|
|
17
|
-
# must allow them.
|
|
18
|
-
if blacklight_config.search_state_fields
|
|
19
|
-
missing_keys = RANGE_LIMIT_FIELDS - blacklight_config.search_state_fields
|
|
20
|
-
blacklight_config.search_state_fields.concat(missing_keys)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
22
|
@facet = blacklight_config.facet_fields[params[:range_field]]
|
|
24
23
|
raise ActionController::RoutingError, 'Not Found' unless @facet&.range
|
|
25
24
|
|
|
@@ -40,6 +39,14 @@ module BlacklightRangeLimit
|
|
|
40
39
|
render BlacklightRangeLimit::RangeSegmentsComponent.new(facet_field: @presenter), layout: !request.xhr?
|
|
41
40
|
end
|
|
42
41
|
|
|
42
|
+
def _range_limit_add_search_state_fields
|
|
43
|
+
# The builder in this action will need our special range_limit fields, so we
|
|
44
|
+
# must allow them.
|
|
45
|
+
blacklight_config.search_state_fields ||= []
|
|
46
|
+
missing_keys = RANGE_LIMIT_FIELDS - blacklight_config.search_state_fields
|
|
47
|
+
blacklight_config.search_state_fields.concat(missing_keys)
|
|
48
|
+
end
|
|
49
|
+
|
|
43
50
|
class_methods do
|
|
44
51
|
def default_range_config
|
|
45
52
|
BlacklightRangeLimit.default_range_config
|
|
@@ -47,15 +47,15 @@ module BlacklightRangeLimit
|
|
|
47
47
|
# Specified field and parameters are specified in incoming parameters
|
|
48
48
|
# range_field, range_start, range_end
|
|
49
49
|
def fetch_specific_range_limit(solr_params)
|
|
50
|
-
field_key =
|
|
50
|
+
field_key = _bl_range_limit_app_params[:range_field] # what field to fetch for
|
|
51
51
|
|
|
52
|
-
unless
|
|
53
|
-
|
|
52
|
+
unless _bl_range_limit_app_params[:range_start].present? && _bl_range_limit_app_params[:range_start].kind_of?(String) &&
|
|
53
|
+
_bl_range_limit_app_params[:range_end].present? && _bl_range_limit_app_params[:range_end].kind_of?(String)
|
|
54
54
|
raise BlacklightRangeLimit::InvalidRange
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
start =
|
|
58
|
-
finish =
|
|
57
|
+
start = _bl_range_limit_app_params[:range_start].to_i
|
|
58
|
+
finish = _bl_range_limit_app_params[:range_end].to_i
|
|
59
59
|
|
|
60
60
|
add_range_segments_to_solr!(solr_params, field_key, start, finish )
|
|
61
61
|
|
|
@@ -69,14 +69,29 @@ module BlacklightRangeLimit
|
|
|
69
69
|
return solr_params
|
|
70
70
|
rescue BlacklightRangeLimit::InvalidRange
|
|
71
71
|
# This will make Rails return a 400
|
|
72
|
-
raise ActionController::BadRequest, "invalid range_start (#{
|
|
72
|
+
raise ActionController::BadRequest, "invalid range_start (#{_bl_range_limit_app_params[:range_start]}) or range_end (#{_bl_range_limit_app_params[:range_end]})"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
bl_version = Gem.loaded_specs["blacklight"]&.version
|
|
76
|
+
|
|
77
|
+
# get the query params correct way for old or newer blacklight
|
|
78
|
+
#
|
|
79
|
+
# https://github.com/projectblacklight/blacklight/pull/3851
|
|
80
|
+
# https://github.com/projectblacklight/blacklight/pull/3849
|
|
81
|
+
if bl_version && bl_version < Gem::Version.new("9.1.0")
|
|
82
|
+
def _bl_range_limit_app_params
|
|
83
|
+
blacklight_params
|
|
84
|
+
end
|
|
85
|
+
else
|
|
86
|
+
def _bl_range_limit_app_params
|
|
87
|
+
search_state.params
|
|
88
|
+
end
|
|
73
89
|
end
|
|
74
90
|
|
|
75
91
|
# hacky polyfill for new Blacklight behavior we need, if we don't have it yet
|
|
76
92
|
#
|
|
77
93
|
# https://github.com/projectblacklight/blacklight/pull/3213
|
|
78
94
|
# https://github.com/projectblacklight/blacklight/pull/3443
|
|
79
|
-
bl_version = Gem.loaded_specs["blacklight"]&.version
|
|
80
95
|
if bl_version && (bl_version <= Gem::Version.new("8.6.1"))
|
|
81
96
|
def facet_value_to_fq_string(facet_field, value, use_local_params: true)
|
|
82
97
|
facet_config = blacklight_config.facet_fields[facet_field]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Meant to be in a Controller, included in our ControllerOverride module.
|
|
2
2
|
module BlacklightRangeLimit
|
|
3
3
|
module SegmentCalculation
|
|
4
|
-
|
|
5
4
|
protected
|
|
6
5
|
|
|
7
6
|
# Calculates segment facets within a given start and end on a given
|
|
@@ -12,7 +11,8 @@ module BlacklightRangeLimit
|
|
|
12
11
|
#
|
|
13
12
|
# Changes solr_params passed in.
|
|
14
13
|
def add_range_segments_to_solr!(solr_params, facet_field, min, max)
|
|
15
|
-
raise InvalidRange,
|
|
14
|
+
raise InvalidRange, 'The min date must be before the max date' if min > max
|
|
15
|
+
|
|
16
16
|
field_config = blacklight_config.facet_fields[facet_field.to_s]
|
|
17
17
|
|
|
18
18
|
return solr_params unless field_config
|
|
@@ -26,7 +26,7 @@ module BlacklightRangeLimit
|
|
|
26
26
|
# Now make the boundaries into actual filter.queries.
|
|
27
27
|
0.upto(boundaries.length - 2) do |index|
|
|
28
28
|
first = boundaries[index]
|
|
29
|
-
last = boundaries[index+1].to_i - 1
|
|
29
|
+
last = boundaries[index + 1].to_i - 1
|
|
30
30
|
|
|
31
31
|
solr_params[:"facet.query"] << "#{field_config.field}:[#{first} TO #{last}]"
|
|
32
32
|
end
|
|
@@ -43,7 +43,8 @@ module BlacklightRangeLimit
|
|
|
43
43
|
# be turned into inclusive ranges, the FINAL boundary will be one
|
|
44
44
|
# unit more than the actual end of the last range later computed.
|
|
45
45
|
def boundaries_for_range_facets(first, last, num_div)
|
|
46
|
-
raise ArgumentError,
|
|
46
|
+
raise ArgumentError, 'The first date must be before the last date' if last < first
|
|
47
|
+
|
|
47
48
|
# arithmetic issues require last to be one more than the actual
|
|
48
49
|
# last value included in our inclusive range
|
|
49
50
|
last += 1
|
|
@@ -54,58 +55,55 @@ module BlacklightRangeLimit
|
|
|
54
55
|
|
|
55
56
|
# Don't know what most of these variables mean, just copying
|
|
56
57
|
# from Flot.
|
|
57
|
-
dec = -1 *
|
|
58
|
-
magn = (10
|
|
59
|
-
norm =
|
|
58
|
+
dec = -1 * Math.log10(delta).floor
|
|
59
|
+
magn = (10**(-1 * dec)).to_f
|
|
60
|
+
norm = magn == 0 ? delta : (delta / magn) # norm is between 1.0 and 10.0
|
|
60
61
|
|
|
61
62
|
size = 10
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
if norm < 1.5
|
|
64
|
+
size = 1
|
|
65
|
+
elsif norm < 3
|
|
66
|
+
size = 2
|
|
67
|
+
# special case for 2.5, requires an extra decimal
|
|
68
|
+
if norm > 2.25
|
|
69
|
+
size = 2.5
|
|
70
|
+
dec + 1
|
|
71
|
+
end
|
|
72
|
+
elsif norm < 7.5
|
|
73
|
+
size = 5
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
size *= magn
|
|
77
|
+
|
|
78
|
+
boundaries = []
|
|
79
|
+
|
|
80
|
+
start = floorInBase(first, size)
|
|
81
|
+
i = 0
|
|
82
|
+
v = Float::MAX
|
|
83
|
+
prev = nil
|
|
84
|
+
begin
|
|
85
|
+
prev = v
|
|
86
|
+
v = start + i * size
|
|
87
|
+
boundaries.push(v.to_i)
|
|
88
|
+
i += 1
|
|
89
|
+
end while (v < last && v != prev)
|
|
90
|
+
|
|
91
|
+
# Can create dups for small ranges, tighten up
|
|
92
|
+
boundaries.uniq!
|
|
93
|
+
|
|
94
|
+
# That algorithm i don't entirely understand will sometimes
|
|
95
|
+
# extend past our first and last, tighten it up and make sure
|
|
96
|
+
# first and last are endpoints.
|
|
97
|
+
boundaries.delete_if { |b| b <= first || b >= last }
|
|
98
|
+
boundaries.unshift(first)
|
|
99
|
+
boundaries.push(last)
|
|
100
|
+
|
|
101
|
+
boundaries
|
|
101
102
|
end
|
|
102
103
|
|
|
103
104
|
# Cribbed from Flot. Round to nearby lower multiple of base
|
|
104
105
|
def floorInBase(n, base)
|
|
105
|
-
|
|
106
|
+
base * (n / base).floor
|
|
106
107
|
end
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
108
|
end
|
|
111
109
|
end
|
|
@@ -77,9 +77,9 @@ module BlacklightRangeLimit
|
|
|
77
77
|
# chart.js is dependency of blacklight-range-limit, currently is not working
|
|
78
78
|
# as vendored importmaps, but instead must be pinned to CDN. You may want to update
|
|
79
79
|
# versions perioidically.
|
|
80
|
-
pin "chart.js", to: "https://
|
|
80
|
+
pin "chart.js", to: "https://cdn.jsdelivr.net/npm/chart.js@4.5.1/+esm"
|
|
81
81
|
# single dependency of chart.js:
|
|
82
|
-
pin "@kurkle/color", to: "https://
|
|
82
|
+
pin "@kurkle/color", to: "https://cdn.jsdelivr.net/npm/@kurkle/color@0.4.0/dist/color.esm.min.js"
|
|
83
83
|
EOS
|
|
84
84
|
end
|
|
85
85
|
else
|
data/package.json
CHANGED
data/solr/conf/schema.xml
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<dynamicField name="*_isi" type="int" stored="true" indexed="true" multiValued="false"/>
|
|
72
72
|
<dynamicField name="*_isim" type="int" stored="true" indexed="true" multiValued="true"/>
|
|
73
73
|
|
|
74
|
-
<!--
|
|
74
|
+
<!-- IntegerPointField (_it...) (for faster range queries) -->
|
|
75
75
|
|
|
76
76
|
<dynamicField name="*_iti" type="tint" stored="false" indexed="true" multiValued="false"/>
|
|
77
77
|
<dynamicField name="*_itim" type="tint" stored="false" indexed="true" multiValued="true"/>
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
<dynamicField name="*_dtsi" type="date" stored="true" indexed="true" multiValued="false"/>
|
|
94
94
|
<dynamicField name="*_dtsim" type="date" stored="true" indexed="true" multiValued="true"/>
|
|
95
95
|
|
|
96
|
-
<!--
|
|
96
|
+
<!-- DatePointField (_dtt...) (for faster range queries) -->
|
|
97
97
|
|
|
98
98
|
<dynamicField name="*_dtti" type="tdate" stored="false" indexed="true" multiValued="false"/>
|
|
99
99
|
<dynamicField name="*_dttim" type="tdate" stored="false" indexed="true" multiValued="true"/>
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
<dynamicField name="*_lsi" type="long" stored="true" indexed="true" multiValued="false"/>
|
|
114
114
|
<dynamicField name="*_lsim" type="long" stored="true" indexed="true" multiValued="true"/>
|
|
115
115
|
|
|
116
|
-
<!--
|
|
116
|
+
<!-- LongPointField (_lt...) (for faster range queries) -->
|
|
117
117
|
|
|
118
118
|
<dynamicField name="*_lti" type="tlong" stored="false" indexed="true" multiValued="false"/>
|
|
119
119
|
<dynamicField name="*_ltim" type="tlong" stored="false" indexed="true" multiValued="true"/>
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
<dynamicField name="*_dbsi" type="double" stored="true" indexed="true" multiValued="false"/>
|
|
134
134
|
<dynamicField name="*_dbsim" type="double" stored="true" indexed="true" multiValued="true"/>
|
|
135
135
|
|
|
136
|
-
<!--
|
|
136
|
+
<!-- DoublePointField (_dbt...) (for faster range queries) -->
|
|
137
137
|
|
|
138
138
|
<dynamicField name="*_dbti" type="tdouble" stored="false" indexed="true" multiValued="false"/>
|
|
139
139
|
<dynamicField name="*_dbtim" type="tdouble" stored="false" indexed="true" multiValued="true"/>
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
<dynamicField name="*_fsi" type="float" stored="true" indexed="true" multiValued="false"/>
|
|
154
154
|
<dynamicField name="*_fsim" type="float" stored="true" indexed="true" multiValued="true"/>
|
|
155
155
|
|
|
156
|
-
<!--
|
|
156
|
+
<!-- FloatPointField (_ft...) (for faster range queries) -->
|
|
157
157
|
|
|
158
158
|
<dynamicField name="*_fti" type="tfloat" stored="false" indexed="true" multiValued="false"/>
|
|
159
159
|
<dynamicField name="*_ftim" type="tfloat" stored="false" indexed="true" multiValued="true"/>
|
|
@@ -175,6 +175,16 @@
|
|
|
175
175
|
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" />
|
|
176
176
|
|
|
177
177
|
|
|
178
|
+
<!-- location (_ll...) -->
|
|
179
|
+
|
|
180
|
+
<dynamicField name="*_lli" type="location" stored="false" indexed="true" multiValued="false"/>
|
|
181
|
+
<dynamicField name="*_llim" type="location" stored="false" indexed="true" multiValued="true"/>
|
|
182
|
+
|
|
183
|
+
<dynamicField name="*_lls" type="location" stored="true" indexed="false" multiValued="false"/>
|
|
184
|
+
<dynamicField name="*_llsm" type="location" stored="true" indexed="false" multiValued="true"/>
|
|
185
|
+
<dynamicField name="*_llsi" type="location" stored="true" indexed="true" multiValued="false"/>
|
|
186
|
+
<dynamicField name="*_llsim" type="location" stored="true" indexed="true" multiValued="true"/>
|
|
187
|
+
|
|
178
188
|
<dynamicField name="*_srpt" type="location_rpt" stored="true" indexed="true" multiValued="true" />
|
|
179
189
|
<dynamicField name="*_bbox" type="bbox" stored="true" indexed="true" />
|
|
180
190
|
|
|
@@ -221,23 +231,23 @@
|
|
|
221
231
|
<fieldType name="rand" class="solr.RandomSortField" omitNorms="true"/>
|
|
222
232
|
|
|
223
233
|
<!-- Default numeric field types. -->
|
|
224
|
-
<fieldType name="int" class="solr.
|
|
225
|
-
<fieldType name="float" class="solr.
|
|
226
|
-
<fieldType name="long" class="solr.
|
|
227
|
-
<fieldType name="double" class="solr.
|
|
234
|
+
<fieldType name="int" class="solr.IntPointField" docValues="true"/>
|
|
235
|
+
<fieldType name="float" class="solr.FloatPointField" docValues="true"/>
|
|
236
|
+
<fieldType name="long" class="solr.LongPointField" docValues="true"/>
|
|
237
|
+
<fieldType name="double" class="solr.DoublePointField" docValues="true"/>
|
|
228
238
|
|
|
229
|
-
<!--
|
|
230
|
-
<fieldType name="tint" class="solr.
|
|
231
|
-
<fieldType name="tfloat" class="solr.
|
|
232
|
-
<fieldType name="tlong" class="solr.
|
|
233
|
-
<fieldType name="tdouble" class="solr.
|
|
239
|
+
<!-- PointField numeric field types for faster range queries -->
|
|
240
|
+
<fieldType name="tint" class="solr.IntPointField" docValues="true"/>
|
|
241
|
+
<fieldType name="tfloat" class="solr.FloatPointField" docValues="true"/>
|
|
242
|
+
<fieldType name="tlong" class="solr.LongPointField" docValues="true"/>
|
|
243
|
+
<fieldType name="tdouble" class="solr.DoublePointField" docValues="true"/>
|
|
234
244
|
|
|
235
245
|
<!-- The format for this date field is of the form 1995-12-31T23:59:59Z
|
|
236
246
|
Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
|
|
237
247
|
-->
|
|
238
|
-
<fieldType name="date" class="solr.
|
|
239
|
-
<!-- A
|
|
240
|
-
<fieldType name="tdate" class="solr.
|
|
248
|
+
<fieldType name="date" class="solr.DatePointField" docValues="true"/>
|
|
249
|
+
<!-- A PointField based date field for faster date range queries and date faceting. -->
|
|
250
|
+
<fieldType name="tdate" class="solr.DatePointField" docValues="true"/>
|
|
241
251
|
|
|
242
252
|
|
|
243
253
|
<!-- This point type indexes the coordinates as separate fields (subFields)
|
|
@@ -253,6 +263,9 @@
|
|
|
253
263
|
-->
|
|
254
264
|
<fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
|
|
255
265
|
|
|
266
|
+
<!-- A specialized field for geospatial search filters and distance sorting. -->
|
|
267
|
+
<fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true"/>
|
|
268
|
+
|
|
256
269
|
<!-- An alternative geospatial field type new to Solr 4. It supports multiValued and polygon shapes.
|
|
257
270
|
For more information about this and other Spatial fields new to Solr 4, see:
|
|
258
271
|
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
|
@@ -263,7 +276,7 @@
|
|
|
263
276
|
<field name="bbox" type="bbox" />
|
|
264
277
|
<fieldType name="bbox" class="solr.BBoxField"
|
|
265
278
|
geo="true" distanceUnits="kilometers" numberType="_bbox_coord" storeSubFields="false"/>
|
|
266
|
-
<fieldType name="_bbox_coord" class="solr.
|
|
279
|
+
<fieldType name="_bbox_coord" class="solr.DoublePointField" docValues="true" stored="false"/>
|
|
267
280
|
|
|
268
281
|
<fieldType name="text" class="solr.TextField" omitNorms="false">
|
|
269
282
|
<analyzer>
|
|
@@ -373,3 +386,4 @@
|
|
|
373
386
|
</types>
|
|
374
387
|
|
|
375
388
|
</schema>
|
|
389
|
+
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
gem 'rails-controller-testing'
|
|
2
2
|
|
|
3
3
|
if ENV['BLACKLIGHT_VERSION']
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if ENV['BLACKLIGHT_VERSION'].start_with?("{")
|
|
7
|
-
gem "blacklight", **JSON.parse(ENV['BLACKLIGHT_VERSION'])
|
|
4
|
+
if ENV['BLACKLIGHT_VERSION'].include?("://")
|
|
5
|
+
gem "blacklight", git: ENV['BLACKLIGHT_VERSION']
|
|
8
6
|
else
|
|
9
7
|
gem "blacklight", ENV['BLACKLIGHT_VERSION']
|
|
10
8
|
end
|
|
11
9
|
end
|
|
12
10
|
|
|
11
|
+
|
|
12
|
+
# pin json to less than 3 in Gemfile until Rails has some releases that work
|
|
13
|
+
# with json 3, at which point we can relax for versions that can handle it
|
|
14
|
+
# https://github.com/rails/rails/pull/58601
|
|
15
|
+
gem "json", "< 3"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Rochkind
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: 7.25.2
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '10'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: 7.25.2
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '10'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: view_component
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -196,6 +196,8 @@ files:
|
|
|
196
196
|
- app/components/blacklight_range_limit/range_facet_component.rb
|
|
197
197
|
- app/components/blacklight_range_limit/range_form_component.html.erb
|
|
198
198
|
- app/components/blacklight_range_limit/range_form_component.rb
|
|
199
|
+
- app/components/blacklight_range_limit/range_input_component.html.erb
|
|
200
|
+
- app/components/blacklight_range_limit/range_input_component.rb
|
|
199
201
|
- app/components/blacklight_range_limit/range_segments_component.html.erb
|
|
200
202
|
- app/components/blacklight_range_limit/range_segments_component.rb
|
|
201
203
|
- app/presenters/blacklight_range_limit/facet_field_presenter.rb
|
|
@@ -280,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
280
282
|
- !ruby/object:Gem::Version
|
|
281
283
|
version: '0'
|
|
282
284
|
requirements: []
|
|
283
|
-
rubygems_version: 3.
|
|
285
|
+
rubygems_version: 3.7.1
|
|
284
286
|
specification_version: 4
|
|
285
287
|
summary: Blacklight Range Limit plugin
|
|
286
288
|
test_files:
|