blacklight_range_limit 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -11,8 +11,6 @@ Decimal numbers and Dates are NOT supported; they theoretically could be in the
11
11
 
12
12
  = Requirements
13
13
 
14
- A Rails app using the Blacklight plugin (post version 2.5. Either git checkout from master, or wait until whatever version comes after 2.5). If you've modified and over-ridden Blacklight a lot, things might get tricky.
15
-
16
14
  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
15
 
18
16
  ==Note on solr field types
@@ -31,27 +29,13 @@ Add
31
29
  gem "blacklight_range_limit"
32
30
  to your Gemfile. Run "bundle install".
33
31
 
34
- Then run "rails generate blacklight_range_limit". This will install some assets in your app's public/ folder. (This process likely to change in Rails 3.1).
35
-
36
- == Blacklight 2.x/Rails 2.x
37
-
38
- Must be installed as a plugin, most easily using 'git', rather than as a gem. Version 0.9.6 is the last version that works with Blacklight 2.x.
39
-
40
- cd ./vendor/plugins/
41
- git clone git://github.com/projectblacklight/blacklight_range_limit.git
42
- cd blacklight_range_limit
43
- git checkout v0.9.6
44
-
45
-
46
- If you don't have git installed, you can try downloading the 0.9.6 package from https://github.com/projectblacklight/blacklight_range_limit/archives/master , and installing in vendor/plugins.
47
-
32
+ Then run "rails generate blacklight_range_limit". This will install some asset references in your application.js and application.css
48
33
 
49
34
  = Configuration
50
35
 
51
- 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 config/initializers/blacklight_config.rb, that field needs to be listed in config[:facet][:field_names], and you also need to create a config[:facet][:range]["your_field] => true key.
36
+ 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:
52
37
 
53
- config[:facet][:field_names] << "my_field"
54
- config[:facet][:range]["my_field"] = true.
38
+ config.add_facet_field 'pub_date', :label => 'Publication Year', :range => true
55
39
 
56
40
  You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
57
41
 
@@ -66,7 +50,7 @@ You can also configure the look and feel of the Flot chart using the jQuery .dat
66
50
  grid: { color: '#aaaaaa', tickColor: '#aaaaaa', borderWidth: 0 }
67
51
  });
68
52
 
69
- You can add this configuration in public/javascripts/application.js, or anywhere else loaded before the blacklight range limit javascript.
53
+ You can add this configuration in app/assets/javascript/application.js, or anywhere else loaded before the blacklight range limit javascript.
70
54
 
71
55
  == A note on AJAX use
72
56
 
@@ -85,7 +69,7 @@ Note that a drill-down will never require the second request, because boundaries
85
69
 
86
70
  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.
87
71
 
