The initial migration (and a subsequent upgrade from 2.6.0 to svn trunk) was pretty much painless, but the database migration didn't take care of mapping permalinks or date queries from the WordPress scheme to the typo scheme. Enter a little mod_rewrite and Ruby (at which I'm a newbie).
The first step is to grab the query string on the old server, e.g., to grab the WordPress-style permalink:
http://oldblog/?p=69
to a new entry point in typo like:
http://newblog/wp/69
the required bit of mod_rewrite script is:
RewriteCond %{QUERY_STRING} p=([^&;]+)
RewriteRule ^/$ http://newblog/wp/%1? [R=301,L]
(The trailing ? drops the query string in the redirected URL, and back references use the % in place of the $.) The 301 response code is "moved permanently", so well-behaved clients should get the idea. The same technique applies to the query string-defined syndication protocols that WordPress uses for the RSS and Atom feeds.
The next bit of work in Ruby is a bit painful because of the way that the database migration script maps the IDs. (If I was in the mood, I could have modified the migration script to dump an id cross-references, but I wasn't and didn't.) The first piece is a new route in config/routes.rb:
map.connect 'wp/:wpid', :controller => 'articles', :action => 'wp'
And then a bit of Ruby in app/controllers/articles_controller.rb:
def wp
begin
wpid = params[:wpid].to_i
case wpid
when (109..109) then wpid = 97
when (100..101) then wpid -= 15
# etc.
end
# imitate the "read" method here...
end
And that should do it. (So far, the most difficult part of Ruby is not typing a ; at the end of a line...)

Add a comment.









