Importing Typo to Tumblr
I’ve decided to start blogging again and my old blog at http://juju.org was running an ancient version of Typo. For various reasons, I’ve decided I don’t have the time to administer a whole web server just for my little blog. So I decided to move to a hosted service and settled on Tumblr. (I also decided to finally put away childish things and register http://tonybuser.com) Unfortunately, there’s no way to import a Typo blog to Tumblr. So this has given me a good excuse to finally play around with the HTTParty and Hpricot ruby gems. During my adventures in trying out different blog services and importing all my old posts, I had already exported my Typo blog to Wordpress XML format. Then to import a Wordpress file to Tumblr was simple. Here’s the script:
#!/usr/bin/env ruby
require "rubygems"
require "hpricot"
require "httparty"
class Tumblr
include HTTParty
base_uri 'www.tumblr.com'
EMAIL = "[YOUR_EMAIL]"
PASSWORD = "[YOUR_PASSWORD]"
end
doc = open("wp.xml") { |f| Hpricot(f) }
(doc/"item").each do |item|
params = {
"email" => Tumblr::EMAIL,
"password" => Tumblr::PASSWORD,
"type" => "regular",
"format" => "html",
"generator" => "Ruby + HTTParty Import Script",
"date" => item.at('wp:post_date').innerHTML,
"title" => item.at('title').innerHTML,
"body" => item.at('content:encoded').innerHTML,
"tags" => (item/"category").collect{|category| category.innerHTML}.join(","),
"group" => "[YOUR_ACCOUNT].tumblr.com"
}
puts Tumblr.post("/api/write", :body => params).inspect
end

