mirror of
https://github.com/kremalicious/blog.git
synced 2025-01-09 13:18:54 +01:00
add date to rake task for new posts
This commit is contained in:
parent
413f86856d
commit
e3c628aa17
47
Rakefile
47
Rakefile
@ -3,7 +3,7 @@ require 'optparse'
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create New Post
|
# Create New Post
|
||||||
# rake post -- Title
|
# rake post -- Title
|
||||||
#
|
#
|
||||||
task :post do
|
task :post do
|
||||||
@ -12,12 +12,19 @@ task :post do
|
|||||||
title = ARGV.join(' ')
|
title = ARGV.join(' ')
|
||||||
|
|
||||||
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
||||||
|
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
puts "Dude, file exists - skipping create"
|
puts "Dude, file exists - skipping create"
|
||||||
else
|
else
|
||||||
File.open(path, "w") do |file|
|
File.open(path, "w") do |file|
|
||||||
file.puts YAML.dump({'layout' => 'post', 'published' => false, 'title' => title, 'author' => 'Matthias Kretschmann'})
|
file.puts YAML.dump({
|
||||||
|
'layout' => 'post',
|
||||||
|
'published' => false,
|
||||||
|
'title' => title,
|
||||||
|
'image' => 'REPLACEME.jpg',
|
||||||
|
'author' => 'Matthias Kretschmann',
|
||||||
|
'date' => Time.now
|
||||||
|
})
|
||||||
file.puts "---"
|
file.puts "---"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -27,7 +34,7 @@ task :post do
|
|||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create New Photo Post
|
# Create New Photo Post
|
||||||
# rake photo -- Title
|
# rake photo -- Title
|
||||||
#
|
#
|
||||||
task :photo do
|
task :photo do
|
||||||
@ -36,12 +43,20 @@ task :photo do
|
|||||||
title = ARGV.join(' ')
|
title = ARGV.join(' ')
|
||||||
|
|
||||||
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
||||||
|
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
puts "Dude, file exists - skipping create"
|
puts "Dude, file exists - skipping create"
|
||||||
else
|
else
|
||||||
File.open(path, "w") do |file|
|
File.open(path, "w") do |file|
|
||||||
file.puts YAML.dump({'layout' => 'photo', 'published' => false, 'title' => title, 'image' => 'REPLACEME.jpg', 'author' => 'Matthias Kretschmann', 'category' => 'photos'})
|
file.puts YAML.dump({
|
||||||
|
'layout' => 'photo',
|
||||||
|
'published' => false,
|
||||||
|
'title' => title,
|
||||||
|
'image' => 'REPLACEME.jpg',
|
||||||
|
'author' => 'Matthias Kretschmann',
|
||||||
|
'date' => Time.now,
|
||||||
|
'category' => 'photos'
|
||||||
|
})
|
||||||
file.puts "---"
|
file.puts "---"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -51,7 +66,7 @@ task :photo do
|
|||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create New Link Post
|
# Create New Link Post
|
||||||
# rake link -- Title
|
# rake link -- Title
|
||||||
#
|
#
|
||||||
task :photo do
|
task :photo do
|
||||||
@ -60,16 +75,22 @@ task :photo do
|
|||||||
title = ARGV.join(' ')
|
title = ARGV.join(' ')
|
||||||
|
|
||||||
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
|
||||||
|
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
puts "Dude, file exists - skipping create"
|
puts "Dude, file exists - skipping create"
|
||||||
else
|
else
|
||||||
File.open(path, "w") do |file|
|
File.open(path, "w") do |file|
|
||||||
file.puts YAML.dump({'layout' => 'link', 'published' => false, 'title' => title, 'author' => 'Matthias Kretschmann'})
|
file.puts YAML.dump({
|
||||||
|
'layout' => 'link',
|
||||||
|
'published' => false,
|
||||||
|
'title' => title,
|
||||||
|
'author' => 'Matthias Kretschmann',
|
||||||
|
'date' => Time.now
|
||||||
|
})
|
||||||
file.puts "---"
|
file.puts "---"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
`mate #{path}`
|
`mate #{path}`
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user