Skip to content

Instantly share code, notes, and snippets.

@jtoy
Forked from al3x/newpost.rb
Created August 20, 2009 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtoy/170776 to your computer and use it in GitHub Desktop.
Save jtoy/170776 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "#{Dir.pwd}/_posts/#{date_prefix}-#{postname}.textile"
header = <<-END
---
layout: post
title: "#{ARGV[0]}"
---
h1. {{ page.title }}
p(meta). #{Time.now.strftime("%d %B %Y")}
END
File.open(post, 'w') do |f|
f << header
end
system("mate", "-a", post)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment