Yggdrasil - Generates a website from a directory tree of content and templates


Yggdrasil - Generates a website from a directory tree of content and templates



Configuration Variables

Path to source directory.
    input_dir => '/home/me/site/source'
Path to output directory.
    output_dir => '/home/me/www'
Directory used to store title and update time caches.
    data_dir => 'data'
Directory create mode used by mkpath().
    dir_mode => 0755
Files matching one or more of the regular expressions in this array are passed to Text::Template. Files that do not match any of the regular expressions are copied to the target directory without processing. Should only match HTML files.
    include => [qw(\.html$ \.shtml$)]
Files or directories matching one or more of the regular expressions in this array are not processed or copied. These regular expressions are applied before the regular expressions in the include array.
    exclude => [qw(^_ \.tmpl$ ~$)]
Directories matching one or more of the regular expressions in this array are not included in the @navigation array.
    skip => [qw(^img ^index$)]
Passed to templates.
    base_url => 'http://www.mysite.com'
Filename of base template. All parent directories of the current directory are searched.
    base_template => 'base.tmpl'
File extension of template files.
    template_extension => '.tmpl'
A hashref containing full paths to override templates. If used there must be at least a ‘default’ override. Other overrides are matched against the current file name. E.g. an override template named ‘beta’ will be applied to all files matching /beta/.
    template_override => {beta => '/home/me/site/template.tmpl'}
Format of the timestamp passed to the template.
    timestamp_format => '%a %b %e %Y (%T)',
These filenames are removed from URL’s in the breadcrumb trail. Should match your webserver configuration.
    html_indices => [qw(index.html index.shtml)]
Set to 1 to give all HTML files (the files in include) the extension .html (this is useful when creating site versions for offline use or for webservers that can’t handle SSI).
    html_only => 0
Set to 1 to create a navigation array for the top level of the site (useful when creating site versions for offline use).
    front_page_navigation => 0
Set to 1 to include ‘index.html’ in navigation and breadcrumb trail links (useful when creating site versions for offline use).
    include_index => 0
Set to 1 to include index files in the siblings array.
    siblings_include_index => 0
Name given to the root page in the breadcrumb trail.
    home_label => 'Home'
The tag in the source HTML document used as the document title.
    title_tag => 'h1'
Title given to files not found in the title cache.
    default_title => 'No Title'
Set to 1 to enable the numbered subpages feature (see User Guide).
    subpages => 1
Page title added to the breadcrumb trail for numbered subpages.
    pagination => 'Page '
URL or IP address of FTP server.
    ftp_host => 'ftp.mysite.com'
FTP server username.
    ftp_username => 'me'
FTP server password.
    ftp_password => 'secret'
Base path to use for remote files.
    ftp_path => '/www'
The first line(s) of the log file.
    log_file_header => "# Yggdrasil log file\n"
The last line(s) of the log file.
    log_file_footer => '# end of log file'
Template for log file lines. The following variables are available: $fullname, $dirname, $filename.
    log_file_format => '{$fullname}'
Name of the file containing the last site release time. Stored in current data directory.
    release_file => '.release'
Set this to the complete commandline for nsgmls if you wish to validate output files while processing. {$filename} is replaced with the current filename. You need to have the SP SGML system (http://www.jclark.com/sp/) installed in order to use this feature.
    sp_command_line => '/usr/bin/nsgmls {$filename}',
Set to 1 to force rebuild of the document title cache.
    forcecache => 0
Set to 1 to display help message.
    help => 0
Name of log file.
    log_file => 'mysite.log'
Set to 1 to only process files added or changed since last release.
    update => 0
Upload processed files via FTP.
    upload => 0
    release => 0
    validate => 0
    verbose => 1

Public methods

This method calls find() from File::Find. Depending on the configuration variables and commandline options it performs the following tasks:

Before calling find(): Open log file for writing, flush output directory, initialize progress bar.

After calling find(): Close log file, delete files from output directory, upload files via FTP, update release file.

Creates a new Yggdrasil object and initializes it with values from the %Configuration hash and the configuration file if applicable.

See also: _init()

Returns a string with site processing stats.

Private methods

Determines which files get sent to the _process() method. Creates or updates the following arrays:

@siblings: A list of all files in the current directory, except subdirectories and HTML index files (set the configuration variable siblings_include_index to 1 to include indexes).

@trail: The path to the current directory. The title of the root page is determined by the home_label configuration variable. If the name of the current directory matches the name of the parent directory and the name of the current directory matches .*\/(\d+)$, the current page is treated as a numbered subpage and a new title is generated from the pagination configuration variable.

@navigation: A list of subpages. Contains all subpages except those matching any of the regexps in skip or those that are numbered subpages of the current page.

All the above arrays contain hashrefs with the following data:

        name => 'Page Title',
        href => 'relative_path/'

See also: _process()

Description of _process().
Removes the current directory from the breadcrumb trail and decrements $depth.
Makes it possible to pass an object reference to the File::Find functions.

See also: http://perlmonks.thepen.com/109068.html

Creates the directory if it doesn’t exist. Uses the directory create mode defined in dir_mode.
Calls $cache->sync() to get a list of the files removed from the input directory (if any). Deletes those files from the output directory.
Removes all content from the output directory.
Returns last release time from release_file. Sets release_time to 0 if release file doesn’t exist.
Returns true if the file is an HTML index file, false otherwise.
Returns true if $filename matches any of the regexps in include, false otherwise.
Description of init.
Resets the counters used to gather processing statistics.
Wrapper for the maketext function, prints the result from maketext() (Print MakeText).
Prints formatted line to logfile.
Reads the configuration file specified on the commandline or the default configuration file. Settings in the configuration file override the defaults in %Configuration.

Creates cache directory if it doesn’t exist.

Initializes external postprocessing sub if present.

Wrapper for the maketext function, returns the result from maketext() (Return MakeText).
Searches the current path for files with the extension template_extension. Templates in subdirectories override templates in the root directory.

The special template __base__ is set according to the configuration variable base_template.

Creates relative links to the pages in the breadcrumb trail. Fixes links if the current file is not an HTML index file.

See also: _html_index()

Prepares the content used by the templating system.
Sets the time in the release file to the current time.
Upload processed files to the FTP server defined in the configuration file.
Check configuration files for basic errors.
Inserts $filename in sp_command_line and executes the command.

Any error messages returned by the validator are appended to the errors string.


No known bugs.


Yggdrasil requires the following modules:





Morten Wulff, <wulff@psyke.org>




Copyright 2002-2003, Morten Wulff

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

 Yggdrasil - Generates a website from a directory tree of content and templates