Package: ikiwiki Version: 2.15 Severity: wishlist Tags: patch Hi,
I would like to be able to change the page template in a subdirectory of my wiki. The natural ikiwiki-ish way to do this would seem to be to have a SubPage named "page.tmpl" that's used instead of the default page.tmpl. An example use case is that I want to put a special footer on blog posts, but not on the whole wiki. I've got a hacky fix for my needs in the attached plugin, which will search for page.tmpl using SubPage rules and make it the default page template if possible. To use it, set the templatedir to the same value as srcdir so ikiwiki can pick up templates from its input directory. Daniel -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages ikiwiki depends on: ii gcc [c-compiler] 4:4.2.1-6 The GNU C compiler ii gcc-4.1 [c-compiler] 4.1.2-18 The GNU C compiler ii gcc-4.2 [c-compiler] 4.2.2-4 The GNU C compiler ii gcc-4.3 [c-compiler] 4.3-20071130-1 The GNU C compiler ii libc6-dev [libc-dev] 2.7-4 GNU C Library: Development Librari ii libcgi-formbuilder-perl 3.05.01-1 Easily generate and process statef ii libcgi-session-perl 4.20-2 Persistent session data in CGI app ii libhtml-parser-perl 3.56-1 A collection of modules that parse ii libhtml-scrubber-perl 0.08-4 Perl extension for scrubbing/sanit ii libhtml-template-perl 2.9-1 HTML::Template : A module for usin ii libmail-sendmail-perl 0.79-4 Send email from a perl script ii libtime-duration-perl 1.02-1 Time::Duration -- rounded or exact ii libtimedate-perl 1.1600-9 Time and date functions for Perl ii liburi-perl 1.35.dfsg.1-1 Manipulates and accesses URI strin ii libxml-simple-perl 2.18-1 Perl module for reading and writin ii markdown 1.0.1-7 Text-to-HTML conversion tool ii perl 5.8.8-12 Larry Wall's Practical Extraction Versions of packages ikiwiki recommends: ii git-core 1:1.5.3.7-1 fast, scalable, distributed revisi ii hyperestraier 1.4.9-1.1+b1 a full-text search system for comm ii liblwpx-paranoidagent-perl 1.03-1 a "paranoid" subclass of LWP::User ii libnet-openid-consumer-perl 0.13-1 library for consumers of OpenID id ii mercurial 0.9.5-2 Scalable distributed version contr ii subversion 1.4.4dfsg1-1 Advanced version control system -- no debconf information
#!/usr/bin/perl # Ikiwiki skeleton plugin. Replace "skeleton" with the name of your plugin # in the lines below, remove hooks you don't use, and flesh out the code to # make it do something. package IkiWiki::Plugin::extrapagetemplate; use warnings; use strict; use IkiWiki 2.00; sub import { #{{{ hook(type => "templatefile", id => "skeleton", call => \&templatefile); } # }}} sub templatefile (@) { #{{{ my [EMAIL PROTECTED]; my $page=$params{page}; my $templatepage=bestlink($page, "page.tmpl"); if(!$templatepage) { debug("extrapagetemplate: no page.tmpl for $page"); return; }; my $templatefile = $pagesources{$templatepage}; if(!$templatefile) { debug("extrapagetemplate: no file found for $templatepage"); return; }; debug("extrapagetemplate: using template $templatefile"); return $templatefile } # }}} 1