Lavoco::Website - Framework to run a tiny website, controlled by a JSON config file and Template::Toolkit.
Version 0.06
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.
pages
Each page object should have a url and template as a bare minimum.
page
url
template
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.
parents
This is useful for building breadcrumb links.
Creates a new instance of the website object.
The identifier for the website, used as the process title.
The base directory of the application, we use FindBin for this.
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.
/live
I typically use /home/user/www.example.com/dev and /home/user/www.example.com/live.
/home/user/www.example.com/dev
/home/user/www.example.com/live
Number of FastCGI process to spawn, 5 by default.
The directory containing the TT templates, by default it's $website->base . '/templates'.
$website->base . '/templates'
Starts the FastCGI daemon.
Stops the FastCGI daemon.
Restarts the FastCGI daemon, with a 1 second delay between stopping and starting.
More documentation.
Rob Brown, <rob at intelcompute.com>
<rob at intelcompute.com>
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.
bug-lavoco-website at rt.cpan.org
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)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Lavoco-Website
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Lavoco-Website
CPAN Ratings
http://cpanratings.perl.org/d/Lavoco-Website
Search CPAN
http://search.cpan.org/dist/Lavoco-Website/
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.
To install Lavoco::Website, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lavoco::Website
CPAN shell
perl -MCPAN -e shell install Lavoco::Website
For more information on module installation, please visit the detailed CPAN module installation guide.