These functions allow code embedded in a <{perl}> or <{perlout}> section of a
WebMake file to be used to script the generation of content.
Each of these functions is defined both as a standalone function, or as a
function on the PerlCode object. Code in one of the <{perl*}> sections can
access this PerlCode object as the $self variable. If you plan to use
WebMake from mod_perl or in a threaded environment, be sure to call them as
methods on $self.
Find all items of content that match the glob pattern $pattern. If
$pattern begins with the prefix RE:, it is treated as a regular
expression. The list of items returned is not in any logical order.
Find all items of content that match the glob-style pattern $pattern. The
list of items returned is ordered according to the sort string $sortstring.
If $pattern begins with the prefix RE:, it is treated as a regular
expression.
See ''sorting.html'' in the WebMake documentation for details on sort strings.
This, by the way, is essentially implemented as follows:
Get the item of content named, but in Perl list format. It is assumed that the
list is stored in the content item in whitespace-separated format.
Note that you may have to assign this list to an array, to force it to be
interpreted by perl as an array instead of as a scalar. This is annoying,
but seems unavoidable.
Set a content chunk to a list containing the values provided, separated by
spaces. This content will not appear in a sitemap, and navigation links will
never point to it.
Set a content chunk to the value provided. This content will appear in a
sitemap and the navigation hierarchy. $upname should be the name of it's
parent content item. This item must not be metadata, or other
dynamically-generated content; only first-class mapped content can be used.
Find all URLs (from <out> and <media> tags) whose name matches the glob-style
pattern $pattern. The names of the URLs, not the URLs themselves, are
returned. If $pattern begins with the prefix RE:, it is treated as a
regular expression.
Generate a list by iterating through the @namelist, setting the content item
item to the current name, and interpreting the content chunk named
$itemname. This content chunk should refer to appropriately.
Each resulting block of content is appended to a $listtext, which is finally
returned.
See the news_site.wmk sample site for an example of this in use.
Define a tag for use in content items. Any occurrences of this tag, with at
least the set of attributes defined in @required_attributes, will cause the
handler function referred to by handlerfn to be called.
Handler functions are called as fcllows:
handler ($tagname, $attrs, $text, $perlcode);
Where $tagname is the name of the tag, $attrs is a reference to a hash
containing the attribute names and the values used in the tag, and $text is the
text between the start and end tags.
$perlcode is the PerlCode object, allowing you to write proper object-oriented
code that can be run in a threaded environment or from mod_perl. This can be
ignored if you like.
Define a tag for use in content items. This is identical to define_tag above,
but is intended for use to define ''empty'' tags, ie. tags which occur alone,
not as part of a start and end tag pair.
The handler in this case is called with an empty string for the $text
argument.
Get the content object representing the ''root'' of the site map. Returns
undef if no root object exists, or the WebMake file does not contain a
<sitemap> command.
Get the ''main'' content on the current output page. The ''main'' content is
defined as the most recently referenced content item which (a) is not generated
content (perl code, sitemaps, breadcrumb trails etc.), and (b) has its
map attribute set to ``true''.
Note that this API should only be called from a deferred content reference;
otherwise the ''main'' content item may not have been referenced by the time
this API is called.
undef is returned if no main content item has been referenced.
Get the current WebMake interpreter's instance of HTML::WebMake::Main
object. Virtually all of WebMake's functionality and internals can be accessed
through this.
Get a path to a temporary file in the WebMake ~/.webmake directory.
Useful for plugins. You should provide a string to use in the filename
as a clue to the tag type, e.g. ``freetable'', ``thumbnail'' etc.; and
you should provide the extension to use on the file, e.g. ``html'', ``txt'',
``gif'' etc.
''Scrape'' a block of HTML or XML text. Given the text in $text, and
regular expressions in qr/start/ and qr/end/, this function will remove
all HTML up to and including the start regexp, and all HTML including and
after the end regexp.
If $keepstart or $keepend is set to 1, then the text matched by that
regexp will be preserved, otherwise it will be stripped. The default values
are 0.
If the patterns match halfway through a HTML or XML tag, then the remainder of
that tag (until the trailing > character) will be stripped automatically.
If a regexp is specified as undef, then it will be ignored.
Given the text in $text, and regular expressions in qr/start/ and
qr/end/, this function will remove all HTML after, and including, the start
regexp, and all HTML up to and including the end regexp.
If $keepstart or $keepend is set to 1, then the text matched by that
regexp will be preserved, otherwise it will be stripped. The default values
are 0.
If the patterns match halfway through a HTML or XML tag, then the remainder of
that tag (until the trailing > character) will be stripped automatically.
The regexps cannot be specified as undef, as scrape_xml() should
be used for that case instead.