add section information
[ikiwiki.git] / 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                         section => "special-purpose",
22                 },
23                 add_underlays => {
24                         type => "string",
25                         example => ["$ENV{HOME}/wiki.underlay"],
26                         description => "extra underlay directories to add",
27                         advanced => 1,
28                         safe => 0,
29                         rebuild => 1,
30                 },
31                 add_templates => {
32                         type => "string",
33                         example => ["$ENV{HOME}/.ikiwiki/templates"],
34                         description => "extra template directories to add",
35                         advanced => 1,
36                         safe => 0,
37                         rebuild => 1,
38                 },
39 }
40
41 sub checkconfig () {
42         if ($config{add_underlays}) {
43                 foreach my $dir (@{$config{add_underlays}}) {
44                         add_underlay($dir);
45                 }
46         }
47         if ($config{add_templates}) {
48                 push @{$config{templatedirs}}, @{$config{add_templates}};
49         }
50 }
51
52 1;