Writing a Pages Storage Provider

Modified on Sun, 14 Feb 2010 16:08 by Dario Solera — Categorized as: Development, dotNET Development, Plugins and Providers

This page is a considered complete and accurate. However, if you find an error, please take the time report it.

In this short article we are going to learn how to write a simple Pages Storage Provider for ScrewTurn Wiki 3.0 (STW from now on). A Pages Storage Provider is a type of plugin that handles pages-related data and content.

Introduction to Pages Storage Providers

This brief section assumes you have already a general knowledge on STW providers.

The main tasks a Pages Storage Provider performs are:


Important note: all providers should be totally thread-safe.

Tip: to handle, split, merge full names (e.g. MyNamespace.Page or Page) you can use the NameTools utility class.

Namespace Management

Namespaces (except the root, which is implicitly represented as null) are described with the NamespaceInfo class, that contains the name, the default page and a reference to the provider. Note: the root namespace is virtually "distributed" across all providers, but sub-namespaces can only be managed by a single provider.

The following methods allow the wiki engine to manage namespaces:


Pages Management

Pages are represented by instances of the PageInfo class, that contains the name, the creation date/time, the user who created it and a reference to the provider. The content of each page, as well as revisions, are represented by the PageContent class.

The following methods are used by the wiki application to manage pages:


Page Discussions Management

Each page has an associated tree of messages. Each message has a unique ID (generated by the provider), a subject, a body, a date/time and an author.

The following methods are used to manage such messages:


Categories Management

Categories are namespace-specific and are described by instances of the CategoryInfo class.

The wiki engine uses the following methods to manage categories:


Search Engine Management

Search engine management is a complex task that must be done by the provider but is assisted by the wiki engine. Every time the content of a page changes, the provider must update the search engine index. The following methods are exposed by the provider:


Page Content Indexing

Note: this section is purposely very brief as we believe that you will not be implementing a custom search engine index.

You can either decide to implement your own search engine, or to use the facilities provided by the wiki engine. To do so, you have to implement the IIndex interface, or the more specialized IInMemoryIndex interface. Alternatively, you can extend the InMemoryIndexBase class, which is ready-to-use and it's the one used by our built-in Pages Storage Provider. If your data cannot reside in memory, for example because you have a web farm, you can take a look at our SqlIndex implementation.

Navigation Paths Management

A navigation path is represented by an instance of the NavigationPath class and has a name and an ordered sequence of pages. Navigation paths are namespace-specific.

The following methods allow the wiki engine to manage navigation paths:


Snippets and Content Templates Management

Snippets are represented by instances of the Snippet class. Content templates are represented by instances of the ContentTemplate class. They're identical in the form, but they're used in different ways. Each has a name and a content.

The following methods are used to managed snippets:


Content templates are managed with a set of methods that are totally equivalent to the ones described for snippets.