Add site namespace and rename site preview/publish rake tasks.

This commit is contained in:
Tom Preston-Werner 2012-12-28 16:09:42 -06:00
parent 6c02483255
commit 88bdb15338
1 changed files with 36 additions and 34 deletions

View File

@ -115,44 +115,46 @@ end
# #
############################################################################# #############################################################################
desc "Generate and view the site locally" namespace :site do
task :site do desc "Generate and view the site locally"
# Yep, it's a hack! Wait a few seconds for the Jekyll site to generate and task :preview do
# then open it in a browser. Someday we can do better than this, I hope. # Yep, it's a hack! Wait a few seconds for the Jekyll site to generate and
Thread.new do # then open it in a browser. Someday we can do better than this, I hope.
sleep 4 Thread.new do
puts "Opening in browser..." sleep 4
sh "open http://localhost:4000" puts "Opening in browser..."
sh "open http://localhost:4000"
end
# Generate the site in server mode.
puts "Running Jekyll..."
sh "cd site && jekyll --server"
end end
# Generate the site in server mode. desc "Commit the local site to the gh-pages branch and deploy"
puts "Running Jekyll..." task :publish do
sh "cd site && jekyll --server" # Ensure the gh-pages dir exists so we can generate into it.
end puts "Checking for gh-pages dir..."
unless File.exist?("./gh-pages")
puts "No gh-pages directory found. Run the following commands first:"
puts " `git clone git@github.com:mojombo/god gh-pages"
puts " `cd gh-pages"
puts " `git checkout gh-pages`"
exit(1)
end
desc "Commit the local site to the gh-pages branch and deploy" # Copy the rest of the site over.
task :site_release do puts "Copying static..."
# Ensure the gh-pages dir exists so we can generate into it. Dir.glob("site/*") do |path|
puts "Checking for gh-pages dir..." next if path == "_site"
unless File.exist?("./gh-pages") sh "cp -R #{path} gh-pages/"
puts "No gh-pages directory found. Run the following commands first:" end
puts " `git clone git@github.com:mojombo/god gh-pages"
puts " `cd gh-pages" # Commit the changes
puts " `git checkout gh-pages`" sha = `git log`.match(/[a-z0-9]{40}/)[0]
exit(1) sh "cd gh-pages && git add . && git commit -m 'Updating to #{sha}.' && git push"
puts 'Done.'
end end
# Copy the rest of the site over.
puts "Copying static..."
Dir.glob("site/*") do |path|
next if path == "_site"
sh "cp -R #{path} gh-pages/"
end
# Commit the changes
sha = `git log`.match(/[a-z0-9]{40}/)[0]
sh "cd gh-pages && git add . && git commit -m 'Updating to #{sha}.' && git push"
puts 'Done.'
end end
############################################################################# #############################################################################