Home » News

New SDK in Technical Preview Release

Submitted by on June 4, 2008 – 9:30 amOne Comment

In the Technical Preview of Live Writer a new SDK is also included.

The new SDK isn’t a release, it’s a Technical Preview like the new Live Writer an therefore it’s not intended for production use. That’s why Live Gallery doesn’t accept plugins based on the SDK 1.1 Technical Preview. It’s also possible that the Developer Team make breaking changes in the new SDK code and new plugins won’t work in final release anymore.

The SDK has get two new plugin base classes:

Publish Notification Hook
Header/Footer Source

Publish Notification Hook

The new class PublishNotificationHook allows you to develop plugins which can run actions after pressing the Publish button. These actions can be executed before or after publishing the post. You can also cancel the publishing process.

Examples for use could be:

  • Notification on new posts to services e.g. Twitter
  • Ask for confirmation if no tags or keywords are provided with the post and cancel the publishing process if necessary
  • Show a warning when the post contains invalid XHTML

With this new base class you can save settings in the post file for later use. Plugins written on that class have to be enabled or diabled for every blog configured in Live Writer individually.

Let’s go to some development stuff. It’s very easy to develop PublishNotificationHook plugins. Follow these steps:

  1. Create a new .NET Class Library (e.g. in Visual Studio)
  2. Add a reference to WindowsLive.Writer.Api
  3. Create a new class extending PublishNotificationHook
  4. Assign a GUID and a Plugin name with WriterPluginAttribute
  5. Overwrite OnPrePublish and/or OnPostPublish method

Here a tiny code example:

using System.Windows.Forms;
using WindowsLive.Writer.Api;

[WriterPlugin("????????-????-????-????-????????????", "My Plugin Name")]
public class MyPublishNotificationHook : PublishNotificationHook
{
    public override bool OnPrePublish(IWin32Window owner, IProperties properties,
            IPublishingContext publishingContext, bool publish)
    {
        // Do pre-publish work
        return true;
    }

    public override void OnPostPublish(IWin32Window owner, IProperties properties,
            IPublishingContext publishingContext, bool publish)
    {
        // Do post-publish work
    }
}

Header/Footer Source

This type of plugins are used to add some text to the header or footer of a post. The user can’t modify this text in the Edit section of Live Writer but this text is visible in the preview section and in the published post.

This type of plugins could be used for example for:

  • Header: Insert a Digg button
  • Footer: Insert Social Bookmark links

The interessting part of this new base class is that the permalink of the post can be used even if it’s not exist yet.

Plugins which make use of this base class have to be enabled or disabled for every blog configured in Live Writer individually.

Let’s go to the development stuff:

  1. Create a new .NET Class Library (e.g. in Visual Studio)
  2. Add a reference to WindowsLive.Writer.Api
  3. Create a new class extending HeaderFooterSource erbt
  4. Assign a GUID and a Plugin name with WriterPluginAttribute
  5. If permalinks are used, overwrite the RquiresPermalink property and return true
  6. Overwrite GeneratePreviewHtml and GeneratePublishHtml
using System.Windows.Forms;
using WindowsLive.Writer.Api;

[WriterPlugin("????????-????-????-????-????????????", "My Plugin Name")]
public class MyHeaderFooterSource : HeaderFooterSource
{
    public override bool RequiresPermalink
    {
        get { return true; }
    }

    public override string GeneratePreviewHtml(ISmartContent smartContent,
            IPublishingContext publishingContext, out Position position)
    {
        position = Position.Footer;
        return “<p><a href=\”#\”>Digg This</a></p>”;
    }

    public override string GeneratePublishHtml(IWin32Window dialogOwner,
            ISmartContent smartContent, IPublishingContext publishingContext,
            bool publish, out Position position)
    {
        position = Position.Footer;
        return “<p><a href=\”http://digg.com/submit?url=”
            + publishingContext.PostInfo.Permalink
            + “\”>Digg This</a></p>”;
    }
}

There are another changes like TaskServices which can run tasks in background.

SDK download (contains documentation and samples)

Live-Side.net

For feedback please use the Live Writer Developer forum

  • Technical Preview Triggers False Expiration
    Users of the Technical Preview might have seen a message in the last days informing that the Windows Live Writer CTP is going to expire. The WLW team published a statement on Writer Zone. We ......

  • Windows Live Writer 2008 Technical Preview released
    The new Technical Preview of the Windows Live Writer 2008 is available. Besides new several new functions and improves in the user interface there is an new Windows Live Writer API (Version 1.1). The CTP ......

  • Windows Live Writer Plug-ins for the Tech Preview
    Last week the Windows Live Writer Team released the new Windows Live Writer CTP. The most important improvement, the new SDK 1.1. The new SDK gives the developer the instrument to create a new sort ......

One Comment »