Forked from corey/migrate_articles_from_mephisto_markdown_files.rb
Created
October 9, 2009 19:34
-
-
Save myabc/206284 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
# To use: | |
# mkdir _posts | |
# script/runner migrate_articles_from_mephisto_markdown_files.rb | |
articles = Article.find(:all) | |
articles.each do |article| | |
published_at = "#{article.published_at.year}-#{article.published_at.month}-#{article.published_at.day}" unless article.published_at.nil? | |
author = article.user.login | |
permalink = article.permalink | |
title = article.title | |
excerpt = article.excerpt | |
body = article.body | |
fp = File.open("_posts/#{'draft-' if article.published_at.nil?}#{published_at}-#{permalink}.markdown", 'w') | |
fp.write(%"--- | |
layout: post | |
title: \"#{title}\" | |
author: #{author} | |
--- | |
#{excerpt} | |
#{body}") | |
fp.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment