Statocles::Site - An entire, configured website
version 0.065
my $site = Statocles::Site->new( title => 'My Site', nav => [ { title => 'Home', href => '/' }, { title => 'Blog', href => '/blog' }, ], apps => { blog => Statocles::App::Blog->new( ... ), }, ); $site->deploy;
A Statocles::Site is a collection of applications.
The site title, used in templates.
The base URL of the site, including protocol and domain. Used mostly for feeds.
This can be overridden by base_url in Deploy.
The theme for this site. All apps share the same theme.
The applications in this site. Each application has a name that can be used later.
The plugins in this site. Each plugin has a name that can be used later.
The page path to use for the site index. Make sure to include the leading slash (but /index.html is optional). Defaults to /, so any app with url_root of / will be the index.
/index.html
/
url_root
Named navigation lists. A hash of arrays of hashes with the following keys:
title - The title of the link href - The href of the link
The most likely name for your navigation will be main. Navigation names are defined by your theme. For example:
main
{ main => [ { title => 'Blog', href => '/blog', }, { title => 'Contact', href => '/contact.html', }, ], }
The store object to use for build(). This is a workspace and will be rebuilt often, using the build and daemon commands. This is also the store the daemon command reads to serve the site.
build()
build
daemon
The deploy object to use for deploy(). This is intended to be the production deployment of the site. A build gets promoted to production by using the deploy command.
deploy()
deploy
A hash of arbitrary data available to theme templates. This is a good place to put extra structured data like social network links or make easy customizations to themes like header image URLs.
A Mojo::Log object to write logs to. Defaults to STDERR.
The Text::Markdown object to use to turn Markdown into HTML. Defaults to a plain Text::Markdown object.
Any object with a "markdown" method will work here.
Register this site as the global site.
my $app = $site->app( $name );
Get the app with the given name.
name
my @links = $site->nav( $key );
Get the list of links for the given nav key. Each link is a Statocles::Link object.
key
If the named nav does not exist, returns an empty list.
$site->build( %options );
Build the site in its build location. The %options hash is passed in to every app's pages method, allowing for customization of app behavior based on command-line.
%options
pages
$site->deploy( %options );
Deploy the site to its destination. The %options are passed to the appropriate deploy object.
my $url = $site->url( $page_url );
Get the full URL to the given path by prepending the base_url.
base_url
The site object exposes the following events.
This event is fired after the pages have been built by the apps, but before any page is written to the build_store.
build_store
You can use this event to add new pages or edit the pages already created.
The event will be a Statocles::Event::Pages object containing all the pages built by the apps.
This event is fired after the site has been built and the pages written to the build_store.
The event will be a Statocles::Event::Pages object containing all the pages built by the site.
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2016 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Statocles, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Statocles
CPAN shell
perl -MCPAN -e shell install Statocles
For more information on module installation, please visit the detailed CPAN module installation guide.