blacklight_range_limit 8.4.0 → 9.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +117 -23
  3. data/.gitignore +2 -0
  4. data/.solr_wrapper.yml +8 -0
  5. data/Gemfile +7 -1
  6. data/README.md +77 -86
  7. data/Rakefile +31 -0
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight-range-limit/index.js +345 -0
  10. data/app/components/blacklight_range_limit/range_facet_component.html.erb +29 -27
  11. data/app/components/blacklight_range_limit/range_facet_component.rb +15 -9
  12. data/app/components/blacklight_range_limit/range_form_component.html.erb +13 -5
  13. data/app/components/blacklight_range_limit/range_form_component.rb +8 -20
  14. data/app/presenters/blacklight_range_limit/facet_field_presenter.rb +13 -2
  15. data/app/presenters/blacklight_range_limit/facet_item_presenter.rb +6 -11
  16. data/app/presenters/blacklight_range_limit/filter_field.rb +2 -2
  17. data/blacklight_range_limit.gemspec +1 -1
  18. data/config/importmap.rb +9 -0
  19. data/config/locales/blacklight_range_limit.ar.yml +13 -8
  20. data/config/locales/blacklight_range_limit.de.yml +13 -8
  21. data/config/locales/blacklight_range_limit.en.yml +5 -1
  22. data/config/locales/blacklight_range_limit.es.yml +18 -0
  23. data/config/locales/blacklight_range_limit.it.yml +13 -8
  24. data/lib/blacklight_range_limit/controller_override.rb +1 -25
  25. data/lib/blacklight_range_limit/engine.rb +48 -0
  26. data/lib/blacklight_range_limit/range_limit_builder.rb +40 -3
  27. data/lib/blacklight_range_limit.rb +8 -31
  28. data/lib/generators/blacklight_range_limit/assets_generator.rb +82 -18
  29. data/lib/generators/blacklight_range_limit/install_generator.rb +1 -1
  30. data/lib/generators/blacklight_range_limit/jsbundling_bl7_fixup_generator.rb +98 -0
  31. data/package-lock.json +51 -0
  32. data/package.json +10 -11
  33. data/spec/components/range_facet_component_spec.rb +41 -32
  34. data/spec/components/range_form_component_spec.rb +2 -2
  35. data/spec/components/range_segments_component_spec.rb +64 -0
  36. data/spec/features/blacklight_range_limit_spec.rb +21 -13
  37. data/spec/features/run_through_spec.rb +157 -0
  38. data/spec/presenters/facet_field_presenter_spec.rb +72 -0
  39. data/spec/presenters/filter_field_spec.rb +36 -1
  40. data/spec/spec_helper.rb +10 -0
  41. data/spec/test_app_templates/Gemfile.extra +11 -1
  42. data/spec/test_app_templates/lib/generators/test_app_generator.rb +37 -6
  43. metadata +26 -44
  44. data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +0 -77
  45. data/app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js +0 -185
  46. data/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +0 -73
  47. data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +0 -161
  48. data/app/assets/javascripts/blacklight_range_limit.js +0 -25
  49. data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +0 -60
  50. data/app/assets/stylesheets/blacklight_range_limit.css +0 -7
  51. data/app/helpers/range_limit_helper.rb +0 -130
  52. data/app/views/blacklight_range_limit/_range_segments.html.erb +0 -8
  53. data/app/views/blacklight_range_limit/range_segments.html.erb +0 -1
  54. data/app/views/catalog/range_limit_panel.html.erb +0 -1
  55. data/spec/features/a_javascript_spec.rb +0 -70
  56. data/spec/helpers/blacklight_range_limit_helper_spec.rb +0 -37
  57. data/vendor/assets/javascripts/bootstrap-slider.js +0 -388
  58. data/vendor/assets/javascripts/flot/jquery.canvaswrapper.js +0 -549
  59. data/vendor/assets/javascripts/flot/jquery.colorhelpers.js +0 -199
  60. data/vendor/assets/javascripts/flot/jquery.event.drag.js +0 -145
  61. data/vendor/assets/javascripts/flot/jquery.flot.browser.js +0 -98
  62. data/vendor/assets/javascripts/flot/jquery.flot.drawSeries.js +0 -662
  63. data/vendor/assets/javascripts/flot/jquery.flot.hover.js +0 -359
  64. data/vendor/assets/javascripts/flot/jquery.flot.js +0 -2818
  65. data/vendor/assets/javascripts/flot/jquery.flot.saturated.js +0 -43
  66. data/vendor/assets/javascripts/flot/jquery.flot.selection.js +0 -527
  67. data/vendor/assets/javascripts/flot/jquery.flot.uiConstants.js +0 -10
  68. data/vendor/assets/stylesheets/slider.css +0 -138
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 510a2e212fd11cacd9e7a83be02dec8ddec4f5e3e551fb64187f022825ae2661
4
- data.tar.gz: c7505814e1172ff021da4ecd65fc7085639771138cf557cf6343707cad9ad577
3
+ metadata.gz: 8f262cbfeff305e3cd1567ffcd35b90e647d3afd3558b95cf9a2f739381b20ff
4
+ data.tar.gz: ddfa401cafc2c1dac75d06c13a2214c7abf2f96fce4dd1421bc0c4a343e0ad8f
5
5
  SHA512:
