blacklight_range_limit 5.2.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +18 -12
- data/README.md +21 -45
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/app/views/blacklight_range_limit/_range_limit_panel.html.erb +3 -3
- data/blacklight_range_limit.gemspec +2 -2
- data/config/jetty.yml +1 -1
- data/lib/blacklight_range_limit.rb +2 -36
- data/lib/blacklight_range_limit/controller_override.rb +7 -21
- data/lib/blacklight_range_limit/engine.rb +1 -11
- data/lib/blacklight_range_limit/range_limit_builder.rb +8 -4
- data/lib/blacklight_range_limit/routes.rb +5 -0
- data/lib/blacklight_range_limit/routes/range_searchable.rb +15 -0
- data/lib/blacklight_range_limit/view_helper_override.rb +2 -2
- data/lib/generators/blacklight_range_limit/install_generator.rb +44 -0
- data/lib/generators/blacklight_range_limit/templates/search_history_controller.rb +6 -0
- data/lib/tasks/blacklight_range_limit.rake +3 -2
- data/spec/features/blacklight_range_limit_spec.rb +18 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -4
- metadata +19 -10
- data/lib/generators/blacklight_range_limit/blacklight_range_limit_generator.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88ce4d1a9977401229bc5968d114d72ffcb78300
|
4
|
+
data.tar.gz: d74d58e4259a6308a77738fc612c6b25e8e33747
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90d24009d5a9c91e3dd11c49f730367e923d8ab175fa5948d4f4f232af0ec8a99827a1b708b78793ab2ab357539220e760719f87c8104aed9567e900b7ee95e5
|
7
|
+
data.tar.gz: d329af1791c03d119e8b22855c03783edbdd643fbd688d00babb9b4b4d0819c15e6d33e3310e2807476329a5fe37d65442691fd1e082dbed3580a74e5eb50a06
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -2,24 +2,30 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
# BEGIN ENGINE_CART BLOCK
|
6
|
+
# engine_cart: 0.8.0
|
7
|
+
# engine_cart stanza: 0.8.0
|
8
|
+
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
|
9
|
+
file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path(".internal_test_app", File.dirname(__FILE__)))
|
10
|
+
if File.exist?(file)
|
11
|
+
begin
|
12
|
+
eval_gemfile file
|
13
|
+
rescue Bundler::GemfileError => e
|
14
|
+
Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
|
15
|
+
Bundler.ui.warn e.message
|
16
|
+
end
|
9
17
|
else
|
18
|
+
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
|
19
|
+
|
10
20
|
gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
|
11
21
|
|
12
|
-
if ENV['RAILS_VERSION']
|
22
|
+
if ENV['RAILS_VERSION'].nil? || ENV['RAILS_VERSION'] =~ /^4.2/
|
23
|
+
gem 'bootstrap-sass', '>= 3.3.5.1'
|
13
24
|
gem 'responders', "~> 2.0"
|
14
25
|
gem 'sass-rails', ">= 5.0"
|
15
26
|
else
|
27
|
+
gem 'bootstrap-sass', '< 3.3.5' # 3.3.5 requires sass 3.3, incompatible with sass-rails 4.x
|
16
28
|
gem 'sass-rails', "< 5.0"
|
17
29
|
end
|
18
30
|
end
|
19
|
-
|
20
|
-
# I'm sorry, this is harsh and I think ought to be done some other way with
|
21
|
-
# engine_cart, but I don't understand how or what's going on, and this
|
22
|
-
# is all I could to avoid:
|
23
|
-
# undefined method `type' for .focus:Sass::Selector::Class
|
24
|
-
# (in .../blacklight_range_limit/spec/internal/app/assets/stylesheets/blacklight.css.scss)
|
25
|
-
gem 'sass', "~> 3.4"
|
31
|
+
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ to your Gemfile. Run "bundle install".
|
|
37
37
|
|
38
38
|
Then run
|
39
39
|
|
40
|
-
rails generate blacklight_range_limit
|
40
|
+
rails generate blacklight_range_limit:install
|
41
41
|
|
42
42
|
This will install some asset references in your application.js and application.css.
|
43
43
|
|
@@ -45,20 +45,23 @@ This will install some asset references in your application.js and application.c
|
|
45
45
|
|
46
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:
|
47
47
|
|
48
|
-
|
48
|
+
```ruby
|
49
|
+
config.add_facet_field 'pub_date', label: 'Publication Year', range: true
|
50
|
+
```
|
49
51
|
|
50
52
|
You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
|
51
53
|
|
52
54
|
|
53
55
|
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:
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}
|
61
|
-
|
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
|
+
});
|
64
|
+
```
|
62
65
|
You can add this configuration in app/assets/javascript/application.js, or anywhere else loaded before the blacklight range limit javascript.
|
63
66
|
|
64
67
|
## A note on AJAX use
|
@@ -78,12 +81,15 @@ Note that a drill-down will never require the second request, because boundaries
|
|
78
81
|
|
79
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.
|
80
83
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
```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
|
+
}
|
91
|
+
```
|
92
|
+
|
87
93
|
* **:num_segments** :
|
88
94
|
* 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
95
|
* **:assumed_boundaries** :
|
@@ -126,36 +132,6 @@ ourselves yet.
|
|
126
132
|
Also not sure how well the flot select UI works on a touch screen. The slider
|
127
133
|
is probably the best touch UI anyway, if it can be made to work well.
|
128
134
|
|
129
|
-
|
130
|
-
## Injection
|
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.
|
133
|
-
|
134
|
-
You can turn off this injection if you like, although it will make the plugin less (or non-) functional unless you manually do similar injection. See lib/blacklight_range_limit.rb#inject! to see exactly what's going on.
|
135
|
-
|
136
|
-
In any initializer, you can set:
|
137
|
-
|
138
|
-
BlacklightRangeLimit.omit_inject = true
|
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.
|
141
|
-
|
142
|
-
You can also turn off injection of individual components, which could be more useful:
|
143
|
-
|
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
|
156
|
-
|
157
|
-
See Javascript Dependencies above for disabling injection of gem's js.
|
158
|
-
|
159
135
|
# Tests
|
160
136
|
|
161
137
|
Test coverage is not great, but there are some tests, using rspec. Run `rake ci` or just `rake` to seed and
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ require 'engine_cart/rake_task'
|
|
10
10
|
|
11
11
|
EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc
|
12
12
|
|
13
|
-
ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.
|
13
|
+
ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.4.zip"
|
14
14
|
|
15
15
|
require 'jettywrapper'
|
16
16
|
|
@@ -37,7 +37,7 @@ namespace :test do
|
|
37
37
|
task :seed => ['engine_cart:generate'] do
|
38
38
|
within_test_app do
|
39
39
|
ENV['RAILS_ENV'] ||= 'test'
|
40
|
-
system "rake blacklight:
|
40
|
+
system "rake blacklight:index:seed"
|
41
41
|
system "rake blacklight_range_limit:seed"
|
42
42
|
end
|
43
43
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.0
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%- # requires solr_config local passed in
|
2
2
|
|
3
3
|
field_config = range_config(solr_field)
|
4
|
-
label =
|
4
|
+
label = facet_field_label(solr_field)
|
5
5
|
|
6
6
|
input_label_range_begin = field_config[:input_label_range_begin] || t("blacklight.range_limit.range_begin", field_label: label)
|
7
7
|
input_label_range_end = field_config[:input_label_range_end] || t("blacklight.range_limit.range_end", field_label: label)
|
@@ -29,8 +29,8 @@
|
|
29
29
|
<% end %>
|
30
30
|
|
31
31
|
<% unless params["range"] && params["range"][solr_field] && params["range"][solr_field]["missing"] %>
|
32
|
-
<%= form_tag
|
33
|
-
<%= render_hash_as_hidden_fields(params_for_search) %>
|
32
|
+
<%= form_tag search_action_path, :method => :get, :class=>"range_limit subsection range_#{solr_field} form-inline" do %>
|
33
|
+
<%= render_hash_as_hidden_fields(search_state.params_for_search) %>
|
34
34
|
|
35
35
|
<!-- we need to include a dummy search_field parameter if none exists,
|
36
36
|
to trick blacklight into displaying actual search results instead
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_dependency "rails", ">= 3.0", "< 5.0"
|
21
21
|
s.add_dependency "jquery-rails" # our JS needs jquery_rails
|
22
|
-
s.add_dependency "blacklight", "
|
22
|
+
s.add_dependency "blacklight", ">= 6.0.0.pre2", "< 7"
|
23
23
|
|
24
24
|
s.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
s.add_development_dependency "rspec-rails"
|
@@ -27,5 +27,5 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency "sqlite3"
|
28
28
|
s.add_development_dependency 'launchy'
|
29
29
|
s.add_development_dependency "jettywrapper", "~> 1.5", ">= 1.5.2"
|
30
|
-
s.add_development_dependency "engine_cart", "~> 0.
|
30
|
+
s.add_development_dependency "engine_cart", "~> 0.8"
|
31
31
|
end
|
data/config/jetty.yml
CHANGED
@@ -4,50 +4,17 @@ module BlacklightRangeLimit
|
|
4
4
|
require 'blacklight_range_limit/range_limit_builder'
|
5
5
|
require 'blacklight_range_limit/controller_override'
|
6
6
|
require 'blacklight_range_limit/view_helper_override'
|
7
|
-
require 'blacklight_range_limit/route_sets'
|
8
7
|
|
9
8
|
require 'blacklight_range_limit/version'
|
10
9
|
require 'blacklight_range_limit/engine'
|
11
10
|
|
11
|
+
autoload :Routes, 'blacklight_range_limit/routes'
|
12
|
+
|
12
13
|
mattr_accessor :labels
|
13
14
|
self.labels = {
|
14
15
|
:missing => "Unknown"
|
15
16
|
}
|
16
|
-
|
17
|
-
|
18
|
-
@omit_inject = {}
|
19
|
-
def self.omit_inject=(value)
|
20
|
-
value = Hash.new(true) if value == true
|
21
|
-
@omit_inject = value
|
22
|
-
end
|
23
|
-
def self.omit_inject ; @omit_inject ; end
|
24
17
|
|
25
|
-
def self.inject!
|
26
|
-
unless omit_inject[:controller_mixin]
|
27
|
-
CatalogController.send(:include, BlacklightRangeLimit::ControllerOverride) unless Blacklight::Catalog.include?(BlacklightRangeLimit::ControllerOverride)
|
28
|
-
end
|
29
|
-
|
30
|
-
unless omit_inject[:view_helpers]
|
31
|
-
SearchHistoryController.send(:helper,
|
32
|
-
BlacklightRangeLimit::ViewHelperOverride
|
33
|
-
) unless
|
34
|
-
SearchHistoryController.helpers.is_a?(
|
35
|
-
BlacklightRangeLimit::ViewHelperOverride
|
36
|
-
)
|
37
|
-
|
38
|
-
SearchHistoryController.send(:helper,
|
39
|
-
RangeLimitHelper
|
40
|
-
) unless
|
41
|
-
SearchHistoryController.helpers.is_a?(
|
42
|
-
RangeLimitHelper
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
unless BlacklightRangeLimit.omit_inject[:routes]
|
47
|
-
Blacklight::Routes.send(:include, BlacklightRangeLimit::RouteSets)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
18
|
# Add element to array only if it's not already there
|
52
19
|
def self.safe_arr_add(array, element)
|
53
20
|
array << element unless array.include?(element)
|
@@ -70,5 +37,4 @@ module BlacklightRangeLimit
|
|
70
37
|
|
71
38
|
config
|
72
39
|
end
|
73
|
-
|
74
40
|
end
|
@@ -1,34 +1,20 @@
|
|
1
1
|
# Meant to be applied on top of a controller that implements
|
2
2
|
# Blacklight::SolrHelper. Will inject range limiting behaviors
|
3
|
-
# to solr parameters creation.
|
3
|
+
# to solr parameters creation.
|
4
4
|
require 'blacklight_range_limit/segment_calculation'
|
5
5
|
module BlacklightRangeLimit
|
6
6
|
module ControllerOverride
|
7
7
|
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
unless BlacklightRangeLimit.omit_inject[:view_helpers]
|
11
|
-
helper BlacklightRangeLimit::ViewHelperOverride
|
12
|
-
helper RangeLimitHelper
|
13
|
-
end
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
if self.blacklight_config.search_builder_class
|
19
|
-
unless self.blacklight_config.search_builder_class.include?(BlacklightRangeLimit::RangeLimitBuilder)
|
20
|
-
self.blacklight_config.search_builder_class.send(:include,
|
21
|
-
BlacklightRangeLimit::RangeLimitBuilder
|
22
|
-
)
|
23
|
-
self.blacklight_config.search_builder_class.default_processor_chain << :add_range_limit_params
|
24
|
-
end
|
25
|
-
end
|
9
|
+
included do
|
10
|
+
helper BlacklightRangeLimit::ViewHelperOverride
|
11
|
+
helper RangeLimitHelper
|
26
12
|
end
|
27
|
-
|
13
|
+
|
28
14
|
# Action method of our own!
|
29
15
|
# Delivers a _partial_ that's a display of a single fields range facets.
|
30
16
|
# Used when we need a second Solr query to get range facets, after the
|
31
|
-
# first found min/max from result set.
|
17
|
+
# first found min/max from result set.
|
32
18
|
def range_limit
|
33
19
|
# We need to swap out the add_range_limit_params search param filter,
|
34
20
|
# and instead add in our fetch_specific_range_limit filter,
|
@@ -36,7 +22,7 @@ module BlacklightRangeLimit
|
|
36
22
|
# field (with start/end params) mentioned in query params
|
37
23
|
# range_field, range_start, and range_end
|
38
24
|
|
39
|
-
@response, _ = search_results(params
|
25
|
+
@response, _ = search_results(params) do |search_builder|
|
40
26
|
search_builder.except(:add_range_limit_params).append(:fetch_specific_range_limit)
|
41
27
|
end
|
42
28
|
|
@@ -4,20 +4,10 @@ require 'rails'
|
|
4
4
|
|
5
5
|
module BlacklightRangeLimit
|
6
6
|
class Engine < Rails::Engine
|
7
|
-
|
8
7
|
# Need to tell asset pipeline to precompile the excanvas
|
9
|
-
# we use for IE.
|
8
|
+
# we use for IE.
|
10
9
|
initializer "blacklight_range_limit.assets", :after => "assets" do
|
11
10
|
Rails.application.config.assets.precompile += %w( flot/excanvas.min.js )
|
12
11
|
end
|
13
|
-
|
14
|
-
# Do these things in a to_prepare block, to try and make them work
|
15
|
-
# in development mode with class-reloading. The trick is we can't
|
16
|
-
# be sure if the controllers we're modifying are being reloaded in
|
17
|
-
# dev mode, if they are in the BL plugin and haven't been copied to
|
18
|
-
# local, they won't be. But we do our best.
|
19
|
-
config.to_prepare do
|
20
|
-
BlacklightRangeLimit.inject!
|
21
|
-
end
|
22
12
|
end
|
23
13
|
end
|
@@ -2,11 +2,15 @@ require 'blacklight_range_limit/segment_calculation'
|
|
2
2
|
|
3
3
|
module BlacklightRangeLimit
|
4
4
|
module RangeLimitBuilder
|
5
|
+
extend ActiveSupport::Concern
|
5
6
|
include BlacklightRangeLimit::SegmentCalculation
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
included do
|
9
|
+
# Use setters so not to propagate changes
|
10
|
+
self.default_processor_chain += [:add_range_limit_params]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Method added to to fetch proper things for date ranges.
|
10
14
|
def add_range_limit_params(solr_params)
|
11
15
|
ranged_facet_configs =
|
12
16
|
blacklight_config.facet_fields.select { |key, config| config.range }
|
@@ -80,4 +84,4 @@ module BlacklightRangeLimit
|
|
80
84
|
end
|
81
85
|
|
82
86
|
end
|
83
|
-
end
|
87
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BlacklightRangeLimit
|
2
|
+
module Routes
|
3
|
+
class RangeSearchable
|
4
|
+
def initialize(defaults = {})
|
5
|
+
@defaults = defaults
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(mapper, options = {})
|
9
|
+
options = @defaults.merge(options)
|
10
|
+
|
11
|
+
mapper.get 'range_limit', action: 'range_limit'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
next unless hash["missing"] || (!hash["begin"].blank?) || (!hash["end"].blank?)
|
50
50
|
content << render_constraint_element(
|
51
|
-
|
51
|
+
facet_field_label(solr_field),
|
52
52
|
range_display(solr_field, my_params),
|
53
53
|
:escape_value => false,
|
54
54
|
:remove => remove_range_param(solr_field, my_params)
|
@@ -66,7 +66,7 @@
|
|
66
66
|
next unless hash["missing"] || (!hash["begin"].blank?) || (! hash["end"].blank?)
|
67
67
|
|
68
68
|
content << render_search_to_s_element(
|
69
|
-
|
69
|
+
facet_field_label(solr_field),
|
70
70
|
range_display(solr_field, my_params),
|
71
71
|
:escape_value => false
|
72
72
|
)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module BlacklightRangeLimit
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
def copy_public_assets
|
8
|
+
generate 'blacklight_range_limit:assets'
|
9
|
+
end
|
10
|
+
|
11
|
+
def install_catalog_controller_mixin
|
12
|
+
inject_into_class 'app/controllers/catalog_controller.rb', CatalogController do
|
13
|
+
"\n include BlacklightRangeLimit::ControllerOverride\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def install_search_builder
|
18
|
+
path = 'app/models/search_builder.rb'
|
19
|
+
if File.exists? path
|
20
|
+
inject_into_file path, after: /include Blacklight::Solr::SearchBuilderBehavior.*$/ do
|
21
|
+
"\n include BlacklightRangeLimit::RangeLimitBuilder\n"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
say_status("error", "Unable to find #{path}. You must manually add the 'include BlacklightRangeLimit::RangeLimitBuilder' to your SearchBuilder", :red)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def install_search_history_controller
|
29
|
+
copy_file "search_history_controller.rb", "app/controllers/search_history_controller.rb"
|
30
|
+
end
|
31
|
+
|
32
|
+
def install_routing_concern
|
33
|
+
route('concern :range_searchable, BlacklightRangeLimit::Routes::RangeSearchable.new')
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_range_limit_concern_to_catalog
|
37
|
+
sentinel = /concerns :searchable.*$/
|
38
|
+
|
39
|
+
inject_into_file 'config/routes.rb', after: sentinel do
|
40
|
+
"\n concerns :range_searchable\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -3,8 +3,9 @@ require 'rails/generators'
|
|
3
3
|
namespace :blacklight_range_limit do
|
4
4
|
desc 'Add in additional Solr docs'
|
5
5
|
task seed: :environment do
|
6
|
+
solr = CatalogController.new.repository.connection
|
6
7
|
docs = Dir['spec/fixtures/solr_documents/*.yml'].map { |f| YAML.load File.read(f) }.flatten
|
7
|
-
|
8
|
-
|
8
|
+
solr.add docs
|
9
|
+
solr.commit
|
9
10
|
end
|
10
11
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "Blacklight Range Limit" do
|
4
4
|
|
5
5
|
it "should show the range limit facet" do
|
6
|
-
visit
|
6
|
+
visit search_catalog_path
|
7
7
|
expect(page).to have_selector 'input.range_begin'
|
8
8
|
expect(page).to have_selector 'input.range_end'
|
9
9
|
expect(page).to have_selector 'label.sr-only[for="range_pub_date_sort_begin"]', :text => 'Publication Date Sort range begin'
|
@@ -12,7 +12,7 @@ describe "Blacklight Range Limit" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should provide distribution information" do
|
15
|
-
visit
|
15
|
+
visit search_catalog_path
|
16
16
|
click_link 'View distribution'
|
17
17
|
|
18
18
|
expect(page).to have_content("1500 to 1599 0")
|
@@ -20,12 +20,27 @@ describe "Blacklight Range Limit" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should limit appropriately" do
|
23
|
-
visit
|
23
|
+
visit search_catalog_path
|
24
24
|
click_link 'View distribution'
|
25
25
|
click_link '2000 to 2008'
|
26
26
|
|
27
27
|
expect(page).to have_content "2000 to 2008 [remove] 12"
|
28
28
|
end
|
29
|
+
|
30
|
+
context 'when I18n translation is available' do
|
31
|
+
before do
|
32
|
+
I18n.backend.store_translations(:en, blacklight: {search: {fields: {facet: {pub_date_sort: 'Publication Date I18n'}}}})
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should render the I18n label' do
|
36
|
+
visit search_catalog_path
|
37
|
+
click_link 'View distribution'
|
38
|
+
click_link '2000 to 2008'
|
39
|
+
|
40
|
+
expect(page).to have_content 'Publication Date I18n'
|
41
|
+
expect(page).to_not have_content 'Publication Date Sort'
|
42
|
+
end
|
43
|
+
end
|
29
44
|
end
|
30
45
|
|
31
46
|
describe "Blacklight Range Limit with configured input labels" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class TestAppGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path("../../../../test_app_templates", __FILE__)
|
4
|
+
source_root File.expand_path("../../../../spec/test_app_templates", __FILE__)
|
5
5
|
|
6
6
|
# This is only necessary for Rails 3
|
7
7
|
def remove_index
|
@@ -17,7 +17,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
17
17
|
def run_blacklight_range_limit_generator
|
18
18
|
say_status("warning", "GENERATING BL", :yellow)
|
19
19
|
|
20
|
-
generate 'blacklight_range_limit'
|
20
|
+
generate 'blacklight_range_limit:install'
|
21
21
|
end
|
22
22
|
|
23
23
|
def fixtures
|
@@ -26,8 +26,8 @@ class TestAppGenerator < Rails::Generators::Base
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def inject_into_catalog_controller
|
29
|
-
inject_into_file 'app/controllers/catalog_controller.rb', after:
|
30
|
-
"\n config.add_facet_field 'pub_date_sort', :
|
29
|
+
inject_into_file 'app/controllers/catalog_controller.rb', after: /config.add_facet_field 'format'.*$/ do
|
30
|
+
"\n config.add_facet_field 'pub_date_sort', label: 'Publication Date Sort', range: true"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
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:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -49,16 +49,22 @@ dependencies:
|
|
49
49
|
name: blacklight
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 6.0.0.pre2
|
55
|
+
- - "<"
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
57
|
+
version: '7'
|
55
58
|
type: :runtime
|
56
59
|
prerelease: false
|
57
60
|
version_requirements: !ruby/object:Gem::Requirement
|
58
61
|
requirements:
|
59
|
-
- - "
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 6.0.0.pre2
|
65
|
+
- - "<"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '7'
|
62
68
|
- !ruby/object:Gem::Dependency
|
63
69
|
name: rspec
|
64
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,14 +161,14 @@ dependencies:
|
|
155
161
|
requirements:
|
156
162
|
- - "~>"
|
157
163
|
- !ruby/object:Gem::Version
|
158
|
-
version: '0.
|
164
|
+
version: '0.8'
|
159
165
|
type: :development
|
160
166
|
prerelease: false
|
161
167
|
version_requirements: !ruby/object:Gem::Requirement
|
162
168
|
requirements:
|
163
169
|
- - "~>"
|
164
170
|
- !ruby/object:Gem::Version
|
165
|
-
version: '0.
|
171
|
+
version: '0.8'
|
166
172
|
description:
|
167
173
|
email:
|
168
174
|
- blacklight-development@googlegroups.com
|
@@ -198,11 +204,14 @@ files:
|
|
198
204
|
- lib/blacklight_range_limit/engine.rb
|
199
205
|
- lib/blacklight_range_limit/range_limit_builder.rb
|
200
206
|
- lib/blacklight_range_limit/route_sets.rb
|
207
|
+
- lib/blacklight_range_limit/routes.rb
|
208
|
+
- lib/blacklight_range_limit/routes/range_searchable.rb
|
201
209
|
- lib/blacklight_range_limit/segment_calculation.rb
|
202
210
|
- lib/blacklight_range_limit/version.rb
|
203
211
|
- lib/blacklight_range_limit/view_helper_override.rb
|
204
212
|
- lib/generators/blacklight_range_limit/assets_generator.rb
|
205
|
-
- lib/generators/blacklight_range_limit/
|
213
|
+
- lib/generators/blacklight_range_limit/install_generator.rb
|
214
|
+
- lib/generators/blacklight_range_limit/templates/search_history_controller.rb
|
206
215
|
- lib/tasks/blacklight_range_limit.rake
|
207
216
|
- spec/features/blacklight_range_limit_spec.rb
|
208
217
|
- spec/fixtures/solr_documents/zero_year.yml
|
@@ -234,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
243
|
version: '0'
|
235
244
|
requirements: []
|
236
245
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.4.5
|
246
|
+
rubygems_version: 2.4.5.1
|
238
247
|
signing_key:
|
239
248
|
specification_version: 4
|
240
249
|
summary: Blacklight Range Limit plugin
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
class BlacklightRangeLimitGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
require File.expand_path('../assets_generator.rb', __FILE__)
|
7
|
-
def copy_public_assets
|
8
|
-
BlacklightRangeLimit::AssetsGenerator.start
|
9
|
-
end
|
10
|
-
end
|