Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (30 sloc) 0.734 kb
# Create new jekyll post and open in textmate
# $ ruby _new.rb This is the title
# The arguments form the title
unless ARGV[0]
raise "Please provide a post title."
end
# Create a URL slug from the title
def slugify(title)
str = title.dup
str.gsub!(/[^a-zA-Z0-9 ]/,"")
str.gsub!(/[ ]+/," ")
str.gsub!(/ /,"-")
str.downcase!
str
end
# Create parameters
title = ARGV.join(' ')
slug = slugify(title)
prefix = Time.new.strftime("%Y-%m-%d")
file = "#{prefix}-#{slug}.markdown"
path = File.join(File.dirname(__FILE__), "_posts/#{file}")
text = <<-eos
---
title: #{title}
layout: post
---
eos
# Create a new file and open it in textmate
File.open(path, 'w') { |f| f.write(text) }
system("mate #{path}")
Jump to Line
Something went wrong with that request. Please try again.