forked from spohlenz/tinymce-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
61 lines (52 loc) · 2.01 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
unless defined? TinyMCE::VERSION
$:.unshift File.expand_path("../lib", __FILE__)
require "tinymce/version"
end
require "af_gems/gem_tasks"
def step(name)
print "#{name} ..."
yield
puts " DONE"
end
def download(url, filename)
puts "Downloading #{url} ..."
`mkdir -p tmp`
`curl -L -# #{url} -o tmp/#{filename}`
end
desc "Update TinyMCE to version specified in lib/tinymce/version.rb"
task :update => [ :fetch, :extract, :process ]
task :fetch do
download("https://github.com/downloads/tinymce/tinymce/tinymce_#{TinyMCE::TINYMCE_VERSION}.zip", "tinymce.zip")
download("https://github.com/downloads/tinymce/tinymce/tinymce_#{TinyMCE::TINYMCE_VERSION}_jquery.zip", "tinymce.jquery.zip")
end
task :extract do
step "Extracting core files" do
`rm -rf tmp/tinymce`
`unzip -u tmp/tinymce.zip -d tmp`
`rm -rf assets/precompiled/tinymce`
`mkdir -p assets/precompiled/tinymce`
`mv tmp/tinymce/jscripts/tiny_mce/* assets/precompiled/tinymce/`
end
step "Extracting jQuery files" do
`rm -rf tmp/tinymce`
`unzip -u tmp/tinymce.jquery.zip -d tmp`
`mv tmp/tinymce/jscripts/tiny_mce/jquery.tinymce.js assets/precompiled/tinymce/jquery.tinymce.js`
`mv tmp/tinymce/jscripts/tiny_mce/tiny_mce.js assets/precompiled/tinymce/tiny_mce_jquery.js`
`mv tmp/tinymce/jscripts/tiny_mce/tiny_mce_src.js assets/precompiled/tinymce/tiny_mce_jquery_src.js`
end
end
task :process do
step "Fixing file encoding" do
require 'iconv'
converter = Iconv.new('UTF-8', 'ISO-8859-1')
Dir["assets/precompiled/tinymce/**/*.js"].each do |file|
contents = converter.iconv(File.read(file)).force_encoding('UTF-8')
File.open(file, 'w') { |f| f.write(contents) }
end
end
step "Copying includeable assets" do
`cp assets/precompiled/tinymce/tiny_mce_src.js assets/vendor/tinymce/tiny_mce.js`
`cp assets/precompiled/tinymce/tiny_mce_jquery_src.js assets/vendor/tinymce/tiny_mce_jquery.js`
`cp assets/precompiled/tinymce/jquery.tinymce.js assets/vendor/tinymce/jquery-tinymce.js`
end
end