Quantcast
Channel: Tech Blog
Viewing all articles
Browse latest Browse all 49

Migrate GeeksWithBlogs to Orchard CMS

$
0
0

As you can see I have migrated my blog to the Orchard CMS platform.

I’ve used Orchard for a few projects and having gone through the pain enjoyment of learning Orchard, it was really the only platform I was going to choose for my blog!

The theme I created myself, based on the Metro blog engine theme and the Mango Orchard theme.  I used Metro Studio to create the icons you see in the top left!

This, as expected was not going to be a simple export and import job, GeeksWithBlogs don’t enable the export to BlogML feature that SubText has, as they told me it was too buggy!

Orchard has a format all of it’s own so some serious Googling was the only plan.

Seems I was not alone in my quest to migrate from GeeksWithBlogs, I don’t have any issue with them or the platform really, yes the themes are quite ugly and its quite dated, I just wanted more control.  MrHinsh has a codeplex project for this, but as I wasn’t going to WordPress I kept looking.

I found this solution on codeplex, to export from MetaWebBlog to BlogML and this to import from BlogML into Orchard.

The export ran and worked fine, except it didn’t include the tags (categories) into the post and it didn’t add any of the comments.  So I played with the code, found out that GeeksWithBlogs doesn’t support the MetaBlog method (GetComments).  With MetaBlog all comments have their own RSS url, so I wrote a little method to take the blog post ID go away and get the XML for the comments, parse that and build it into the BlogML output file.

IEnumerable<BlogMLComment> GetCommentsForPost(Post post) {
    string commentsUrl = _blogUrl + "/Comments/commentRss/" + post.postid.ToString() + ".aspx";

    XNamespace dc = "http://purl.org/dc/elements/1.1/";
    XDocument doc = XDocument.Load(commentsUrl);

    var comments = from d in doc.Descendants("item")
                   select new BlogMLComment {
                       DateCreated = DateTime.Parse(d.Element("pubDate").Value),
                       UserName = d.Element(dc + "creator").Value,
                       Title = d.Element("title").Value,
                       Content = new BlogMLContent { Text = d.Element("description").Value }
                   };

    return comments ?? null;
}

 

That worked great (I’m not really sure if the comments RSS URL format is specific for GeeksWithBlogs or is a MetaWebBlog thing). 

The full code I am happy to share, I did get in touch with the author of the original project requesting to be added as a developer so I could check in my enhancements.  I’ve heard nothing yet, the last checkin from them was in 2008 so perhaps it’s a gone and forgotten project!  I might create my own project or submit a patch to the work item.

So I have my content all ready to go!

With the import I immediately came across a problem which i raise here, the Orchard module is not working in v 1.4.  This was swiftly sorted by the author and I’m very grateful!  Well there are a few of us in the discussion that are!!

There were still a few little things to work around with the import, it didn’t import into the selected blog for example, it created a new one…the way round this was to put in a slug!

So that’s it, the journey is complete!  From GeeksWithBlogs to Orchard in only 4000 steps!

Not quite…images, ahhhhh, images!!!  The source url on all image elements are still pointing to GWB.  I haven’t sorted this and not sure I ever will!   Now it’ll be a job to spin through the Orchard content to update them all, something I would like to do, but finding the time and inclination will be challenge all in itself!

With regard to the Metro theme, I haven’t published that to the Theme Gallery, it’s really in no state to do so!  I am overriding many views to make little changes here and there.  The way the navigation works is a little hacky as well, because I wanted to keep the standard navigation functionality in the admin section (don’t know why now!) I have overridden the view to stick in my own CSS class based on the title of the navigation item.  Then in CSS i set the image.  If I don’t want to use an image I suffix the title with /t!  hmmmm. 

image

The tag cloud, if you are wondering is taken from here.  It does actually seem a little flakey…it sometimes doesn’t load – I may go back to the standard way!  It’s also a bugger to use on an iPad!

I do want to create a mobile specific theme (it doesn’t work great on my phone!) – not sure how I go about switching themes on the fly in Orchard based on the browser, but I’m sure it’s possible.  One of the beauties of Orchard is it flexibility and extensibility!


Viewing all articles
Browse latest Browse all 49

Trending Articles