X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/506bcbac0420a46997ad531961d543e62c011513..8c55424b11edbe1fd3e6ff1e20ec85c1f3c6e593:/plugins/externaldemo diff --git a/plugins/externaldemo b/plugins/externaldemo index 6bbced30e..be7aba8b9 100755 --- a/plugins/externaldemo +++ b/plugins/externaldemo @@ -23,9 +23,10 @@ sub rpc_read { while (<>) { $accum.=$_; - # Kinda hackish approch to parse a single XML RPC out of the - # accumulated input. Relies on calls always ending with a - # newline, which ikiwiki's protocol requires be true. + # Kinda hackish approach to parse a single XML RPC out of the + # accumulated input. Perl's RPC::XML library doesn't + # provide a better way to do it. Relies on calls always ending + # with a newline, which ikiwiki's protocol requires be true. if ($accum =~ /^\s*(<\?xml\s.*?<\/(?:methodCall|methodResponse)>)\n(.*)/s) { $accum=$2; # the rest @@ -100,15 +101,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. - rpc_call("inject", name => "IkiWiki::bob", call => "bob"); - # 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"; }