wiki:InfoarenaWikiSystem

Info-arena wiki system

In info-arena2 most content is kept in simple wiki pages. Except for a bunch of very special urls, like "/login", "/register" and the like everything is in fact a fully editable wiki page. We have a very powerful macro system that allows us to include things like ranking tables in any normal wiki page, removing the need for special pages.

Syntax

Info-arena doesn't have it's own wiki syntax, instead it uses  textile, a light-weight plain-text markup language. There is very little use in creating yet another way to mark bold text and italics.

We've hacked up a  php textile implementation to suport wiki links and use page attachments. The way this works is not particularly interesting, go read the code if you insist.

Textile by default uses == markers for inline html. Inline html can pose a security risk and may break formatting, so we decided to hack this syntax for our own usage. Right now ==Macro(arg="value")== is used for macros, but we might decide to use == markers for other purposes as well.

We also use == code(cpp) |.. code here ..== for syntax-highlighting (and maybe in the future something like ==html| for inline html).

Macros

The real power in the info-arena wiki system comes from the macro system. Right now macros are inserted using a ==Macro(arg1="val1" arg2="val2")== syntax. The syntax is parsed using regular expressions, future work on a smarter system could allow a better syntax, but the current implementation works just fine.

In code macros are implemented with simple functions somewhere in the www/macros directory. These functions receive a hash with the macro parameters and must return a html chunk to the wiki parser. Macros return raw html, not textile code.

Macros can do just about everything, so they are very powerful. The main use of macros is to insert data from the database in arbritary wiki pages. This is a lot more flexible than writing special views and controllers.

Macros can be used for a lot of things: ranking tables, automatic table-of-contents, nicer way to insert images (though textile is nice enough), links to user pages with contain the avatar, etc.

Templates

Pages in "template/" are templates, they are not meant to be visualised directly. Instead you should include them with the ==Include== macro.

Some pages in "template/" have a bunch of %xxx% markers inside. The include macro replaces those macros with arguments. For example ==Include(page="template/taskheader" task_id="12perm")== replaces all %task_id% markers in "template/taskheader" with "12perm" before passing it to textile. This is a very primitive way to include with parmaters.

Forms

It is sometimes useful to have forms in random wiki pages. All task statements have a simple macro which displays a tiny submit form. That form is just a shortcut to the main submit page.

Paging is done by linking to the same page with paramters like display_entry and first_entry. You can even give a $param_prefix to the macro if you want to place multiple paging macros on the same page. This is a decent system and it would be nice if we could extend it.