NAME

WWW::Wikipedia::TemplateFiller - Fill Wikipedia templates with your eyes closed

SYNOPSIS

use WWW::Wikipedia::TemplateFiller;

my $filler = new WWW::Wikipedia::TemplateFiller();

# Bit by bit
my $source = $filler->get( pubmed_id => '2309482' )->fill;
print $source->output;

# Or all at once
print $filler->get( pubmed_id => '2309482' )->fill->output;

# With fill-time options
$source = $filler->get( pubmed_id => '123456' )->fill( add_url => 1 );
print $source->output;

# With output-time (mostly formatting) options
print $source->output( vertical => 1, add_accessdate => 1 );

DESCRIPTION

This module generates Wikipedia template markup for various sources of information such as PubMed IDs, ISBNs, URLs, etc. While it works with multiple templates, it was predominantly created to lower the activation energy associated with filling out citation templates.

In writing a Wikipedia article, one aims to cite sufficient references. The trouble is that there are many different ways of citing different sources, all with different Wikipedia citation templates, and many requiring information that may be difficult to obtain. The initial goal of this module was to streamline the process of generating citation templates. Sure, the module's grown and it's been generalized to other templates (Drugbox, etc.), but the principles persist.

METHODS

new

my $filler = new WWW::Wikipedia::TemplateFiller( %attrs );

Creates a new template filler. Attributes are allowed in %attrs. These include isbndb_access_key, which is the API key to be used for making ISBN queries via isbndb.com.

get

my $source = $filler->get( $source_type => $id, %attrs );

Grabs the requested data from the net and returns it as a source object (actually a subclass of WWW::Wikipedia::TemplateFiller::Source). $source_type is something like pubmed_id, drugbank_id, hgnc_id, isbn, etc. It corresponds to a class in the WWW::Wikipedia::TemplateFiller::Source:: namespace.

$id is the corresponding ID, the format of which varies depending on the value of $source_type. For example, $id is numeric if $source_type is pubmed_id.

%attrs are additional attributes that are passed to the source class used to grab the requested data. Consult WWW::Wikipedia::TemplateFiller::Source for information.

cache

my $cache = $filler->cache;

Returns the cache associated with this filler.

ISBNdb ACCESS

Currently W::W::TF uses ISBNdb (http://www.isbndb.com) for accessing information about books. This will likely change somewhat in the future to allow for multiple book databases to be queried. For now, however, ISBNdb is the only option. If you plan to use this module for querying book data, then you must supply an ISBNdb access key.

There are two ways to provide an access key. The first is accomplished by passing a parameter to W::W::TF's new() method:

use WWW::Wikipedia::TemplateFiller;
my $tf = new WWW::Wikipedia::TemplateFiller(
  isbndb_access_key => 'your_access_key'
);

The second method is used by the W::W::TF::WebApp web application. For this, simply edit the %config hash within the included web application instance script in cgi/index.cgi. The INSTALL file provides more details.

The third and final method is to assign the access key to an environment variable called ISBNDB_ACCESS_KEY. This is accomplished something like this:

$ export ISBNDB_ACCESS_KEY=your_access_key

(This environment variable-based solution is the only way to test ISBNdb support during installation.)

AUTHOR

David J. Iberri, <diberri at cpan.org>

BUGS

Please report any bugs or feature requests to bug-www-wikipedia-templatefiller at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Wikipedia-TemplateFiller. 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 WWW::Wikipedia::TemplateFiller

You can also look for information at:

COPYRIGHT & LICENSE

Copyright (c) David J. Iberri, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.