forked from hmfaysal/hmfaysal-omega-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile
97 lines (94 loc) · 3.55 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# adapted from https://github.com/imathis/octopress/blob/master/Rakefile
# usage rake new_post['My New Post'] or rake new_post (defaults to "My New Post")
desc "Start a new post"
task :new, :title do |t, args|
args.with_defaults(:title => 'My New Post')
title = args.title
filename = "_posts/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.md"
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "description: "
post.puts "headline: "
post.puts "modified: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "category: personal"
post.puts "tags: []"
post.puts "image: "
post.puts " feature: "
post.puts "comments: true"
post.puts "mathjax: "
post.puts "---"
end
end
desc "Start a new quote"
task :newquote, :title do |t, args|
args.with_defaults(:title => 'My New quote')
title = args.title
filename = "_posts/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.md"
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "type: quote"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "description: "
post.puts "headline: "
post.puts "modified: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "category: quotes"
post.puts "tags: []"
post.puts "image: "
post.puts " feature: "
post.puts "comments: false"
post.puts "mathjax: "
post.puts "---"
end
end
desc "Start a new status"
task :newstatus, :title do |t, args|
args.with_defaults(:title => 'My New Post')
title = args.title
filename = "_posts/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.md"
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "type: status"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "description: "
post.puts "headline: "
post.puts "modified: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "category: status"
post.puts "tags: []"
post.puts "image: "
post.puts " feature: "
post.puts "comments: false"
post.puts "mathjax: "
post.puts "---"
end
end
# adapted from https://github.com/imathis/octopress/blob/master/Rakefile
# usage rake new_post['My New Post'] or rake new_post (defaults to "My New Post")
desc "Start a new page"
task :newpage, :title do |t, args|
args.with_defaults(:title => 'My New page')
title = args.title
filename = "#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.md"
puts "Creating new page: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: page"
post.puts "permalink: #{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}/index.html"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "description: "
post.puts "headline: "
post.puts "modified: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "tags: []"
post.puts "image: "
post.puts " feature: "
post.puts "comments: true"
post.puts "mathjax: "
post.puts "---"
end
end