Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a way to make one big fat chartr.js file.

  • Loading branch information...
commit e06f62273272fe3cb0097a494e0a0ee68345efc1 1 parent dca248a
David N. Welton authored
14 install.rb
View
@@ -1,3 +1,5 @@
+require 'chartrfiles'
+
# Workaround a problem with script/plugin and http-based repos.
# See http://dev.rubyonrails.org/ticket/8189
Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do
@@ -7,23 +9,13 @@
## directory to public/
##
- chartr_path = RAILS_ROOT + "/vendor/plugins/chartr"
destination = RAILS_ROOT + "/public/javascripts/chartr"
- flotr = "flotr/release/prototype/flotr-0.2.0-test/flotr"
-
- # Files to be copied
- files = ["#{chartr_path}/#{flotr}/flotr-min.js",
- "#{chartr_path}/#{flotr}/lib/canvastext.js",
- "#{chartr_path}/#{flotr}/lib/excanvas.js",
- "#{chartr_path}/#{flotr}/lib/base64.js",
- "#{chartr_path}/#{flotr}/lib/canvas2image.js"]
-
# Create destination directory (RAILS_ROOT/public/javascripts/chartr)
FileUtils.mkdir_p(destination)
# Copy each file to the destination directory
- files.each do |f|
+ ChartrFiles.each do |f|
FileUtils.cp_r(f, destination)
end
end
9 lib/chartrfiles.rb
View
@@ -0,0 +1,9 @@
+chartr_path = RAILS_ROOT + "/vendor/plugins/chartr"
+flotr = "flotr/release/prototype/flotr-0.2.0-test/flotr"
+
+ # Files to be copied
+ChartrFiles = ["#{chartr_path}/#{flotr}/flotr-min.js",
+ "#{chartr_path}/#{flotr}/lib/canvastext.js",
+ "#{chartr_path}/#{flotr}/lib/excanvas.js",
+ "#{chartr_path}/#{flotr}/lib/base64.js",
+ "#{chartr_path}/#{flotr}/lib/canvas2image.js"]
21 tasks/chartr.rake
View
@@ -0,0 +1,21 @@
+root = File.dirname(__FILE__) + "/../"
+
+require root + "lib/chartrfiles"
+
+namespace :chartr do
+ desc "Compress JS files into chartr.js"
+ task :singlefile do
+ FileUtils.cd('public/javascripts') do
+ output = ""
+ output << File.read('prototype.js')
+ ChartrFiles.each do |f|
+ output << File.read(f)
+ end
+ File.open('/tmp/chartr.js', 'w') do |f|
+ f.write(output)
+ end
+ end
+
+ `java -jar #{root}./flotr/yuicompressor-2.4.2.jar /tmp/chartr.js > public/javascripts/chartr.js`
+ end
+end
16 tasks/chartr.rake~
View
@@ -0,0 +1,16 @@
+namespace :chartr do
+ desc "Compress JS files into chartr.js"
+ task :compress_js do
+ FileUtils.cd('public/javascripts') do
+ output = ""
+ ['prototype.js', 'excanvas.js', 'plotr_uncompressed.js'].each do |f|
+ output << File.read(f)
+ end
+ File.open('/tmp/chartr.js', 'w') do |f|
+ f.write(output)
+ end
+ end
+
+ `java -jar ./flotr/yuicompressor-2.4.2.jar /tmp/chartr.js > public/javascripts/chartr.js`
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.