Created
January 18, 2013 02:54
-
-
Save picandocodigo/4562010 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Create a new post, in Spanish and English." | |
task :new_post, :author, :title do |t, args| | |
post = <<-HTML | |
--- | |
layout: post | |
title: TITLE | |
lang: LANG | |
author: AUTHOR | |
--- | |
HTML | |
title = args[:title] | |
author = args[:author] | |
post.gsub!("AUTHOR", args[:author]).gsub!("TITLE", title) | |
["en", "es"].each do |lang| | |
filename = "#{Time.new.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/\s/,'-')}-#{lang}.markdown" | |
post_path = File.join("_posts", filename) | |
File.open(post_path, 'w') do |f| | |
f.puts post.gsub("LANG", lang) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment