jrk (owner)

Fork Of

gist: 100171 by al3x Handy new post script for J...

Revisions

gist: 106869 Download_button fork
public
Description:
Creates a new Jekyll post, opens it in TextMate, and adds to the git index
Public Clone URL: git://gist.github.com/106869.git
Embed All Files: show embed
newpost.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env ruby
 
require Dir
 
unless ARGV[0]
  puts 'Usage: newpost "the post title"'
  exit(-1)
end
 
blog_root = "/Users/jrk/proj/blog"
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "#{blog_root}/_posts/#{date_prefix}-#{postname}.md"
 
header = <<-END
---
layout: post
title: "#{ARGV[0]}"
---
END
 
Dir.chdir(blog_root)
 
File.open(post, 'w') do |f|
  f << header
end
 
system("mate", "-w", post)
system("git", "add", post)