NAME

PurpleWiki::Tree - Basic PurpleWiki data structure

SYNOPSIS

use PurpleWiki::Tree;

my $wiki = PurpleWiki::Tree->new;

$wiki->title("WikiPage");  # sets the title to "WikiPage"

$wiki->authors([ ['Joe Schmoe', 'joe@schmoe.net'],
                 ['Bob Marley', 'bob@jamaica.net'] ]);

$wiki->root;               # returns the root StructuralNode

$wiki->view('wikihtml');   # serializes tree as XHTML

DESCRIPTION

PurpleWiki views Wiki pages as a tree of StructuralNodes, which in turn are trees of InlineNodes. A PurpleWiki::Tree is generated by a parser, and the tree is traversed using the nodes' methods, starting with the root node.

PurpleWiki::Tree's main purpose is to hold the document's root node and metadata about the document. Current metadata are title, subtitle, id, date, version, and authors. PurpleWiki only uses the first two, but the rest are useful if PurpleWiki is used as a document authoring system.

The root node of a tree should always be a structural node of type 'document'.

VIEW DRIVERS

PurpleWiki::Tree can be serialized using the view method, which uses the output format defined by a view driver. View drivers are perl modules with a function called view(). view() takes two parameters: a PurpleWiki::Tree object, and an optional hash containing options for the view driver.

Currently, there are three view drivers:

debug    -- Text debugging output
wikihtml -- XHTML w/ no header tags
wikitext -- Wiki text markup

You can create your own view drivers. Install them by dropping them in the PurpleWiki/View directory.

METHODS

new(%options)

Constructor. Creates a root StructuralNode object. The %options has contains default metadata values.

If you want to include a default value for author, then $options{author} must be a reference to a list of arrays. The first value of the array is the author's name, the second value is the author's e-mail.

For example:

my $wiki = PurpleWiki::Tree->new(author=>[
   ['Chris Dent', 'cdent@blueoxen.org'] ]);

root()

Returns the root StructuralNode object.

Accessors/Mutators

title()
subtitle()
id()
date()
version()
authors()

authors() returns a list reference. See the documentation for new() for details. A side effect of the way authors() is implemented is that once you have given it a value, you can change that value, but you can't clear it. This shouldn't be an issue, but if it ever becomes one, we should add a clearAuthors() method.

view($driver, %params)

$driver is the name of the view driver, %params contains parameters that are passed to the driver. See "VIEW DRIVERS" above for more details. Drivers are stored in PurpleWiki/View and are dynamically loaded. To install new drivers, just drop it into the appropriate directory.

debug
wikihtml
wikitext

AUTHORS

Chris Dent, <cdent@blueoxen.org>

Eugene Eric Kim, <eekim@blueoxen.org>

SEE ALSO

PurpleWiki::StructuralNode, PurpleWiki::InlineNode.