Permalink
Browse files

Markdown format export command for Octopress, use command: `rake mark…

…down:export`
  • Loading branch information...
1 parent 8efdec8 commit cc546785a25bd3c70f082d62530d448537e8186e @huacnlee committed Feb 21, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 Rakefile
View
@@ -36,3 +36,32 @@ namespace :reader_share do
end
end
+# Google Reader
+namespace :markdown do
+ desc "Google Reader reload shere items."
+ task :export => :environment do
+ Post.all(:include => [:category]).each do |post|
+ print "post: <#{post.slug}>"
+ categories = ""
+ if not post.tags.blank?
+ categories = "\n- #{post.tags.join("\n- ")}"
+ end
+
+ file_name = "#{Rails.root}/_posts/#{post.created_at.strftime('%Y-%m-%d')}-#{post.slug}.markdown"
+
+ summary = %(---
+layout: post
+title: "#{post.title}"
+date: #{post.created_at.strftime("%Y-%m-%d %H:%M")}
+comments: true
+categories: #{categories}
+---
+)
+ File.open(file_name,"w+") do |f|
+ f.puts summary
+ f.puts post.body
+ end
+ puts "[done]"
+ end
+ end
+end

0 comments on commit cc54678

Please sign in to comment.