The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MediaWiki::EditFramework - a framework for editing MediaWiki pages.

SYNOPSIS

 use MediaWiki::EditFramework;

 my $wiki = MediaWiki::EditFramework->new('example.com', 'wiki');
 my $page = $wiki->get_page('Main_Page');
 my $text = $page->get_text;
 $text =~ s/old thing/new update/g;
 $page->edit($text, 'update page');

DESCRIPTION

This is a higher level framework for editing MediaWiki pages. It depends on another module for lower level API access, and doesn't provide functionality unrelated to editing. By using a higher-level abstraction layer in scripts, it becomes simpler to change out backend modules as needed.

This is the framework that I've been using for the past few years to run an archiving bot. The main features that it has over lower-level frameworks are:

  • Pages are represented as objects.

    This allows the page to store additional information, such as the last updated timestamp when they were retrieved. The timestamp is then passed back to the server when the page is edited, to allow it to properly detect edit conflicts.

  • The module supports specified a write_prefix, which is appended to pages titles when editing a page.

    This makes it easier to create a test mode for a bot script. By specifying the write prefix in your own user space, the bot will retrieve the normal pages, but the modifications will be written to user space so you can review them without impacting others.

CONSTRUCTOR

new(SITE,PATH)

Create a new instance pointing to the specified SITE and PATH (default w). The underling API object points to http://SITE/PATH/api.php.

METHODS

Passes FILE to LWP::UserAgent's cookie_jar method, to store cookies for a persistent login.

login(USER,PASS)

Log in the specified USER.

get_page(TITLE)

Get the wiki page with the specified TITLE. Returns an instance of MediaWiki::EditFramework::Page, which has methods to get/edit the page text.

create_page(TITLE)

Get the wiki page with the specified TITLE; then croak if it already exists.

write_prefix(PREFIX)

When writing pages, prepend the specified PREFIX to the page title.

This makes it easier to create a test mode for a bot script. By specifying the write prefix in your own user space, the bot will retrieve the normal pages, but the modifications will be written to user space so you can review them without impacting others.

SEE ALSO

MediaWiki::API

COPYRIGHT

Copyright (C) 2012 by Steve Sanbeg

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.