NAME
Lavoco::Website - EXPERIMENTAL FRAMEWORK. Framework to run small websites, URL dispatching based on a flexible config file, to render Template::Toolkit templates.
VERSION
Version 0.11
SYNOPSIS
A FastCGI web-app for serving Template::Toolkit templates.
This is an experimental framework to control various small websites, use at your own risk.
use Lavoco::Website;
my $website = Lavoco::Website->new( name => 'Example' );
my $action = lc( $ARGV[0] ); # (start|stop|restart)
$website->$action;
METHODS
Class Methods
new
Creates a new instance of the website object, performs basic validation of your setup and dies if there's a problem.
Instance Methods
name
The identifier for the website, used as the process title.
base
The base directory of the application, using FindBin.
dev
Flag to indicate whether we're running a development instance of the website.
It's on by default, and currently turned off if the base directory contains /live.
I typically use working directories such as /home/user/www.example.com/dev and /home/user/www.example.com/live.
processes
Number of FastCGI process to spawn, 5 by default.
templates
The directory containing the TT templates, by default it's $website->base . '/templates'.
start
Starts the FastCGI daemon.
stop
Stops the FastCGI daemon.
restart
Restarts the FastCGI daemon, with a 1 second delay between stopping and starting.
CONFIG
A JSON config file named website.json should be placed in the base directory of your website.
{
"pages" : [
{
"path" : "/",
"template":"index.tt",
...
},
...
]
...
"send_alerts_from":"The Example Website <no-reply@example.com>",
"send_404_alerts_to":"you@example.com",
...
}
The entire config hash is available in all templates, and is flexible, there are only a couple of mandatory/reserved attributes.
The mandatory field in the config is pages, an array of JSON objects.
Each page object should have a path (URL) and template.
All other fields are up to you, to fit your requirements.
When a request is made, a lookup is performed for a page by matching the path - the associated template will be rendered.
If no page is found, the template 404.tt will be rendered.
The page object is available in the templates.
It is often useful to have sub-pages, simply create a pages attribute in a page object.
If a sub-page is selected, an extra key for parents is included in the page object as a list of the parent pages, this is useful for building breadcrumb links.
TODO
More documentation.
AUTHOR
Rob Brown, <rob at intelcompute.com>
BUGS
Please report any bugs or feature requests to bug-lavoco-website at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lavoco-Website. I will be notified, and then you will automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Lavoco::Website
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2014 Rob Brown.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.