Major update of Selectricity to work with Rails 2.2.2 from 1.2!
[selectricity] / app / controllers / sparklines_controller.rb
index d08bbc569fda37058dd37cf748484fa50f06854d..50a330fc7afda4aaaed46a9e3b82c047766db023 100644 (file)
@@ -1,61 +1,30 @@
-# Selectricity: Voting Machinery for the Masses
-# Copyright (C) 2007, 2008 Benjamin Mako Hill <mako@atdot.cc>
-# Copyright (C) 2007 Massachusetts Institute of Technology
+
+# Handles requests for sparkline graphs.
 #
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# You shouldn't need to edit or extend this, but you can read
+# the documentation for SparklinesHelper to see how to call it from
+# another view.
 #
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Affero General Public License for more details.
+# AUTHOR
+# 
+# Geoffrey Grosenbach[mailto:boss@topfunky.com]
+#
+# http://topfunky.com
 #
-# You should have received a copy of the GNU Affero General Public
-# License along with this program.  If not, see
-# <http://www.gnu.org/licenses/>.
-
 class SparklinesController < ApplicationController
-    # Handles requests for sparkline graphs from views.
-    #
-    # Params are generated by the sparkline_tag helper method.
-    #
-       def index
-               # Make array from comma-delimited list of data values
-               ary = []
-               if params.has_key?('results') && !params['results'].nil?
-                 params['results'].split(',').each do |s|
-                         ary << s.to_i
-                 end
-               end
+       layout nil
+
+       def index
+               # Make array from comma-delimited list of data values
+               ary = []
+               params['results'].split(',').each do |s|
+                       ary << s.to_i
+               end
+               
+               send_data( Sparklines.plot( ary, params ), 
+                                       :disposition => 'inline',
+                                       :type => 'image/png',
+                                       :filename => "spark_#{params[:type]}.png" )
+       end
 
-               send_data( Sparklines.plot( ary, params ), 
-                                       :disposition => 'inline',
-                                       :type => 'image/png',
-                                       :filename => "spark_#{params[:type]}.png" )
-       end
-    
-    def spark_pie
-      send_data(Sparklines.plot( ))
-    end
-    # Use this type of method for sparklines that can be cached. (Doesn't work with the helper.)
-    #
-    # To make caching easier, add a line like this to config/routes.rb:
-    # map.sparklines "sparklines/:action/:id/image.png", :controller => "sparklines"
-    #
-    # Then reference it with the named route:
-    #   image_tag sparklines_url(:action => 'show', :id => 42)
-    def show
-      send_data(Sparklines.plot(
-                  [42, 37, 89, 74, 70, 50, 40, 30, 40, 50],
-                  :type => 'bar', :above_color => 'orange'
-                ), 
-                :disposition => 'inline', 
-                :type => 'image/png', 
-                :filename => "sparkline.png")
-    end
-  
-  
-  
 end

Benjamin Mako Hill || Want to submit a patch?