]> sipb.mit.edu Git - ikiwiki.git/blobdiff - plugins/externaldemo
web commit by http://www.larted.org.uk/~dom/: add question
[ikiwiki.git] / plugins / externaldemo
index 6bbced30ee70cc697e7745a8c478df40ccf81733..fa93e672d86f24c1e253d20717e4c09b19109be1 100755 (executable)
@@ -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
        
@@ -102,8 +103,9 @@ sub import {
 
        # 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");
+       # 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: ".