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

Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2006-11-04 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.