Package: ikiwiki
Version: 3.20101023
Severity: wishlist

Hi,

Is there any particular reason why format hooks are not run against the content
generated by IkiWiki CGI? For instance I'd like to include some JavaScript code
fetch from an external JavaScript file also in the CGI content without forking
any templates just for this cause. So I wrote a plugin that rewrites the
content HTML to include proper <script> elements in the document. Works great
for static files, but not for the content output by IkiWiki in CGI mode.

If there's no obstacles with this idea that I'm not aware of, please consider
merging the attached patch that enables format hooks for CGI. Thanks.
>From 5943cc18abf19b85e91fa7ad20ebd7a9f7375413 Mon Sep 17 00:00:00 2001
From: Tuomas Jormola <t...@solitudo.net>
Date: Sun, 31 Oct 2010 03:36:20 +0200
Subject: Run format hooks in CGI mode


Signed-off-by: Tuomas Jormola <t...@solitudo.net>
---
 IkiWiki/CGI.pm |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index f2a32a9..b0fd762 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -46,7 +46,14 @@ sub showform ($$$$;@) {
        my $cgi=shift;
 
        printheader($session);
-       print misctemplate($form->title, $form->render(submit => $buttons), @_);
+       my $content = misctemplate($form->title, $form->render(submit => 
$buttons), @_);
+       run_hooks(format => sub {
+               $content=shift->(
+                       page => undef,
+                       content => $content,
+               );
+       });
+       print $content;
 }
 
 sub redirect ($$) {
-- 
1.7.0.4

Reply via email to