]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Setup/Standard.pm
formatting
[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         }
32         foreach my $c (keys %setup) {
33                 $config{$c}=possibly_foolish_untaint($setup{$c})
34                         if defined $setup{$c} && ! ref $setup{$c};
35         }
36         if (! $config{refresh}) {
37                 $config{rebuild}=1;
38                 debug("rebuilding wiki..");
39         }
40         else {
41                 debug("refreshing wiki..");
42         }
43
44         checkconfig();
45         lockwiki();
46         loadindex();
47         refresh();
48
49         debug("done");
50         saveindex();
51 }
52
53 1