]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - ikiwiki.in
* Add a htmlext config option, this can be used to make ikiwiki generate
[git.ikiwiki.info.git] / ikiwiki.in
1 #!/usr/bin/perl -T
2 $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
3 delete @ENV{qw{IFS CDPATH ENV BASH_ENV}};
5 package IkiWiki;
7 use warnings;
8 use strict;
9 use lib '.'; # For use in nonstandard directory, munged by Makefile.
10 use IkiWiki;
12 sub usage () { #{{{
13         die gettext("usage: ikiwiki [options] source dest"), "\n";
14 } #}}}
16 sub getconfig () { #{{{
17         if (! exists $ENV{WRAPPED_OPTIONS}) {
18                 %config=defaultconfig();
19                 eval q{use Getopt::Long};
20                 Getopt::Long::Configure('pass_through');
21                 GetOptions(
22                         "setup|s=s" => \$config{setup},
23                         "wikiname=s" => \$config{wikiname},
24                         "verbose|v!" => \$config{verbose},
25                         "syslog!" => \$config{syslog},
26                         "rebuild!" => \$config{rebuild},
27                         "refresh!" => \$config{refresh},
28                         "post-commit" => \$config{post_commit},
29                         "render=s" => \$config{render},
30                         "wrappers!" => \$config{wrappers},
31                         "usedirs!" => \$config{usedirs},
32                         "getctime" => \$config{getctime},
33                         "wrappermode=i" => \$config{wrappermode},
34                         "numbacklinks=i" => \$config{numbacklinks},
35                         "rcs=s" => \$config{rcs},
36                         "no-rcs" => sub { $config{rcs}="" },
37                         "cgi!" => \$config{cgi},
38                         "discussion!" => \$config{discussion},
39                         "w3mmode!" => \$config{w3mmode},
40                         "notify!" => \$config{notify},
41                         "url=s" => \$config{url},
42                         "cgiurl=s" => \$config{cgiurl},
43                         "historyurl=s" => \$config{historyurl},
44                         "diffurl=s" => \$config{diffurl},
45                         "svnrepo" => \$config{svnrepo},
46                         "svnpath" => \$config{svnpath},
47                         "adminemail=s" => \$config{adminemail},
48                         "timeformat=s" => \$config{timeformat},
49                         "sslcookie!" => \$config{sslcookie},
50                         "httpauth!" => \$config{httpauth},
51                         "userdir=s" => \$config{userdir},
52                         "htmlext=s" => \$config{htmlext},
53                         "exclude=s@" => sub {
54                                 push @{$config{wiki_file_prune_regexps}}, $_[1];
55                         },
56                         "adminuser=s@" => sub {
57                                 push @{$config{adminuser}}, $_[1]
58                         },
59                         "templatedir=s" => sub {
60                                 $config{templatedir}=possibly_foolish_untaint($_[1])
61                         },
62                         "underlaydir=s" => sub {
63                                 $config{underlaydir}=possibly_foolish_untaint($_[1])
64                         },
65                         "wrapper:s" => sub {
66                                 $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
67                         },
68                         "plugin=s@" => sub {
69                                 push @{$config{plugin}}, $_[1];
70                         },
71                         "disable-plugin=s@" => sub {
72                                 push @{$config{disable_plugins}}, $_[1];
73                         },
74                         "pingurl=s" => sub {
75                                 push @{$config{pingurl}}, $_[1];
76                         },
77                         "version" => sub {
78                                 print "ikiwiki version $IkiWiki::version\n";
79                                 exit;
80                         },
81                 ) || usage();
83                 if (! $config{setup} && ! $config{render}) {
84                         loadplugins();
85                         usage() unless @ARGV == 2;
86                         $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
87                         $config{destdir} = possibly_foolish_untaint(shift @ARGV);
88                         checkconfig();
89                 }
90         }
91         else {
92                 # wrapper passes a full config structure in the environment
93                 # variable
94                 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
95                 if ($@) {
96                         error("WRAPPED_OPTIONS: $@");
97                 }
98                 loadplugins();
99                 checkconfig();
100         }
101 } #}}}
103 sub main () { #{{{
104         getconfig();
105         
106         if ($config{cgi}) {
107                 loadindex();
108                 require IkiWiki::CGI;
109                 cgi();
110         }
111         elsif ($config{setup}) {
112                 require IkiWiki::Setup;
113                 setup();
114         }
115         elsif ($config{wrapper}) {
116                 lockwiki();
117                 require IkiWiki::Wrapper;
118                 gen_wrapper();
119         }
120         elsif ($config{render}) {
121                 require IkiWiki::Render;
122                 commandline_render();
123         }
124         elsif ($config{post_commit} && ! commit_hook_enabled()) {
125                 if ($config{notify}) {
126                         loadindex();
127                         rcs_notify();
128                 }
129         }
130         else {
131                 lockwiki();
132                 loadindex();
133                 require IkiWiki::Render;
134                 rcs_update();
135                 refresh();
136                 rcs_notify() if $config{notify};
137                 saveindex();
138         }
139 } #}}}
141 main;