App-ZofCMS
view release on metacpan or search on metacpan
lib/App/ZofCMS/Plugin/GooglePageRank.pm view on Meta::CPAN
ZofCMS Template take precedence. Possible keys/values are as follows:
=head3 C<uri>
uri => 'zoffix.com',
uri => [
'zoffix.com',
'haslayout.net',
'http://zofdesign.com',
],
uri => sub {
my ( $t, $q, $config ) = @_;
},
B<Optional>. Takes a string, a coderef or an arrayref of strings each of which would specify
the page(s) for which to obtain Google Page Rank. If the value is a coderef, then it will
be exectued and its value will be assigned to C<uri>. The C<@_> will contain (in that order):
ZofCMS Template hashref, query parameters hashref, L<App::ZofCMS::Config> object.
B<Defaults to:> if not specified, then the URI of the current page will be calculated. Note
that this may depend on the server and is made up as:
C<< 'http://' . $ENV{HTTP_HOST} . $ENV{REQUEST_URI} >>
=head3 C<timeout>
timeout => 20,
B<Optional>. Takes a positive integer as a value. Specifies a Page Rank request
timeout in seconds. B<Defaults to:> C<20>
=head3 C<agent>
agent => 'Opera 9.6',
B<Optional>. Takes a string as a value that specifies the User-Agent string to use when
making the requests. B<Defaults to:> C<'Opera 9.6'>
=head3 C<host>
host => 'suggestqueries.google.com',
B<Optional>. Specifies which google host to use for making requests.
B<Defaults to:> C<suggestqueries.google.com> (B<Note:> if all your queries failing try to set
this on to C<toolbarqueries.google.com>)
=head3 C<cell>
cell => 't',
B<Optional>. Specifies the first-level key in ZofCMS Template hashref into which to store
the result. Must point to an C<undef> or a hashref. B<Defaults to:> C<t>
=head3 C<key>
key => 'plug_google_page_rank',
B<Optional>. Specifies the second-level key inside C<cell> first-level key into which
to put the results. B<Defaults to:> C<plug_google_page_rank>
=head1 OUTPUT
Depending on whether the C<uri> argument was set to a string (or not set at all) or an
arrayref the output will be either a string indicating page's rank or an arrayref of
hashrefs - enabling you to use a simple C<< <tmpl_loop> >>, each of the hashrefs will contain two keys: C<rank> and C<uri> - the rank of
the page referenced by that URI.
If there was an error while obtaining the rank (i.e. request timeout) the rank will
be shown as string C<'N/A'>.
=head2 EXAMPLE DUMP 1
plug_google_page_rank => {
uri => [
'zoffix.com',
'haslayout.net',
'http://zofdesign.com',
'yahoo.com',
],
},
't' => {
'plug_google_page_rank' => [
{
'rank' => '3',
'uri' => 'http://zoffix.com'
},
{
'rank' => '3',
'uri' => 'http://haslayout.net'
},
{
'rank' => '3',
'uri' => 'http://zofdesign.com'
},
{
'rank' => '9',
'uri' => 'http://yahoo.com'
}
]
=head2 EXAMPLE DUMP 2
plug_google_page_rank => {
uri => 'zoffix.com',
},
't' => {
'plug_google_page_rank' => '3'
}
=head2 EXAMPLE DUMP 3
# URI became http://zcms/ which is a local address and not pageranked
plug_google_page_rank => {},
't' => {
'plug_google_page_rank' => 'N/A'
}
( run in 0.742 second using v1.01-cache-2.11-cpan-5b529ec07f3 )