2011-11-25 15:06:17 +00:00
|
|
|
require "bundler/gem_tasks"
|
|
|
|
require 'httparty'
|
|
|
|
require 'zip/zip'
|
|
|
|
|
|
|
|
sources = {
|
2011-11-25 15:20:13 +00:00
|
|
|
'jquery.cookies' => [
|
2011-12-06 20:57:52 +00:00
|
|
|
'http://cookies.googlecode.com/svn/trunk/jquery.cookies.js',
|
|
|
|
'http://cookies.googlecode.com/svn/trunk/jaaulde.cookies.js',
|
|
|
|
lambda {
|
|
|
|
lines = File.readlines(cookies = 'vendor/assets/javascripts/jquery.cookies.js')
|
|
|
|
|
|
|
|
lines.unshift("//= require jaaulde.cookies")
|
|
|
|
File.open(cookies, 'wb') { |fh| fh.print lines.collect(&:strip).join("\n") }
|
|
|
|
}
|
2011-11-25 15:06:17 +00:00
|
|
|
],
|
|
|
|
'jquery-elastic' => lambda {
|
2011-11-28 11:31:41 +00:00
|
|
|
process_zip_url('http://jquery-elastic.googlecode.com/files/jquery.elastic-1.6.11.zip', {
|
|
|
|
'jquery.elastic.source.js' => 'jquery.elastic.js'
|
|
|
|
})
|
2011-11-25 15:06:17 +00:00
|
|
|
},
|
|
|
|
'jquery-viewport' => [
|
2011-11-25 15:26:37 +00:00
|
|
|
'http://www.appelsiini.net/download/jquery.viewport.js'
|
2011-11-25 15:06:17 +00:00
|
|
|
],
|
|
|
|
'better-autocomplete' => [
|
|
|
|
'https://raw.github.com/betamos/Better-Autocomplete/develop/src/jquery.better-autocomplete.js',
|
|
|
|
'https://raw.github.com/betamos/Better-Autocomplete/develop/src/better-autocomplete.css'
|
|
|
|
],
|
|
|
|
'moment' => [
|
|
|
|
'https://raw.github.com/timrwood/moment/master/moment.js'
|
|
|
|
],
|
|
|
|
'ajaxfileuploader' => lambda {
|
2011-11-28 11:31:41 +00:00
|
|
|
process_zip_url('http://phpletter.com/download_project_version.php?version_id=34', {
|
|
|
|
'ajaxfileupload.js' => 'ajaxfileupload.js'
|
|
|
|
})
|
2011-11-25 15:06:17 +00:00
|
|
|
},
|
|
|
|
'jquery-ui-timepicker' => [
|
|
|
|
'http://trentrichardson.com/examples/timepicker/js/jquery-ui-timepicker-addon.js'
|
2011-11-28 11:42:24 +00:00
|
|
|
],
|
|
|
|
'underscore.string' => [
|
|
|
|
'https://raw.github.com/edtsech/underscore.string/master/lib/underscore.string.js'
|
2011-12-06 19:57:28 +00:00
|
|
|
],
|
|
|
|
'jScroll' => [
|
|
|
|
'https://github.com/downloads/wduffy/jScroll/jquery.jscroll.js'
|
2011-11-25 15:06:17 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2012-07-02 22:31:44 +00:00
|
|
|
def open_zip_url(url, &block)
|
2011-12-06 20:57:52 +00:00
|
|
|
mkdir_p 'tmp'
|
2011-12-06 19:57:28 +00:00
|
|
|
|
|
|
|
response = HTTParty.get(url)
|
2012-07-02 22:31:44 +00:00
|
|
|
File.open(target = 'tmp/zip.zip', 'wb') { |fh| fh.print response.body }
|
|
|
|
|
|
|
|
Zip::ZipFile.foreach(target, &block)
|
|
|
|
end
|
2011-12-06 19:57:28 +00:00
|
|
|
|
2012-07-02 22:31:44 +00:00
|
|
|
def process_zip_url(url, entries = {})
|
|
|
|
open_zip_url(url) do |entry|
|
2011-12-06 19:57:28 +00:00
|
|
|
entries.each do |search_entry, target_filename|
|
|
|
|
if entry.name[search_entry]
|
|
|
|
case File.extname(search_entry)
|
|
|
|
when '.js'
|
|
|
|
target = 'vendor/assets/javascripts'
|
|
|
|
when '.css'
|
|
|
|
target = 'vendor/assets/stylesheets'
|
|
|
|
end
|
|
|
|
|
|
|
|
entry.extract(File.join(target, target_filename))
|
|
|
|
end
|
2012-07-02 22:31:44 +00:00
|
|
|
|
2011-12-06 19:57:28 +00:00
|
|
|
yield entry if block_given?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-02 22:31:44 +00:00
|
|
|
desc 'Update everything'
|
2011-11-25 15:06:17 +00:00
|
|
|
task :update do
|
2011-11-25 15:20:13 +00:00
|
|
|
rm_rf 'vendor/assets'
|
|
|
|
|
2011-11-25 15:06:17 +00:00
|
|
|
sources.each do |name, files|
|
|
|
|
case files
|
|
|
|
when Array
|
|
|
|
files.each do |url|
|
2011-12-06 20:57:52 +00:00
|
|
|
case url
|
|
|
|
when String
|
|
|
|
puts "Retrieving #{url} for #{name}..."
|
|
|
|
response = HTTParty.get(url, :format => 'application/octet-stream')
|
2011-11-25 15:06:17 +00:00
|
|
|
|
2011-12-06 20:57:52 +00:00
|
|
|
case File.extname(url)
|
|
|
|
when '.js'
|
|
|
|
target = Pathname('vendor/assets/javascripts')
|
|
|
|
when '.css'
|
|
|
|
target = Pathname('vendor/assets/stylesheets')
|
|
|
|
end
|
2011-11-25 15:06:17 +00:00
|
|
|
|
2011-12-06 20:57:52 +00:00
|
|
|
target.mkpath
|
|
|
|
target.join(File.basename(url)).open('wb') { |fh| fh.print response.body }
|
|
|
|
when Proc
|
|
|
|
url.call
|
|
|
|
end
|
2011-11-25 15:06:17 +00:00
|
|
|
end
|
|
|
|
when Proc
|
|
|
|
puts "Executing code for #{name}..."
|
|
|
|
files.call
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :default => :update
|
|
|
|
|
2012-07-02 22:31:44 +00:00
|
|
|
desc 'Update Plupload'
|
|
|
|
task :update_plupload do
|
2012-07-02 22:42:03 +00:00
|
|
|
root = "vendor-special/assets"
|
|
|
|
|
|
|
|
js = "#{root}/javascripts/plupload"
|
|
|
|
css = "#{root}/stylesheets/plupload"
|
|
|
|
img = "#{root}/images/plupload"
|
2012-07-02 22:31:44 +00:00
|
|
|
|
|
|
|
[ js, css, img ].each do |dir|
|
|
|
|
rm_rf dir
|
|
|
|
mkdir_p dir
|
|
|
|
end
|
|
|
|
|
|
|
|
open_zip_url("https://github.com/downloads/moxiecode/plupload/plupload_1_5_4.zip") do |entry|
|
|
|
|
if entry.file?
|
|
|
|
target = case File.extname(entry.name)
|
|
|
|
when '.js'
|
|
|
|
js
|
|
|
|
when '.css'
|
|
|
|
css
|
|
|
|
else
|
|
|
|
img
|
|
|
|
end
|
|
|
|
|
|
|
|
[
|
2012-07-03 00:44:41 +00:00
|
|
|
[ 'plupload/js/jquery.plupload.queue/img/*', 'img' ],
|
|
|
|
[ 'plupload/js/jquery.plupload.queue/*', 'jquery.plupload.queue' ],
|
|
|
|
[ 'plupload/js/jquery.ui.plupload/img/*', 'img' ],
|
|
|
|
[ 'plupload/js/jquery.ui.plupload/*', 'jquery.ui.plupload' ],
|
2012-07-02 22:31:44 +00:00
|
|
|
[ 'plupload/js/*', '.' ],
|
|
|
|
].each do |glob, dir|
|
|
|
|
if File.fnmatch?(glob, entry.name)
|
|
|
|
target = File.expand_path(File.join(target, dir, File.basename(entry.name)))
|
|
|
|
|
|
|
|
FileUtils.mkdir_p File.dirname(target)
|
|
|
|
|
|
|
|
entry.extract(target)
|
|
|
|
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|