blacklight_dates2svg 0.0.1.beta1 → 0.0.1.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1 +1,81 @@
1
1
  # BlacklightDates2SVG
2
+
3
+ This gem is intended to be installed into Blacklight applications ( https://github.com/projectblacklight/blacklight ) to generate an SVG of date data into a heat-map style grid from date facet data.
4
+
5
+ ![date range heat map](http://i.imgur.com/6dcL09C.png)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'blacklight_dates2svg'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install blacklight_dates2svg
20
+
21
+ Add asset references to application.css and application.js.
22
+
23
+ $ rails generate blacklight_dates2svg
24
+
25
+
26
+ ## Components
27
+
28
+ This gem simply provides the form elements to interact with the SVG grid, the logic to inject the range query into Blacklight's Solr parameters, and brings in a few other gems/plugins to drive the interaction and process the data for Blacklight.
29
+
30
+ * Dates2SVG gem ( https://github.com/jkeck/dates2svg ) to generate the SVG grid.
31
+ * svgMonthGridSelector jQuery plugin ( https://github.com/jkeck/svgMonthGridSelector ) to drive the interaction with the form elements.
32
+ * date_range_solr_query gem ( https://github.com/jkeck/date_range_solr_query ) to turn the YYYY-MM dates into full date range queries for Solr.
33
+
34
+
35
+ ## Solr Requirements
36
+
37
+ The data should be a facet that is a DateField ( http://lucene.apache.org/solr/api/org/apache/solr/schema/DateField.html ). The facet limit should be set to return all values in the response to drive the SVG grid. Alternatively you can pass an array of dates in as a :dates option (see Usage below).
38
+
39
+ ## Usage
40
+
41
+ Once the gem is installed you will need to include the BlacklightDates2SVG module into you search controller (CatalogController by default in Blacklight).
42
+
43
+ include BlacklightDates2SVG
44
+
45
+ You will need to add 2 lines in the contorller level Blacklight configuration ( configure_blacklight block ). One to configure the facet (and most likely set :show to false) and another to let the gem know which field is the date field.
46
+
47
+ config.add_facet_field 'date_facet', :label => "Date", :show => false
48
+ config.search_date_field = 'date_facet'
49
+
50
+ Now in any helper or view rendered under that controller will have the render_date_range_selector_grid helper method available.
51
+
52
+ <%= render_date_range_selector_grid %>
53
+
54
+ You can pass all the options described in the [README](https://github.com/jkeck/dates2svg) of the Dates2SVG gem to the render_date_range_selector_grid helper method.
55
+
56
+ This gem adds an additional :dates option that when passed will ignore the facets in the response and just use the array passed in that option.
57
+
58
+ dates = [OpenStruct.new(:value => "2012-03-23", :hits => 836),
59
+ OpenStruct.new(:value => "2012-02-21", :hits => 584)]
60
+
61
+ svg = render_date_range_selector_grid(:dates => dates)
62
+
63
+ ## Customizing
64
+
65
+ There are 4 partials that can be overridden at the application level to customize some markup.
66
+
67
+ 1. [app/views/blacklight_dates2svg/_date_range_selector](https://github.com/jkeck/blacklight_dates2svg/blob/master/app/views/blacklight_dates2svg/_date_range_selector.html.erb) (The main layout)
68
+ 2. [app/views/blacklight_dates2svg/_date_range_grid](https://github.com/jkeck/blacklight_dates2svg/blob/master/app/views/blacklight_dates2svg/_date_range_grid.html.erb) (The SVG grid)
69
+ 3. [app/views/blacklight_dates2svg/_date_range_form](https://github.com/jkeck/blacklight_dates2svg/blob/master/app/views/blacklight_dates2svg/_date_range_form.html.erb) (The form elements and the rendering of the legend partial)
70
+ 4. [app/views/blacklight_dates2svg/_legend](https://github.com/jkeck/blacklight_dates2svg/blob/master/app/views/blacklight_dates2svg/_legend.html.erb) (The legend)
71
+
72
+
73
+ The [svgMonthGridSelector](https://github.com/jkeck/svgMonthGridSelector) jQuery plugin has some defaults that we adhere to. If you customize the form you may want to instantiate the plugin on your own and pass the necessary options to customize the behavior of the jQuery plugin.
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create new Pull Request
@@ -22,7 +22,7 @@ module BlacklightDates2SVG
22
22
  end
23
23
  end
24
24
 
25
- def render_date_range_selector_grid(options)
25
+ def render_date_range_selector_grid(options={})
26
26
  items = (options[:dates] || @response.facets.select do |facet|
27
27
  facet.name == blacklight_config.search_date_field
28
28
  end.first.items)
@@ -1,3 +1,3 @@
1
1
  module BlacklightDates2SVG
2
- VERSION = "0.0.1.beta1"
2
+ VERSION = "0.0.1.beta2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_dates2svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta1
4
+ version: 0.0.1.beta2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-12 00:00:00.000000000 Z
12
+ date: 2013-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  segments:
163
163
  - 0
164
- hash: -968421337915451210
164
+ hash: -4449922145157925452
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  none: false
167
167
  requirements: