We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Plugins Web>VoodooPadXmlRpcAddOn (04 Nov 2006, PeterThoeny)
Tags:
create new tag
, view all tags

VoodooPad XML-RPC Add-On

provides an XmlRpc interface according to the VoodooPad api spec

Usage

loginStruct = { 'username': 'steve',    #string
                'password': 'NeXT4ever' #string
              }

Next we have the page struct. These arethe minimum required fields:

%pageStruct = { key => 'homepad',  #string
                page =>'Welcome to my personal wiki... etc',  #string
                version => 5,      #int
             }

pageStruct may also contain more keys than just "key," "page," and "version". In the case of VoodooPad, it's going to send over more values. In the case of TWiki, TWikiMetaData data are also exported (eg, topicinfo.date, topicinfo.format, topicinfo.version, topicinfo.author, topicparent, etc.). this is done automatically based on whatever metadata are stored in the topic

myboolean = vpwiki.authenticate(loginStruct) This method just takes a login struct and authenticates the user. It returns true if the user authenticates, false otherwise.

myarray = vpwiki.getPageKeys(loginStruct) This method returns all the keys that the server has on it's end. If there are none, then it will return an empty array.

mypageStruct = getPage(loginStruct, key) This method returns a pageStruct for the given key.

myboolean = setPage(loginStruct, pageStruct) This method takes a pageStruct, and places it in the store. It returns a boolean on success, otherwise it'll throw an exception if something goes wrong.

some sample script which use VoodooPadXmlRpcAddOn

login.pl

#! /usr/bin/perl -w
use strict;
use Data::Dumper;

use XMLRPC::Lite;

my $proxy = XMLRPC::Lite->proxy( 'http://sane-asylum.com/twiki/bin/xmlrpc-voodoo' );

my ($data,$cmd);

my $login = { username => 'WillNorris', password => 'wrong-password' };

$cmd = 'vpwiki.authenticate';
$data = $proxy->call( $cmd, $login )->result;
print "$cmd: ", Dumper( $data ), "\n";

test-xml-rpc.pl

#! /usr/bin/perl -w
use strict;
use Data::Dumper;

use XMLRPC::Lite;

my $proxy = XMLRPC::Lite->proxy( 'http://sane-asylum.com/twiki/bin/xmlrpc-voodoo' );

my ($data,$cmd);

my $login = { username => 'TWikiGuest', password => 'TWikiGuest' };

$cmd = 'vpwiki.authenticate';
$data = $proxy->call( $cmd, $login )->result;
print "$cmd: ", Dumper( $data ), "\n";

$cmd = 'vpwiki.getPageKeys';
$data = $proxy->call( $cmd, $login )->result;
#print "$cmd: ", Dumper( $data ), "\n";

$cmd = 'vpwiki.getPage';
$data = $proxy->call( $cmd, $login, 'TestTopicXmlRpc' )->result;
print "$cmd: ", Dumper( $data ), "\n";

my $page = $data;
$page->{page} = "i was here!\n\n" . $page->{page};
print Dumper( $page->{page} ), "\n";

$cmd = 'vpwiki.setPage';
$data = $proxy->call( $cmd, $login, $page )->result;
print "$cmd: ", Dumper( $data ), "\n";

strip-main-namespace.pl

#! /usr/bin/perl -w
use strict;

use XMLRPC::Lite;

my $proxy = XMLRPC::Lite->proxy( 'http://sane-asylum.com/twiki/bin/xmlrpc-voodoo' );

my $login = { username => 'TWikiGuest', password => 'TWikiGuest' };

#$bAuthenticated = $proxy->call( 'vpwiki.authenticate', $login )->result;

my @pages = @{ $proxy->call( 'vpwiki.getPageKeys', $login )->result };

foreach my $page ( @pages )
{
    print STDERR "\n$page ";

    my $data = $proxy->call( 'vpwiki.getPage', $login, $page )->result;

    next unless (my $pageStruct = $data)->{page};
    my $origPage = $pageStruct->{page};
    $pageStruct->{page} =~ s|-- People\.|-- |g;
    $pageStruct->{page} =~ s|-- Main\.|-- |g;
    $pageStruct->{page} =~ s|-- %MAINWEB%\.|-- |g;

    # don't bother writing if we haven't changed anything (slower and creates an unnecessary revision)
    next if $origPage eq $pageStruct->{page};
    print STDERR "changed"
        if $proxy->call( 'vpwiki.setPage', $login, $pageStruct )->result;
}

InterWikiMove.pl

#! /usr/bin/perl -w
use strict;
use Data::Dumper;

use XMLRPC::Lite;

my $login = { username => 'TWikiGuest', password => 'TWikiGuest' };

my $proxySource = XMLRPC::Lite->proxy( 'http://sane-asylum.com/twiki/bin/xmlrpc-voodoo' ) or die $!;
my $proxyDest = XMLRPC::Lite->proxy( 'http://biohack.net/twiki/bin/xmlrpc-voodoo' ) or die $!;

my $topic = 'TestTopicInterWikiMove';

my $page = $proxySource->call( 'vpwiki.getPage', $login, $topic )->result;
#print Dumper( $page ), "\n";

if ( $proxyDest->call( 'vpwiki.setPage', $login, $page )->result )
{   # leave a breadcrumb
    $page->{page} = "Moved to http://biohack.net/twiki/bin/view/Sandbox/TestTopicInterWikiMove";
    my $data = $proxySource->call( 'vpwiki.setPage', $login, $page )->result;
}

Add-On Installation Instructions

Note: You do not need to install anything on the browser to use this add-on. The following instructions are for the administrator who installs the add-on on the server where TWiki is running.

  • Download the ZIP file from the Add-on Home (see below)
  • Unzip VoodooPadXmlRpcAddOn.zip in your twiki installation directory. Content:
File: Description:
bin/xmlrpc-voodoo
  • Test if the installation was successful:
    • describe, with example

Add-On Info

  • SHORTDESCRIPTION = Provides an XML-RPC interface based on VoodooPad API spec

Add-on Author: TWiki:Main/WillNorris
Add-on Version: 19 Jan 2004 (v0.9.0)
Change History:  
19 Jan 2004: Initial version
CPAN Dependencies: CPAN:SOAP::Lite
Other Dependencies: none
Perl Version: 5.6 (?)
License: GPL
Add-on Home: http://TWiki.org/cgi-bin/view/Plugins/VoodooPadXmlRpcAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/VoodooPadXmlRpcAddOnDev

Related Topic: TWikiAddOns

-- TWiki:Main/WillNorris - 19 Jan 2004

Topic attachments
I Attachment Action Size Date Who Comment
zipzip VoodooPadXmlRpcAddon.zip manage 1.9 K 19 Jan 2004 - 12:30 WillNorris  
Topic revision: r11 - 04 Nov 2006 - 06:08:48 - PeterThoeny
Plugins.VoodooPadXmlRpcAddOn moved from Plugins.VoodooPadXmlRpcAddon on 16 Feb 2004 - 22:12 by SvenDowideit - put it back
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback