NAME
App::ZofCMS::Plugin::GetRemotePageTitle - plugin to obtain page titles from remote URIs
SYNOPSIS
In ZofCMS Template or Main Config File:
plugins => [
qw/GetRemotePageTitle/
],
plug_get_remote_page_title => {
uri => 'http://zoffix.com',
},
In HTML::Template file:
<tmpl_if name='plug_remote_page_title_error'>
<p class="error">Got error: <tmpl_var escape='html' name='plug_remote_page_title_error'></p>
<tmpl_else>
<p>Title: <tmpl_var escape='html' name='plug_remote_page_title'></p>
</tmpl_if>
DESCRIPTION
The module is a plugin for App::ZofCMS that provides means to get page titles from remote URIs which can be utilized when automatically parsing URIs posted in coments, etc.
This documentation assumes you've read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template
FIRST-LEVEL ZofCMS TEMPLATE AND MAIN CONFIG FILE KEYS
plugins
plugins => [
qw/GetRemotePageTitle/
],
Mandatory. You must specify the plugin in the list of plugins to execute.
plug_get_remote_page_title
plug_get_remote_page_title => {
uri => 'http://zoffix.com',
ua => LWP::UserAgent->new(
agent => "Opera 9.5",
timeout => 30,
max_size => 2000,
),
},
plug_get_remote_page_title => sub {
my ( $t, $q, $config ) = @_;
return {
uri => 'http://zoffix.com',
};
},
Mandatory. Takes either a hashref or a subref as a value. If subref is specified, its return value will be assigned to plug_get_remote_page_title
as if it was already there. If sub returns an undef
, then plugin will stop further processing. The @_
of the subref will contain (in that order): ZofCMS Tempalate hashref, query parameters hashref and App::ZofCMS::Config object. Possible keys/values for the hashref are as follows:
uri
plug_get_remote_page_title => {
uri => 'http://zoffix.com',
}
plug_get_remote_page_title => {
uri => [
'http://zoffix.com',
'http://haslayout.net',
],
}
plug_get_remote_page_title => {
uri => sub {
my ( $t, $q, $config ) = @_;
return 'http://zoffix.com';
},
}
Mandatory. Specifies URI(s) titles of which you wish to obtain. The value can be either a direct string, an arrayref or a subref. When value is a subref, its @_
will contain (in that order): ZofCMS Template hashref, query parameters hashref and App::ZofCMS::Config object. The return value of the sub will be assigned to uri
argument as if it was already there.
The single string vs. arrayref values affect the output format (see section below).
ua
plug_get_remote_page_title => {
ua => LWP::UserAgent->new(
agent => "Opera 9.5",
timeout => 30,
max_size => 2000,
),
},
Optional. Takes an LWP::UserAgent object as a value; this object will be used for fetching titles from the remote pages. Defaults to:
LWP::UserAgent->new(
agent => "Opera 9.5",
timeout => 30,
max_size => 2000,
),
PLUGIN'S OUTPUT
# uri argument set to a string
<tmpl_if name='plug_remote_page_title_error'>
<p class="error">Got error: <tmpl_var escape='html' name='plug_remote_page_title_error'></p>
<tmpl_else>
<p>Title: <tmpl_var escape='html' name='plug_remote_page_title'></p>
</tmpl_if>
# uri argument set to an arrayref
<ul>
<tmpl_loop name='plug_remote_page_title'>
<li>
<tmpl_if name='error'>
Got error: <tmpl_var escape='html' name='error'>
<tmpl_else>
Title: <tmpl_var escape='html' name='title'>
</tmpl_if>
</li>
</tmpl_loop>
</ul>
Plugin will set $t->{t}{plug_remote_page_title}
(where $t
is ZofCMS Template hashref) to either a string or an arrayref when uri
plugin's argument is set to a string or arrayref respectively. Thus, for arrayref values you'd use a <tmpl_loop>
plugins will use two variables inside that loop: error
and title
; the error
variable will be present when an error occured during title fetching. The title
will be the title of the URI. Order for arrayrefs will be the same as the order in uri
argument.
If uri
argument was set to a single string, then {plug_remote_page_title}
will contain the actual title of the page and {plug_remote_page_title_error}
will be set if an error occured.
AUTHOR
'Zoffix, <'zoffix at cpan.org'>
(http://haslayout.net/, http://zoffix.com/, http://zofdesign.com/)
BUGS
Please report any bugs or feature requests to bug-app-zofcms-plugin-getremotepagetitle at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-ZofCMS-Plugin-GetRemotePageTitle. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::ZofCMS::Plugin::GetRemotePageTitle
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-ZofCMS-Plugin-GetRemotePageTitle
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-ZofCMS-Plugin-GetRemotePageTitle
CPAN Ratings
http://cpanratings.perl.org/d/App-ZofCMS-Plugin-GetRemotePageTitle
Search CPAN
http://search.cpan.org/dist/App-ZofCMS-Plugin-GetRemotePageTitle/
COPYRIGHT & LICENSE
Copyright 2009 'Zoffix, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.