]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Setup/Standard.pm
web commit from 88.230.123.173: poll vote (Accept only OpenID for logins)
[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                         gen_wrapper();
40                 }
41                 %config=(%startconfig);
42         }
43         
44         foreach my $c (keys %setup) {
45                 if (defined $setup{$c}) {
46                         if (! ref $setup{$c}) {
47                                 $config{$c}=possibly_foolish_untaint($setup{$c});
48                         }
49                         elsif (ref $setup{$c} eq 'ARRAY') {
50                                 $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
51                         }
52                         elsif (ref $setup{$c} eq 'HASH') {
53                                 foreach my $key (keys %{$setup{$c}}) {
54                                         $config{$c}{$key}=possibly_foolish_untaint($setup{$c}{$key});
55                                 }
56                         }
57                 }
58                 else {
59                         $config{$c}=undef;
60                 }
61         }
62
63         if ($config{render}) {
64                 commandline_render();
65         }
66         elsif (! $config{refresh}) {
67                 $config{rebuild}=1;
68                 debug(gettext("rebuilding wiki.."));
69         }
70         else {
71                 debug(gettext("refreshing wiki.."));
72         }
73
74         loadplugins();
75         checkconfig();
76         lockwiki();
77         loadindex();
78         refresh();
79
80         debug(gettext("done"));
81         saveindex();
82 }
83
84 1