blacklight_range_limit 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.rdoc → README.md} +50 -48
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +1 -1
- data/doc/example-screenshot.png +0 -0
- metadata +4 -3
data/{README.rdoc → README.md}
RENAMED
@@ -1,8 +1,10 @@
|
|
1
1
|
BlacklightRangeLimit: integer range limiting and profiling for Blacklight applications
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/projectblacklight/blacklight_range_limit.png?branch=v5.0.0)](https://travis-ci.org/projectblacklight/blacklight_range_limit) [![Gem Version](https://badge.fury.io/rb/blacklight_range_limit.png)](http://badge.fury.io/rb/blacklight_range_limit)
|
4
4
|
|
5
|
-
|
5
|
+
![Screen shot](doc/example-screenshot.png)
|
6
|
+
|
7
|
+
# Description
|
6
8
|
|
7
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).
|
8
10
|
|
@@ -11,11 +13,11 @@ The primary use case of this plugin is for 'year' data, but it should work for a
|
|
11
13
|
Decimal numbers and Dates are NOT supported; they theoretically could be in the future, although it gets tricky.
|
12
14
|
|
13
15
|
|
14
|
-
|
16
|
+
# Requirements
|
15
17
|
|
16
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.
|
17
19
|
|
18
|
-
|
20
|
+
## Note on solr field types
|
19
21
|
|
20
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".
|
21
23
|
|
@@ -23,13 +25,13 @@ You need to use a "sortable" numeric-type field. In Solr 1.4, the standard "int"
|
|
23
25
|
|
24
26
|
The pre Solr 1.4 now deprecated sint or slong types should work fine too.
|
25
27
|
|
26
|
-
|
28
|
+
# Installation
|
27
29
|
|
28
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.
|
29
31
|
|
30
32
|
Add
|
31
33
|
|
32
|
-
|
34
|
+
gem "blacklight_range_limit"
|
33
35
|
|
34
36
|
to your Gemfile. Run "bundle install".
|
35
37
|
|
@@ -39,28 +41,27 @@ Then run
|
|
39
41
|
|
40
42
|
This will install some asset references in your application.js and application.css.
|
41
43
|
|
42
|
-
|
44
|
+
# Configuration
|
43
45
|
|
44
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:
|
45
47
|
|
46
|
-
|
48
|
+
config.add_facet_field 'pub_date', :label => 'Publication Year', :range => true
|
47
49
|
|
48
50
|
You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
|
49
51
|
|
50
52
|
|
51
53
|
You can also configure the look and feel of the Flot chart using the jQuery .data() method. On the `.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 `.facet_limit` container. In order to customize the plot colors, for example, you could use this code:
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
$('.blacklight-year_i').data('plot-config', {
|
56
|
+
selection: { color: '#C0FF83' },
|
57
|
+
colors: ['#ffffff'],
|
58
|
+
series: { lines: { fillColor: 'rgba(255,255,255, 0.5)' }},
|
59
|
+
grid: { color: '#aaaaaa', tickColor: '#aaaaaa', borderWidth: 0 }
|
60
|
+
});
|
59
61
|
|
60
62
|
You can add this configuration in app/assets/javascript/application.js, or anywhere else loaded before the blacklight range limit javascript.
|
61
63
|
|
62
|
-
|
63
|
-
== A note on AJAX use
|
64
|
+
## A note on AJAX use
|
64
65
|
|
65
66
|
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).
|
66
67
|
|
@@ -73,7 +74,7 @@ If you'd like to avoid this, you can turn off segment display altogether with th
|
|
73
74
|
Note that a drill-down will never require the second request, because boundaries on a drill-down are always taken from the specified limits.
|
74
75
|
|
75
76
|
|
76
|
-
|
77
|
+
## Range Facet Configuration
|
77
78
|
|
78
79
|
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.
|
79
80
|
|
@@ -83,16 +84,16 @@ Instead of simply passing "true", you can pass a hash with additional configurat
|
|
83
84
|
:segments => false
|
84
85
|
}
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
* **:num_segments** :
|
88
|
+
* 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.
|
89
|
+
* **:assumed_boundaries** :
|
90
|
+
* 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.
|
91
|
+
* **:segments** :
|
92
|
+
* Default true. If set to false, then distribution segment facets will not be loaded at all.
|
92
93
|
|
93
|
-
|
94
|
+
## Javascript dependencies
|
94
95
|
|
95
|
-
The selectable histograms/barcharts are done with Javascript, using Flot
|
96
|
+
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. In IE previous to IE9, canvas element support can be added with [excanvas](http://excanvas.sourceforge.net/). 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.
|
96
97
|
|
97
98
|
A `require 'blacklight_range_limit'` in a Rails asset pipeline manifest file will automatically include all of these things. The blacklight_range_limit adds just this line to your `app/assets/application.js`.
|
98
99
|
|
@@ -102,20 +103,20 @@ Note this means a copy of jquery, from the jquery-rails gem, will be included in
|
|
102
103
|
|
103
104
|
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.
|
104
105
|
|
105
|
-
|
106
|
+
## IE8, excanvas
|
106
107
|
|
107
108
|
IE8 and below do not support the 'canvas' element, needed for flot to render the chart.
|
108
109
|
Without canvas, view will cleanly degrade to an ordinary textual listing of range segments
|
109
110
|
as facets.
|
110
111
|
|
111
|
-
Or, you can use excanvas.js to add canvas support to IE. blacklight_range_limit includes
|
112
|
-
the excanvas.js file, but you'll have to manually add a reference to it to your Rails layout
|
112
|
+
Or, you can use excanvas.js to add canvas support to IE. `blacklight_range_limit` includes
|
113
|
+
the `excanvas.js` file, but you'll have to manually add a reference to it to your Rails layout
|
113
114
|
template -- if you were previously using the stock Blacklight layout, you'll have to add a
|
114
|
-
local custom layout instead. Then add this to the html
|
115
|
+
local custom layout instead. Then add this to the html `<head>` section:
|
115
116
|
|
116
117
|
<!--[if lte IE 8]><%= javascript_include_tag 'flot/excanvas.min' %><![endif]-->
|
117
118
|
|
118
|
-
|
119
|
+
## Touch?
|
119
120
|
|
120
121
|
For touch screens, one wants the UI to work well. The slider used is
|
121
122
|
[bootstrap_slider](http://www.eyecon.ro/bootstrap-slider/), which says if you add
|
@@ -126,7 +127,7 @@ Also not sure how well the flot select UI works on a touch screen. The slider
|
|
126
127
|
is probably the best touch UI anyway, if it can be made to work well.
|
127
128
|
|
128
129
|
|
129
|
-
|
130
|
+
## Injection
|
130
131
|
|
131
132
|
The plugin assumes it is in a Blacklight Rails app, and uses Blacklight methods, Rails methods, and standard ruby module includes to inject it's behaviors into the app.
|
132
133
|
|
@@ -134,35 +135,36 @@ You can turn off this injection if you like, although it will make the plugin le
|
|
134
135
|
|
135
136
|
In any initializer, you can set:
|
136
137
|
|
137
|
-
|
138
|
+
BlacklightRangeLimit.omit_inject = true
|
138
139
|
|
139
140
|
to turn off all injection. The plugin will be completely non-functional if you do this, of course. But perhaps you could try to re-use some of it's classes in a non-Blacklight, highly hacked Blacklight, or even non-Rails application this way.
|
140
141
|
|
141
142
|
You can also turn off injection of individual components, which could be more useful:
|
142
143
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
144
|
+
BlacklightRangeLimit.omit_inject = {
|
145
|
+
:view_helpers => false,
|
146
|
+
:controller_mixin => false,
|
147
|
+
:routes => false
|
148
|
+
}
|
149
|
+
|
150
|
+
* **:view_helpers** :
|
151
|
+
* Set to false and the plugin will not insert it's own rails view helpers into the app. It will raise lots of errors if you do this, you probably don't want to.
|
152
|
+
* **:controller_mixin** :
|
153
|
+
* The plugin mixes some methods into CatalogController, both over-riding Blacklight methods, and providing a new action of it's own. Set to false, and the plugin won't. You've basically disabled the plugin if you do this.
|
154
|
+
* **:routes** :
|
155
|
+
* Disable automatic routes loading
|
154
156
|
|
155
157
|
See Javascript Dependencies above for disabling injection of gem's js.
|
156
158
|
|
157
|
-
|
159
|
+
# Tests
|
158
160
|
|
159
|
-
|
161
|
+
Test coverage is not great, but there are some tests, using rspec. Run `rake ci` or just `rake` to seed and
|
162
|
+
start a demo jetty server, build a clean test app, and run tests.
|
160
163
|
|
161
|
-
|
164
|
+
Just `rake spec` to just run tests against an existing test app and jetty server.
|
162
165
|
|
163
|
-
|
166
|
+
# Possible future To Do
|
164
167
|
|
165
|
-
= Possible future To Do
|
166
168
|
* 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.
|
167
169
|
* tests
|
168
170
|
* 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.
|
data/Rakefile
CHANGED
@@ -23,7 +23,7 @@ RSpec::Core::RakeTask.new do |t|
|
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
-
task :ci => ['jetty:clean', 'engine_cart:generate'] do
|
26
|
+
task :ci => ['jetty:clean', 'engine_cart:clean', 'engine_cart:generate'] do
|
27
27
|
jetty_params = Jettywrapper.load_config('test')
|
28
28
|
jetty_params[:startup_wait]= 60
|
29
29
|
error = Jettywrapper.wrap(jetty_params) do
|
@@ -43,4 +43,4 @@ namespace :test do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
end
|
46
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.0.
|
1
|
+
5.0.1
|
Binary file
|
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: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -185,7 +185,7 @@ files:
|
|
185
185
|
- .travis.yml
|
186
186
|
- Gemfile
|
187
187
|
- LICENSE
|
188
|
-
- README.
|
188
|
+
- README.md
|
189
189
|
- Rakefile
|
190
190
|
- VERSION
|
191
191
|
- app/assets/javascripts/blacklight_range_limit.js
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- config/jetty.yml
|
202
202
|
- config/routes.rb
|
203
203
|
- config/solr.yml
|
204
|
+
- doc/example-screenshot.png
|
204
205
|
- lib/blacklight_range_limit.rb
|
205
206
|
- lib/blacklight_range_limit/controller_override.rb
|
206
207
|
- lib/blacklight_range_limit/engine.rb
|