CMS::MediaWiki - Perl extension for creating, reading and updating MediaWiki pages
use CMS::MediaWiki; my $mw = CMS::MediaWiki->new( # protocol => 'https', # Optional, default is http host => 'localhost', # Default: localhost path => 'wiki' , # Can be empty on 3rd-level domain Wikis debug => 0 # Optional. 0=no debug msgs, 1=some msgs, 2=more msgs );
Create or update MediaWiki pages. An update of a MediaWiki page can also be reduced to a specific page section. You may update many pages with the same object handle ($mw in the shown example).
You could change the login name between an update. This might be necessary if you would like to update a public page *and* a protected page by the WikiSysop user in just one cycle.
if ($mw->login(user => 'Reto', pass => 'yourpass')) { print STDERR "Could not login\n"; exit; } else { # Logged in. Do stuff ... }
$rc = $mw->login( protocol => 'https', # optional, default is http host => 'localhost' , # optional here, but wins if (re-)set here path => 'wiki', # optional here, but wins user => 'Reto' , # default: Perlbot pass => 'yourpass' , );
$rc = $mw->editPage( title => 'Online_Directory:Computers:Software:Internet:Authoring' , section => '' , # 2 means edit second section etc. # '' = no section means edit the full page text => "== Your Section Title ==\nbar foo\n\n", summary => "Your summary." , # optional );
$lines_ref = $mw->getPage(title => 'Perl_driven', section => 1); # omit section to get full page # Process Wiki lines ... print sprintf('%08d ', ++$i), " $_\n" foreach @$lines_ref;
In general, $rc returns 0 on success unequal 0 on failure.
After a successful call of the editPage function you had the following information available:
print "Edit time (before) was ", $mw->get('EDIT_TIME_BEFORE'), "\n"; print "Page title was " , $mw->get('PAGE_TITLE') , "\n"; print "The Wiki name was " , $mw->get('WIKI_NAME') , "\n";
None by default.
http://meta.pgate.net/cms-mediawiki/
http://www.screenpoint.biz/
https://twitter.com/screenpoint
Reto Schaer, <retoh@nospam-cpan.org>
Copyright (C) 2005-2010 by Reto Schaer
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
http://www.infocopter.com/perl/licencing.html
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install CMS::MediaWiki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CMS::MediaWiki
CPAN shell
perl -MCPAN -e shell install CMS::MediaWiki
For more information on module installation, please visit the detailed CPAN module installation guide.