Add transient plugin, which adds ~/.ikiwiki/transient as an underlay
[ikiwiki.git] / IkiWiki / Plugin / transient.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::transient;
3
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
7
8 sub import {
9         hook(type => "getsetup", id => "transient",  call => \&getsetup);
10         hook(type => "checkconfig", id => "transient", call => \&checkconfig);
11 }
12
13 sub getsetup () {
14         return
15                 plugin => {
16                         # this plugin is safe but only makes sense as a
17                         # dependency; similarly, it needs a rebuild but
18                         # only if something else does
19                         safe => 0,
20                         rebuild => 0,
21                 },
22 }
23
24 our $transientdir;
25
26 sub checkconfig () {
27         eval q{use Cwd 'abs_path'};
28         error($@) if $@;
29         $transientdir = abs_path($config{wikistatedir})."/transient";
30         add_underlay($transientdir);
31 }
32
33 1;