Every week I write a simple wrap up of all the things I’ve posted during the week you can subscribe to them here. Creating it can be slow going if I’ve posted tons of stuff and copy and pasting all the links creating some spiffy text to flow around it and that sort of thing can be a pain. So I decided to automate it.
I wanted to be able to use Windows Live Writer to create the post so that I had maximum flexibility and a really great editor to be able tweak the post in. I’m currently using the Windows Live Writer Beta from the Live Essentials Beta, which really is the best blogging tool available and it has super cool plug-in framework. I went looking for a way of getting those posts and producing the wrap-up post but there weren’t any plug-ins out there.
So it was time to do some digging into what resources are available for creating plug-ins. The Windows Live Writer SDK came up containing a bunch of useful APIs, there are three really: Application (for manipulating the Application), Content Source Plugin (which really is used to do stuff inside a post) and the Provider Customization API (used to customise how WLW works with different blog engines).
I went directly for the Application API. Also just so you know, I’m not a very good coder.
The Application API is what’s used to poke stuff into WLW, essentially it’s how the Blog This stuff in IE works. I have an idea, an API, now what…err…..I grabbed Visual C# Express 2010, a free download and tried to remember how C# works (I’m a VB guy and any chance I get now I move my
botched programs skills to C#). Express is great for having your first play with code. The next thing I did was to work out how the UI was going to work, I wanted it to be really obvious how to use this thing. I thought about 2 calendars and some text boxes and a REALLY big button.
I created a WPF form and found the calendar control. Then I started to read up on it and found out that it’s possible to use it to select a date range…brilliant, I only need one calendar control which is far less clutter. A couple of text boxes and a button and we’re done.
I’m not going to go through all the code but Windows Live Writer MVP Scott’s Live Spaces page guided me through what I needed to do.
Essentially the core of the code is this:
wlwapp = new WindowsLiveWriterApplication();
All I’m doing is creating a new instance of the wlwapp and passing it a prepopulated string of HTML called BuildHTML. That kind of begs the question, where does BuildHTML come from? The answer is that I use SyndicationFeed (part of .net 4) to read my blogs RSS feed and poke it into Build HTML. It’s very simple stuff as you can see… I’ve also been very lazy and not renamed my TextBoxes or any other controls oops…
XmlReader reader = XmlReader.Create(textBox1.Text);
SyndicationFeed feed = SyndicationFeed.Load(reader);
///parse the feed items
foreach (var item in feed.Items)
///check that the item is within the range we want
BuildHTML = BuildHTML + "<li><a href='";
//within each item we look for the link
foreach (var link in item.Links)
BuildHTML = BuildHTML + link.Uri.ToString() + "'>";
BuildHTML = BuildHTML + item.Title.Text +
There’s not much more to this application really other than the fact that I’ve published it (Project > Publish xxx in Visual C# Express 2010) to the internet and that built me an install on my server to publish and maintain the application. This simple tool will save me 1 hour a week from here to eternity. If you do it once, great, if you do it twice, automate.
Check out my tool at its application page.