Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 07d78cb350
Fetching contributors…

Cannot retrieve contributors at this time

executable file 131 lines (103 sloc) 3.122 kb
#!/usr/bin/env bundle exec nake
# encoding: utf-8
Encoding.default_internal = "utf-8"
Encoding.default_external = "utf-8"
# Task.tasks.default_proc = lambda { |*| Task[:generate] }
Task.new(:tags) do |task|
task.description = "Show available tags."
task.define do
ARGV.clear.push("--no-generate")
load `which ace`.chomp
puts
Tag.tags_by_occurrence.each do |tag|
puts "#{tag.name} (#{tag.posts.size})"
end
end
end
Task.new(:publish) do |task|
task.description = "Publish given draft."
task.define do |draft_path|
date = Time.now.strftime("%Y-%m-%d")
slug = File.basename(draft_path)
path = "content/posts/#{date}-#{slug}"
sh "mv #{draft_path} #{path}"
sh "git rm #{draft_path} 2> /dev/null"
sh "git add #{path}"
Task[:regenerate].call
sh "git add output"
sh "git commit #{path} output/ -m '[POST] #{slug} published.'"
end
end
Task.new(:generate) do |task|
task.description = "Generate static HTML."
task.define do
sh "./boot.rb"
end
end
Task.new(:clobber) do |task|
task.description = "Remove all generated files."
task.define do
sh "rm -rf output"
end
end
Task.new(:regenerate) do |task|
task.description = "Remove all generated files and generate them again."
task.dependencies << :clobber
task.dependencies << :generate
end
Task.new(:commit) do |task|
task.description = "Regenerate all generated files and commit them."
task.dependencies << :regenerate
task.define do
sh "git add output"
sh "git commit -a -m 'Regenerated output/.'"
end
end
Task.new(:rsync) do |task|
task.description = "Rsync the output to server."
# config
task.config[:user] = "static"
task.config[:server] = "tagadab"
task.config[:path] = "/webs/static/blog.101ideas.cz/site"
def task.rsync
sh "rsync -av --delete output/ #{config[:user]}@#{config[:server]}:#{config[:path]}"
end
task.define do |options|
options[:test] = true unless options.has_key?(:test)
if options[:test]
puts "~ Running tests ..."
results = %x{bundle exec rspec spec}
if $?.exitstatus == 0
puts "~ Tests succeeded, deploying ..."
else
puts "~ Tests failed!"
puts results
exit 1
end
end
self.rsync
end
end
Task.new("rsync:vhost") do |task|
task.description = "Re-upload vhost.conf to the server."
# config
task.config[:user] = Task[:rsync].config[:user]
task.config[:server] = Task[:rsync].config[:server]
task.config[:path] = "/webs/static/blog.101ideas.cz/vhost.conf"
task.define do
config = task.config
sh "rsync -av vhost.conf #{config[:user]}@#{config[:server]}:#{config[:path]}"
end
end
Task.new("rsync:vhost:reload") do |task|
task.description = "Re-upload vhost.conf & restart the server."
# dependencies
task.dependencies << "rsync:vhost"
# config
task.config[:user] = "root"
task.config[:server] = Task[:rsync].config[:server]
task.define do
config = task.config
sh "ssh #{config[:user]}@#{config[:server]} '/etc/init.d/nginx stop && /etc/init.d/nginx start'"
end
end
Jump to Line
Something went wrong with that request. Please try again.