]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Setup/Standard.pm
utf-8 support seems to be working now
[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 @wrappers=@{$setup{wrappers}};
25                 delete $setup{wrappers};
26                 my %startconfig=(%config);
27                 foreach my $wrapper (@wrappers) {
28                         %config=(%startconfig, verbose => 0, %setup, %{$wrapper});
29                         checkconfig();
30                         gen_wrapper();
31                 }
32                 %config=(%startconfig);
33         }
34         else {
35                 delete $setup{wrappers};
36         }
37         
38         foreach my $c (keys %setup) {
39                 if (defined $setup{$c}) {
40                         if (! ref $setup{$c}) {
41                                 $config{$c}=possibly_foolish_untaint($setup{$c});
42                         }
43                         elsif (ref $setup{$c} eq 'ARRAY') {
44                                 $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
45                         }
46                 }
47                 else {
48                         $config{$c}=undef;
49                 }
50         }
51
52         if (! $config{refresh}) {
53                 $config{rebuild}=1;
54                 debug("rebuilding wiki..");
55         }
56         else {
57                 debug("refreshing wiki..");
58         }
59
60         checkconfig();
61         lockwiki();
62         loadindex();
63         refresh();
64
65         debug("done");
66         saveindex();
67 }
68
69 1