newbamboo (owner)

Forks

Revisions

gist: 65418 Download_button fork
public
Public Clone URL: git://gist.github.com/65418.git
Embed All Files: show embed
migrate_articles_from_mephisto_markdown_files.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
articles = Article.find(:all)
 
articles.each do |article|
  published_at = "#{published_at.year}-#{published_at.month}-#{published_at.day}"
  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