]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Setup/Standard.pm
add news item for ikiwiki 1.49
[git.ikiwiki.info.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.
6 use warnings;
7 use strict;
8 use IkiWiki::Wrapper;
9 use IkiWiki::Render;
11 package IkiWiki::Setup::Standard;
13 sub import {
14         IkiWiki::setup_standard(@_);
15 }
16         
17 package IkiWiki;
19 sub setup_standard {
20         my %setup=%{$_[1]};
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         }
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                 next if $c eq 'syslog';
49                 if (defined $setup{$c}) {
50                         if (! ref $setup{$c}) {
51                                 $config{$c}=possibly_foolish_untaint($setup{$c});
52                         }
53                         elsif (ref $setup{$c} eq 'ARRAY') {
54                                 $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
55                         }
56                         elsif (ref $setup{$c} eq 'HASH') {
57                                 foreach my $key (keys %{$setup{$c}}) {
58                                         $config{$c}{$key}=possibly_foolish_untaint($setup{$c}{$key});
59                                 }
60                         }
61                 }
62                 else {
63                         $config{$c}=undef;
64                 }
65         }
67         if ($config{render}) {
68                 commandline_render();
69         }
70         elsif (! $config{refresh}) {
71                 $config{rebuild}=1;
72                 debug(gettext("rebuilding wiki.."));
73         }
74         else {
75                 debug(gettext("refreshing wiki.."));
76         }
78         loadplugins();
79         checkconfig();
80         lockwiki();
81         loadindex();
82         refresh();
84         debug(gettext("done"));
85         saveindex();
86 }
88 1