-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
93 lines (70 loc) · 2.32 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require "rubygems"
require "bundler"
require "fileutils"
Dir.chdir(File.dirname(__FILE__) + "/site")
Bundler.require(:default)
# http://stackoverflow.com/questions/1113422/how-to-bypass-ssl-certificate-verification-in-open-uri
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
require 'open-uri'
class Package
class R < Redcarpet::Render::XHTML
attr_reader :downloads
def initialize(*a)
@downloads = []
super
end
def link(link, title, content)
tpl = '<a href="%s" title="%s">%s</a>'
tpl % [rewrite(link), title, content]
end
def image(link, title, alt_text)
tpl = '<img style="max-width: 912px" src="%s" title="%s" alt="%s" />'
tpl % [rewrite(link), title, alt_text]
end
private
# Ideally this will make links relative
def rewrite(link)
return link if link =~ /^http/
@downloads.push(link)
File.basename(link)
end
end
def self.for(*names)
names.flatten.map{|name| new(name)}
end
def initialize(name)
@name = name
end
def repo_url
"https://github.com/guerilla-di/framecurve_%s" % @name
end
def package!
render_engine = R.new
md = Redcarpet::Markdown.new(render_engine)
# Download the readme
readme_handle = open(File.join(repo_url, "/raw/master/README.markdown"))
rewritten_readme_html = md.render(readme_handle.read)
assets = render_engine.downloads.map do |e|
url = File.join('https://github.com/guerilla-di/', e)
url = url.gsub(/ /, '%20')
[File.basename(e), open(url)]
end
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "site", "scripts", @name))
# Write out the index.erb
File.open(File.join(File.dirname(__FILE__), "site", "scripts", @name, "index.erb"), "wb") do | index |
index.write(rewritten_readme_html)
end
assets.each do | a |
# Write out the index.erb
File.open(File.join(File.dirname(__FILE__), "site", "scripts", @name, a[0]), "wb") do | index |
index.write(a[1].read)
end
end
end
end
task :consolidate_scripts do
Package.for(%w( aftereffects maya houdini nuke)).each{|p| p.package! }
end
task :generate => [:consolidate_scripts] do
`rm -rf html && serve export && rsync -rvz html/ serveur.julik.nl:/home/julik/web-apps/framecurve-website/`
end