* 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).
master
joey 2006-09-16 00:52:26 +00:00
parent 6206e9a62e
commit 0f25ec8eb6
10 changed files with 73 additions and 17 deletions

View File

@ -604,6 +604,9 @@ sub misctemplate ($$;@) { #{{{
baseurl => baseurl(),
@_,
);
run_hooks(pagetemplate => sub {
shift->(page => "", destpage => "", template => $template);
});
return $template->output;
}#}}}

View File

@ -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);

View File

@ -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

5
debian/changelog vendored
View File

@ -33,8 +33,11 @@ ikiwiki (1.27) UNRELEASED; urgency=low
* Patch from Recai to fix a wide character warning from the search plugin
during setup if the wikiname contains utf8.
* Yet another fix for those poor case-insensative OSX users.
* 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).
-- Joey Hess <joeyh@debian.org> Fri, 15 Sep 2006 13:19:54 -0400
-- Joey Hess <joeyh@debian.org> Fri, 15 Sep 2006 19:39:36 -0400
ikiwiki (1.26) unstable; urgency=low

View File

@ -0,0 +1,6 @@
[[template id=plugin name=favicon included=1 author="Joey Hess"]]
[[tag type/chrome]]
If this plugin is enabled, then an icon link is added to pages, for web
browsers to display. The icon is currently hardcoded to be a favicon.png,
which must be in the root of the wiki.

View File

@ -105,13 +105,13 @@ return the htmlized content.
hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
Each time a page (or part of a blog page, or an rss feed) is rendered, a
[[template|templates]] is filled out. This hook allows modifying that
template. The function is passed named parameters. The "page" and
"destpage" parameters are the same as for a preprocess hook. The "template"
parameter is a `HTML::Template` object that is the template that will be
used to generate the page. The function can manipulate that template
object.
[[Templates]] are filled out for many different things in ikiwiki,
like generating a page, or part of a blog page, or an rss feed, or a cgi.
This hook allows modifying those templates. The function is passed named
parameters. The "page" and "destpage" parameters are the same as for a
preprocess hook. The "template" parameter is a `HTML::Template` object that
is the template that will be used to generate the page. The function can
manipulate that template object.
The most common thing to do is probably to call $template->param() to add
a new custom parameter to the template.

View File

@ -7,6 +7,9 @@
<title><TMPL_VAR FORM-TITLE></title>
<link rel="stylesheet" href="<TMPL_VAR BASEURL>style.css" type="text/css" />
<link rel="stylesheet" href="<TMPL_VAR BASEURL>local.css" type="text/css" />
<TMPL_IF NAME="FAVICON">
<link rel="icon" href="<TMPL_VAR BASEURL><TMPL_VAR FAVICON>" type="image/png" />
</TMPL_IF>
</head>
<body>
<TMPL_IF NAME="PAGE_CONFLICT">

View File

@ -7,6 +7,9 @@
<title><TMPL_VAR TITLE></title>
<link rel="stylesheet" href="<TMPL_VAR BASEURL>style.css" type="text/css" />
<link rel="stylesheet" href="<TMPL_VAR BASEURL>local.css" type="text/css" />
<TMPL_IF NAME="FAVICON">
<link rel="icon" href="<TMPL_VAR BASEURL><TMPL_VAR FAVICON>" type="image/png" />
</TMPL_IF>
</head>
<body>

View File

@ -6,12 +6,11 @@
<title><TMPL_VAR TITLE></title>
<link rel="stylesheet" href="<TMPL_VAR BASEURL>style.css" type="text/css" />
<link rel="stylesheet" href="<TMPL_VAR BASEURL>local.css" type="text/css" />
<TMPL_IF NAME="RSSLINK">
<TMPL_VAR RSSLINK>
</TMPL_IF>
<TMPL_IF NAME="META">
<TMPL_VAR META>
<TMPL_IF NAME="FAVICON">
<link rel="icon" href="<TMPL_VAR BASEURL><TMPL_VAR FAVICON>" type="image/png" />
</TMPL_IF>
<TMPL_IF NAME="RSSLINK"><TMPL_VAR RSSLINK></TMPL_IF>
<TMPL_IF NAME="META"><TMPL_VAR META></TMPL_IF>
</head>
<body>

View File

@ -7,6 +7,9 @@
<title><TMPL_VAR TITLE></title>
<link rel="stylesheet" href="<TMPL_VAR BASEURL>style.css" type="text/css" />
<link rel="stylesheet" href="<TMPL_VAR BASEURL>local.css" type="text/css" />
<TMPL_IF NAME="FAVICON">
<link rel="icon" href="<TMPL_VAR BASEURL><TMPL_VAR FAVICON>" type="image/png" />
</TMPL_IF>
</head>
<body>