Monday, September 10, 2007

Back to Blogger

I left Blogger back in October 2005 to switch to Community Server as my blogging platform.  I had the fortune of working at an institution that was happy to lend me some server space where I could host it myself.  Now I need to move off of their server, which left me wondering which blog platform to choose.

The search for a blog system

I considered GoDaddy, which offers a red-carpet of a Community Server setup for just a few dollars a month, but they limit database size to 200MB and mine was over 400MB.  Also, there was no convenient story (that I could figure out anyway) for transporting all of my existing posts and comments to that server, since they do not let you restore databases that were backed up from a non-GoDaddy server, and their interface for executing database commands directly against their server is a joke (exactly one operation at a time -- no 1MB SQL file that will regenerate all my data at once).

I was about to switch to BlogEngine.NET and stick with GoDaddy as my hosting provider.  BlogEngine.NET had the advantage of no dependency at all on a database but rather uses XML files on the web server (actually that being an advantage is arguable).  It might have worked, but their themes don't look as nice, and I found many features lacking.  I actually spent an afternoon adding OpenID support to it, but OpenID on .NET 2.0 (which is what GoDaddy is limited to) requires unsafe C# code which GoDaddy of course will not allow.  So I realized I was spending a lot of extra time building up an open-source blogging engine in order to use features that wouldn't work with my hosting provider.

After considering one other hosting provider and finding them unreliable, I looked back to my roots: Blogger.  I left it a couple years back because I found it limiting in what I could do to the template.  Looking at it closely lately, I see that I can do almost everything to it that I could with any other blogging engine.  I can't make it support OpenID or InfoCard (as I would have liked on my blog) but I couldn't do it with any of those other blog platforms either so I haven't really lost anything.

Moving my posts to the new blog

But I still had the problem of moving all my posts from Community Server to Blogger.  Microsoft's Windows Live Writer offered a smart client app that could download posts from my Community Server blog and then post them to Blogger, but the process was one post at a time and tedious.  To make matters worse, the publishing date for every post would show up as the same day (today).  I really didn't want that.  Blogger also doesn't let you pre-date posts using their web UI.  So I couldn't manually fix each one either.

Well, Blogger offers a .NET API for manipulating your posts programmatically.  In about an hour I whipped up a C# app that would read the atom feed from Community Server and upload every post up to Blogger, preserving the content and publishing date of each post (anyone want the program?).  I did run into the problem that Blogger only allows 50 posts per day.  Of course I didn't know about this policy, so I banged my head against the wall for a couple hours trying to figure out why posts were supposedly successfully uploaded (their API returned no errors) and yet they didn't show up in Blogger.  I'll finish uploading my posts in 24 hours when my counter is reset.

I was not able to transfer the comments.  They weren't included in the atom feed from Community Server that I was reading, and Blogger's API doesn't appear to provide an interface to add comments programmatically.

Forwarding users to the new location

It's simple enough to forward visitors who used my home page and newsfeed URLs to the new locations.  But each of my 64 posts will need redirectors as well.  That's a lot of tedious redirecting pages to write.  Not sure how to best handle that -- yet.  But I think I'll write a script to automate it. 

And about those inter-post links that are now bad

I have lots of intra-blog post links in my blog.  All those links now have invalid URLs.  Grrr.... another C# app to whip up.  After uploading the posts to the new location, I'll download atom feeds from the old and the new blog system, find the correlating posts and build up a URL substitution dictionary, and then programmatically go through each post on Blogger and do a search-and-replace for each link. 

In fact that same app should be able to create the redirect pages I need as well.

6 comments:

  1. I am interested in the program you wrote to pull from Community Server to Blogger. How would I go about getting a copy?
    Thanks!
    -Chris

    ReplyDelete
  2. I've posted the tool on github. You can get the source code there.
    Warning though: you should review the source code to see what it will do before running it. I wrote it for my own use not for general consumption, so you'll want to verify that it does what you need before doing it.

    ReplyDelete
  3. Thanks! I ended up using the wordpress import option from rss which worked for everything except comments.
    I still plan to download and look at the code becase I'm interested in how you did it.
    Thanks again
    -Chris

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. FYI, using VS2008 and attempting to build the current source available at the above link generates type conversion error.

    Line #33 of Window1.xaml.cs currently says:

    service.Credentials = new NetworkCredential(destinationUsernameBox.Text, destinationPasswordBox.Password);

    Which throws an error when building due to inability to implicitly convert from GData credentials to .Net credentials.

    I believe what you should have here is:

    service.Credentials = new GDataCredentials(destinationUsernameBox.Text, destinationPasswordBox.Password);

    ReplyDelete
  6. Hi Keith,

    Thanks for the tip on the outdated source code. Please consider using Github's fork feature to fork the project and make your changes there. github makes collaboration across forked projects very easy, and easy to discover yours from mine so others can find your work.

    ReplyDelete