Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 76 lines (65 sloc) 2.264 kB
require "rake"
require 'stringex'
require 'fileutils'
SOURCE_DIR = "./"
DESTINATION_DIR = "./_site"
POSTS_DIR = "_posts"
NEW_POST_EXT = "md"
#
# From Octopress.
#
desc "Begin a new post in #{SOURCE_DIR}/#{POSTS_DIR}"
task :create, :title do |t, args|
mkdir_p "#{SOURCE_DIR}/#{POSTS_DIR}"
args.with_defaults(:title => 'new-post')
title = args.title
filename = "#{SOURCE_DIR}/#{POSTS_DIR}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{NEW_POST_EXT}"
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "date: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "published: false"
post.puts "tags: []"
post.puts "categories: "
post.puts "---"
end
end
desc "Process LESS into CSS."
task :less do
FileUtils.mkdir_p 'assets/css/'
sh "lessc assets/_less/onox.less -x > assets/css/screen.css"
end
desc "Deploy to Dreamhost."
task :deploy do
system "rsync -avz --perms --delete --progress --chmod=go+rx #{DESTINATION_DIR}/ $DH_ONOX_PATH"
end
desc "List unpublished posts."
task :unpublished do
grep_unpublished = "grep -lRE '^\s*published:\s*false\s*$' _posts"
get_titles = "parallel grep -E '^title:' {}"
remove_extra_characters = "cut -c 8-"
result = `#{grep_unpublished} | #{get_titles} | #{remove_extra_characters}`
result.split("\n").each do |l|
puts l.gsub(/^_posts\//, "").gsub(/:published:\s+false\s*$/, "")
end
end
# desc "Create a quotes.json file in the _data dir"
# task :get_quotes, [:api_key_location] do |t, args|
# # Create _data dir if it doesn't exist.
# Dir.mkdir("./_data") unless File.directory? "./_data"
#
# puts "Reading API key..."
# api_url = "http://api.tumblr.com/v2/blog/turing-machine.tumblr.com/posts/quote?api_key="
# api_key_file = args.api_key_location || "./_data/api_key"
# api_key = File.open(api_key_file, 'r').readlines.first
#
# puts "Getting data from Tumblr's API..."
# File.open("./_data/quotes.json", 'w') do |f|
# f << open(api_url + api_key).readlines.first
# end
# end
Jump to Line
Something went wrong with that request. Please try again.