summaryrefslogtreecommitdiff
path: root/rakefile
blob: 8876b2d266bc0baea6f3c13b91f59d4b4ce1b6a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require "stringex"

def jekyll(opts="", path="")
  sh "rm -rf _site"
  sh "mkdir _site"
  sh path + "jekyll " + opts
end

desc "Build site using Jekyll"
task :build do
  jekyll
end

desc "Serve on Localhost with port 4000"
task :default do
  jekyll "--server --auto "
end

namespace :posts do
  task :new, :title do |t, args|
    title = args.title
    filename = "_posts/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.mkd"
    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 %H:%M')}"
      post.puts "comments: true"
      post.puts "categories: "
      post.puts "---"
    end
  end
end