A blog for developers programming with Autodesk platforms, particularly AutoCAD and Forge. With a special focus on AR/VR and IoT.

May 09, 2014

Creating an index of blog posts to launch Windows Live Writer

This one’s mainly for my fellow bloggers – especially those using the Typepad blogging platform – to help address a problem related to editing old blog posts using Windows Live Writer, a tool I can honestly say I can no longer blog without. Incidentally I’m now working with Live Writer 2012.

With that said, it may also be of interest for people who want to programmatically query their favourite blogs and create offline indices into their posts. Maybe. :-)

I use Live Writer primarily to author blog posts – which it allows me to do offline, something I find incredibly valuable – but I also use it to edit older posts, whether to add an update or to change its assigned categories. It’s easy to access recent posts – they’re accessible directly within the product – but from time to time I need to modify a post that was written before I’d adopted Live Writer for writing my blog (or one that for some reason doesn’t show up in my “recent posts”).

Typepad does provide a web-based post editor but this very often messes up the formatting of code that I’ve posted, which I find extremely frustrating. I therefore avoid it at all costs – I want to do as much as possible in Live Writer.

Live Writer does a reasonable job of pulling down posts from your preferred blogging service, but – at least with Typepad, and admittedly they’ve been having problems of late – it’s very hard to load posts beyond the last 100 or so. If I try to go back to the last 500 or more I get a timeout error:

And now that I have around more than 1100 posts I find myself regularly having to go back and make edits to posts that are not in the last 100.

I did a bit of research and came across this post that referred to this helpful Windows Live Writer plugin. The application installs a custom URI handler using the “wlw” prefix that can (for instance) be launched via the “Run” command or the address bar in Windows/Internet Explorer:

wlw://[yourblogdomain]/?postid=[postid]

As an example, here’s a link that opens the first ever post made to this blog:

So far so good. The tricky bit is to work out the IDs of the individual posts. The good news is that Typepad provides a RESTful API to get at this information (more work will be needed to support blogs hosted by other providers).

I threw together a simple C#/WinForms app that queries the specified blog and populates a grid for copying/pasting into Excel. I decided to fill this grid with the number and title of the post, as well as links to the published post and to load the editable post into Live Writer. So it may be of some use to avid readers as well as my fellow bloggers. We’ll see.

One thing the Typepad API calls need, in particular, is the blog’s ID. I found this for my blog by loading the web-based Typepad dashboard and extracting it from the URL:

The code is fairly straightforward: it downloads batches of posts (you can specify the number of posts per batch, as well as configuring which one to start from). Typepad posts are retrieved in reverse chronological order via the API, it seems, so the code assigns a number from the total number of posts down to 1 (the first ever post).

The intention is that you’ll copy the contents of the list of posts – and there’s a button to simplify that part of things – and paste it into Excel (and presumably save it as an spreadsheet file of some sort). When you paste the contents in (as plain text – the formatting is ugly), you’ll find the links in column D and F are indeed links (to the published post and to load Live Writer, respectively), even if they aren’t blue and underlined.

You can use this spreadsheet to find your preferred post and then either load the published post via the link in the D column or into Live Writer (assuming you have authoring permission on my blog, of course ;-). I’ve hidden columns C and E, by the way, as these are the “plain text” versions of columns D and F.

The links for Live Writer do indeed launch the product…

… which pulls down the post’s contents and loads them into the editor:

Hopefully this tool will be of some use to people who want an offline set of links into this blog or for my fellow bloggers who want to use it to create a set of Live Writer links to their own posts.

The tool could clearly be enhanced to perform an incremental download & update, but as bloggers can always access recent posts from within Live Writer they shouldn’t need to run it very often once they have a populated Excel spreadsheet. And the code is provided for people to extend as they wish. :-)