Newcomen

Description A static content generator.
Newcomen > Perl Manuals > Newcomen::Manual::Hooks
Source

Index


NAME ^

Newcomen::Manual::Hooks - Hooks to be implemented by plugins.

HOOKS ^

The following is a complete list of hooks plugins may implement. The hooks are run in the order they are listed below.

Note: In the following description, the term standard hook simply means that this hook is called without any parameters and its return value will be ignored.

For filter hooks, parameters and behaviour are described below. Please see Newcomen::Plugins' run_filter() method for more information.

Initialization

hook_pre_init, hook_init, hook_post_init

Standard hooks.

Gathering And Processing Source Data

hook_pre_crawl

Standard hook.

hook_crawl

Called without any parameters. This hook must return a list of Newcomen::Source instances, or an empty list. All sources returned will be added automatically to the global Newcomen::Crawler instance.

hook_post_crawl

Standard hook.

hook_pre_sources

Standard hook.

hook_prepare_source, hook_process_source, hook_refine_source

Filter hooks. These hooks will be called for every Newcomen::Source instance of the global Newcomen::Crawler instance. The source instance will be supplied as the only parameter. If one filter hook returns a false value for a source instance, this source instance will be removed from the global crawler instance.

hook_post_sources

Standard hook.

Creating And Processing Collections

hook_pre_build_collections

Standard hook.

hook_build_collections

Called without any parameters. This hook must return a list of Newcomen::Collection instances, or an empty list. All instances returned will be added to global Newcomen::Catalog instance.

hook_post_build_collections

Standard hook.

hook_pre_clean_collections

Standard hook.

hook_clean_collection

Filter hook. This hook will be called with three parameters: An Newcomen::Source instance, an Newcomen::Collection instance and an integer (in that order). The collection instance contains the source instance at the position specified by the third parameter. If the hook returns a false value, the source instance will be removed from the collection.

hook_post_clean_collections

Standard hook.

hook_pre_collections

Standard hook.

hook_prepare_collection, hook_process_collection, hook_refine_collection

Filter hooks. These hooks will be called with an Newcomen::Collection instance as the only parameter. If a hook returns a false value for a collection, the collection will be removed from the global Newcomen::Catalog instance.

hook_post_collections

Standard hook.

Creating And Processing Pages

hook_pre_build_pages

Standard hook.

hook_build_pages

Called without any parameters. This hook must return a list of Newcomen::Page instances, or an empty list. Every instance returned will be added to the global Newcomen::Site instance.

hook_rewrite_target

This hook is called every time a new Newcomen::Page instance is created. It will be called with two parameters: the first parameter is the current page target, the second specifies the creator ID of the page. Both are strings. The hook must return a string, specifying the (possibly rewritten) page target. These hooks will be chained, so every hook_rewrite_target() method implemented by a plugin will see the return value of the previous hook_rewrite_target() hook of another plugin as first parameter (except the first hook called, obviously). The return value of the last hook will then be used as the page target for the new Newcomen::Page instance.

hook_post_build_pages

Standard hook.

hook_pre_pages

Standard hook.

hook_prepare_page, hook_process_page, hook_refine_page

Filter hooks. These hooks will be called with an Newcomen::Page instance as the only parameter. If a hook returns a false value for a page instance, this instance will be removed from the global Newcomen::Site instance.

hook_post_pages

Standard hook.

Setting Formatters

hook_pre_format

Standard hook.

hook_formatters

This hook will be called with three parameters: an Newcomen::Content instance, an Newcomen::Page instance and an integer, in that order. The integer specifies the index of the content instance in the page instance. The hook should set formatters for the content instance as required. Once all plugins implementing this hook have been called for a specific content instance, this content instance will automatically be formatted.

hook_post_format

Standard hook.

Setting Renderers

hook_pre_render

Standard hook.

hook_renderer

This hook will be called for every page of the global Newcomen::Site instance with one parameter: an Newcomen::Page instance. The hook should set the renderer for the page. Once the hooks of all plugins have been called for a page instance, this page will be rendered automatically.

hook_post_render

Standard hook.

Setting Writers

hook_pre_write

Standard hook.

hook_writer

Similar to the hook_renderer() hook, this hook will be called for every page of the global Newcomen::Site instance with one parameter: an Newcomen::Page instance. The hook should set the writer for the page. Once the hooks of all plugins have been called for a page instance, this page will be written by the writer backend automatically.

hook_post_write

Standard hook.

Deployment

hook_pre_deploy, hook_deploy, hook_post_deploy

Standard hooks.

Clean Up

hook_pre_cleanup, hook_cleanup, hook_post_cleanup

Standard hooks.

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/>.