6
- metadata.gz: 5c6ef8dd3df728ab8790ddb050ab05f4ff1d72053410af3a138891160f9cb00d287d341586463e6e91081ea271f6c2afaa08773420177d3d455f966fa366b789
7
- data.tar.gz: 8c91836e3eaa68af79f7192d18a81a1c0d57f3d6f8d49d0a1fa278ffc657dc597bfe01294e12e87f7954972c3a9f47ac1cd8a479a9279292b81d20cb637de791
6
+ metadata.gz: 914a2910f0b99f6a9223cbdb32779c7a862d19a4d0d0c3ca973383c90e45e05fcf04fdc928ed3a7f7c0222ee87924071ae2af9cd4f219479adabd2601634d2f0
7
+ data.tar.gz: 8a11a84d0c57be9a3036518d284bd2f698e70303fbfcde30ad2d3ee66c4018ae15543df19c6d010423b724fb1452998faa3129682a6ce13f7300746e0a68e5b8
@@ -9,37 +9,131 @@ name: CI
9
9
 
10
10
  on:
11
11
  push:
12
- branches: [ main ]
12
+ branches: [main]
13
13
  pull_request:
14
- branches: [ main ]
14
+ branches: [main]
15
15
 
16
16
  jobs:
17
17
  test:
18
18
  runs-on: ubuntu-latest
19
- name: test (ruby ${{ matrix.ruby }} / rails ${{ matrix.rails_version }})
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
- ruby: [2.7, '3.0']
23
- rails_version: ['6.1.7.1', '7.0.4.1']
24
- additional_engine_cart_rails_options: ['']
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
- - ruby: '3.2'
27
- rails_version: '7.0.4.1'
28
- - ruby: '3.1'
29
- rails_version: '7.0.4.1'
30
- - ruby: '3.0'
31
- rails_version: '7.0.4.1'
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
+
32
111
  env:
33
- BLACKLIGHT_VERSION: "~> 7.0" # only test on BL 7 for now
112
+ BLACKLIGHT_VERSION: ${{ matrix.blacklight_version || '~> 8.0' }}
34
113
  RAILS_VERSION: ${{ matrix.rails_version }}
35
- ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.engine_cart_rails_options }}"
114
+ ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
36
115
  steps:
37
- - uses: actions/checkout@v3
38
- - name: Set up Ruby
39
- uses: ruby/setup-ruby@v1
40
- with:
41
- ruby-version: ${{ matrix.ruby }}
42
- - name: Install dependencies
43
- run: bundle install
44
- - name: Run tests
45
- run: bundle exec rake ci
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
@@ -23,7 +23,9 @@ Gemfile.lock
23
23
 
24
24
  /spec/internal
25
25
  .internal_test_app
26
+ spec/examples.txt
26
27
  /jetty
27
28
  /pkg
28
29
  /tmp
29
30
  /.bundle
31
+ /node_modules
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
- gem "blacklight", ENV['BLACKLIGHT_VERSION']
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,148 @@ 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. It may not work right for negative numbers, however.
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. Depending on your data, it may or may not be advantageous to use a tint (trie with non-zero precision) type field.
18
+ * A Solr integer field. It might be advantageous to use an IntPointField.
19
19
 
20
- ## Note on solr field types
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
- If all your integers are the same number of digits, you can use just about any solr type, including string/type, and all will be well. But if your integers vary in digits, strings won't sort correctly, making your numbers behave oddly in partitions and limits. This is also true if you use a pre-1.4 "integer"/pint/solr.IntField field -- these are not "sortable".
22
+ * Blaklight 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 "bundle install".
31
+ to your Gemfile. Run `bundle install`.
37
32
 
38
- Then run
33
+ Run `rails generate blacklight_range_limit:install`
39
34
 
40
- rails generate blacklight_range_limit:install
35
+ ### Manual Javascript setup is not hard
41
36
 
42
- This will install some asset references in your application.js and application.css.
37
+ The installer could have trouble figuring out how to add Javascript to your particular setup. In the end, all you need is `blacklight-range-limit` either importmap-pinned (with it's chart.js dependency), or added to your package.json, and then, in a file that has access to the `Blacklight` import:
43
38
 
44
- # Configuration
39
+ import BlacklightRangeLimit from "blacklight-range-limit";
40
+ BlacklightRangeLimit.init({ onLoadHandler: Blacklight.onLoad });
45
41
 
46
- 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:
42
+ A package.json might include:
47
43
 
48
- ```ruby
49
- config.add_facet_field 'pub_date', label: 'Publication Year', **default_range_config
50
44
  ```
45
+ "blacklight-range-limit": "^9.0.0",
46
+ ```
47
+ (direct to git references also supported in package.json)
51
48
 
52
- You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
49
+ importmap.rb pins might look like:
53
50
 
51
+ ```
52
+ pin "chart.js", to: "https://ga.jspm.io/npm:chart.js@4.2.0/dist/chart.js"
53
+ pin "@kurkle/color", to: "https://ga.jspm.io/npm:@kurkle/color@0.3.2/dist/color.esm.js"
54
+ ```
54
55
 
55
- You can also configure the look and feel of the Flot chart using the jQuery .data() method. On the `.blrl-plot-config` or `.facet-limit` container you want to configure, add a Flot options associative array (documented at http://people.iola.dk/olau/flot/API.txt) as the `plot-config` key. The `plot-config` key to set the `plot-config` key on the appropriate `.blrl-plot-config` or `.facet-limit` container. In order to customize the plot colors, for example, you could use this code:
56
+ For import map pins, note:
57
+ * 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.
58
+ * versions in importmap pins will have to be updated manually if you want to upgrade.
56
59
 
57
- ```javascript
58
- $('.blacklight-year_i').data('plot-config', {
59
- selection: { color: '#C0FF83' },
60
- colors: ['#ffffff'],
61
- series: { lines: { fillColor: 'rgba(255,255,255, 0.5)' }},
62
- grid: { color: '#aaaaaa', tickColor: '#aaaaaa', borderWidth: 0 }
63
- });
60
+ ### Unreleased version?
61
+
62
+ If you'd like to use an unrelased version from git, just add that to your Gemfile in the usual way.
63
+
64
+ importmap-rails use should then Just Work.
65
+
66
+ 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.
67
+
68
+
69
+ # Facet Configuration
70
+
71
+ 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:
72
+
73
+ ```ruby
74
+ config.add_facet_field 'pub_date', label: 'Publication Year', range: true
64
75
  ```
65
- You can add this configuration in app/assets/javascript/application.js, or anywhere else loaded before the blacklight range limit javascript.
76
+
77
+ You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
66
78
 
67
79
  ## A note on AJAX use
68
80
 
69
81
  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
82
 
71
- So, ordinarily, after we've gotten the result set, only then can we calculate the segment ranges, and then we need to do another Solr request to actually fetch the segment range counts.
83
+ 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.
72
84
 
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.
74
-
75
- If you'd like to avoid this, you can turn off segment display altogether with the :segment option below; or you can set :assumed_boundaries below to use fixed boundaries for not-yet-limited segments instead of taking boundaries from the result set.
85
+ 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
86
 
77
87
  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
88
 
79
89
 
80
90
  ## Range Facet Configuration
81
91
 
82
- Instead of simply passing "true", you can pass a hash with additional configuration. Here's an example with all the available keys, you don't need to use them all, just the ones you want to set to non-default values.
92
+ 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
93
 
84
94
  ```ruby
85
- config.add_facet_field 'pub_date', label: 'Publication Year',
86
- range: {
87
- num_segments: 6,
88
- assumed_boundaries: [1100, Time.now.year + 2],
89
- segments: false,
90
- maxlength: 4
91
- }
95
+ config.add_facet_field 'pub_date', label: 'Publication Year', range_config: {
96
+ num_segments: 6,
97
+ assumed_boundaries: [1100, Time.now.year + 2],
98
+ segments: true,
99
+ chart_js: true,
100
+ textual_facets: true,
101
+ textual_facets_collapsible: true,
102
+ chart_segment_border_color: "rgba(0,0,0, 0.5)",
103
+ chart_segment_bg_color: "#ccddcc",
104
+ chart_aspect_ratio: "2"
105
+ }
106
+ )
92
107
  ```
93
108
 
94
109
  * **:num_segments** :
95
110
  * 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
111
  * **:assumed_boundaries** :
97
112
  * 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
- * **:segments** :
99
- * Default true. If set to false, then distribution segment facets will not be loaded at all.
100
- * **:maxlength** :
101
- * Default 4. Changes the value of the `maxlength` attribute of the text boxes, which determines how many digits can be entered.
102
-
103
- ## Javascript dependencies
113
+ * **chart_js**:
114
+ * Default true. If false, the Javascript chart is not loaded, you can still get textual facets for bucket with `textual_facets` config.
115
+ * **textual_facets**: Default true. Should we show textual facet list too? Universal design
116
+ for accessibility, may have accessibilty concerns to turn off.
117
+ * **textual_facets_collapsible**: Put the textual facets in a collapse/expand
118
+ disclosure. If you set chart_js to false, may make sense to set this to false too, to have
119
+ textual facets only instead of chart?
120
+ * **chart_segment_border_color** / **chart_segment_bg_color** :
121
+ * Set colors for the edge and fill of the segment bars in the histogram.
122
+ * chart_aspect_ratio: for chart.js, will fill available width then this determines size of chart. defaults to 2
104
123
 
105
- The selectable histograms/barcharts are done with Javascript, using [Flot](http://code.google.com/p/flot/). Flot requires JQuery, as well as support for the HTML5 canvas element. For the slider, [bootstrap-slider](http://www.eyecon.ro/bootstrap-slider/) is used (bootstrap-slider is actually third party, not officially bootstrap). Flot and bootstrap-slider are both directly included in blacklight_range_limit in vendor, rather than referenced as dependencies.
106
124
 
107
- The blacklight_range_limit installer will add `require 'blacklight_range_limit'` to your `application.js` sprockets manifest. This will include flot, bootstrap-slider, and the blacklight_range_limit glue JS.
108
-
109
- Both flot and blacklight_range_limit's own JS depend on JQuery; the host app is expected to include JQuery; a default Blacklight-generated app already does. (Jquery 1, 2, or 3 should work)
110
-
111
- If you don't want any of this gem's JS, you can simply remove the `require 'blacklight_range_limit'` line from your application.js, and hack something else together yourself.
125
+ ## Javascript dependencies
112
126
 
113
- ## Touch?
127
+ We use [chart.js](https://www.chartjs.org/) to draw the chart. It has one dependency of it's own. These need to be either pinned with importmap-rails, or used via the chart.js npm package and an npm-package-based bundler.
114
128
 
115
- For touch screens, one wants the UI to work well. The slider used is
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.
129
+ There is **no CSS** needed.
119
130
 
120
- Also not sure how well the flot select UI works on a touch screen. The slider
121
- is probably the best touch UI anyway, if it can be made to work well.
131
+ ## Upgrading from blacklight-range-limit 8.x to 9.x
122
132
 
123
- ## JavaScript Customization
133
+ All back-end configuration should be backwards compatible.
124
134
 
125
- There are two main types of JavaScript implemented for BlacklightRangeLimit:
126
- - Initialization and refresh of Range Limit plugin based off of events
127
- - Range Limit plugin functionality called from event listeners
135
+ You will need to change how you load JS. (There is no longer any blacklight_range_limit CSS to load).
128
136
 
129
- The second class of range limit functionality is customizable in your local application by overriding the specified function.
137
+ 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.
130
138
 
131
- A simple example of this is overriding the display ratio used to create the histogram
139
+ Then, remove ALL existing (sprockets) references to blacklight_range_limit in your JS or CSS pipelines.
132
140
 
133
- ```javascript
134
- BlacklightRangeLimit.display_ratio = 1
135
- ```
141
+ 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>.
136
142
 
137
- This will now create a square histogram.
143
+ For an unreleased version from git -- the installer is not presently capable of installing
144
+ that, but simply add the unreleased version of the gem to your Gemfile.
138
145
 
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
146
 
150
147
  # Tests
151
148
 
152
149
  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 jetty server, build a clean test app, and run tests.
150
+ start a demo solr server, build a clean test app, and run tests.
154
151
 
155
- Just `bundle exec rake spec` to just run tests against an existing test app and jetty server.
152
+ Just `bundle exec rake spec` to just run tests against an existing test app and solr server.
156
153
 
157
154
  ## Local Testing
158
155
  If you want to iterate on a test locally and do not want to rebuild the
@@ -173,9 +170,3 @@ Once you are done iterating on your test you will need to stop the application s
173
170
 
174
171
  run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit
175
172
 
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,17 @@ task ci: ['engine_cart:generate'] do
20
25
  end
21
26
  end
22
27
 
28
+
23
29
  namespace :test do
30
+ namespace :spec do
31
+ desc "call task spec:prepare within test app"
32
+ task :prepare do
33
+ within_test_app do
34
+ system "bin/rake spec:prepare"
35
+ end
36
+ end
37
+ end
38
+
24
39
  desc "Put sample data into solr"
25
40
  task seed: ['engine_cart:generate'] do
26
41
  within_test_app do
@@ -30,6 +45,22 @@ namespace :test do
30
45
  end
31
46
  end
32
47
 
48
+ desc "run just solr, useful for local tests"
49
+ task :solr, [:rails_sever_args] do |_t, args|
50
+ unless File.exist? EngineCart.destination
51
+ Rake::Task['engine_cart:generate'].invoke
52
+ end
53
+
54
+ SolrWrapper.wrap(port: '8983') do |solr|
55
+ solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path(File.dirname(__FILE__)), "solr", "conf")) do
56
+ Rake::Task['test:seed'].invoke
57
+ # sleep forever, make us cntrl-c to get out
58
+ puts "solr is running on port 8983, ctrl-c to exit..."
59
+ system "while true; do sleep 10000; done"
60
+ end
61
+ end
62
+ end
63
+
33
64
  desc 'Run Solr and Blacklight for interactive development'
34
65
  task :server, [:rails_server_args] do |_t, args|
35
66
  if File.exist? EngineCart.destination
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.4.0
1
+ 9.0.0.beta1