From 0f25ec8eb640a850a8f1efe7081c03d05d04eda4 Mon Sep 17 00:00:00 2001 From: joey Date: Sat, 16 Sep 2006 00:52:26 +0000 Subject: * pagetemplate hooks are now also called when generating cgi pages. * Add a favicon plugin, which simply adds a link tag for an icon to each page (and cgis). --- IkiWiki/CGI.pm | 20 ++++++++++++++++---- IkiWiki/Plugin/favicon.pm | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 IkiWiki/Plugin/favicon.pm (limited to 'IkiWiki') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 01c5812ef..f07a4e5a2 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -99,6 +99,9 @@ sub cgi_recentchanges ($) { #{{{ changelog => $changelog, baseurl => baseurl(), ); + run_hooks(pagetemplate => sub { + shift->(page => "", destpage => "", template => $template); + }); print $q->header(-charset => 'utf-8'), $template->output; } #}}} @@ -349,9 +352,19 @@ sub cgi_editpage ($$) { #{{{ my $q=shift; my $session=shift; - eval q{use CGI::FormBuilder}; + my @fields=qw(do rcsinfo subpage from page type editcontent comments); + my @buttons=("Save Page", "Preview", "Cancel"); + + eval q{use CGI::FormBuilder; use CGI::FormBuilder::Template::HTML}; + my $renderer=CGI::FormBuilder::Template::HTML->new( + fields => \@fields, + template_params("editpage.tmpl"), + ); + run_hooks(pagetemplate => sub { + shift->(page => "", destpage => "", template => $renderer->engine); + }); my $form = CGI::FormBuilder->new( - fields => [qw(do rcsinfo subpage from page type editcontent comments)], + fields => \@fields, header => 1, charset => "utf-8", method => 'POST', @@ -363,9 +376,8 @@ sub cgi_editpage ($$) { #{{{ params => $q, action => $config{cgiurl}, table => 0, - template => {template_params("editpage.tmpl")}, + template => $renderer, ); - my @buttons=("Save Page", "Preview", "Cancel"); decode_form_utf8($form); diff --git a/IkiWiki/Plugin/favicon.pm b/IkiWiki/Plugin/favicon.pm new file mode 100644 index 000000000..518d2c2ff --- /dev/null +++ b/IkiWiki/Plugin/favicon.pm @@ -0,0 +1,24 @@ +#!/usr/bin/perl +# favicon plugin. + +package IkiWiki::Plugin::favicon; + +use warnings; +use strict; +use IkiWiki; + +sub import { #{{{ + hook(type => "pagetemplate", id => "favicon", call => \&pagetemplate); +} # }}} + +sub pagetemplate (@) { #{{{ + my %params=@_; + + my $template=$params{template}; + + if ($template->query(name => "favicon")) { + $template->param(favicon => "favicon.png"); + } +} # }}} + +1 -- cgit v1.2.3