]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Setup/Standard.pm
add check marks
[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         $setup{plugin}=$config{plugin};
23         if (exists $setup{add_plugins}) {
24                 push @{$setup{plugin}}, @{$setup{add_plugins}};
25                 delete $setup{add_plugins};
26         }
27         if (exists $setup{exclude}) {
28                 push @{$config{wiki_file_prune_regexps}}, $setup{exclude};
29         }
30
31         if (! $config{render} && (! $config{refresh} || $config{wrappers})) {
32                 debug(gettext("generating wrappers.."));
33                 my @wrappers=@{$setup{wrappers}};
34                 delete $setup{wrappers};
35                 my %startconfig=(%config);
36                 foreach my $wrapper (@wrappers) {
37                         %config=(%startconfig, verbose => 0, %setup, %{$wrapper});
38                         checkconfig();
39                         if (! $config{cgi} && ! $config{post_commit}) {
40                                 $config{post_commit}=1;
41                         }
42                         gen_wrapper();
43                 }
44                 %config=(%startconfig);
45         }
46         
47         foreach my $c (keys %setup) {
48                 if (defined $setup{$c}) {
49                         if (! ref $setup{$c}) {
50                                 $config{$c}=possibly_foolish_untaint($setup{$c});
51                         }
52                         elsif (ref $setup{$c} eq 'ARRAY') {
53                                 $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
54                         }
55                         elsif (ref $setup{$c} eq 'HASH') {
56                                 foreach my $key (keys %{$setup{$c}}) {
57                                         $config{$c}{$key}=possibly_foolish_untaint($setup{$c}{$key});
58                                 }
59                         }
60                 }
61                 else {
62                         $config{$c}=undef;
63                 }
64         }
65
66         if ($config{render}) {
67                 commandline_render();
68         }
69         elsif (! $config{refresh}) {
70                 $config{rebuild}=1;
71                 debug(gettext("rebuilding wiki.."));
72         }
73         else {
74                 debug(gettext("refreshing wiki.."));
75         }
76
77         loadplugins();
78         checkconfig();
79         lockwiki();
80         loadindex();
81         refresh();
82
83         debug(gettext("done"));
84         saveindex();
85 }
86
87 1