2014-03-10 22:19:53 +01:00
|
|
|
require 'rubygems'
|
|
|
|
require 'optparse'
|
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
#
|
2015-08-02 21:58:40 +02:00
|
|
|
# Create New Post
|
2014-03-10 22:19:53 +01:00
|
|
|
# rake post -- Title
|
|
|
|
#
|
|
|
|
task :post do
|
|
|
|
OptionParser.new.parse!
|
|
|
|
ARGV.shift
|
|
|
|
title = ARGV.join(' ')
|
|
|
|
|
2015-09-13 22:12:42 +02:00
|
|
|
path = "_src/_drafts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
2015-08-02 21:58:40 +02:00
|
|
|
|
2014-03-10 22:19:53 +01:00
|
|
|
if File.exist?(path)
|
2015-08-02 21:58:40 +02:00
|
|
|
puts "Dude, file exists - skipping create"
|
2014-03-10 22:19:53 +01:00
|
|
|
else
|
|
|
|
File.open(path, "w") do |file|
|
2015-08-02 21:58:40 +02:00
|
|
|
file.puts YAML.dump({
|
|
|
|
'layout' => 'post',
|
|
|
|
'title' => title,
|
|
|
|
'image' => 'REPLACEME.jpg',
|
|
|
|
'author' => 'Matthias Kretschmann',
|
|
|
|
'date' => Time.now
|
|
|
|
})
|
2014-03-10 22:19:53 +01:00
|
|
|
file.puts "---"
|
|
|
|
end
|
|
|
|
end
|
2015-09-13 22:12:42 +02:00
|
|
|
`atom #{path}`
|
2014-03-10 22:19:53 +01:00
|
|
|
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2015-08-02 21:58:40 +02:00
|
|
|
# Create New Photo Post
|
2014-03-10 22:19:53 +01:00
|
|
|
# rake photo -- Title
|
|
|
|
#
|
|
|
|
task :photo do
|
|
|
|
OptionParser.new.parse!
|
|
|
|
ARGV.shift
|
|
|
|
title = ARGV.join(' ')
|
|
|
|
|
2015-09-13 22:12:42 +02:00
|
|
|
path = "_src/_drafts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
2015-08-02 21:58:40 +02:00
|
|
|
|
2014-03-10 22:19:53 +01:00
|
|
|
if File.exist?(path)
|
2015-08-02 21:58:40 +02:00
|
|
|
puts "Dude, file exists - skipping create"
|
2014-03-10 22:19:53 +01:00
|
|
|
else
|
|
|
|
File.open(path, "w") do |file|
|
2015-08-02 21:58:40 +02:00
|
|
|
file.puts YAML.dump({
|
|
|
|
'layout' => 'photo',
|
|
|
|
'title' => title,
|
|
|
|
'image' => 'REPLACEME.jpg',
|
|
|
|
'author' => 'Matthias Kretschmann',
|
|
|
|
'date' => Time.now,
|
|
|
|
'category' => 'photos'
|
|
|
|
})
|
2014-03-10 22:19:53 +01:00
|
|
|
file.puts "---"
|
|
|
|
end
|
|
|
|
end
|
2015-09-13 22:12:42 +02:00
|
|
|
`atom #{path}`
|
2014-03-10 22:19:53 +01:00
|
|
|
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2015-08-02 21:58:40 +02:00
|
|
|
# Create New Link Post
|
2014-03-10 22:19:53 +01:00
|
|
|
# rake link -- Title
|
|
|
|
#
|
|
|
|
task :photo do
|
|
|
|
OptionParser.new.parse!
|
|
|
|
ARGV.shift
|
|
|
|
title = ARGV.join(' ')
|
|
|
|
|
2015-09-13 22:12:42 +02:00
|
|
|
path = "_src/_drafts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
2015-08-02 21:58:40 +02:00
|
|
|
|
2014-03-10 22:19:53 +01:00
|
|
|
if File.exist?(path)
|
2015-08-02 21:58:40 +02:00
|
|
|
puts "Dude, file exists - skipping create"
|
2014-03-10 22:19:53 +01:00
|
|
|
else
|
|
|
|
File.open(path, "w") do |file|
|
2015-08-02 21:58:40 +02:00
|
|
|
file.puts YAML.dump({
|
|
|
|
'layout' => 'link',
|
|
|
|
'title' => title,
|
|
|
|
'author' => 'Matthias Kretschmann',
|
|
|
|
'date' => Time.now
|
|
|
|
})
|
2014-03-10 22:19:53 +01:00
|
|
|
file.puts "---"
|
|
|
|
end
|
|
|
|
end
|
2015-09-13 22:12:42 +02:00
|
|
|
`atom #{path}`
|
2014-03-10 22:19:53 +01:00
|
|
|
|
|
|
|
exit 1
|
2015-08-02 21:58:40 +02:00
|
|
|
end
|