Newcomen

Description A static content generator.
Newcomen > Perl Modules > Newcomen::Site
Source

Index


NAME ^

Newcomen::Site - Manages all pages of the project.

SYNOPSIS ^

use Newcomen::Site;

my $site = Newcomen::Site -> new ();

# Add a page:
$site -> add ($page);

# Get a page:
my $page = $site -> page ($target);

# Iterate over all pages:
for my $page ($site -> pages ()) {
   # ...
}

DESCRIPTION ^

Newcomen::Site is a container for the pages of the Newcomen project (see Newcomen::Page). See the developer section in Newcomen::Manual for a description of how Newcomen works and how Newcomen::Site fits in.

Plugins may use Newcomen::Role::Attribute::Site to access the main Newcomen::Site instance.

CLASS METHODS ^

new

my $site = Newcomen::Site -> new ();

Constructor. No parameters, the page list will be empty initially.

INSTANCE METHODS ^

Newcomen::Site uses a hashref to store the pages, with the page targets as keys, and the page instances as values. It uses the hash methods of Newcomen::Util::Traits, with the following exceptions and additions:

Please see Newcomen::Util::Traits for a complete list of methods and more details.

add

Toggle source:   add

sub add {

   my $self = shift;
   my $page = shift;

   confess 'Page target not unique: ' . $page -> target () if $self -> exists ($page -> target ());

   $self -> _set ($page -> target (), $page);

}
$site -> add ($page);

This method adds a page (an Newcomen::Page instance, the only parameter) to the site. The page may then be accessed by its target. The target must be unique, trying to add a page with a target that already exists in the list will cause a fatal error.

SEE ALSO ^

Newcomen::Manual, Newcomen::Page, Newcomen::Role::Attribute::Site, Newcomen::Util::Traits

VERSION ^

This is version 2014052501.

AUTHOR ^

Stefan Goebel - newcomen {at} subtype {dot} de

COPYRIGHT AND LICENSE ^

Copyright 2013-2014 Stefan Goebel.

This file is part of Newcomen.

Newcomen is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the license, or (at your option) any later version.

Newcomen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Newcomen. If not, see <http://www.gnu.org/licenses/>.