blacklight_range_limit 8.5.0 → 9.0.0.beta2
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 +117 -26
- data/.gitignore +2 -1
- data/.solr_wrapper.yml +8 -0
- data/Gemfile +7 -1
- data/README.md +84 -87
- data/Rakefile +69 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight-range-limit/index.js +345 -0
- data/app/components/blacklight_range_limit/range_facet_component.html.erb +29 -27
- data/app/components/blacklight_range_limit/range_facet_component.rb +27 -9
- data/app/components/blacklight_range_limit/range_form_component.html.erb +23 -5
- data/app/components/blacklight_range_limit/range_form_component.rb +8 -20
- data/app/presenters/blacklight_range_limit/facet_field_presenter.rb +13 -2
- data/app/presenters/blacklight_range_limit/facet_item_presenter.rb +15 -11
- data/app/presenters/blacklight_range_limit/filter_field.rb +9 -3
- data/blacklight_range_limit.gemspec +1 -1
- data/config/importmap.rb +9 -0
- data/config/locales/blacklight_range_limit.ar.yml +13 -8
- data/config/locales/blacklight_range_limit.de.yml +13 -8
- data/config/locales/blacklight_range_limit.en.yml +5 -1
- data/config/locales/blacklight_range_limit.es.yml +18 -0
- data/config/locales/blacklight_range_limit.it.yml +13 -8
- data/doc/example-screenshot.png +0 -0
- data/lib/blacklight_range_limit/controller_override.rb +8 -35
- data/lib/blacklight_range_limit/engine.rb +48 -0
- data/lib/blacklight_range_limit/range_limit_builder.rb +61 -3
- data/lib/blacklight_range_limit.rb +10 -30
- data/lib/generators/blacklight_range_limit/assets_generator.rb +82 -18
- data/lib/generators/blacklight_range_limit/install_generator.rb +5 -2
- data/lib/generators/blacklight_range_limit/jsbundling_bl7_fixup_generator.rb +98 -0
- data/package-lock.json +8 -7
- data/package.json +10 -14
- data/spec/components/range_facet_component_spec.rb +101 -32
- data/spec/components/range_form_component_spec.rb +2 -2
- data/spec/components/range_segments_component_spec.rb +64 -0
- data/spec/features/blacklight_range_limit_spec.rb +21 -13
- data/spec/features/run_through_spec.rb +210 -0
- data/spec/presenters/facet_field_presenter_spec.rb +72 -0
- data/spec/presenters/filter_field_spec.rb +36 -1
- data/spec/requests/bad_param_requests_spec.rb +61 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/test_app_templates/Gemfile.extra +11 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +37 -6
- metadata +27 -51
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js +0 -534
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map +0 -1
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js +0 -542
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map +0 -1
- data/app/assets/javascripts/blacklight_range_limit.js +0 -27
- data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +0 -60
- data/app/assets/stylesheets/blacklight_range_limit.css +0 -7
- data/app/helpers/range_limit_helper.rb +0 -130
- data/app/javascript/blacklight_range_limit/index.js +0 -11
- data/app/javascript/blacklight_range_limit/range_limit_distro_facets.js +0 -76
- data/app/javascript/blacklight_range_limit/range_limit_plotting.js +0 -186
- data/app/javascript/blacklight_range_limit/range_limit_shared.js +0 -112
- data/app/javascript/blacklight_range_limit/range_limit_slider.js +0 -163
- data/app/javascripts/blacklight_range_limit/index.js +0 -13
- data/app/views/blacklight_range_limit/_range_segments.html.erb +0 -8
- data/app/views/blacklight_range_limit/range_segments.html.erb +0 -1
- data/app/views/catalog/range_limit_panel.html.erb +0 -1
- data/rollup.config.js +0 -37
- data/spec/features/a_javascript_spec.rb +0 -70
- data/spec/helpers/blacklight_range_limit_helper_spec.rb +0 -37
- data/vendor/assets/javascripts/bootstrap-slider.js +0 -388
- data/vendor/assets/javascripts/flot/jquery.canvaswrapper.js +0 -549
- data/vendor/assets/javascripts/flot/jquery.colorhelpers.js +0 -199
- data/vendor/assets/javascripts/flot/jquery.event.drag.js +0 -145
- data/vendor/assets/javascripts/flot/jquery.flot.browser.js +0 -98
- data/vendor/assets/javascripts/flot/jquery.flot.drawSeries.js +0 -662
- data/vendor/assets/javascripts/flot/jquery.flot.hover.js +0 -359
- data/vendor/assets/javascripts/flot/jquery.flot.js +0 -2818
- data/vendor/assets/javascripts/flot/jquery.flot.saturated.js +0 -43
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +0 -527
- data/vendor/assets/javascripts/flot/jquery.flot.uiConstants.js +0 -10
- data/vendor/assets/stylesheets/slider.css +0 -138
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfe80b379721a4e19e01ecb97a0f1ca6335e2e85ae3914abec0f2ae9ee9546b6
|
4
|
+
data.tar.gz: cdc7468b2f1e7f649f72a9f4200948cbc543d9f1e6a86bcac03b467c65b18ba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df819d6ceb0f782c612d1eb83648a178ed2f555b599df666240cfa2cc7a75d0b3554ff29ff12ada5bdf3766bb74be88b76d054a95fd233d41309d2737bcb6cf2
|
7
|
+
data.tar.gz: 269df83223ddbed2fa371c9b0aa1ebc6d5afff775d5a313a6482ba8948412456b59bbe7b1b438e51143fe2941c3e643b3ba98f5a918287ce32b4867542871c69
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,40 +9,131 @@ name: CI
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [
|
12
|
+
branches: [main]
|
13
13
|
pull_request:
|
14
|
-
branches: [
|
14
|
+
branches: ['**']
|
15
15
|
|
16
16
|
jobs:
|
17
17
|
test:
|
18
18
|
runs-on: ubuntu-latest
|
19
|
-
name: test (
|
19
|
+
name: test (${{ matrix.blacklight_version && format('bl {0} / ', matrix.blacklight_version) }}rails ${{ matrix.rails_version }} / rb ${{ matrix.ruby }} ${{ matrix.additional_name }})
|
20
20
|
strategy:
|
21
|
+
fail-fast: false
|
21
22
|
matrix:
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
# We have SEVERAL axes of difference we support.
|
24
|
+
#
|
25
|
+
# * Blacklight: 7, 8, or 9
|
26
|
+
# * Rails: 7 or 8
|
27
|
+
# * sprockets or propshaft(with cssbundling-rails sass)
|
28
|
+
# * importmap-rails or esbuild (each with sprockets or importmaps)
|
29
|
+
#
|
30
|
+
# We should work with almost every combo of these (even though BL itself
|
31
|
+
# doesn't officially support every one), but we don't test with every one,
|
32
|
+
# that'd be too much. Plus BL can't *generate* every one even though it
|
33
|
+
# can be made to work with every one. We test with some good significant
|
34
|
+
# representative samples.
|
35
|
+
|
25
36
|
include:
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rails_version:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
# BLACKLIGHT EDGE, can test with Rails 8 beta, importmap and esbuild
|
38
|
+
#
|
39
|
+
|
40
|
+
- rails_version: "~> 8.0.0"
|
41
|
+
blacklight_version: '{ "git": "https://github.com/projectblacklight/blacklight.git" }'
|
42
|
+
ruby: "3.3"
|
43
|
+
additional_name: "/ importmap-rails"
|
44
|
+
additional_engine_cart_rails_options: "--css=bootstrap"
|
45
|
+
- rails_version: "~> 8.0.0"
|
46
|
+
blacklight_version: '{ "git": "https://github.com/projectblacklight/blacklight.git" }'
|
47
|
+
ruby: "3.3"
|
48
|
+
additional_name: "/ esbuild"
|
49
|
+
additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
# BLACKLIGHT 8, can test with use importmaps and esbuild
|
54
|
+
#
|
55
|
+
|
56
|
+
- rails_version: "7.2.1"
|
57
|
+
blacklight_version: "~> 8.0"
|
58
|
+
ruby: "3.3"
|
59
|
+
additional_name: "/ importmap-rails, sprockets"
|
60
|
+
- rails_version: "7.2.1"
|
61
|
+
blacklight_version: "~> 8.0"
|
62
|
+
ruby: "3.3"
|
63
|
+
additional_name: "/ importmap-rails, propshaft"
|
64
|
+
additional_engine_cart_rails_options: "-a propshaft --css=bootstrap"
|
65
|
+
- rails_version: "7.2.1"
|
66
|
+
blacklight_version: "~> 8.0"
|
67
|
+
ruby: 3.3
|
68
|
+
additional_engine_cart_rails_options: "-a propshaft --javascript=esbuild --css=bootstrap"
|
69
|
+
additional_name: "/ esbuild, propshaft"
|
70
|
+
|
71
|
+
# We can't currently test Blacklight 8 in a few situations we'd like to.
|
72
|
+
#
|
73
|
+
# * Blacklight 8 can't easily generate an app with Rails 7 and sprockets and esbuild
|
74
|
+
# (the default layout won't be right), although I think it should work fine.
|
75
|
+
#
|
76
|
+
# * Can't test with unreleaed Blacklight main and esbuild because the blacklight-frontend
|
77
|
+
# npm package doens't work from git checkout. So currently can't test with Rails8
|
78
|
+
# and esbuild.
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
# BLACKLIGHT 7, only test with esbuild, not sure if it supports importmaps, it won't generate it
|
83
|
+
|
84
|
+
- rails_version: "7.2.1"
|
85
|
+
blacklight_version: "~> 7.0"
|
86
|
+
ruby: "3.3"
|
87
|
+
additional_engine_cart_rails_options: "--javascript=esbuild"
|
88
|
+
additional_name: "/ esbuild, sprockets"
|
89
|
+
- rails_version: "7.2.1"
|
90
|
+
blacklight_version: "~> 7.0"
|
91
|
+
ruby: "3.3"
|
92
|
+
additional_engine_cart_rails_options: "--javascript=esbuild --css=bootstrap -a propshaft"
|
93
|
+
additional_name: "/ esbuild, propshaft"
|
94
|
+
|
95
|
+
- rails_version: "7.1.4"
|
96
|
+
blacklight_version: "~> 7.0"
|
97
|
+
ruby: "3.2"
|
98
|
+
additional_engine_cart_rails_options: "--javascript=esbuild"
|
99
|
+
additional_name: "/ esbuild, sprockets"
|
100
|
+
|
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
|
+
|
34
111
|
env:
|
35
|
-
BLACKLIGHT_VERSION:
|
112
|
+
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version || '~> 8.0' }}
|
36
113
|
RAILS_VERSION: ${{ matrix.rails_version }}
|
37
|
-
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.
|
114
|
+
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
|
38
115
|
steps:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
116
|
+
- uses: actions/checkout@v4
|
117
|
+
- name: Set up Ruby
|
118
|
+
uses: ruby/setup-ruby@v1
|
119
|
+
with:
|
120
|
+
ruby-version: ${{ matrix.ruby }}
|
121
|
+
bundler: "latest"
|
122
|
+
|
123
|
+
- name: Install dependencies
|
124
|
+
run: bundle install
|
125
|
+
|
126
|
+
# Try to cache solr dist download, which may not save us much time,
|
127
|
+
# but hopes to save us from being throttled/blocked on some runs by
|
128
|
+
# apache foundation servers unhappy that we're downloading the dist zip
|
129
|
+
# so much.
|
130
|
+
- name: Cache solr install
|
131
|
+
uses: actions/cache@v3
|
132
|
+
with:
|
133
|
+
# these paths specified in .solr_wrapper.yml:
|
134
|
+
path: |
|
135
|
+
ci_dl_solr_dist
|
136
|
+
key: ${{ runner.os }}-solr-${{ hashFiles('.solr_wrapper.yml') }}
|
137
|
+
|
138
|
+
- name: Run tests
|
139
|
+
run: bundle exec rake ci
|
data/.gitignore
CHANGED
data/.solr_wrapper.yml
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Place any default configuration for solr_wrapper here
|
2
|
+
#
|
3
|
+
# We try to use a cacheable and cached location for solr at tmp/solr_dist
|
4
|
+
# in Github Actions CI, to avoid excessive downloads from
|
5
|
+
# apache (which also get sometimes blocked/rate-limited)
|
6
|
+
|
2
7
|
port: 8983
|
3
8
|
verbose: true
|
9
|
+
version: 9.6.1
|
10
|
+
<% ENV['CI'] && FileUtils.mkdir_p('ci_dl_solr_dist') %>
|
11
|
+
download_dir: <%= 'ci_dl_solr_dist' if ENV['CI'] %>
|
4
12
|
collection:
|
5
13
|
dir: solr/conf/
|
6
14
|
name: blacklight-core
|
data/Gemfile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
source 'https://rubygems.org'
|
4
5
|
|
@@ -14,7 +15,12 @@ end
|
|
14
15
|
# a blacklight version other than the latest allowed by gemspec, to get
|
15
16
|
# tests to pass, or to test on older BL still supported here.
|
16
17
|
if ENV['BLACKLIGHT_VERSION']
|
17
|
-
|
18
|
+
# allow direct git and other with serialized json kw args
|
19
|
+
if ENV['BLACKLIGHT_VERSION'].start_with?("{")
|
20
|
+
gem "blacklight", **JSON.parse(ENV['BLACKLIGHT_VERSION'])
|
21
|
+
else
|
22
|
+
gem "blacklight", ENV['BLACKLIGHT_VERSION']
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
# BEGIN ENGINE_CART BLOCK
|
data/README.md
CHANGED
@@ -8,151 +8,155 @@ BlacklightRangeLimit: integer range limiting and profiling for Blacklight appli
|
|
8
8
|
|
9
9
|
The BlacklightRangeLimit plugin provides a 'facet' or limit for integer fields, that lets the user enter range limits with a text box or a slider, and also provides area charts giving a sense of the distribution of values (with drill down).
|
10
10
|
|
11
|
-
The primary use case of this plugin is for 'year' data, but it should work for any integer field.
|
11
|
+
The primary use case of this plugin is for 'year' data, but it should work for any integer field.
|
12
12
|
|
13
13
|
Decimal numbers and Dates are NOT supported; they theoretically could be in the future, although it gets tricky.
|
14
14
|
|
15
15
|
|
16
16
|
# Requirements
|
17
17
|
|
18
|
-
A Solr integer field.
|
18
|
+
* A Solr integer field. It might be advantageous to use an IntPointField.
|
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
|
-
|
22
|
+
* Blacklight 7.0+. Rails 7.0+
|
23
23
|
|
24
|
-
You need to use a "sortable" numeric-type field. In Solr 1.4, the standard "int"/solr.TrieIntField should work fine and is probably prefered. For some distributions of data, it may be more efficient to use "tint" (solr.TrieIntField with non-zero precision).
|
25
|
-
|
26
|
-
The pre Solr 1.4 now deprecated sint or slong types should work fine too.
|
27
24
|
|
28
25
|
# Installation
|
29
26
|
|
30
|
-
Current 5.x version of `blacklight_range_limit` work with `blacklight` 5.x -- we now synchronize the _major version number_ between `blacklight` and `blacklight_range_limit`. `blacklight_range_limit` 2.1 is the last version believed to work with blacklight 4.x or possibly blacklight 3.x.
|
31
|
-
|
32
27
|
Add
|
33
28
|
|
34
29
|
gem "blacklight_range_limit"
|
35
30
|
|
36
|
-
to your Gemfile. Run
|
31
|
+
to your Gemfile. Run `bundle install`.
|
37
32
|
|
38
|
-
|
33
|
+
Run `rails generate blacklight_range_limit:install`
|
39
34
|
|
40
|
-
|
35
|
+
### Manual Javascript setup is not hard
|
41
36
|
|
42
|
-
|
37
|
+
The installer could have trouble figuring out how to add Javascript to your particular setup. If it's not working right and you want the installer to skip asset generation, you can execute as `rails generate blacklight_range_limit:install --skip-assets`.
|
43
38
|
|
44
|
-
# Configuration
|
45
39
|
|
46
|
-
|
40
|
+
In the end, all you need is `blacklight-range-limit` either importmap-pinned (with its chart.js dependency), or added to your package.json, and then, in a file that has access to the `Blacklight` import:
|
41
|
+
|
42
|
+
import BlacklightRangeLimit from "blacklight-range-limit";
|
43
|
+
BlacklightRangeLimit.init({ onLoadHandler: Blacklight.onLoad });
|
44
|
+
|
45
|
+
A package.json might include:
|
47
46
|
|
48
|
-
```ruby
|
49
|
-
config.add_facet_field 'pub_date', label: 'Publication Year', **default_range_config
|
50
47
|
```
|
48
|
+
"blacklight-range-limit": "^9.0.0",
|
49
|
+
```
|
50
|
+
(direct to git references also supported in package.json)
|
51
51
|
|
52
|
-
|
52
|
+
importmap.rb pins might look like:
|
53
|
+
|
54
|
+
```
|
55
|
+
pin "chart.js", to: "https://ga.jspm.io/npm:chart.js@4.2.0/dist/chart.js"
|
56
|
+
pin "@kurkle/color", to: "https://ga.jspm.io/npm:@kurkle/color@0.3.2/dist/color.esm.js"
|
57
|
+
```
|
58
|
+
|
59
|
+
For import map pins, note:
|
60
|
+
* The standard "locally vendored" importmap-rails setup is not working with chart.js at the time of this writing, so you need to pin to CDN as above.
|
61
|
+
* versions in importmap pins will have to be updated manually if you want to upgrade.
|
62
|
+
|
63
|
+
### Unreleased version?
|
64
|
+
|
65
|
+
If you'd like to use an unreleased version from git, just add that to your Gemfile in the usual way.
|
66
|
+
|
67
|
+
importmap-rails use should then Just Work.
|
68
|
+
|
69
|
+
package.json-based use will additionally need to point to the matching unreleaesd version in git in package.json, eg `yarn add blacklight-range-limit@git+https://github.com/projectblacklight/blacklight_range_limit.git#branch_name_or_commit_sha`. Still simple.
|
53
70
|
|
54
71
|
|
55
|
-
|
72
|
+
# Facet Configuration
|
56
73
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
series: { lines: { fillColor: 'rgba(255,255,255, 0.5)' }},
|
62
|
-
grid: { color: '#aaaaaa', tickColor: '#aaaaaa', borderWidth: 0 }
|
63
|
-
});
|
74
|
+
You have at least one solr field you want to display as a range limit, that's why you've installed this plugin. In your CatalogController, the facet configuration should look like:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
config.add_facet_field 'pub_date', label: 'Publication Year', range: true
|
64
78
|
```
|
65
|
-
|
79
|
+
|
80
|
+
You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
|
66
81
|
|
67
82
|
## A note on AJAX use
|
68
83
|
|
69
84
|
In order to calculate distribution segment ranges, we need to first know the min and max boundaries. But we don't really know that until we've fetched the result set (we use the Solr Stats component to get min and max with a result set).
|
70
85
|
|
71
|
-
So, ordinarily, after we've gotten the result set,
|
72
|
-
|
73
|
-
The plugin uses an AJAX request on the result page to do this. This means that for every application results display that includes any values at all in your range field, your application will get a second AJAX http request, and make a second solr request.
|
86
|
+
So, ordinarily, after we've gotten the result set, an additional round trip to back-end and solr will happen, with min max identified, to fetch segments.
|
74
87
|
|
75
|
-
If you'd like to avoid this, you can
|
88
|
+
If you'd like to avoid this, you can set :assumed_boundaries below to use fixed boundaries for not-yet-limited segments instead of taking boundaries from the result set. Or you can disable the segment behavior by setting `chart_js` and `textual_facets` both to false.
|
76
89
|
|
77
90
|
Note that a drill-down will never require the second request, because boundaries on a drill-down are always taken from the specified limits.
|
78
91
|
|
79
92
|
|
80
93
|
## Range Facet Configuration
|
81
94
|
|
82
|
-
|
95
|
+
There are some additional configuration options that can be passed in facet config in the `range_config` key. You can pass some or all of them like this:
|
83
96
|
|
84
97
|
```ruby
|
85
|
-
config.add_facet_field 'pub_date', label: 'Publication Year',
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
98
|
+
config.add_facet_field 'pub_date', label: 'Publication Year', range_config: {
|
99
|
+
num_segments: 6,
|
100
|
+
assumed_boundaries: [1100, Time.now.year + 2],
|
101
|
+
segments: true,
|
102
|
+
chart_js: true,
|
103
|
+
textual_facets: true,
|
104
|
+
textual_facets_collapsible: true,
|
105
|
+
show_missing_link: true,
|
106
|
+
chart_segment_border_color: "rgba(0,0,0, 0.5)",
|
107
|
+
chart_segment_bg_color: "#ccddcc",
|
108
|
+
chart_aspect_ratio: "2"
|
109
|
+
}
|
92
110
|
```
|
93
111
|
|
94
112
|
* **:num_segments** :
|
95
113
|
* Default 10. Approximately how many segments to divide the range into for segment facets, which become segments on the chart. Actual segments are calculated to be 'nice' values, so may not exactly match your setting.
|
96
114
|
* **:assumed_boundaries** :
|
97
115
|
* Default null. For a result set that has not yet been limited, instead of taking boundaries from results and making a second AJAX request to fetch segments, just assume these given boundaries. If you'd like to avoid this second AJAX Solr call, you can set :assumed_boundaries to a two-element array of integers instead, and the assumed boundaries will always be used. Note this is live ruby code, you can put calculations in there like Time.now.year + 2.
|
98
|
-
* **:
|
99
|
-
* Default true. If
|
100
|
-
* **:
|
101
|
-
* Default
|
116
|
+
* **chart_js**:
|
117
|
+
* Default true. If false, the Javascript chart is not loaded, you can still get textual facets for bucket with `textual_facets` config.
|
118
|
+
* **textual_facets**:
|
119
|
+
* Default true. Should we show textual facet list too? Universal design
|
120
|
+
for accessibility, may have accessibilty concerns to turn off.
|
121
|
+
* **textual_facets_collapsible**:
|
122
|
+
* Put the textual facets in a collapse/expand
|
123
|
+
disclosure. If you set chart_js to false, may make sense to set this to false too, to have
|
124
|
+
textual facets only instead of chart?
|
125
|
+
* **show_missing_link**:
|
126
|
+
* Default true. Display a link (with count) to results that are _missing_ a value for the range field.
|
127
|
+
* **chart_segment_border_color** / **chart_segment_bg_color**:
|
128
|
+
* Set colors for the edge and fill of the segment bars in the histogram.
|
129
|
+
* **chart_aspect_ratio**:
|
130
|
+
* Defaults to 2. For chart.js, will fill available width then this determines size of chart.
|
102
131
|
|
103
132
|
## Javascript dependencies
|
104
133
|
|
105
|
-
|
134
|
+
We use [chart.js](https://www.chartjs.org/) to draw the chart. It has one dependency of its own. These need to be either pinned with importmap-rails, or used via the chart.js npm package and an npm-package-based bundler.
|
106
135
|
|
107
|
-
|
136
|
+
There is **no CSS** needed.
|
108
137
|
|
109
|
-
|
138
|
+
## Upgrading from blacklight-range-limit 8.x to 9.x
|
110
139
|
|
111
|
-
|
140
|
+
All back-end configuration should be backwards compatible.
|
112
141
|
|
113
|
-
|
142
|
+
You will need to change how you load JS. (There is no longer any blacklight_range_limit CSS to load).
|
114
143
|
|
115
|
-
|
116
|
-
[bootstrap_slider](http://www.eyecon.ro/bootstrap-slider/), which says if you add
|
117
|
-
Modernizr to your page, touch events will be supported. We haven't tested it
|
118
|
-
ourselves yet.
|
144
|
+
You will need to be using either importmap-rails or a package.json-based javascript bunder (jsbundling-rails or vite) to deliver JS to your app. Legacy sprockets-only is not supported.
|
119
145
|
|
120
|
-
|
121
|
-
is probably the best touch UI anyway, if it can be made to work well.
|
146
|
+
Then, remove ALL existing (sprockets) references to blacklight_range_limit in your JS or CSS pipelines.
|
122
147
|
|
123
|
-
|
148
|
+
And run `rails g blacklight_range_limit:assets` -- or manually set up the JS for unusual setups (such as vite-rails), see above at <a href="#installation">Installation</a>.
|
124
149
|
|
125
|
-
|
126
|
-
|
127
|
-
- Range Limit plugin functionality called from event listeners
|
150
|
+
For an unreleased version from git -- the installer is not presently capable of installing
|
151
|
+
that, but simply add the unreleased version of the gem to your Gemfile.
|
128
152
|
|
129
|
-
The second class of range limit functionality is customizable in your local application by overriding the specified function.
|
130
|
-
|
131
|
-
A simple example of this is overriding the display ratio used to create the histogram
|
132
|
-
|
133
|
-
```javascript
|
134
|
-
BlacklightRangeLimit.display_ratio = 1
|
135
|
-
```
|
136
|
-
|
137
|
-
This will now create a square histogram.
|
138
|
-
|
139
|
-
Not only these variables and functions be customized, you can call them based off of custom events in your application.
|
140
|
-
|
141
|
-
```javascript
|
142
|
-
$('.custom-class').on('doSomething', function() {
|
143
|
-
BlacklightRangeLimit.checkForNeededFacetsToFetch();
|
144
|
-
$(".range_limit .profile .range.slider_js").each(function() {
|
145
|
-
BlacklightRangeLimit.buildSlider(this);
|
146
|
-
});
|
147
|
-
});
|
148
|
-
```
|
149
153
|
|
150
154
|
# Tests
|
151
155
|
|
152
156
|
Test coverage is not great, but there are some tests, using rspec. Run `bundle exec rake ci` or just `bundle exec rake` to seed and
|
153
|
-
start a demo
|
157
|
+
start a demo solr server, build a clean test app, and run tests.
|
154
158
|
|
155
|
-
Just `bundle exec rake spec` to just run tests against an existing test app and
|
159
|
+
Just `bundle exec rake spec` to just run tests against an existing test app and solr server.
|
156
160
|
|
157
161
|
## Local Testing
|
158
162
|
If you want to iterate on a test locally and do not want to rebuild the
|
@@ -172,10 +176,3 @@ Once you are done iterating on your test you will need to stop the application s
|
|
172
176
|
# Publishing Javascript
|
173
177
|
|
174
178
|
run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit
|
175
|
-
|
176
|
-
# Possible future To Do
|
177
|
-
|
178
|
-
* StatsComponent replacement. We use StatsComponent to get min/max of result set, as well as missing count. StatsComponent is included on every non-drilldown request, so ranges and slider can be displayed. However, StatsComponent really can slow down the solr response with a large result set. So replace StatsComponent with other strategies. No ideal ones, we can use facet.missing to get missing count instead, but RSolr makes it harder than it should be to grab this info. We can use seperate solr queries to get min/max (sort on our field, asc and desc), but this is more complicated, more solr queries, and possibly requires redesign of AJAXy stuff, so even a lone slider can have min/max.
|
179
|
-
* tests
|
180
|
-
* In cases where an AJAX request is needed to fetch more results, don't trigger the AJAX until the range facet has actually been opened/shown. Currently it's done on page load.
|
181
|
-
* If :assumed_boundaries ends up popular, we could provide a method to fetch min and max values from entire corpus on app startup or in a rake task, and automatically use these as :assumed_boundaries.
|
data/Rakefile
CHANGED
@@ -11,6 +11,11 @@ task :default => :ci
|
|
11
11
|
desc "Run specs"
|
12
12
|
RSpec::Core::RakeTask.new
|
13
13
|
|
14
|
+
# rspec hooks up spec task with spec:prepapre dependency. But we need to make sure
|
15
|
+
# it gets called *within test app* so for jsbundling-rails JS is properly built.
|
16
|
+
# So we add our custom as a dependency.
|
17
|
+
task spec: ["test:spec:prepare"]
|
18
|
+
|
14
19
|
task ci: ['engine_cart:generate'] do
|
15
20
|
SolrWrapper.wrap do |solr|
|
16
21
|
solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path(File.dirname(__FILE__)), "solr", "conf")) do
|
@@ -20,7 +25,55 @@ task ci: ['engine_cart:generate'] do
|
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
28
|
+
desc "check npm and gem versions match before release"
|
29
|
+
task :guard_version_match do
|
30
|
+
gem_version = File.read(__dir__ + "/VERSION").chomp
|
31
|
+
npm_version = JSON.parse(File.read(__dir__ + "/package.json"))["version"]
|
32
|
+
|
33
|
+
# 9.0.0.beta1 in gem becomes 9.0.0-beta1 in npm
|
34
|
+
gem_version_parts = gem_version.split(".")
|
35
|
+
npm_version_required = [
|
36
|
+
gem_version_parts.slice(0, 3).join("."),
|
37
|
+
gem_version_parts.slice(3, gem_version_parts.length).join(".")
|
38
|
+
].join("-")
|
39
|
+
|
40
|
+
if npm_version != npm_version_required
|
41
|
+
raise <<~EOS
|
42
|
+
You should not publish without npm version in package.json matching gem version
|
43
|
+
|
44
|
+
gem version: #{gem_version}
|
45
|
+
package.json version: #{npm_version}
|
46
|
+
|
47
|
+
expected package.json version: #{npm_version_required}
|
48
|
+
|
49
|
+
EOS
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get our guard to run before `rake release`'s, and warning afterwards
|
54
|
+
task "release:guard_clean" => :guard_version_match
|
55
|
+
Rake::Task["guard_version_match"].enhance do
|
56
|
+
puts <<~EOS
|
57
|
+
|
58
|
+
⚠️ Please remember to run `npm publish` the npm package too! ⚠️
|
59
|
+
|
60
|
+
If you don't have permission, please ask someone who does for help.
|
61
|
+
https://www.npmjs.com/package/blacklight-range-limit
|
62
|
+
|
63
|
+
EOS
|
64
|
+
end
|
65
|
+
|
66
|
+
|
23
67
|
namespace :test do
|
68
|
+
namespace :spec do
|
69
|
+
desc "call task spec:prepare within test app"
|
70
|
+
task :prepare do
|
71
|
+
within_test_app do
|
72
|
+
system "bin/rake spec:prepare"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
24
77
|
desc "Put sample data into solr"
|
25
78
|
task seed: ['engine_cart:generate'] do
|
26
79
|
within_test_app do
|
@@ -30,6 +83,22 @@ namespace :test do
|
|
30
83
|
end
|
31
84
|
end
|
32
85
|
|
86
|
+
desc "run just solr, useful for local tests"
|
87
|
+
task :solr, [:rails_sever_args] do |_t, args|
|
88
|
+
unless File.exist? EngineCart.destination
|
89
|
+
Rake::Task['engine_cart:generate'].invoke
|
90
|
+
end
|
91
|
+
|
92
|
+
SolrWrapper.wrap(port: '8983') do |solr|
|
93
|
+
solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path(File.dirname(__FILE__)), "solr", "conf")) do
|
94
|
+
Rake::Task['test:seed'].invoke
|
95
|
+
# sleep forever, make us cntrl-c to get out
|
96
|
+
puts "solr is running on port 8983, ctrl-c to exit..."
|
97
|
+
system "while true; do sleep 10000; done"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
33
102
|
desc 'Run Solr and Blacklight for interactive development'
|
34
103
|
task :server, [:rails_server_args] do |_t, args|
|
35
104
|
if File.exist? EngineCart.destination
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
9.0.0.beta2
|