The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Statocles::App - Base role for Statocles applications

VERSION

version 0.080

SYNOPSIS

    package MyApp;
    use Statocles::Base 'Class';
    with 'Statocles::App';

    sub pages {
        return Statocles::Page::Content->new(
            path => '/index.html',
            content => 'Hello, World',
        );
    }

DESCRIPTION

A Statocles App creates a set of pages that can then be written to the filesystem (or served directly, if desired).

Pages can be created from documents stored in a store (see Statocles::Page::Document), files stored in a store (see Statocles::Page::File), lists of content (see Statocles::Page::List), or anything at all (see Statocles::Page::Content).

ATTRIBUTES

site

The site this app is part of.

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.

url_root

The URL root of this application. All pages from this app will be under this root. Use this to ensure two apps do not try to write the same path.

templates

The templates to use for this application. A mapping of template names to template paths (relative to the theme root directory).

Developers should get application templates using the template method.

template_dir

The directory (inside the theme directory) to use for this app's templates.

METHODS

pages

    my @pages = $app->pages;

Get the pages for this app. Must return a list of Statocles::Page objects.

url

    my $app_url = $app->url( $path );

Get a URL to a page in this application. Prepends the app's url_root attribute if necessary. Strips "index.html" if possible.

    my $link = $app->link( %args )

Create a link to a page in this application. %args are attributes to be given to Statocles::Link constructor. The app's url_root attribute is prepended, if necessary.

template

    my $template = $app->template( $tmpl_name );

Get a template object for the given template name. The default template is determined by the app's class name and the template name passed in.

Applications should list the templates they have and describe what page class they use.

EVENTS

All apps by default expose the following events:

build

This event is fired after the app pages have been prepares and are ready to be rendered. This event allows for modifying the pages before they are rendered.

The event will be a Statocles::Event::Pages object containing all the pages prepared by the app.

INCLUDED APPS

These applications are included with the core Statocles distribution.

Statocles::App::Blog
Statocles::App::Basic
Statocles::App::Static
Statocles::App::Perldoc

SEE ALSO

Statocles::Store
Statocles::Page

AUTHOR

Doug Bell <preaction@cpan.org>

COPYRIGHT AND LICENSE

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.