Mvs
From Bjoern Hassler
Mediawiki mirroring and synchronisation - Mirroring - moving - Offline mediawiki (mvs, MWEclipse) - API/Mirroring - Mwlib - OAI - [Edit]
Contents |
[edit] 1 mvs
[edit] 1.1 About
An approach to a cvs like system is implemented in 'mvs', which provides both a command line utility (mvs) as well as perl bindings.
- http://wikitravel.org/en/User:Mark/WWW-Mediawiki-Client
- WWW-Mediawiki-Client is a cvs-like perl client interface for Mediawiki driven wiki websites. It's packaged with a script, mvs which allows you to work offline using the editor of your choice, to check for conflicting changes, and commit your local version of the wiki pages in separate steps.
- Similar page http://meta.wikimedia.org/wiki/WWW::Mediawiki::Client
- CPAN
- http://search.cpan.org/~markj/WWW-Mediawiki-Client/ (Page at CPAN with versions
- http://search.cpan.org/~markj/WWW-Mediawiki-Client-0.31/ ( 01 Jul 2006)
- http://search.cpan.org/~markj/WWW-Mediawiki-Client/bin/mvs (details about the mvs command)
Latest version: Mediawiki versioning system version 0.31, 01 Jul 2006. Author: Mark Jaroski, http://wikitravel.org/en/User:Mark.
[edit] 1.2 Installation
You need perl. Installation and man page:
sudo perl -MCPAN -e 'install WWW::Mediawiki::Client' perldoc mvs
[edit] 1.3 A typical mvs session
From http://search.cpan.org/~markj/WWW-Mediawiki-Client/bin/mvs, a typical command line mvs session might look like this:
mkdir wikitravel.en cd wikitravel.en mvs login -d www.wikitravel.org -u <username> -p 'secret' mvs update User:<username>.wiki User:<username>/Test_Page.wiki emacs User:<username>.wiki mvs commit -m 'commit message' User:<username>.wiki
[edit] 1.4 Features
The possibilities are clear: the system allows you to offline a bunch of pages, then edit them offline using a text editor. The system could be used with other text-based interfaces, such as a wiki mirror, or by email.
Note: When you upload pages, your changes are merged: Even if the live wiki page has been edited, your changes are merged (if there is no conflict). Where there are conflicts, you can resolve this before uploading.
Also see Mediawiki_mirror.
[edit] 2 Issues and enhancements
[edit] 2.1 Feeding pages to mvs
mvs cannot check out sets of pages, e.g. belonging to a category, or pages that have been edited by a user, etc.
Mvs/mvs_co.pl Script available here shortly, that allows you to generate sets of pages using the API to checkout pages.
[edit] 2.2 Errors and bugs
https://rt.cpan.org/Public/Dist/Display.html?Name=WWW-Mediawiki-Client
[edit] 2.2.1 Can't call method isa
The following error occurs:
Can't call method "isa" without a package or object reference at /usr/local/bin/mvs line 96.
Often this error is intermittent, and doing another "mvs login" seems to help. This seems to be a problem partially to do with parsing error messages.
Patch here: http://rt.cpan.org/Public/Bug/Display.html?id=43079 Alternatively, in mvs, you can insert this
if ($@ eq ) {
die "Fatal error, and error in error handling: \$\@ is empty.\nSee $LOGFILE for details of the error.\n" ;
};
before
if ($@->isa('WWW::Mediawiki::Client::LoginException')) {
[edit] 2.2.2 Failing on pages ending in "wiki"
It's not possible to checkout the page Mediawiki which fails with the same error "isa" error.
Patch: In Client.pm, line 1319 change
) if $name =~ /.wiki$/;
to
) if $name =~ /\.wiki$/;
The name must not match '.wiki$', as literal string, not regexp ".wiki$".
[edit] 2.2.3 Page appending
When you check out a page, and then modify the page on the wiki, and check out again, all is well. The local page is updated. When you check out a page, and then append to the page on the wiki, and check out again (without changes to local page), local/remote pages are shown as conflicting.
This seems to be a problem with Client.pm appending a spurious blank line.
sub _merge { my ($self, $filename, $ref, $server, $local) = @_; my $control = { in => $\, out => $/, chomp => 1 }; $ref = VCS::Lite->new('ref', "\n", "$ref\n"); $server = VCS::Lite->new('server', "\n", "$server\n"); $local = VCS::Lite->new('local', "\n", "$local\n"); my $merge = $ref->merge($server, $local); return scalar $merge->text(); }
In the above code, a "\n" is added to the $server and the $local file. This causes the merged file to have an extra blank line, even if server and local are identical. I assume the "\n" was added for a good reason, (probably to do with merging the last line) so the solution is to remove the "\n" from the end. Replace
return scalar $merge->text();
with
my $output = $merge->text(); $output =~ s/\n$//s; return $output;
This fixes the above problem, but may have other side effects.
[edit] 2.2.4 Page names
Not all page names are translated to valid filenames. Valid pages:
W:/
If no namespace NS: is defined,
NS:
is also valid. The following two pages are valid, and distinct
MWM MWM/
(Note that MMW//, MWM///, etc are all the same as MWM/.)
If your file system isn't case sensitive, then you have a problem with pages like
CSSF Cssf
[edit] 2.2.5 Other errors
Other errors and issues on the cpan page. Mvs was last updated in 2006. It might benefit from rewriting and including more of the MediaWiki-API. (Much of the functionality should be possible through the API now, except for the local mirroring part.)
The to do on http://wikitravel.org/en/User:Mark/WWW-Mediawiki-Client says:
- Use of "Special:All pages" to return a list of every page in the host wiki
- Image handling, upload and download of images
The first one is solved through the above script, but Image handling also needs to be done. MediaWiki-API can handle image upload.
[edit] 3 More links
- A mediawiki API perl interface, see MWAPI and http://search.cpan.org/~exobuzz/MediaWiki-API-0.24/
- MWEclipse
- Also see comment about ikiwiki on MW Other approaches.
More perl/Mediawiki related things:
- Perl extension for creating, reading and updating MediaWiki pages, Perl module to download, and upload, mediawiki pages: http://search.cpan.org/~retoh/CMS-MediaWiki-0.8013, http://meta.pgate.net/cms-mediawiki/
- a Wikipedia bot framework written in Perl http://search.cpan.org/~dcollins/Perlwikipedia-1.5.2
- Perl extension for flat mirror of mediawikis http://search.cpan.org/~cselt/Mediawiki-Spider-0.31
- http://search.cpan.org/~triddle/Parse-MediaWikiDump-0.55
- http://search.cpan.org/~diberri/HTML-WikiConverter-0.67