Kwiki::GoogleLink - easy links to Google searches


Kwiki-GoogleLink documentation Contained in the Kwiki-GoogleLink distribution.

Index


Code Index:

NAME

Top

Kwiki::GoogleLink - easy links to Google searches

SYNOPSIS

Top

 $ cpan Kwiki::GoogleLink
 $ cd /path/to/kwiki
 $ echo "Kwiki::GoogleLink" >> plugins
 $ kwiki -update

DESCRIPTION

Top

This was written as a demonstration of a plugin to add a new WAFL phrase to the Kwiki formatting rules.

This plugin makes it quick and easy to add a Google search link to a Kwiki page, for example:

    Search Google for: {google:Kwiki}

will be rendered as

    Search Google for: <a href="http://www.google.com/search?q=Kwiki">Kwiki</a>

This example can be used as the basis for custom shortcuts at your own site.

AUTHORS

Top

Michael Gray <mjg17@eng.cam.ac.uk>

SEE ALSO

Top

Kwiki

COPYRIGHT AND LICENSE

Top


Kwiki-GoogleLink documentation Contained in the Kwiki-GoogleLink distribution.

package Kwiki::GoogleLink;
use strict;
use warnings;
use Kwiki::Plugin '-Base';

our $VERSION = 0.01;

const class_title => 'Google Search Link';
const class_id => 'google_link';

sub register {
    my $registry = shift;
    $registry->add(wafl => google => 'Kwiki::GoogleLink::Wafl');
}

package Kwiki::GoogleLink::Wafl;
use Spoon::Formatter ();
use base 'Spoon::Formatter::WaflPhrase';

const google_search => 'http://www.google.com/search?q=';

sub html {
    my $search = $self->arguments;
    join('', 
         '<a href="', 
         $self->google_search,
         $self->uri_escape($search), '">',
         $self->html_escape($search), '</a>'
        );
}

1;

__DATA__