1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-30 07:58:11 +01:00
blog/Rakefile

97 lines
1.9 KiB
Ruby
Raw Normal View History

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(' ')
path = "_src/_posts/#{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',
'published' => false,
'title' => title,
'image' => 'REPLACEME.jpg',
'author' => 'Matthias Kretschmann',
'date' => Time.now
})
2014-03-10 22:19:53 +01:00
file.puts "---"
end
end
`mate #{path}`
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(' ')
path = "_src/_posts/#{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',
'published' => false,
'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
`mate #{path}`
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(' ')
path = "_src/_posts/#{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',
'published' => false,
'title' => title,
'author' => 'Matthias Kretschmann',
'date' => Time.now
})
2014-03-10 22:19:53 +01:00
file.puts "---"
end
end
`mate #{path}`
exit 1
2015-08-02 21:58:40 +02:00
end