SWiki 0.9 released

Okay, that was quick. I've just released 0.8 a few hours ago, but there was one feature I really wanted to have in a wiki that 0.8 does not have, and that is linking between articles in the wiki. As I am using the WebBrowser Control, I wasn't sure if there is a way to interact with my C# Application from within the browser. As it turns out, you can easily interact through JavaScript! The WebBrowser supports the ObjectForScripting property, which allows to specify a (Com-Visible) Class to interact with. I just pass in "this" to make the Browser interact with my Main Form.

    this.browser.ObjectForScripting = this;

The next step was to create a function in my Form that can be called:

    public void BrowserInternalLink(int targetPageId)
    {
        ChangePage(targetPageId,null);
    }

I've created some code for testing that illustrates how to call it:

    sb.Append("<a href=\"javascript:window.external.BrowserInternalLink(1)\">Test</a>");

So this would call my BrowserInternalLink Function with the Parameter 1. Pretty neat, but still useless as it's hardcoded 🙂

The next step is to add support to the [wiki:PageId|Description] syntax to WikiPlex. Here, two articles are really important: Extending WikiPlex with Custom Macros and Extending WikiPlex with Custom Renderers.

If you want to add your own Tags to WikiPlex, you may need both usually. A Macro is some RegEx that tells WikiPlex to search for certain tokens and how to interpret them (For example, you can tell WikiPlex that you want to discard a part of the token, but pass other parts into a renderer). A renderer takes the Input and outputs some HTML. As said, your Macro is split into multiple parts (depending on your RegEx) and in theory you can pass every part into a different Renderer.

Have a look at WikiPlexExtensions.cs in the SWiki Source Code to see my implementation. The main downside of this whole approach is that it requires FullTrust, but so far I don't know a better alternative. There is a GDI+ HtmlRenderer on CodeProject, but that sadly renders out images, which means: No links, no Copy/Paste, just look but don't touch. The Mono Project seems to have a very interesting approach, but "Replacing the Browser" is currently low priority, especially since Windows 7 E will not happen 🙂 (By the Way: SWiki is of course compatible with Windows 7)

I really like WikiPlex so far, as it is a very clean and extensible Wiki Parser, and I think I will have a lot of fun with it 🙂

SWiki 0.9 also allows you to print out pages now, simply click the new Printer-Button on the lower left toolbar.

Grab it from CodePlex now 🙂