As a Silverlight developer, you’re likely to need to blog occasionally on your app. I use Windows Live Writer (WLW) to handle all my posting – even with WordPress’s super-easy UI, I like the desktop shortcuts inherent in WLW – keyboard shortcuts (e.g. Ctrl-K for links), drag ‘n drop images (including auto uploading). There are also some neat plugins that make WLW even better. One I really like is Code Snippet by Leo Vildosola – takes you IDE code and keep it just as is in your post. For example, here’s method from a recent app:
1: private void trvArcs_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
2: {
3: Node n = (Node)trvArcs.SelectedItem;
4: TaxFullDbDom tdc = new TaxFullDbDom();
5: EntityQuery<Arc> query =
6: from c in tdc.GetArcsQuery()
7: where c.ArcID == n.ArcID
8: select c;
9: LoadOperation<Arc> loadOp = tdc.Load(query);
10: this.arcDataForm.ItemsSource = loadOp.Entities;
11: arcDataForm.AutoEdit = true;
12: arcDataForm.CurrentIndex = 0;
13: }
WLW also taps into your WordPress (WP) tags list so there’s no WP involvement needed – though confusingly WLW calls tags categories in its parlance.
Another useful plugin is Twitter Notify. Simple – after publishing a post, this sends a tweet notifying your followers of the new post.
For my money anything that keeps the posting process in WLW if worth a few minutes. WLW is very much an underappreciated desktop app – maybe not everything is best server-side
Update:
Things move pretty fast! Code Snippet showed some issues with a blank line inserted between each line as you might see above. Looking at this further, it seems SyntaxHighlighter by Alex Gorbatchev has a well respected Javascript library which does a very nice job on syntax colour coding etc. – for a growing stable of languages (e.g. XML and C# in my case). SyntaxHighlighter Evolved has subsumed this library and packaged it as a WordPress plugin. Still with me? Well, byinstalling this plugin to your hosted WP, it (almost) automatically prettifies any code in your posts – from within WordPress, that is. Doing so is real easy – just wrap your clipboarded code in a [language] tag – e.g. place [language] before your C# code and [/language] at the end of the code, where language is something like csharp. You won’t see it until you Preview or Publish the post but it’s a high quality output.
Now, to integrate with Windows Live Writer. Over on CodePlex, there’s a WLW plugin called PreCode. This works with SyntaxHighlighter (remember, you installed that on WP) to wrap your offline WLW edited post in the necessary tags so that when it gets server-side and published by WP, SyntaxHighlighter will do its thing – and give you beautiful formatted code like this:
private void trvArcs_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
Node n = (Node)trvArcs.SelectedItem;
TaxFullDbDom tdc = new TaxFullDbDom();
EntityQuery<Arc> query =
from c in tdc.GetArcsQuery()
where c.ArcID == n.ArcID
select c;
LoadOperation<Arc> loadOp = tdc.Load(query);
this.arcDataForm.ItemsSource = loadOp.Entities;
arcDataForm.AutoEdit = true;
arcDataForm.CurrentIndex = 0;
}
Now the funny thing here is that (at least in my WP install), the above code shows up nicely rendered (by the SyntaxHighlighter Javascript library) on the excerpts post listing. However, occasionally, when you click through to the full post, we lose the formatting. Answers on a postcard, please. Scott Hanselman has more details on integrating the Javascript into any blog template so when I get time. Come to think of it, it could be a side-effect of the WP-Cache plugin. Seems it might also be rectified by setting the ‘Load All Brushes’ checkbox in the WP SyntaxHighlighter plugin.
Update on SyntaxHighlighter in WP:
Having lucked out with what I thought was a perfect solution with PreCode and SyntaxHighlighter, I found another WLW plugin (SourceCode plugin)that purports to work with SyntaxHighlighter – and well, it does but my occasional loss of formatting persists on the full post page. So, not a SyntaxHighlighter issue then. I prefer this plugin over PreCode – it’s lighter and easier to work with.
private void trvArcs_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
Node n = (Node)trvArcs.SelectedItem;
TaxFullDbDom tdc = new TaxFullDbDom();
EntityQuery<Arc> query =
from c in tdc.GetArcsQuery()
where c.ArcID == n.ArcID
select c;
LoadOperation<Arc> loadOp = tdc.Load(query);
this.arcDataForm.ItemsSource = loadOp.Entities;
arcDataForm.AutoEdit = true;
arcDataForm.CurrentIndex = 0;
}
Addendum:
Finally, to Silverlight. This takes a little more patience but thanks to Tim Heuer and Erno de Weerd, and their Silverlight for WordPress and SLforWP.dll plugins respectively, the process works as you can see below. Tim’s plugin is a straight-forward WLW install, and Erno’s is just a dll to dump in the plugins folder of WLW. Erno also describes another plugin – this time for you WP install – to help it with the MIME mapping for XAP files. You’ll also need write access to the upload folder on your WP install but it’s all good.
There’s more work to do though as I suspect the MIME mapping isn’t working but I’ll update when I diagnose the problem and post properly.