diff --git a/lib/jekyll/migrators/wordpressdotcom.rb b/lib/jekyll/migrators/wordpressdotcom.rb index 53218e50..62187a77 100644 --- a/lib/jekyll/migrators/wordpressdotcom.rb +++ b/lib/jekyll/migrators/wordpressdotcom.rb @@ -4,6 +4,7 @@ require 'rubygems' require 'hpricot' require 'fileutils' require 'yaml' +require 'time' module Jekyll # This importer takes a wordpress.xml file, which can be exported from your @@ -18,13 +19,26 @@ module Jekyll (doc/:channel/:item).each do |item| title = item.at(:title).inner_text.strip permalink_title = item.at('wp:post_name').inner_text - date = Time.parse(item.at(:pubDate).inner_text) + date = Time.parse(item.at('wp:post_date').inner_text) + status = item.at('wp:status').inner_text + type = item.at('wp:post_type').inner_text tags = (item/:category).map{|c| c.inner_text}.reject{|c| c == 'Uncategorized'}.uniq + + metas = Hash.new + item.search("wp:postmeta").each do |meta| + key = meta.at('wp:meta_key').inner_text + value = meta.at('wp:meta_value').inner_text + metas[key] = value; + end + name = "#{date.strftime('%Y-%m-%d')}-#{permalink_title}.html" header = { 'layout' => 'post', 'title' => title, - 'tags' => tags + 'tags' => tags, + 'status' => status, + 'type' => type, + 'meta' => metas } File.open("_posts/#{name}", "w") do |f|