Quick Look at Infogami

Types

There are 2 kinds of types in infogami. Primitive types and Compound Types. Primitive types are for representing integers, strings etc.

Available primitive types are:

type/int
type/boolean
type/string - for single line text
type/text - for multiline text

Compound types specify what properties a thing of that type must have.

Available compound types are:

Other primitive and compound type can be added by creating a page in the wiki with type type/type.

Some times you might want to link 2 different types. For example, book type has author property and you want to add a books field to the author, which contains all books where author property of the book is this author. This is achieved by adding a backreference to the author type.

Templates

Infogami uses templates to control the look and feel of the site. Custom templates can be provided in the wiki to customize the look and feel.

There are 2 kinds of templates. Regular templates and type-specific templates. Type-specific templates are used to render a wiki page based on its type.

regular templates must be placed at path templates/ and end with .tmpl extension. type-specific templates must be placed at type// and end with .tmpl extension.

There can be 4 type-specific templates for every type.

  1. view.tmpl - Template to specify how to view a page
  2. edit.tmpl - Template to specify how to edit a page
  3. repr.tmpl - Template to specify how objects of this type appear when viewing pages of other types which has a property of this type.
  4. input.tmpl - Template to specify how objects of this type appear when editing pages of other types which has a property of this type.

How repr and input templates are used is explained later in this document.

It is not compulsory to specify all these templates for every type. When a type-specific template is not specified for a type, a default template is used. The following are the default templates:

There are many other interesting regular templates. Some of them are:

Macros

Macros are like functions in any programming language. Macros look very much like templates, but they can be called from wikipages and other templates and macros.

Macros can be written in the wiki just like templates. Macros must be placed in macros/ path and type must be type/macro. As a convention, they are named in CamelCase.

The syntax to call a macro from a wiki page is:

{{HelloWorld()}} or {{MyMacro("arg1", "arg2")}}

The syntax to call a macro from templates and macros is:

$:macros.HelloWorld() and $:macros.MyMacro("arg1", "arg2")

There are some useful macros, which are very handy in writing view and edit templates.

thingrepr(value, type): This calls repr template of the specified type with value as argument.

thinginput(type, name, value): This calls input template of the specified type with value, name as arguments.

Lets take an example. Suppose there are many types, which need to display an image. Probably they will do that by defining a type type/image for representing images. Instead of worrying how to display and edit (upload) images, these types can just use thingrepr and thinginput macros and define repr and input templates for type/image. Later in future, if you want to change how to display/upload image, you don't have to change in multiple places.

Edit History Last Modified October 4, 2007