diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-10-21 17:57:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-10-21 17:57:19 -0400 |
commit | e75818572fff5256d16221a2b065b214d8cb9f5d (patch) | |
tree | 30e45561111b4dcc48f4726bfaef0ca99f5d47d2 /IkiWiki/Plugin/external.pm | |
parent | 92a43d5d384ba4e504c5255989a869ced424219c (diff) | |
download | ikiwiki-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 'IkiWiki/Plugin/external.pm')
-rw-r--r-- | IkiWiki/Plugin/external.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm index 287e118f1..4ce9c8bab 100644 --- a/IkiWiki/Plugin/external.pm +++ b/IkiWiki/Plugin/external.pm @@ -202,10 +202,16 @@ sub inject ($@) { #{{{ my $sub = sub { IkiWiki::Plugin::external::rpc_call($plugin, $params{call}, @_) }; + $sub=memoize($sub) if $params{memoize}; + + # This will add it to the symbol table even if not present. no warnings; eval qq{*$params{name}=\$sub}; use warnings; - memoize($params{name}) if $params{memoize}; + + # This will ensure that everywhere it was exported to sees + # the injected version. + IkiWiki::inject(name => $params{name}, call => $sub); return 1; } #}}} |