This repository has been archived by the owner on Apr 28, 2023. It is now read-only.
forked from vonconrad/ruby.org.au
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Rakefile
65 lines (55 loc) · 1.73 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
require "rubygems"
require "bundler/setup"
require "tilt"
task :default => 'build:all'
namespace :build do
desc "Build the stylesheets, outputting to ./site/css"
task :stylesheets do
sh 'compass compile -c compass-config.rb'
end
desc "Build the javascripts, outputting to ./site/js"
task :javascripts do
sh 'mkdir -p ./site/js'
sh 'cp -r javascripts/*.js ./site/js'
end
desc "Copy the static images to ./site/images"
task :images do
sh 'mkdir -p ./site/images'
sh 'cp -r images/* ./site/images'
end
desc "Copy the static files to ./site/files"
task :images do
sh 'mkdir -p ./site/files'
sh 'cp -r files/* ./site/files'
end
desc "Setup the CNAME"
task :cname do
sh 'cp CNAME ./site/'
end
desc "Build the page templates, outputting to ./site"
task :pages do
layout = Tilt.new('layout.html.haml')
pages = Dir.glob("pages/**/*.html.*")
p pages
pages.each do |template|
output_path = template.gsub(/^pages/, 'site').gsub(File.extname(template), '')
puts "Rendering #{template}"
puts " to #{output_path}"
FileUtils.mkdir_p(File.expand_path(File.dirname(output_path)))
File.open(output_path, "w") do |f|
f << layout.render do
Tilt.new(template).render
end
end
end
end
desc "Build all the dynamic bits of the site"
task :all => [:stylesheets, :javascripts, :pages, :cname, :images, :files]
end
desc "Commit the latest version of the site to the gh-pages branch"
task :deploy do
site = `git ls-tree -d HEAD site | awk '{print $3}'`.strip
new_commit = `echo 'Update site' | git commit-tree #{site} -p refs/heads/gh-pages`.strip
`git update-ref refs/heads/gh-pages #{new_commit}`
`git push origin gh-pages -f`
end