User:AnomieBOT/source/d/Redirects.pm/doc

NAME edit

d::Redirects - AnomieBOT redirect functions decorator

SYNOPSIS edit

 use AnomieBOT::API;
 
 $api = new AnomieBOT::API('conf.ini', 1);
 $api->decorators(qw/d::Redirects/);

DESCRIPTION edit

d::Redirects contains functions for handling redirects for use by an AnomieBOT task. When "d::Redirects" is used as a decorator on the API object, the following methods are available.

METHODS PROVIDED edit

$api->resolve_redirects( @pages )
Returns a hash mapping each page name in the list to its target (possibly itself). The returned value is cached for a short time, so repeated calls are not particularly inefficient.
If an error occurs, returns a 1-element hash mapping the empty string to the the API error object.
$api->apply_redirect_map( $title, $mapping )
Uses the mapping hash to find the target title, correctly detecting loops.
$api->redirects_to( @pages )
Returns a hash mapping each redirect back to the page name, as well as an entry mapping each page to itself. The returned value is cached for a short time, so repeated calls are not particularly inefficient.
If an error occurs, returns a 1-element hash mapping the empty string to the the API error object.
$api->redirects_to_resolved( @pages )
This is roughly equivalent to passing the list of pages through $api->resolve_redirects then $api->redirects_to. Returns a hash like the latter.
If an error occurs, returns a 1-element hash mapping the empty string to the the API error object.
$api->flush_redirect_cache()
Clears the caches used by resolve_redirects() and redirects_to().
$api->redirect_regex()
Returns a regex that matches the magic at the start of an article that makes it into a redirect (i.e. the "#REDIRECT").
If an error occurs, returns the API error object.

COPYRIGHT edit

Copyright 2008–2019 Anomie

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