88
- config[:facet][:range]["my_field"] = {
72
+ config.add_facet_field 'pub_date', :label => 'Publication Year', :range => {
89
73
  :num_segments => 6,
90
74
  :assumed_boundaries => [1100, Time.now.year + 2],
91
75
  :slider_js => false,
@@ -119,19 +103,12 @@ to turn off all injection. The plugin will be completely non-functional if you d
119
103
  You can also turn off injection of individual components, which could be more useful:
120
104
 
121
105
  BlacklightRangeLimit.omit_inject = {
122
- :css => false,
123
- :js => false,
124
- :flot => false,
106
+ :excanvas => false,
125
107
  :view_helpers => false,
126
108
  :controller_mixin => false
127
109
  }
128
-
129
- [:css]
130
- set to false and the plugin will not insert it's own CSS.
131
- [:js]
132
- set to false and the plugin will not insert it's own JS, which means none of your range limits will get sliders or charts. Perhaps you don't like JS, or don't like ours.
133
- [:flot]
134
- Normally the plugin will insert <script> links to the Flot plugin, the Flot Selection plugin, and the IE canvas emulator Flot needs on IE. Perhaps you are already including these files, or would like to include them yourself. Set to false.
110
+ [:excanvas]
111
+ Set to false to disable loading the IE 'excanvas' compatibility layer
135
112
  [:view_helpers]
136
113
  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.
137
114
  [:controller_mixin]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -0,0 +1,9 @@
1
+ // Master manifest file for engine, so local app can require
2
+ // this one file, but get all our files -- and local app
3
+ // require does not need to change if we change file list.
4
+
5
+ //= require 'jquery'
6
+ //= require 'jquery-ui'
7
+ //= require 'flot/jquery.flot.js'
8
+ //= require 'flot/jquery.flot.selection.js'
9
+ //= require_tree './blacklight_range_limit'
@@ -0,0 +1,6 @@
1
+ /* Master manifest file for engine, so local app can require
2
+ * this one file, but get all our files -- and local app
3
+ * require does not need to change if we change file list.
4
+ *
5
+ *= require_tree './blacklight_range_limit'
6
+ */
@@ -3,7 +3,6 @@
3
3
  field_config = range_config(solr_field)
4
4
  -%>
5
5
 
6
- <h3><%= facet_field_labels[solr_field] -%></h3>
7
6
  <div class="limit_content range_limit">
8
7
  <% if params["range"] &&
9
8
  params["range"][solr_field] &&
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
 
20
20
 
21
21
  s.add_dependency "rails", "~> 3.0"
22
- s.add_dependency "blacklight"
22
+ s.add_dependency "blacklight", "~> 3.2"
23
23
  end
@@ -52,8 +52,4 @@ module BlacklightRangeLimit
52
52
  array << element unless array.include?(element)
53
53
  end
54
54
 
55
- def self.use_asset_pipeline?
56
- (Rails::VERSION::MAJOR >= 3 and Rails::VERSION::MINOR >= 1) and Rails.application.config.assets.enabled
57
- end
58
-
59
55
  end
@@ -19,26 +19,13 @@ module BlacklightRangeLimit
19
19
  end
20
20
 
21
21
  before_filter do |controller|
22
- unless BlacklightRangeLimit.omit_inject[:css] || use_asset_pipeline?
23
- controller.stylesheet_links << "blacklight_range_limit"
24
- end
25
-
26
- unless BlacklightRangeLimit.omit_inject[:flot]
27
- unless use_asset_pipeline?
28
- controller.javascript_includes << "flot/jquery.flot.js"
29
- controller.javascript_includes << "flot/jquery.flot.selection.js"
30
- end
31
-
22
+ unless BlacklightRangeLimit.omit_inject[:excanvas]
23
+
32
24
  # canvas for IE. Need to inject it like this even with asset pipeline
33
25
  # cause it needs IE conditional include. view_context hacky way
34
26
  # to get asset url helpers.
35
27
  controller.extra_head_content << ('<!--[if IE]>' + view_context.javascript_include_tag("flot/excanvas.min.js") + '<![endif]-->').html_safe
36
28
  end
37
-
38
- unless BlacklightRangeLimit.omit_inject[:js] || use_asset_pipeline?
39
- controller.javascript_includes << "range_limit_slider"
40
- controller.javascript_includes << "range_limit_distro_facets"
41
- end
42
29
  end
43
30
  end
44
31
 
@@ -73,11 +60,7 @@ module BlacklightRangeLimit
73
60
  # Method added to solr_search_params_logic to fetch
74
61
  # proper things for date ranges.
75
62
  def add_range_limit_params(solr_params, req_params)
76
- all_range_config.each_pair do |solr_field, config|
77
- config = {} if config == true
78
- # If we have any range facets configured, we want to ask for
79
- # the stats component to get min/max.
80
-
63
+ blacklight_config.facet_fields.select { |key, config| config.range }.each_pair do |solr_field, config|
81
64
  solr_params["stats"] = "true"
82
65
  solr_params["stats.field"] ||= []
83
66
  solr_params["stats.field"] << solr_field
@@ -99,13 +82,13 @@ module BlacklightRangeLimit
99
82
  solr_params[:fq] ||= []
100
83
  solr_params[:fq] << "#{solr_field}: [#{start} TO #{finish}]"
101
84
 
102
- if (config[:segments] != false && start != "*" && finish != "*")
85
+ if (config.segments != false && start != "*" && finish != "*")
103
86
  # Add in our calculated segments, can only do with both boundaries.
104
87
  add_range_segments_to_solr!(solr_params, solr_field, start.to_i, finish.to_i)
105
88
  end
106
89
 
107
- elsif (config[:segments] != false &&
108
- boundaries = config[:assumed_boundaries])
90
+ elsif (config.segments != false &&
91
+ boundaries = config.assumed_boundaries)
109
92
  # assumed_boundaries in config
110
93
  add_range_segments_to_solr!(solr_params, solr_field, boundaries[0], boundaries[1])
111
94
  end
@@ -118,23 +101,13 @@ module BlacklightRangeLimit
118
101
  # if not configured. Returns hash even if configured to 'true'
119
102
  # for consistency.
120
103
  def range_config(solr_field)
121
- config = all_range_config[solr_field] || false
122
- config = {} if config == true # normalize bool true to hash
123
- return config
124
- end
125
- # returns a hash of solr_field => config for all configured range
126
- # facets, or empty hash.
127
- # Uses Blacklight.config, needs to be modified when
128
- # that changes to be controller-based. This is the only method
129
- # in this plugin that accesses Blacklight.config, single point
130
- # of contact.
131
- def all_range_config
132
- Blacklight.config[:facet][:range] || {}
133
- end
134
-
135
- private
136
- def use_asset_pipeline?
137
- BlacklightRangeLimit.use_asset_pipeline?
104
+ field = blacklight_config.facet_fields[solr_field]
105
+ return false unless field.range
106
+
107
+ config = field.range
108
+ config = {} if config === true
109
+
110
+ config
138
111
  end
139
112
  end
140
113
  end
@@ -5,14 +5,9 @@
5
5
 
6
6
 
7
7
 
8
- def render_facet_limit(solr_field)
9
- if ( range_config(solr_field) )
10
- if (should_show_limit(solr_field))
11
- render(:partial => "blacklight_range_limit/range_limit_panel", :locals=> {:solr_field => solr_field })
12
- end
13
- else
14
- super(solr_field)
15
- end
8
+ def facet_partial_name(display_facet)
9
+ return "blacklight_range_limit/range_limit_panel" if range_config(display_facet.name) and should_show_limit(display_facet.name)
10
+ super
16
11
  end
17
12
 
18
13
  def render_constraints_filters(my_params = params)
@@ -16,32 +16,22 @@ module BlacklightRangeLimit
16
16
  source_root File.join(BlacklightRangeLimit::Engine.root, 'app', 'assets')
17
17
 
18
18
  def assets
19
- if BlacklightRangeLimit.use_asset_pipeline?
20
- insert_into_file "app/assets/stylesheets/application.css", :before => "*/" do
19
+ insert_into_file "app/assets/stylesheets/application.css", :before => "*/" do
21
20
  %q{
22
21
  *
23
22
  * Used by blacklight_range_limit
24
- *= require 'blacklight_range_limit/blacklight_range_limit'
23
+ *= require 'blacklight_range_limit'
25
24
  *
26
25
  }
27
- end
26
+ end
28
27
 
29
- insert_into_file "app/assets/javascripts/application.js", :after => "//= require jquery" do
28
+ insert_into_file "app/assets/javascripts/application.js", :after => "//= require jquery$" do
30
29
  %q{
31
30
 
32
- // Used by blacklight_range_limit
33
- //= require 'flot/jquery.flot.js'
34
- //= require 'flot/jquery.flot.selection.js'
35
31
  // You can elmiminate one or both of these if you don't want their functionality
36
- //= require 'blacklight_range_limit/range_limit_slider'
37
- //= require 'blacklight_range_limit/range_limit_distro_facets'
32
+ //= require 'blacklight_range_limit'
38
33
 
39
34
  }
40
- end
41
- else
42
- directory("stylesheets/blacklight_range_limit", "public/stylesheets")
43
- directory("javascripts/blacklight_range_limit", "public/javascripts")
44
- directory("javascripts/flot", "public/javascripts/flot")
45
35
  end
46
36
  end
47
37
 
metadata CHANGED
@@ -1,72 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: blacklight_range_limit
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 0
10
- version: 1.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jonathan Rochkind
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-20 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2169256060 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- version: "3.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: blacklight
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2169256060
25
+ - !ruby/object:Gem::Dependency
26
+ name: blacklight
27
+ requirement: &2169255380 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.2'
48
33
  type: :runtime
49
- version_requirements: *id002
34
+ prerelease: false
35
+ version_requirements: *2169255380
50
36
  description:
51
- email:
37
+ email:
52
38
  - blacklight-development@googlegroups.com
53
39
  executables: []
54
-
55
40
  extensions: []
56
-
57
41
  extra_rdoc_files: []
58
-
59
- files:
42
+ files:
60
43
  - .gitignore
61
44
  - MIT-LICENSE
62
45
  - README.rdoc
63
46
  - Rakefile
64
47
  - VERSION
48
+ - app/assets/javascripts/blacklight_range_limit.js
65
49
  - app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js
66
50
  - app/assets/javascripts/blacklight_range_limit/range_limit_slider.js
67
51
  - app/assets/javascripts/flot/excanvas.min.js
68
52
  - app/assets/javascripts/flot/jquery.flot.js
69
53
  - app/assets/javascripts/flot/jquery.flot.selection.js
54
+ - app/assets/stylesheets/blacklight_range_limit.css.scss
70
55
  - app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css
71
56
  - app/helpers/range_limit_helper.rb
72
57
  - app/views/blacklight_range_limit/_range_limit_panel.html.erb
@@ -83,39 +68,28 @@ files:
83
68
  - lib/blacklight_range_limit/view_helper_override.rb
84
69
  - lib/generators/blacklight_range_limit/assets_generator.rb
85
70
  - lib/generators/blacklight_range_limit/blacklight_range_limit_generator.rb
86
- has_rdoc: true
87
71
  homepage: http://projectblacklight.org/
88
72
  licenses: []
89
-
90
73
  post_install_message:
91
74
  rdoc_options: []
92
-
93
- require_paths:
75
+ require_paths:
94
76
  - lib
95
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
96
78
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
104
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
84
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 3
110
- segments:
111
- - 0
112
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
113
89
  requirements: []
114
-
115
90
  rubyforge_project: blacklight
116
- rubygems_version: 1.6.2
91
+ rubygems_version: 1.8.10
117
92
  signing_key:
118
93
  specification_version: 3
119
94
  summary: Blacklight Range Limit plugin
120
95
  test_files: []
121
-