]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* pagetemplate hooks are now also called when generating cgi pages.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 16 Sep 2006 00:52:26 +0000 (00:52 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 16 Sep 2006 00:52:26 +0000 (00:52 +0000)
* Add a favicon plugin, which simply adds a link tag for an icon to each
  page (and cgis).

IkiWiki.pm
IkiWiki/CGI.pm
IkiWiki/Plugin/favicon.pm [new file with mode: 0644]
debian/changelog
doc/plugins/favicon.mdwn [new file with mode: 0644]
doc/plugins/write.mdwn
templates/editpage.tmpl
templates/misc.tmpl
templates/page.tmpl
templates/recentchanges.tmpl

index 6484e8cb0370782bed6182665566779c0215a4cf..174d2413bb93e6fc8b203def020f35f59dd61cb2 100644 (file)
@@ -604,6 +604,9 @@ sub misctemplate ($$;@) { #{{{
                baseurl => baseurl(),
                @_,
        );
                baseurl => baseurl(),
                @_,
        );
+       run_hooks(pagetemplate => sub {
+               shift->(page => "", destpage => "", template => $template);
+       });
        return $template->output;
 }#}}}
 
        return $template->output;
 }#}}}
 
index 01c5812ef03dd134c8078d40b25d7b6c1d066395..f07a4e5a2c7941561d3d1416b13de3cf47d30feb 100644 (file)
@@ -99,6 +99,9 @@ sub cgi_recentchanges ($) { #{{{
                changelog => $changelog,
                baseurl => baseurl(),
        );
                changelog => $changelog,
                baseurl => baseurl(),
        );
+       run_hooks(pagetemplate => sub {
+               shift->(page => "", destpage => "", template => $template);
+       });
        print $q->header(-charset => 'utf-8'), $template->output;
 } #}}}
 
        print $q->header(-charset => 'utf-8'), $template->output;
 } #}}}
 
@@ -349,9 +352,19 @@ sub cgi_editpage ($$) { #{{{
        my $q=shift;
        my $session=shift;
 
        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(
        my $form = CGI::FormBuilder->new(
-               fields => [qw(do rcsinfo subpage from page type editcontent comments)],
+               fields => \@fields,
                header => 1,
                charset => "utf-8",
                method => 'POST',
                header => 1,
                charset => "utf-8",
                method => 'POST',
@@ -363,9 +376,8 @@ sub cgi_editpage ($$) { #{{{
                params => $q,
                action => $config{cgiurl},
                table => 0,
                params => $q,
                action => $config{cgiurl},
                table => 0,
-               template => {template_params("editpage.tmpl")},
+               template => $renderer,
        );
        );
-       my @buttons=("Save Page", "Preview", "Cancel");
        
        decode_form_utf8($form);
        
        
        decode_form_utf8($form);
        
diff --git a/IkiWiki/Plugin/favicon.pm b/IkiWiki/Plugin/favicon.pm
new file mode 100644 (file)
index 0000000..518d2c2
--- /dev/null
@@ -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
index c4c3aa10de5c351b923359e23ff1a833f3594d4d..5ed49c8e7a752265d5dfecd330cfe23f50b92c91 100644 (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.
   * 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
 
 
 ikiwiki (1.26) unstable; urgency=low
 
diff --git a/doc/plugins/favicon.mdwn b/doc/plugins/favicon.mdwn
new file mode 100644 (file)
index 0000000..f301433
--- /dev/null
@@ -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.
index a78785e0286b900afbf97bc1a583d7789c1bc96a..57521687e10a7534e55df59be277a9e000a9dfff 100644 (file)
@@ -105,13 +105,13 @@ return the htmlized content.
 
        hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
 
 
        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.
 
 The most common thing to do is probably to call $template->param() to add
 a new custom parameter to the template.
index b215d9df32d44cd08e8b3ebc738419f89ffa26f4..0bec3d6b2653e172364bb122113ece3608753900 100644 (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" />
 <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">
 </head>
 <body>
 <TMPL_IF NAME="PAGE_CONFLICT">
index d6be08a6189404df7aad4662ea7dabfdfd8eba9d..e48627393cda72c8c5c590c2fc41c49d09e87b81 100644 (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" />
 <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>
 
 </head>
 <body>
 
index 15d39fbef21228a46a1a3ad60ad194eb45571cc9..746fa63ef2d182fa5354c77c2812b4c403c5cb12 100644 (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" />
 <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>
+<TMPL_IF NAME="RSSLINK"><TMPL_VAR RSSLINK></TMPL_IF>
+<TMPL_IF NAME="META"><TMPL_VAR META></TMPL_IF>
 </head>
 <body>
 
 </head>
 <body>
 
index 726e52f6492051e6c7092fa8942c25982c2fd540..d9eea14e789a4f29901b403dcc5edeb274dab349 100644 (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" />
 <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>
 
 </head>
 <body>