Newcomen

Description A static content generator.
Newcomen > Perl Modules > Newcomen::Plugin::Blog::Excerpt
Source

Index


NAME ^

Newcomen::Plugin::Blog::Excerpt - Creates excerpts for blog content.

DESCRIPTION ^

This plugin extracts parts of the content of all Newcomen::Content instances that belong to pages with a creator ID starting with 'Blog::' and stores the extracted parts in the meta data of the Newcomen::Content instance under a user defined key.

The part(s) to extract are delimited by a start and a stop string, which can be freely configured. Multiple parts of the content may be extracted using multiple keys and different start and stop strings for each key. If neither a start nor a stop string is found in some content, the key will not be created in the meta data. If at least one of the strings is found, the key will be created. If only a start string is found, everything from the start string to the end of the content will be extracted. If only a stop string is found, everything from the start of the content to the stop string will be extracted. If both are found, everything between the two strings will be extracted. If one start and/or stop string occurs multiple times, the longest matching part of the content will be extracted.

Start and stop strings are not interpreted as regular expressions, but as literal strings.

If the Newcomen::Content instance or the Newcomen::Source instance referenced by it already contain meta data for a configured key, it will not be overridden, even if it is empty or undef.

Extraction of parts of the content will be done after all formatters have been applied, so the extracted parts of the content are formatted.

OPTIONS ^

{
   'blog'       => {
      'excerpt' => {},
   },
}

These are the default options set by this plugin. They may be overridden by user configuration.

blog/excerpt has to be a hashref (or undef, if you know what you are doing). Its keys will be used as meta data keys. Its values have to be arrayrefs, with two elements: the first one being the start string, the second one being the stop string. Everything between the start and stop strings will be extracted from the content and stored in the Newcomen::Content instance's meta data under the specified key. Note that nested meta data structures are supported, using slashes (/) as separators in the key.

By default, nothing will be extracted (with blog/excerpt being an empty hashref).

Example

To extract everything between '<!--excerpt-->' and '<!--/excerpt-->' and store it in the meta data under the key excerpt, the following configuration may be used:

{
   'blog'          => {
      'excerpt'    => {
         'excerpt' => ['<!--excerpt-->', '<!--/excerpt-->'],
      },
   },
}

META DATA ^

Content ^

Meta data set for the blog's Newcomen::Content instances depends on the configuration. By default, nothing will be set by this plugin.

HOOKS ^

This plugin implements the hook_post_format() hook (default priority).

SEE ALSO ^

Newcomen::Content, Newcomen::Source

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