forked from wadewegner/wadewegner.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
37 lines (35 loc) · 1.15 KB
/
Rakefile
File metadata and controls
37 lines (35 loc) · 1.15 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
require 'fileutils'
namespace :draft do
desc "Creating a new draft for post/entry"
task :new do
puts "What's the name for your next post?"
@name = STDIN.gets.chomp
@slug = "#{@name}"
# @slug = @slug.tr('ÁáÉéÍíÓóÚú', 'AaEeIiOoUu')
@slug = @slug.downcase.strip.gsub(' ', '-')
FileUtils.touch("_drafts/#{@slug}.md")
open("_drafts/#{@slug}.md", 'a' ) do |file|
file.puts "---"
file.puts "layout: post"
file.puts "title: #{@name}"
file.puts "description: maximum 155 char description"
file.puts "categories:"
file.puts "- blog"
file.puts "---"
end
end
desc "copy draft to production post!"
task :ready do
puts "Posts in _drafts:"
Dir.foreach("_drafts") do |fname|
next if fname == '.' or fname == '..' or fname == '.keep'
puts fname
end
puts "what's the name of the draft to post?"
@post_name = STDIN.gets.chomp
@post_date = Time.now.strftime("%F")
FileUtils.mv("_drafts/#{@post_name}", "_posts/#{@post_name}")
FileUtils.mv("_posts/#{@post_name}", "_posts/#{@post_date}-#{@post_name}")
puts "Post copied and ready to deploy!"
end
end