NAME
App::ZofCMS::Plugin::GoogleTime - plugin to get times for different locations using Google
SYNOPSIS
In ZofCMS Template or Main Config File:
plugins => [
qw/GoogleTime/
],
plug_google_time => {
location => 'Toronto',
},
In HTML::Template file:
<tmpl_if name='plug_google_time_error'>
<p class="error">Got error: <tmpl_var escape='html' name='plug_google_time_error'></p>
<tmpl_else>
<p>Time: <tmpl_var escape='html' name='plug_google_time'></p>
</tmpl_if>
DESCRIPTION
The module is a plugin for App::ZofCMS that provides means to obtain times for different locations using Google.
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/GoogleTime/
],
Mandatory. You must specify the plugin in the list of plugins to execute.
plug_google_time
plug_google_time => {
location => 'Toronto',
ua => LWP::UserAgent->new(
agent => "Opera 9.5",
timeout => 30,
max_size => 2000,
),
},
plug_google_time => sub {
my ( $t, $q, $config ) = @_;
return {
location => 'Toronto',
}
},
Mandatory. Takes either a hashref or a subref as a value. If subref is specified, its return value will be assigned to plug_google_time
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:
location
plug_google_time => {
location => 'Toronto',
}
plug_google_time => {
location => [
'Toronto',
'New York',
],
}
plug_google_time => {
location => sub {
my ( $t, $q, $config ) = @_;
return 'Toronto';
},
}
Mandatory. Specifies location(s) for which you wish to obtain times. 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 location
argument as if it was already there.
The single string vs. arrayref values affect the output format (see section below).
ua
plug_google_time => {
ua => LWP::UserAgent->new(
agent => "Opera 9.5",
timeout => 30,
),
},
Optional. Takes an LWP::UserAgent object as a value; this object will be used for accessing Google. Defaults to:
LWP::UserAgent->new(
agent => "Opera 9.5",
timeout => 30,
),
PLUGIN'S OUTPUT
# location argument set to a string
<tmpl_if name='plug_google_time_error'>
<p class="error">Got error: <tmpl_var escape='html' name='plug_google_time_error'></p>
<tmpl_else>
<p>Time: <tmpl_var escape='html' name='plug_google_time'></p>
</tmpl_if>
# location argument set to an arrayref
<ul>
<tmpl_loop name='plug_google_time'>
<li>
<tmpl_if name='error'>
Got error: <tmpl_var escape='html' name='error'>
<tmpl_else>
Time: <tmpl_var escape='html' name='time'>
</tmpl_if>
</li>
</tmpl_loop>
</ul>
Plugin will set $t->{t}{plug_google_time}
(where $t
is ZofCMS Template hashref) to either a string or an arrayref when location
plugin's argument is set to a string or arrayref respectively. Thus, for arrayref values you'd use a <tmpl_loop>
plugins will use three variables inside that loop: error
, time
and hash
; the error
variable will be present when an error occured during title fetching. The time
will be the formated string of the time including the location. The hash
variable will contain a hashref that is the output of data()
method of WWW::Google::Time module. Order for arrayrefs will be the same as the order in location
argument.
If location
argument was set to a single string, then {plug_google_time}
will contain the formated time of the location, {plug_google_time_error}
will be set if an error occured and {plug_google_time_hash}
will contain the output of data()
method of WWW::Google::Time module.
REPOSITORY
Fork this module on GitHub: https://github.com/zoffixznet/App-ZofCMS
BUGS
To report bugs or request features, please use https://github.com/zoffixznet/App-ZofCMS/issues
If you can't access GitHub, you can email your request to bug-App-ZofCMS at rt.cpan.org
AUTHOR
Zoffix Znet <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/)
LICENSE
You can use and distribute this module under the same terms as Perl itself. See the LICENSE
file included in this distribution for complete details.