NAME
Lavoco::Website - Framework to run a tiny website, controlled by a JSON config file and Template::Toolkit.
VERSION
Version 0.06
SYNOPSIS
Runs a FastCGI web-app for serving Template::Toolkit templates.
This module is purely a personal project to control various small websites, use at your own risk.
#!/usr/bin/env perl
use strict;
use warnings;
use Lavoco::Website;
my $website = Lavoco::Website->new( name => 'Example' );
my $action = lc( $ARGV[0] ); # (start|stop|restart)
$website->$action;
A JSON config file (named website.json by default) should be placed in the base directory of your website.
{
"title":"The Example Website",
"pages" : [
{
"url" : "/",
"template":"index.tt",
"label" : "Home",
"title" : "Your online guide to the example website"
},
...
}
The mandetory field in the config is pages
, as an array of JSON objects.
Each page
object should have a url
and template
as a bare minimum.
All other fields are up to you, to fit your requirements.
When a request is made, a lookup is done for a matching url
, and that page
is then selected.
The page
object is available in your template.
It is useful to have pages within a page.
When a page is selected that is a sub-page, 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.
METHODS
Class Methods
new
Creates a new instance of the website object.
Instance Methods
name
The identifier for the website, used as the process title.
base
The base directory of the application, we use FindBin for this.
dev
Flag to indicate whether this we're running a development instance of the website.
It's on by default, and only turned off if the base directory contains /live
.
I typically use /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.
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.