class Webgen::Website

About

Represents a webgen website and provides the main interface for users.

Normally, webgen is used from the command line via the webgen command or from Rakefiles via Webgen::RakeTask. However, you can also easily use webgen as a library and this class provides the interface for this usage!

You may notice that this class doesn't have many methods. This is because webgen is designed from ground up to be extensible. Most of the 'magic' happens in extensions which are registered on the ext OpenStruct object. The simple 'core' classes that are not extensions have separate accessor methods (config for the Configuration object, blackboard for the Blackboard and so on).

Since a webgen website is, basically, just a directory, the only parameter needed for creating a new Website object is the website directory. Once created, the website is fully initialized and one can work with it:

  • If you want to generate the website, you just need to call execute_task with :generate_website as parameter.

  • If you want to retrieve data from the website, you can use the various accessors on the Website object itself or use ext to access all available extensions.

    Note: This is generally only useful if the website has been generated before because otherwise there probably is no data to retrieve.

Constants

CONFIG_FILENAME

The name of the configuration file webgen uses.

Attributes

blackboard[R]

The blackboard used for inter-object communication.

cache[R]

A cache to store information that should be available the next time the website gets generated.

config[R]

The website configuration.

directory[R]

The website directory.

ext[R]

Access to all extension objects. An OpenStruct object.

logger[R]

The Webgen::Logger used for logging.

tree[R]

The internal data structure used to store information about individual nodes.

See Tree for more information

Public Class Methods

new(dir, logger = nil, &block)

Create a new webgen Website object for the website in the directory dir.

If no logger is specified, a dummy logger that logs to a StringIO is created.

You can provide a block for modifying the Website object in any way during the initialization:

  • If the block only takes one parameter, it is called with the Website object after the initialization is done but before the cache is restored.

  • If it takes two parameters, the first one is the Website object and the second one is a boolean specifying whether the block is currently called any initialization (value is true) or after it (value is +false).

Public Instance Methods

execute_task(task, *options)

Execute the given task.

See Webgen::Task and the classes in its namespace for available classes.

save_cache()

Save the cache.

tmpdir(path = '', create = false)

Append the path to the website's temporary directory and return the full path to it.

Note that the temporary directory is only created if the create parameter is set to true.