Description | A static content generator. |
Newcomen::Plugin::Static - Copy static files to the destination directory.
This plugin will gather source items (Newcomen::Source instances) from the file system, prepare a collection (an Newcomen::Collection instance) and pages (Newcomen::Page instances) ready to be written by the Newcomen::Writer::Copy writer backend. This will effectively just copy static files from one or more source directories to a target directory, while complying to the Newcomen concepts.
Note: Empty directories will not be copied.
Source items will be gathered using the _crawl_fs()
method of Newcomen::Role::Crawler::Filesystem according to the configuration, see
OPTIONS. See Newcomen::Role::Crawler::Filesystem for the properties of the source
items, including the meta data included. The creator ID of the items will be set to 'Static'
.
One collection will always be created. Every source item with the ID 'Static'
will be added, in
no particular order. The collection may be empty if there are no source items. The collection's ID
and creator attributes will both be set to 'Static'
.
One page will be created for every item in the collection with the ID 'Static'
. Every created
page will contain exactly one content item, referencing the static source item to be copied to the
page's target. The target will be the path of the source file relative to the source's data
directory (not the project's root directory). The creator of the page will be set to 'Static'
,
and the page's collection attribute will be set to the source collection instance. The writer of all
pages with the creator set to 'Static'
will be set to the Newcomen::Writer::Copy backend
(without any further options), unless another plugin already set a writer for a page. The page will
include the meta data source_file, set to the absolute path of the source file.
Any page's (possibly rewritten) target will be added to the URL map (see Newcomen::URL) under the
key ['Static', $source_id]
, with the $source_id
being the ID of the Newcomen::Source
instance belonging to the page. This ID is set by Newcomen::Role::Crawler::Filesystem's
_crawl_fs() method, it is the path of the source
file relative to the project's root directory.
{ 'static' => { 'match' => undef, 'dirs' => undef, }, }
These are the default options set by the plugin. They may be overridden by user configuration.
static/match will be used in a regular expression to decide if a source file should be considered
for inclusion or not. It will be matched against the file name relative to the project's root
directory. All matching files will be included. If this is undef
(the default), it will be set to
a never matching regexp, preventing any file from being copied. Set it to '.'
to copy every file.
static/dirs must be either a string specifying one directory or an arrayref containing zero or
more strings specifying the directories in which to look for source files. The directories' paths
must be specified relative to the project's root directory. Setting this to an empty arrayref or
undef
(the default) will effectively prevent any file from being copied.
The source items created by this plugin will include all the information set by the Newcomen::Role::Crawler::Filesystem role. No additional data will be added.
{ 'source_file' => $source_file, }
source_file will be set to the absolute path of the source file of the page (i.e. the file to be copied to the output directory).
The following hooks are implemented: hook_crawl(), hook_build_collections(), hook_build_pages() and hook_writer(). All hooks are using the default hook priority.
Newcomen::Collection, Newcomen::Page, Newcomen::Role::Crawler::Filesystem, Newcomen::Source, Newcomen::URL, Newcomen::Writer::Copy
This is version 2014052501
.
Stefan Goebel - newcomen {at} subtype {dot} de
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/>.