From 9e0eb75170e56ec9fcc68bab6c7a639ad3a23f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Wed, 15 Dec 2010 15:44:01 -0300 Subject: [PATCH] updated/fixed wordpress.com migration script --- lib/jekyll/migrators/wordpress.com.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/migrators/wordpress.com.rb b/lib/jekyll/migrators/wordpress.com.rb index 5be1b42d..96e0d917 100644 --- a/lib/jekyll/migrators/wordpress.com.rb +++ b/lib/jekyll/migrators/wordpress.com.rb @@ -1,7 +1,11 @@ +# coding: utf-8 + require 'rubygems' require 'hpricot' require 'fileutils' +require 'date' + # This importer takes a wordpress.xml file, # which can be exported from your # wordpress.com blog (/wp-admin/export.php) @@ -15,8 +19,13 @@ module Jekyll doc = Hpricot::XML(File.read(filename)) (doc/:channel/:item).each do |item| - title = item.at(:title).inner_text - name = "#{Date.parse((doc/:channel/:item).first.at(:pubDate).inner_text).to_s("%Y-%m-%d")}-#{title.downcase.gsub('[^a-z0-9]', '-')}.html" + title = item.at(:title).inner_text.strip + date = item.at(:pubDate).inner_text + + ftitle = title.downcase.tr('áéíóúàèìòùâêîôûãẽĩõũñäëïöüç','aeiouaeiouaeiouaeiounaeiouc').gsub(/[^a-z0-9]/, '-') + fdate = DateTime.strptime(date, '%a, %d %b %G %T') + + name = "#{fdate.strftime('%Y-%m-%d')}-#{ftitle}.html" File.open("_posts/#{name}", "w") do |f| f.puts <<-HEADER @@ -32,7 +41,7 @@ HEADER posts += 1 end - "Imported #{posts} posts" + puts "Imported #{posts} posts" end end -end \ No newline at end of file +end