]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - plugins/externaldemo
git: Do the revert operation in a secondary working tree
[git.ikiwiki.info.git] / plugins / externaldemo
index 4d13f244453badfb4eaaa406611d5b64047b2fe6..24861dcc91d4c9dfe44e4277e80ce357f1e56577 100755 (executable)
@@ -8,7 +8,6 @@ use strict;
 print STDERR "externaldemo plugin running as pid $$\n";
 
 use RPC::XML;
-use RPC::XML::Parser;
 use IO::Handle;
 
 # autoflush stdout
@@ -31,7 +30,19 @@ sub rpc_read {
                        $accum=$2; # the rest
        
                        # Now parse the XML RPC.
-                       my $r = RPC::XML::Parser->new->parse($1);
+                       my $parser;
+                       eval q{
+                               use RPC::XML::ParserFactory;
+                               $parser = RPC::XML::ParserFactory->new;
+                       };
+                       if ($@) {
+                               # old interface
+                               eval q{
+                                       use RPC::XML::Parser;
+                                       $parser = RPC::XML::Parser->new;
+                               };
+                       }
+                       my $r=$parser->parse($1);
                        if (! ref $r) {
                                die "error: XML RPC parse failure $r";
                        }
@@ -106,9 +117,8 @@ sub import {
                rpc_call("getvar", "config", "url")."\n";
 
        # Here's an example of how to inject an arbitrary function into
-       # ikiwiki, replacing a core function.
-       # Note use of automatic memoization.
-       rpc_call("inject", name => "IkiWiki::formattime",
+       # ikiwiki. Note use of automatic memoization.
+       rpc_call("inject", name => "IkiWiki::bob",
                call => "formattime", memoize => 1);
 
        print STDERR "externaldemo plugin successfully imported\n";
@@ -126,9 +136,8 @@ sub preprocess {
        return "externaldemo plugin preprocessing on $title!";
 }
 
-sub formattime {
-       print STDERR "externaldemo plugin's formattime called via RPC";
-       return scalar "formatted time: ".localtime(shift);
+sub bob {
+       print STDERR "externaldemo plugin's bob called via RPC";
 }
 
 # Now all that's left to do is loop and handle each incoming RPC request.