NAME
Statocles::Site - An entire, configured website
SYNOPSIS
my $site = Statocles::Site->new(
title => 'My Site',
nav => [
{ title => 'Home', href => '/' },
{ title => 'Blog', href => '/blog' },
],
apps => {
blog => Statocles::App::Blog->new( ... ),
},
);
$site->deploy;
DESCRIPTION
A Statocles::Site is a collection of applications.
ATTRIBUTES
title
The site title, used in templates.
base_url
The base URL of the site, including protocol and domain. Used mostly for feeds.
This can be overridden by base_url in Deploy.
theme
The theme for this site. All apps share the same theme.
apps
The applications in this site. Each application has a name that can be used later.
index
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.
nav
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 => [
{
title => 'Blog',
href => '/blog',
},
{
title => 'Contact',
href => '/contact.html',
},
],
}
build_store
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.
deploy
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.
data
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.
log
A Mojo::Log object to write logs to. Defaults to STDERR.
markdown
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.
METHODS
BUILD
Register this site as the global site.
app
my $app = $site->app( $name );
Get the app with the given name
.
nav
my @links = $site->nav( $key );
Get the list of links for the given nav key
. Each link is a Statocles::Link object.
title - The title of the link
href - The href of the link
If the named nav does not exist, returns an empty list.
build
$site->build;
Build the site in its build location.
deploy
$site->deploy;
Deploy the site to its destination.
url
my $url = $site->url( $page_url );
Get the full URL to the given path by prepending the base_url
.
EVENTS
The site object exposes the following events.
before_build_write
This event is fired after the pages have been built by the apps, but before any page is written to the 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.
build
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.