-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathRakefile
More file actions
55 lines (44 loc) · 1.18 KB
/
Rakefile
File metadata and controls
55 lines (44 loc) · 1.18 KB
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
45
46
47
48
49
50
51
52
53
54
55
require 'date'
require 'active_support'
require 'jekyll'
desc "Given a category and title as an argument, create a new post file"
task :post do
print 'Enter the category (blog, recipes, travel, or tech): '
category = $stdin.gets.chomp.strip
today = DateTime::now().strftime('%Y-%m-%d')
print 'Enter the post title: '
title = $stdin.gets.chomp.strip
slug = title.downcase
slug = slug.gsub(/[^-\w\s]/, '')
slug = slug.gsub(/^\s+|\s+$/, '')
slug = slug.gsub(/[-\s]+/, '-')
filename = "#{today}-#{slug}.md"
path = File.join("#{category}/_posts", filename)
if File.exist? path; raise RuntimeError.new("Won't clobber #{path}"); end
File.open(path, 'w') do |file|
file.write <<-EOS
---
layout: post
title: #{title}
tags:
- tag
description: Enter description here
---
Content goes here
EOS
end
sh "open #{path} -a bbedit"
end
task :deploy do
sh 'jekyll /var/www/admin/marran.com /var/www/html'
end
task :commit do
print 'Enter git commit message: '
message = $stdin.gets.chomp.strip
sh 'git add blog/*'
sh 'git add recipes/*'
sh 'git add travel/*'
sh 'git add statuses/*'
sh "git commit --all --message \"#{message}\""
sh 'git push origin master'
end