Hi, I'm Chris Moyer's Blog.

Ramblings Moved to Tumblr

Not exactly sure why.   I decided to make the home page of inarow.net something else (which isn’t done yet.)  So, I started shopping around for blogging options.  I see too much of wordpress on the clock, so I wrote that off.  I ended up on tumblr because I liked their API, flexibility and capabilities.

Speaking of API, it was about an hour to import all my posts from bloxsom.

  1. Install ruby-tumblr gem
  2. Install RedCloth gem
  3. Whip up a script
    require 'rubygems'
    require 'redcloth'
    require 'net/http'
    require 'uri'
    user = 'your@email.here'
    pass = 'thisisnotit'
    url = URI.parse('http://www.tumblr.com/api/write')
    ARGF.each do |f|
    f.strip!
    dt = `ls -lh --time-style=long-iso #{f}`
    dt.sub!(/.* 200/, '200')
    dt.sub!(/( .*) .*/, '\1')
    title = nil
    tags = nil
    body = ''
    File.open(f).each do |l|
    if not title then title = l
    elsif !tags and l.match(/^tags:/i) then
    tags = l.sub(/^tags:\s*/i,'').split(/,/).map {|s|s.strip.gsub(/_/,' ')}
    else
    body += l
    end
    end
    body.sub(/^\s*/, '')
    body = RedCloth.new(body).to_html
    # title, body, dt, tags
    res = Net::HTTP.post_form(url,
    {
    'email' => user,
    'password' => pass,
    'type' => 'regular',
    'generator' => 'CDMoyer\'s Custom Importer',
    'date' => dt,
    'tags' => tags ? tags.map {|s| "\"#{s}\""} .join(',') : "",
    'format' => 'html',
    'title' => title,
    'body' => body
    }
    )
    puts res.body
    sleep(5)
    end
  4. Run the script

    find blog/entries/ -type f -name ‘*.txt’ | grep -v ‘draft/’ | ruby tumbleit.rb



Back to Blog Home »