Skip to content

Instantly share code, notes, and snippets.

@tjun
Created October 26, 2012 15:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjun/3959588 to your computer and use it in GitHub Desktop.
Save tjun/3959588 to your computer and use it in GitHub Desktop.
jekyll
# Usage: rake preview
desc "Build files and launch preview server"
task :preview do
sh "open -a 'Google\ Chrome' 'http://localhost:4000'"
sh "jekyll --server --auto"
end
# Usage: rake post["title"]
desc "Create a new post file with title"
task :post do
print 'title :'
title = STDIN.gets.strip
dirname = File.join(".", "_posts")
if not FileTest.directory?(dirname)
abort("rake aborted: #{dirname} directory not found.")
end
date = Time.now.strftime('%Y-%m-%d')
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
filename = "#{date}-#{slug}.md"
fullpath = File.join(dirname, filename)
if File.exist?(fullpath)
abort("rake aborted: #{fullpath} already exists.")
end
File.open(fullpath, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "category: "
post.puts "title: #{title}"
post.puts "date: #{date}"
post.puts "summary: "
post.puts "---"
end
#puts "Open #{fullpath} in an editor."
sh "open -a Mou #{fullpath}"
end
#Usage: rake sass
desc "convert scss to css"
task :sass do
sh "sass --style compressed _scss/style.scss:css/style.css"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment