aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/underlay.pm
blob: 116fe7324e5d3b4a770acd6876067eb020cf4ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
package IkiWiki::Plugin::underlay;
# Copyright © 2008 Simon McVittie <http://smcv.pseudorandom.co.uk/>
# Licensed under the GNU GPL, version 2, or any later version published by the
# Free Software Foundation

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type => "getsetup", id => "underlay",  call => \&getsetup);
	hook(type => "checkconfig", id => "underlay", call => \&checkconfig);
}

sub getsetup () {
	return
		plugin => {
			safe => 0,
			rebuild => undef,
		},
		add_underlays => {
			type => "string",
			example => ["$ENV{HOME}/wiki.underlay"],
			description => "extra underlay directories to add",
			advanced => 1,
			safe => 0,
			rebuild => 1,
		},
		add_templates => {
			type => "string",
			example => ["$ENV{HOME}/.ikiwiki/templates"],
			description => "extra template directories to add",
			advanced => 1,
			safe => 0,
			rebuild => 1,
		},
}

sub checkconfig () {
	if ($config{add_underlays}) {
		foreach my $dir (@{$config{add_underlays}}) {
			add_underlay($dir);
		}
	}
	if ($config{add_templates}) {
		push @{$config{templatedirs}}, @{$config{add_templates}};
	}
}

1;