]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Setup/Standard.pm
web commit by joey
[ikiwiki.git] / IkiWiki / Setup / Standard.pm
1 #!/usr/bin/perl
2 # Standard ikiwiki setup module.
3 # Parameters to import should be all the standard ikiwiki config stuff,
4 # plus an array of wrappers to set up.
5
6 use warnings;
7 use strict;
8 use IkiWiki::Wrapper;
9 use IkiWiki::Render;
10
11 package IkiWiki::Setup::Standard;
12
13 sub import {
14         IkiWiki::setup_standard(@_);
15 }
16         
17 package IkiWiki;
18
19 sub setup_standard {
20         my %setup=%{$_[1]};
21
22         if (! $config{refresh}) {
23                 debug("generating wrappers..");
24                 my %startconfig=(%config);
25                 foreach my $wrapper (@{$setup{wrappers}}) {
26                         %config=(%startconfig, verbose => 0, %setup, %{$wrapper});
27                         checkconfig();
28                         gen_wrapper();
29                 }
30                 %config=(%startconfig);
31                 delete $config{wrappers};
32         }
33         foreach my $c (keys %setup) {
34                 if (defined $setup{$c}) {
35                         if (! ref $setup{$c}) {
36                                 $config{$c}=possibly_foolish_untaint($setup{$c});
37                         }
38                         elsif (ref $setup{$c} eq 'ARRAY') {
39                                 $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
40                         }
41                 }
42                 else {
43                         $config{$c}=undef;
44                 }
45         }
46
47         if (! $config{refresh}) {
48                 $config{rebuild}=1;
49                 debug("rebuilding wiki..");
50         }
51         else {
52                 debug("refreshing wiki..");
53         }
54
55         checkconfig();
56         lockwiki();
57         loadindex();
58         refresh();
59
60         debug("done");
61         saveindex();
62 }
63
64 1