-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
44 lines (39 loc) · 1.02 KB
/
Rakefile
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
38
39
40
41
42
43
44
task :default => :build
desc 'Build site with Jekyll.'
task :build => :tags do
print "Compiling website...\n"
sh "jekyll"
end
desc 'Enter development mode.'
task :local => :build do
print "Auto-regenerating enabled.\n"
print "Development server started at http://localhost:4000/ \n"
print "Development mode entered.\n"
sh "jekyll --auto --server"
end
desc "Create a new post"
task :new do
throw "No title given" unless ARGV[1]
title = ""
ARGV[1..ARGV.length - 1].each { |v| title += " #{v}" }
title.strip!
now = Time.now
path = "_posts/" + now.strftime('%F') + "-" + title.downcase.gsub(/[\s\.]/, '-').gsub(/[^\w\-]/, '') + ".html"
File.open(path, "w") do |f|
f.puts "---"
f.puts "layout: default"
f.puts "title: #{title}"
f.puts "date: #{now.strftime('%F %T')}"
f.puts "speakers:"
f.puts " - name:"
f.puts " handle:"
f.puts " pic:"
f.puts " about:"
f.puts " website:"
f.puts "---"
f.puts ""
f.puts ""
end
`subl #{path}`
exit
end