Migrating from Typo to Webby

Posted by Daniel Lyons Thu, 18 Sep 2008 16:10:00 GMT

Without realtime preview, I don’t have much reason to put up with the resource usage of Typo. I recently looked into Webby and like it quite a bit, especially because of its integration with source code highlighters, which are a major issue on my site.

I won’t be able to do comments unless I use a service like Disqus. I’m going to try really hard to care. See this? I’m trying really hard… I give up. It isn’t working. So yeah, I don’t care. 90% of you are already my friends, so just email me and maybe I’ll include your commentary. I delete most of your comments anyway, as I’m sure you’ve noticed.

Unless Reid decides to make me a web design for no particular reason it’s probably going to look a lot like the new xmonad design, because I think it’s really hot. Nowhere near as awesome as something Reid might make though. Hint hint.

So, if you’re trying to convert your Typo site to the state-of-the-art in statically generated content, you might want to follow my instructions:

  1. Put this into a file migrate.rb in your Typo install:
    class Article
        def migrate_to_webby        
            # get the YAML header
            attrs = self.attributes.slice('title','keywords','created_at')
            if keywords then attrs['keywords'] = keywords.split(',') end
            attrs['filters'] = 'textile'
    
            # make the destination directory
            dir = created_at.strftime('blog/%Y/%m/%d/')
            FileUtils.mkdir_p dir
    
            # status message
            puts "migrating #{title} to #{dir}#{permalink}.txt" 
    
            # dump the info out to the file
            File.open(dir + permalink + '.txt', 'w') do |f|
                f.write attrs.to_yaml
                f.write "---\n" 
                f.write body
            end
        end
    end
  2. Run this: script/console production
  3. Type this in:
    load 'migrate.rb'
    Article.find(:all, :conditions => {:published => true}).each {|a| a.migrate_to_webby }

A couple things you should note:

  1. Notice I hardcoded the format. You might have to fix that.
  2. I left out the author because I wrote all my own blog posts.
  3. I didn’t migrate any of the comments (oops? not really)
  4. I didn’t get any of the non-published content.

Still, if it’s any help to you, there it is. When I migrate the blog to Webby I might go through and change that to highlight the syntax.

Film at 11.

Tags , ,  | 1 comment