Created
November 28, 2011 09:11
-
-
Save chagel/1399713 to your computer and use it in GitHub Desktop.
Rakefile to manage jekyll commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Begin a new post' | |
task :post do | |
ROOT_DIR = File.dirname(__FILE__) | |
title = ARGV[1] | |
tags = ARGV[2 ] | |
unless title | |
puts %{Usage: rake post "The Post Title"} | |
exit(-1) | |
end | |
datetime = Time.now.strftime('%Y-%m-%d') # 30 minutes from now. | |
slug = title.strip.downcase.gsub(/ /, '-') | |
path = "#{ROOT_DIR}/_posts/#{datetime}-#{slug}.markdown" | |
header = <<-END | |
--- | |
layout: post | |
title: #{title} | |
date: #{Time.now} | |
excerpt: | |
tag: #{tags} | |
--- | |
END | |
File.open(path, 'w') {|f| f << header } | |
system("subl", path) | |
end | |
desc 'build static files' | |
task :build do | |
`rm -rf _site && jekyll` | |
end | |
desc 'preview local blogs' | |
task :preview do | |
`open "http://localhost:4000"` | |
end | |
desc 'start jekyll server' | |
task :server do | |
`jekyll --server 4000 --auto` | |
end | |
desc 'deploy on the server' | |
task :deploy do | |
`ssh -t webuser@xxx.xxx.xxx.xxx 'cd /home/webuser/www/gchen.cn && git pull'` | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment