X-Git-Url: http://git.tremily.us/?p=ikiwiki.git;a=blobdiff_plain;f=plugins%2Fexternaldemo;h=24861dcc91d4c9dfe44e4277e80ce357f1e56577;hp=fa93e672d86f24c1e253d20717e4c09b19109be1;hb=1ce0d17dc758c4025d2e2eea79a691a8dbb90414;hpb=27299788e8fdc97c7fc1ad112f4610b1bdbaa3a6 diff --git a/plugins/externaldemo b/plugins/externaldemo index fa93e672d..24861dcc9 100755 --- a/plugins/externaldemo +++ b/plugins/externaldemo @@ -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"; } @@ -101,16 +112,15 @@ sub import { # stage of ikiwiki. rpc_call("hook", type => "preprocess", id => "externaldemo", call => "preprocess"); - # Here's an example of how to inject an arbitrary function into - # ikiwiki. Ikiwiki will be able to call bob() just like any other - # function. Note use of automatic memoization. - rpc_call("inject", name => "IkiWiki::bob", call => "bob", - memoize => 1); - # Here's an exmaple of how to access values in %IkiWiki::config. print STDERR "url is set to: ". rpc_call("getvar", "config", "url")."\n"; + # Here's an example of how to inject an arbitrary function into + # ikiwiki. Note use of automatic memoization. + rpc_call("inject", name => "IkiWiki::bob", + call => "formattime", memoize => 1); + print STDERR "externaldemo plugin successfully imported\n"; }