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

NAME

WWW::Mediawiki::Client

SYNOPSIS

  use WWW::Mediawiki::Client;

  my $filename = 'Subject.wiki';
  my $wmc = WWW::Mediawiki::Client->new(
      site_url => 'http://www.wikitravel.org/en'
  );

  # output info messages, but not debug
  $wmc->set_output_level(WWW::Mediawiki::Client::INFO);

  # like cvs update
  $wmc->do_update($filename);

  # like cvs commit
  $wmc->do_commit($filename, $message);

  #aliases
  $wmc->do_up($filename);
  $wmc->do_com($filename, $message);

DESCRIPTION

WWW::Mediawiki::Client provides a very simple cvs-like interface for Mediawiki driven WikiWiki websites, such as http://www.wikitravel.org|Wikitravel or http://www.wikipedia.org|Wikipedia. The interface mimics the two most basic cvs commands: update and commit with similarly named methods. Each of these has a shorter alias, as in cvs. Verbosity is controled through an output_level accessor method.

CONSTRUCTORS

new

  my $wmc = WWW::Mediawiki::Client->new(site_url = 'http://www.wikitravel.org');

Accepts name-value pairs which will be used as initial values for any of the fields which have accessors below. Throws the same execptions as the accessor for any field named.

ACCESSORS

site_url

  my $url = $wmc->site_url($url);

The site URL is the base url for reaching the Mediawiki server who's content you wish to edit. There is no default. This has to be set before attempting to use any of the methods which attempt to access the server.

site_url

  my $char = $wmc->space_substitute($char);

Mediawiki allows article names to have spaces, for instance the default Meidawiki main page is called "Main Page". The spaces need to be converted for the URL, and to avoid the normal but somewhat difficult to read URL escape the Mediawiki software substitutes some other character. Wikipedia uses a '+', as in "Main+Page" and Wikitravel uses a '_' as in "Main_page". WWW::Mediawiki::Client always writes wiki files using the '_', but converts them to whatever the space_substitute is set to for the URL.

username

  my $url = $wmc->username($url);

The username to use if WWW::Mediawiki::Client is to log in to the Mediawiki server as a given user.

password

  my $url = $wmc->password($url);

The password to use if WWW::Mediawiki::Client is to log in to the Mediawiki server as a given user. Note that this password is sent en clair, so it's probably not a good idea to use an important one.

edit_path

  my $path = $wmc->edit_path($path);

The edit path is a string which given the site URL and a page name can be used to construct the balance of the URL to the edit page for that page on the wikimedia server. You shouldn't have to worry about this unless the Mediawiki software on your server has been altered or is very out-of-date.

action_path

  my $path = $wmc->action_path($path);

The action path is a string which given the site URL and a page name can be used to construct the balance of the URL to the action page for that page on the wikimedia server. You shouldn't have to worry about this unless the Mediawiki software on your server has been altered or is very out-of-date.

login_path

  my $path = $wmc->login_path($path);

The login path is a string which given the site URL and a page name can be used to construct the balance of the URL to the login page for that page on the wikimedia server. You shouldn't have to worry about this unless the Mediawiki software on your server has been altered or is very out-of-date.

output_level

  my $ol = $wmc->output_level(WWW::Mediawiki::Client::INFO);

This output level accessor provides for verbosity control. There are a number of different output levels:

WWW::Mediawiki::Client::QUIET
WWW::Mediawiki::Client::ERROR
WWW::Mediawiki::Client::INFO
WWW::Mediawiki::Client::DEBUG

commit_message

  my $msg = $wmc->commit_message($msg);

A commit_message must be specified before do_commit can be run. This will be used as the comment when submitting pages to the Mediawiki server.

minor_edit

  my $bool = $wmc->minor_edit($bool);

Mediawiki allows users to mark some of their edits as minor using the "This is a minor edit" checkbox. The field minor_edit allows a commit from the mediawiki client to be marked as a minor edit.

Instance Methods

do_login

  $wmc->do_login;

The do_login method operates like the cvs login command. The site_url, username, and password attributes must be set before attempting to login. Once do_login has been called successfully any successful commit from the same directory will be logged in the Mediawiki server as having been done by username.

do_li

  $wmc->do_li;

An alias for do_login.

do_update

  $self->do_update($filename, ...);

The do_update method operates like a much-simplified version of the cvs update command. The argument is a list of filenames, whose contents will be compared to the version on the WikiMedia server and to a locally stored reference copy. Lines which have changed only in the server version will be merged into the local version, while lines which have changed in both the server and local version will be flagged as possible conflicts, and marked as such, somewhate in the manner of cvs (actually this syntax comes from the default conflict behavior of Algorithm::Diff::Apply):

  >>>>>> http://server.somewiki.org/en
  The line as it appears on the server
  >>>>>> Filename.wiki
  The line as it appears locally
  <<<<<<

After the merging, and conflict marking is complete the server version will be copied into the reference version.

If either the reference version or the local version are empty, or if either file does not exist they will both be created as a copy of the current server version.

Throws:

CouldNotGetServerVersion

do_up

An alias for do_update.

do_commit

  $self->do_commit($filename);

As with do_update the do_commit method operates like a much simplified version of the cvs commit command. Again, the argument is a filename. In keeping with the operation of cvs, do_commit does not automatically do an update, but does check the server version against the local reference copy, throwing an error if the server version has changed, thus forcing the user to do an update. A different error is thrown if the conflict pattern sometimes created by do_update is found.

After the error checking is done the local copy is submitted to the server, and, if all goes well, copied to the local reference version.

Throws:

UpdateNeeded
ConflictsPresent
CouldNotGetServerVersion
UploadFailed

do_com

This is an alias for do_commit.

save_state

  $wmc->save_state;

Saves the current state of the wmc object in the current working directory.

load_state

  $wmc = $wmc->load_state;

Loads the state of the wmc object from that saved in the current working directory.

AUTHORS

Mark Jaroski <mark@geekhive.net>

Original author

Mike Wesemann <mike@fhi-berlin.mpg.de>

Added support for Mediawiki 1.3.10+ edit tokens

Bernhard Kaindl <bkaindl@ffii.org>

Improved error messages.

LICENSE

Copyright (c) 2004 Mark Jaroski.

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

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 819:

'=item' outside of any '=over'

Around line 831:

You forgot a '=back' before '=head1'