Habitat's new features

1. Page HTML Embedding
2. Page Raw Text Embedding
3. Object-oriented wiki pages
4. Wikipage Rules - Pre-viewer

1. Page HTML Embedding

By typing:
{{test/demo1}}

you can embed the HTML form of page test/demo1 into the current page, such as the following example:

1. Embedding Content

This text comes from the embedded page.

the content of test/demo1 is

== # Embedding Content ==
This text comes from the embedded page.

2. Page Raw Text Embedding

By typing:
{(test/demo1)}

you can embed the raw text form of page test/demo1 into the current page, such as in this example test/demo3. The raw text for test/demo3 can be found here.

3. Object-oriented wiki pages

In Habitat, each wiki page is an "object". It has its own data (i.e. content) and methods (rules). The methods can alter the form or representation of the data at different stages. There are 4 basic rules: pre-viewer rules, post-viewer rules, pre-editor rules and post-editor rules.

Pre-viewer and post-viewer rules are called when a user browses a page (or browse a page where this page is embedded with). The difference is that "pre-viewer" rules are called before converting wiki raw text to HTML, and "post-viewer" are called after the conversion.

Pre- and post-editor rules are called when a user is trying to edit the content of a page. The pre-editor rules will modify the page text before sending the editing interface to the user. With this rule, one can define a HTML editor (using HTML and javascript) to modify the page content with a specific format. The post-editor rules are applied when user submits the modified content from the editor.

The methods associated with a wiki page are automatically inherited by its subpages. For example, if you define the pre-viewer rules for page atomic/menu, when browsing page atomic/menu/style1, the rules for atomic/menu will be executed first, before executing any rules defined for atomic/menu/style1 itself (this allows mutation).

4. Wikipage Rules - Pre-viewer

The pre-viewer rules are defined in a special wiki page named "pagename/.v0" where "pagename" is the associated wiki page. Currently, Habitat only supports regular expression replacement commands as the rules. We will extend this to more complex languages in the future.

Here we show a simple demo for how to use pre-viewer rules. Let's first define a page called test/code, and set the pre-viewer rules in test/code/.v0 as

^/<pre>
$/<\/pre>

You can see, the rules adds some HTML tages before and after the raw data. Let's define a subpage named test/code/codedemo with content

// sample C++ code
class HabitatWikiPage{
      char *name;
      char *text;
      HabitatWikiPage(char *pagename);
      void previewer();
};

when you browse test/code/codedemo, you will see

// sample C++ code
class HabitatWikiPage{
      char *name;
      char *text;
      HabitatWikiPage(char *pagename);
      void previewer();
};
Powered by Habitat