aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-09-16 00:52:26 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-09-16 00:52:26 +0000
commit0f25ec8eb640a850a8f1efe7081c03d05d04eda4 (patch)
tree5c290f48fb651b7c8c24849208328ef634ec22e9
parent6206e9a62e06ca9bf55f6bc659e7229ba0b911d1 (diff)
downloadikiwiki-0f25ec8eb640a850a8f1efe7081c03d05d04eda4.tar
ikiwiki-0f25ec8eb640a850a8f1efe7081c03d05d04eda4.tar.gz
* 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).
-rw-r--r--IkiWiki.pm3
-rw-r--r--IkiWiki/CGI.pm20
-rw-r--r--IkiWiki/Plugin/favicon.pm24
-rw-r--r--debian/changelog5
-rw-r--r--doc/plugins/favicon.mdwn6
-rw-r--r--doc/plugins/write.mdwn14
-rw-r--r--templates/editpage.tmpl3
-rw-r--r--templates/misc.tmpl3
-rw-r--r--templates/page.tmpl9
-rw-r--r--templates/recentchanges.tmpl3
10 files changed, 73 insertions, 17 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 6484e8cb0..174d2413b 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -604,6 +604,9 @@ sub misctemplate ($$;@) { #{{{
baseurl => baseurl(),
@_,
);
+ run_hooks(pagetemplate => sub {
+ shift->(page => "", destpage => "", template => $template);
+ });
return $template->output;
}#}}}
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
diff --git a/debian/changelog b/debian/changelog
index c4c3aa10d..5ed49c8e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/plugins/favicon.mdwn b/doc/plugins/favicon.mdwn
new file mode 100644
index 000000000..f301433fa
--- /dev/null
+++ b/doc/plugins/favicon.mdwn
@@ -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.
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index a78785e02..57521687e 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -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.
diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl
index b215d9df3..0bec3d6b2 100644
--- a/templates/editpage.tmpl
+++ b/templates/editpage.tmpl
@@ -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">
diff --git a/templates/misc.tmpl b/templates/misc.tmpl
index d6be08a61..e48627393 100644
--- a/templates/misc.tmpl
+++ b/templates/misc.tmpl
@@ -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>
diff --git a/templates/page.tmpl b/templates/page.tmpl
index 15d39fbef..746fa63ef 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -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>
diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl
index 726e52f64..d9eea14e7 100644
--- a/templates/recentchanges.tmpl
+++ b/templates/recentchanges.tmpl
@@ -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>