Mvs

From Bjoern Hassler's website
Jump to: navigation, search
"Mediawiki mirroring and synchronisation"

Mediawiki mirroring and synchronisation - Mirroring - moving - Offline mediawiki (mvs, MWEclipse) - API/Mirroring - Mwlib - OAI - [Edit]

1 mvs[edit]

1.1 About[edit]

An approach to a cvs like system is implemented in 'mvs', which provides both a command line utility (mvs) as well as perl bindings.

Latest version: Mediawiki versioning system version 0.31, 01 Jul 2006. Author: Mark Jaroski, http://wikitravel.org/en/User:Mark.

1.2 Installation[edit]

You need perl. Installation and man page:

sudo  perl -MCPAN -e 'install WWW::Mediawiki::Client'
perldoc mvs

1.3 A typical mvs session[edit]

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

1.4 Features[edit]

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.

2 Issues and enhancements[edit]

2.1 Feeding pages to mvs[edit]

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.

2.2 Errors and bugs[edit]

https://rt.cpan.org/Public/Dist/Display.html?Name=WWW-Mediawiki-Client


2.2.1 Can't call method isa[edit]

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')) {

2.2.2 Failing on pages ending in "wiki"[edit]

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$".

2.2.3 Page appending[edit]

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.

2.2.4 Page names[edit]

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

2.2.5 Other errors[edit]

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.

3 More links[edit]

More perl/Mediawiki related things: