WikiDB/Syntax

From TestWiki
< WikiDB
Revision as of 03:12, 9 July 2006 by HappyDog (Talk | contribs) (First draft)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page describes the current syntax for all user input handled by the extension. Note that this is highly likely to change, but I shall endeavour to keep this page up-to-date with the current working version.

Table definitions

Within a DB namespace, the entire page is parsed as follows:

  • All lines that begin with > (as the very first character) are treated as field definitions (see below).
  • The rest of the page will be treated as standard wiki markup.

This means that you can include whatever you like along with your table definition, including images and links and even table data itself!

Field definitions

Each field row has the following syntax, where elements in square brackets are optional and whitespace may be omitted:

> FieldName [: Type [(TypeOptions)]] [LinkDetails] [-- Comment]
  • FieldName - Required - The name of the field. Currently case-sensitive. May contain any characters that don't confuse the syntax (I will fill in the details about this later). Whitespace is trimmed from either end, but internal whitespace is preserved.
  • Type - Optional - One of the defined Types. Must be preceeded by a colon to separate it from the name. If the specified type is not recognised then it is ignored.
  • TypeOptions - Optional. Only valid if Type is defined - A comma-separated list of type options, surrounded in parentheses. The usage varies according to the Type.
  • LinkDetails - Optional - Currently only used for aliases, but will also be used for foreign keys if they get implemented. A standard wiki link to the field name being aliased to, preceeded by #. E.g. use [[#Company name]] to make an alias for 'Company name'.
  • Comment - Optional - A space for you to make notes about the field. Unlike notes elsewhere in the page, this comment is displayed at the top in the main table definition. Starts with two hyphens and runs to the end of the line.

Data tag

The tag is as follows:

<data table="..." template="...">
  name1=value1
  name2=value2
  Any line without an equals sign is ignored.
</data>

The table attribute is required, and tells the extension which table the data belongs to. The table need not be defined on the wiki.

The template attribute is optional, and contains either "none" (in which case the data is not displayed), "default" (which outputs the data in a standard format) or the name of a page to use as a template. This works the same as for standard templates, and each of the fields is passed to the template as named parameters. If this attribute is omitted, then "none" is assumed.

The contents of the tag contain name=value pairs. Any line without an equals sign is ignored.

Repeat tag

This tag allows you to query the data.

<repeat table="..." criteria="..." sort="..."></repeat>

The table attribute is required, and defines where the data comes from. Again, the table does not need to be defined on the wiki - the tag will pull data for all rows that specified this table, even if the table does not exist.

The criteria is optional. Specifying this allows you to specify which records to return. Options are currently very limited, partly due to limitations of passing in an attribute. Currently you can provide a comma-separated list of "field=value" or "field!=value" pairs, which are ANDed together.

The sort contains a comma separated list of fields with an optional 'DESC' modifier (e.g. "Field1,Field2 DESC,Field3"). The rows are sorted by the fields in the order specified.