]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/pagetemplate.pm
amazon_s3: Fix to support the EU S3 datacenter, which is more picky about attempts...
[git.ikiwiki.info.git] / IkiWiki / Plugin / pagetemplate.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::pagetemplate;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 my %templates;
10 sub import {
11         hook(type => "getsetup", id => "pagetemplate", call => \&getsetup);
12         hook(type => "preprocess", id => "pagetemplate", call => \&preprocess);
13         hook(type => "templatefile", id => "pagetemplate", call => \&templatefile);
14 }
16 sub getsetup () {
17         return 
18                 plugin => {
19                         safe => 1,
20                         rebuild => undef,
21                 },
22 }
24 sub preprocess (@) {
25         my %params=@_;
27         if (! exists $params{template} ||
28             $params{template} !~ /^[-A-Za-z0-9._+]+$/ ||
29             ! defined IkiWiki::template_file($params{template})) {
30                  error gettext("bad or missing template")
31         }
33         if ($params{page} eq $params{destpage}) {
34                 $templates{$params{page}}=$params{template};
35         }
37         return "";
38 }
40 sub templatefile (@) {
41         my %params=@_;
43         if (exists $templates{$params{page}}) {
44                 return $templates{$params{page}};
45         }
46         
47         return undef;
48 }
50 1