Zoffix Znet > App-ZofCMS > App::ZofCMS::Plugin::GooglePageRank

Download:
App-ZofCMS-1.001004.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 1.001004   Source  

NAME ^

App::ZofCMS::Plugin::GooglePageRank - Plugin to show Google Page Ranks

SYNOPSIS ^

    plugins => [
        { GooglePageRank => 200 },
    ],

    # all defaults and URI is set to the current page
    plug_google_page_rank => {},

    # all options set
    plug_google_page_rank => {
        uri => 'zoffix.com',
        timeout => 20,
        agent   => 'Opera 9.6',
        host    => 'suggestqueries.google.com',
        cell    => 't',
        key     => 'plug_google_page_rank',
    },

DESCRIPTION ^

The module is a plugin for App::ZofCMS that provides means to obtain Google Page Rank. 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/GooglePageRank/
    ],

Mangatory. You need to add the plugin to list of plugins to execute.

plug_google_page_rank

    plug_google_page_rank => {
        uri     => 'zoffix.com',
        timeout => 20,
        agent   => 'Opera 9.6',
        host    => 'suggestqueries.google.com',
        cell    => 't',
        key     => 'plug_google_page_rank',
    },

    plug_google_page_rank => {
        my ( $t, $q, $config ) = @_;
        return {
            uri     => 'zoffix.com',
            timeout => 20,
            agent   => 'Opera 9.6',
            host    => 'suggestqueries.google.com',
            cell    => 't',
            key     => 'plug_google_page_rank',
        };
    },

Mandatory. Takes a hashref or a subref as a value. If subref is specified, its return value will be assigned to plug_google_page_rank 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. The plug_google_page_rank first-level key can be set in either (or both) ZofCMS Template and Main Config File files. If set in both, the values of keys that are set in ZofCMS Template take precedence. Possible keys/values are as follows:

uri

    uri => 'zoffix.com',

    uri => [
        'zoffix.com',
        'haslayout.net',
        'http://zofdesign.com',
    ],

    uri => sub {
        my ( $t, $q, $config ) = @_;
    },

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 uri. The @_ will contain (in that order): ZofCMS Template hashref, query parameters hashref, App::ZofCMS::Config object. 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: 'http://' . $ENV{HTTP_HOST} . $ENV{REQUEST_URI}

timeout

    timeout => 20,

Optional. Takes a positive integer as a value. Specifies a Page Rank request timeout in seconds. Defaults to: 20

agent

    agent => 'Opera 9.6',

Optional. Takes a string as a value that specifies the User-Agent string to use when making the requests. Defaults to: 'Opera 9.6'

host

    host => 'suggestqueries.google.com',

Optional. Specifies which google host to use for making requests. Defaults to: suggestqueries.google.com (Note: if all your queries failing try to set this on to toolbarqueries.google.com)

cell

    cell => 't',

Optional. Specifies the first-level key in ZofCMS Template hashref into which to store the result. Must point to an undef or a hashref. Defaults to: t

key

    key => 'plug_google_page_rank',

Optional. Specifies the second-level key inside cell first-level key into which to put the results. Defaults to: plug_google_page_rank

OUTPUT ^

Depending on whether the 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 <tmpl_loop>, each of the hashrefs will contain two keys: rank and 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 'N/A'.

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'
            }
        ]

EXAMPLE DUMP 2

    plug_google_page_rank => {
        uri => 'zoffix.com',
    },


    't' => {
        'plug_google_page_rank' => '3'
    }

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'
    }

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.

syntax highlighting: