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