aboutsummaryrefslogtreecommitdiff
path: root/plugins/externaldemo
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-10-21 17:57:19 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-10-21 17:57:19 -0400
commite75818572fff5256d16221a2b065b214d8cb9f5d (patch)
tree30e45561111b4dcc48f4726bfaef0ca99f5d47d2 /plugins/externaldemo
parent92a43d5d384ba4e504c5255989a869ced424219c (diff)
downloadikiwiki-e75818572fff5256d16221a2b065b214d8cb9f5d.tar
ikiwiki-e75818572fff5256d16221a2b065b214d8cb9f5d.tar.gz
function injection overhaul
Add an inject function, that can be used by plugins that want to replace one of ikiwiki's functions with their own version. (This is a scary thing that grubs through the symbol table, and replaces all exported occurances of a function with the injected version.) external: RPC functions can be injected to replace exported functions. Removed the stupid displaytime hook, and use injection instead.
Diffstat (limited to 'plugins/externaldemo')
-rwxr-xr-xplugins/externaldemo10
1 files changed, 4 insertions, 6 deletions
diff --git a/plugins/externaldemo b/plugins/externaldemo
index 4d13f2444..be7aba8b9 100755
--- a/plugins/externaldemo
+++ b/plugins/externaldemo
@@ -106,9 +106,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 +125,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.