]> sipb.mit.edu Git - ikiwiki.git/blob - ikiwiki
add htmlise
[ikiwiki.git] / ikiwiki
1 #!/usr/bin/perl -T
2 $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
3
4 package IkiWiki;
5 use warnings;
6 use strict;
7 use lib '.'; # For use without installation, removed by Makefile.
8 use IkiWiki;
9
10 sub usage () { #{{{
11         die "usage: ikiwiki [options] source dest\n";
12 } #}}}
13
14 sub getconfig () { #{{{
15         if (! exists $ENV{WRAPPED_OPTIONS}) {
16                 %config=defaultconfig();
17                 eval q{use Getopt::Long};
18                 GetOptions(
19                         "setup|s=s" => \$config{setup},
20                         "wikiname=s" => \$config{wikiname},
21                         "verbose|v!" => \$config{verbose},
22                         "rebuild!" => \$config{rebuild},
23                         "refresh!" => \$config{refresh},
24                         "getctime" => \$config{getctime},
25                         "wrappermode=i" => \$config{wrappermode},
26                         "rcs=s" => \$config{rcs},
27                         "no-rcs" => sub { $config{rcs}="" },
28                         "anonok!" => \$config{anonok},
29                         "rss!" => \$config{rss},
30                         "cgi!" => \$config{cgi},
31                         "discussion!" => \$config{discussion},
32                         "notify!" => \$config{notify},
33                         "url=s" => \$config{url},
34                         "cgiurl=s" => \$config{cgiurl},
35                         "historyurl=s" => \$config{historyurl},
36                         "diffurl=s" => \$config{diffurl},
37                         "svnrepo" => \$config{svnrepo},
38                         "svnpath" => \$config{svnpath},
39                         "adminemail=s" => \$config{adminemail},
40                         "timeformat=s" => \$config{timeformat},
41                         "exclude=s@" => sub {
42                                 $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
43                         },
44                         "adminuser=s@" => sub {
45                                 push @{$config{adminuser}}, $_[1]
46                         },
47                         "templatedir=s" => sub {
48                                 $config{templatedir}=possibly_foolish_untaint($_[1])
49                         },
50                         "underlaydir=s" => sub {
51                                 $config{underlaydir}=possibly_foolish_untaint($_[1])
52                         },
53                         "wrapper:s" => sub {
54                                 $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
55                         },
56                         "plugin=s@" => sub {
57                                 push @{$config{plugin}}, $_[1];
58                         },
59                         "disable-plugin=s@" => sub {
60                                 $config{plugin}=[grep { $_ ne $_[1] } @{$config{plugin}}];
61                         },
62                         "pingurl" => sub {
63                                 push @{$config{pingurl}}, $_[1];
64                         }
65                 ) || usage();
66
67                 if (! $config{setup}) {
68                         usage() unless @ARGV == 2;
69                         $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
70                         $config{destdir} = possibly_foolish_untaint(shift @ARGV);
71                         checkconfig();
72                 }
73         }
74         else {
75                 # wrapper passes a full config structure in the environment
76                 # variable
77                 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
78                 if ($@) {
79                         error("WRAPPED_OPTIONS: $@");
80                 }
81                 checkconfig();
82         }
83 } #}}}
84
85 sub main () { #{{{
86         getconfig();
87         
88         if ($config{cgi}) {
89                 lockwiki();
90                 loadindex();
91                 require IkiWiki::CGI;
92                 cgi();
93         }
94         elsif ($config{setup}) {
95                 require IkiWiki::Setup;
96                 setup();
97         }
98         elsif ($config{wrapper}) {
99                 lockwiki();
100                 require IkiWiki::Wrapper;
101                 gen_wrapper();
102         }
103         else {
104                 lockwiki();
105                 loadindex();
106                 require IkiWiki::Render;
107                 rcs_update();
108                 refresh();
109                 rcs_notify() if $config{notify};
110                 saveindex();
111         }
112 } #}}}
113
114 main;