underlay: Also allow configuring additional directories to search for template files in.
[ikiwiki] / IkiWiki / Plugin / underlay.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::underlay;
3 # Copyright © 2008 Simon McVittie <http://smcv.pseudorandom.co.uk/>
4 # Licensed under the GNU GPL, version 2, or any later version published by the
5 # Free Software Foundation
6
7 use warnings;
8 use strict;
9 use IkiWiki 3.00;
10
11 sub import {
12         hook(type => "getsetup", id => "underlay",  call => \&getsetup);
13         hook(type => "checkconfig", id => "underlay", call => \&checkconfig);
14 }
15
16 sub getsetup () {
17         return
18                 plugin => {
19                         safe => 0,
20                         rebuild => undef,
21                 },
22                 add_underlays => {
23                         type => "string",
24                         default => [],
25                         description => "extra underlay directories to add",
26                         advanced => 1,
27                         safe => 0,
28                         rebuild => 1,
29                 },
30                 add_templates => {
31                         type => "string",
32                         default => [],
33                         description => "extra template directories to add",
34                         advanced => 1,
35                         safe => 0,
36                         rebuild => 1,
37                 },
38 }
39
40 sub checkconfig () {
41         foreach my $dir (@{$config{add_underlays}}) {
42                 add_underlay($dir);
43         }
44         push @{$config{templatedirs}}, @{$config{add_templates}};
45 }
46
47 1;