11 $blosxom::version="is a proper perl module too much to ask?";
12 do "/usr/bin/markdown";
15 $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
16 my ($srcdir, $templatedir, $destdir, %links, %oldlinks, %oldpagemtime,
17 %renderedfiles, %pagesources);
18 my $wiki_link_regexp=qr/\[\[([^\s]+)\]\]/;
19 my $wiki_file_regexp=qr/(^[-A-Za-z0-9_.:\/+]+$)/;
20 my $wiki_file_prune_regexp=qr!((^|/).svn/|\.\.|^\.|\/\.|\.html?$)!;
23 my $default_pagetype=".mdwn";
33 die "usage: ikiwiki [options] source templates dest\n";
38 print "Content-type: text/html\n\n";
39 print misctemplate("Error", "<p>Error: @_</p>");
49 print "@_\n" if $verbose;
52 print STDERR "@_\n" if $verbose;
59 return (stat($page))[9];
62 sub possibly_foolish_untaint ($) { #{{{
64 my ($untainted)=$tainted=~/(.*)/;
68 sub basename ($) { #{{{
75 sub dirname ($) { #{{{
82 sub pagetype ($) { #{{{
85 if ($page =~ /\.mdwn$/) {
93 sub pagename ($) { #{{{
96 my $type=pagetype($file);
98 $page=~s/\Q$type\E*$// unless $type eq 'unknown';
102 sub htmlpage ($) { #{{{
105 return $page.".html";
108 sub readfile ($) { #{{{
112 open (IN, "$file") || error("failed to read $file: $!");
118 sub writefile ($$) { #{{{
122 my $dir=dirname($file);
125 foreach my $s (split(m!/+!, $dir)) {
128 mkdir($d) || error("failed to create directory $d: $!");
133 open (OUT, ">$file") || error("failed to write $file: $!");
138 sub findlinks ($) { #{{{
142 while ($content =~ /$wiki_link_regexp/g) {
148 # Given a page and the text of a link on the page, determine which existing
149 # page that link best points to. Prefers pages under a subdirectory with
150 # the same name as the source page, failing that goes down the directory tree
151 # to the base looking for matching pages.
152 sub bestlink ($$) { #{{{
159 $l.="/" if length $l;
162 if (exists $links{$l}) {
163 #debug("for $page, \"$link\", use $l");
166 } while $cwd=~s!/?[^/]+$!!;
168 #print STDERR "warning: page $page, broken link: $link\n";
172 sub isinlinableimage ($) { #{{{
175 $file=~/\.(png|gif|jpg|jpeg)$/;
181 my $noimageinline=shift; # don't turn links into inline html images
182 my $createsubpage=shift; # force creation of a subpage if page DNE
184 my $bestlink=bestlink($page, $link);
186 return $link if length $bestlink && $page eq $bestlink;
188 # TODO BUG: %renderedfiles may not have it, if the linked to page
189 # was also added and isn't yet rendered! Note that this bug is
190 # masked by the bug mentioned below that makes all new files
192 if (! grep { $_ eq $bestlink } values %renderedfiles) {
193 $bestlink=htmlpage($bestlink);
195 if (! grep { $_ eq $bestlink } values %renderedfiles) {
196 if (! $createsubpage) {
197 return "<a href=\"$cgiurl?do=create&page=$link&from=$page\">?</a>$link"
200 return "<a href=\"$cgiurl?do=create&page=$page/$link\">?</a>$link"
204 $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
206 if (! $noimageinline && isinlinableimage($bestlink)) {
207 return "<img src=\"$bestlink\">";
209 return "<a href=\"$bestlink\">$link</a>";
212 sub linkify ($$) { #{{{
216 $content =~ s/$wiki_link_regexp/htmllink(pagename($file), $1)/eg;
221 sub htmlize ($$) { #{{{
225 if ($type eq '.mdwn') {
226 return Markdown::Markdown($content);
229 error("htmlization of $type not supported");
233 sub backlinks ($) { #{{{
237 foreach my $p (keys %links) {
238 next if bestlink($page, $p) eq $page;
239 if (grep { length $_ && bestlink($p, $_) eq $page } @{$links{$p}}) {
240 my $href=File::Spec->abs2rel(htmlpage($p), dirname($page));
242 # Trim common dir prefixes from both pages.
244 my $page_trimmed=$page;
246 1 while (($dir)=$page_trimmed=~m!^([^/]+/)!) &&
248 $p_trimmed=~s/^\Q$dir\E// &&
249 $page_trimmed=~s/^\Q$dir\E//;
251 push @links, { url => $href, page => $p_trimmed };
255 return sort { $a->{page} cmp $b->{page} } @links;
258 sub parentlinks ($) { #{{{
265 foreach my $dir (reverse split("/", $page)) {
267 unshift @ret, { url => "$path$dir.html", page => $dir };
274 unshift @ret, { url => $path , page => $wikiname };
278 sub indexlink () { #{{{
279 return "<a href=\"$url\">$wikiname</a>";
282 sub finalize ($$) { #{{{
286 my $title=basename($page);
289 my $template=HTML::Template->new(blind_cache => 1,
290 filename => "$templatedir/page.tmpl");
292 if (length $cgiurl) {
293 $template->param(editurl => "$cgiurl?do=edit&page=$page");
295 $template->param(recentchangesurl => "$cgiurl?do=recentchanges");
299 if (length $historyurl) {
301 $u=~s/\[\[\]\]/$pagesources{$page}/g;
302 $template->param(historyurl => $u);
307 wikiname => $wikiname,
308 parentlinks => [parentlinks($page)],
310 backlinks => [backlinks($page)],
311 discussionlink => htmllink($page, "Discussion", 1, 1),
314 return $template->output;
317 # Important security check. Make sure to call this before saving any files
318 # to the source directory.
319 sub check_overwrite ($$) { #{{{
323 if (! exists $renderedfiles{$src} && -e $dest && ! $rebuild) {
324 error("$dest exists and was rendered from ".
325 join(" ",(grep { $renderedfiles{$_} eq $dest } keys
327 ", not from $src before not overwriting");
331 sub render ($) { #{{{
334 my $type=pagetype($file);
335 my $content=readfile("$srcdir/$file");
336 if ($type ne 'unknown') {
337 my $page=pagename($file);
339 $links{$page}=[findlinks($content)];
341 $content=linkify($content, $file);
342 $content=htmlize($type, $content);
343 $content=finalize($content, $page);
345 check_overwrite("$destdir/".htmlpage($page), $page);
346 writefile("$destdir/".htmlpage($page), $content);
347 $oldpagemtime{$page}=time;
348 $renderedfiles{$page}=htmlpage($page);
352 check_overwrite("$destdir/$file", $file);
353 writefile("$destdir/$file", $content);
354 $oldpagemtime{$file}=time;
355 $renderedfiles{$file}=$file;
359 sub loadindex () { #{{{
360 open (IN, "$srcdir/.ikiwiki/index") || return;
362 $_=possibly_foolish_untaint($_);
364 my ($mtime, $file, $rendered, @links)=split(' ', $_);
365 my $page=pagename($file);
366 $pagesources{$page}=$file;
367 $oldpagemtime{$page}=$mtime;
368 $oldlinks{$page}=[@links];
369 $links{$page}=[@links];
370 $renderedfiles{$page}=$rendered;
375 sub saveindex () { #{{{
376 if (! -d "$srcdir/.ikiwiki") {
377 mkdir("$srcdir/.ikiwiki");
379 open (OUT, ">$srcdir/.ikiwiki/index") || error("cannot write to index: $!");
380 foreach my $page (keys %oldpagemtime) {
381 print OUT "$oldpagemtime{$page} $pagesources{$page} $renderedfiles{$page} ".
382 join(" ", @{$links{$page}})."\n"
383 if $oldpagemtime{$page};
388 sub rcs_update () { #{{{
389 if (-d "$srcdir/.svn") {
390 if (system("svn", "update", "--quiet", $srcdir) != 0) {
391 warn("svn update failed\n");
396 sub rcs_commit ($) { #{{{
399 if (-d "$srcdir/.svn") {
400 if (system("svn", "commit", "--quiet", "-m",
401 possibly_foolish_untaint($message), $srcdir) != 0) {
402 warn("svn commit failed\n");
407 sub rcs_add ($) { #{{{
410 if (-d "$srcdir/.svn") {
411 my $parent=dirname($file);
412 while (! -d "$srcdir/$parent/.svn") {
414 $parent=dirname($file);
417 if (system("svn", "add", "--quiet", "$srcdir/$file") != 0) {
418 warn("svn add failed\n");
423 sub rcs_recentchanges ($) { #{{{
427 eval q{use Date::Parse};
428 eval q{use Time::Duration};
430 if (-d "$srcdir/.svn") {
431 my $info=`LANG=C svn info $srcdir`;
432 my ($svn_url)=$info=~/^URL: (.*)$/m;
434 # FIXME: currently assumes that the wiki is somewhere
435 # under trunk in svn, doesn't support other layouts.
436 my ($svn_base)=$svn_url=~m!(/trunk(?:/.*)?)$!;
438 my $div=qr/^--------------------+$/;
439 my $infoline=qr/^r(\d+)\s+\|\s+([^\s]+)\s+\|\s+(\d+-\d+-\d+\s+\d+:\d+:\d+\s+[-+]?\d+).*/;
441 my ($rev, $user, $when, @pages, @message);
442 foreach (`LANG=C svn log -v '$svn_url'`) {
444 if ($state eq 'start' && /$div/) {
447 elsif ($state eq 'header' && /$infoline/) {
450 $when=concise(ago(time - str2time($3)));
452 elsif ($state eq 'header' && /^\s+[A-Z]\s+\Q$svn_base\E\/(.+)$/) {
453 push @pages, { link => htmllink("", pagename($1), 1) }
456 elsif ($state eq 'header' && /^$/) {
459 elsif ($state eq 'body' && /$div/) {
460 my $committype="web";
461 if (defined $message[0] &&
462 $message[0]->{line}=~/^web commit by (\w+):?(.*)/) {
464 $message[0]->{line}=$2;
470 push @ret, { rev => $rev,
471 user => htmllink("", $user, 1),
472 committype => $committype,
473 when => $when, message => [@message],
474 pages => [@pages] } if @pages;
475 return @ret if @ret >= $num;
478 $rev=$user=$when=undef;
481 elsif ($state eq 'body') {
482 push @message, {line => $_},
494 my $dir=dirname($file);
495 while (rmdir($dir)) {
500 sub refresh () { #{{{
501 # Find existing pages.
507 if (/$wiki_file_prune_regexp/) {
508 $File::Find::prune=1;
511 my ($f)=/$wiki_file_regexp/; # untaint
513 warn("skipping bad filename $_\n");
516 $f=~s/^\Q$srcdir\E\/?//;
518 $exists{pagename($f)}=1;
526 # check for added or removed pages
528 foreach my $file (@files) {
529 my $page=pagename($file);
530 if (! $oldpagemtime{$page}) {
531 debug("new page $page");
534 $pagesources{$page}=$file;
538 foreach my $page (keys %oldpagemtime) {
539 if (! $exists{$page}) {
540 debug("removing old page $page");
541 push @del, $renderedfiles{$page};
542 prune($destdir."/".$renderedfiles{$page});
543 delete $renderedfiles{$page};
544 $oldpagemtime{$page}=0;
545 delete $pagesources{$page};
549 # render any updated files
550 foreach my $file (@files) {
551 my $page=pagename($file);
553 if (! exists $oldpagemtime{$page} ||
554 mtime("$srcdir/$file") > $oldpagemtime{$page}) {
555 debug("rendering changed file $file");
561 # if any files were added or removed, check to see if each page
562 # needs an update due to linking to them
563 # TODO: inefficient; pages may get rendered above and again here;
564 # problem is the bestlink may have changed and we won't know until
567 FILE: foreach my $file (@files) {
568 my $page=pagename($file);
569 foreach my $f (@add, @del) {
571 foreach my $link (@{$links{$page}}) {
572 if (bestlink($page, $link) eq $p) {
573 debug("rendering $file, which links to $p");
583 # handle backlinks; if a page has added/removed links, update the
585 # TODO: inefficient; pages may get rendered above and again here;
586 # problem is the backlinks could be wrong in the first pass render
590 foreach my $file (keys %rendered, @del) {
591 my $page=pagename($file);
592 if (exists $links{$page}) {
593 foreach my $link (@{$links{$page}}) {
594 $link=bestlink($page, $link);
596 ! exists $oldlinks{$page} ||
597 ! grep { $_ eq $link } @{$oldlinks{$page}}) {
598 $linkchanged{$link}=1;
602 if (exists $oldlinks{$page}) {
603 foreach my $link (@{$oldlinks{$page}}) {
604 $link=bestlink($page, $link);
606 ! exists $links{$page} ||
607 ! grep { $_ eq $link } @{$links{$page}}) {
608 $linkchanged{$link}=1;
613 foreach my $link (keys %linkchanged) {
614 my $linkfile=$pagesources{$link};
615 if (defined $linkfile) {
616 debug("rendering $linkfile, to update its backlinks");
623 # Generates a C wrapper program for running ikiwiki in a specific way.
624 # The wrapper may be safely made suid.
625 sub gen_wrapper ($$) { #{{{
626 my ($svn, $rebuild)=@_;
628 eval q{use Cwd 'abs_path'};
629 $srcdir=abs_path($srcdir);
630 $destdir=abs_path($destdir);
631 my $this=abs_path($0);
633 error("$this doesn't seem to be executable");
636 my @params=($srcdir, $templatedir, $destdir, "--wikiname=$wikiname");
637 push @params, "--verbose" if $verbose;
638 push @params, "--rebuild" if $rebuild;
639 push @params, "--nosvn" if !$svn;
640 push @params, "--cgi" if $cgi;
641 push @params, "--url=$url" if $url;
642 push @params, "--cgiurl=$cgiurl" if $cgiurl;
643 push @params, "--historyurl=$historyurl" if $historyurl;
644 push @params, "--anonok" if $anonok;
645 my $params=join(" ", @params);
647 foreach my $p ($this, $this, @params) {
653 push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
654 CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE
655 HTTP_COOKIE} if $cgi;
657 foreach my $var (@envsave) {
659 if ((s=getenv("$var")))
660 asprintf(&newenviron[i++], "%s=%s", "$var", s);
664 open(OUT, ">ikiwiki-wrap.c") || error("failed to write ikiwiki-wrap.c: $!");;
666 /* A wrapper for ikiwiki, can be safely made suid. */
673 extern char **environ;
675 int main (int argc, char **argv) {
676 /* Sanitize environment. */
678 char *newenviron[$#envsave+3];
681 newenviron[i++]="HOME=$ENV{HOME}";
685 if (argc == 2 && strcmp(argv[1], "--params") == 0) {
686 printf("$params\\n");
691 perror("failed to run $this");
696 if (system("gcc", "ikiwiki-wrap.c", "-o", "ikiwiki-wrap") != 0) {
697 error("failed to compile ikiwiki-wrap.c");
699 unlink("ikiwiki-wrap.c");
700 print "successfully generated ikiwiki-wrap\n";
704 sub misctemplate ($$) { #{{{
708 my $template=HTML::Template->new(
709 filename => "$templatedir/misc.tmpl"
713 indexlink => indexlink(),
714 wikiname => $wikiname,
715 pagebody => $pagebody,
717 return $template->output;
720 sub cgi_recentchanges ($) { #{{{
723 my $template=HTML::Template->new(
724 filename => "$templatedir/recentchanges.tmpl"
727 title => "RecentChanges",
728 indexlink => indexlink(),
729 wikiname => $wikiname,
730 changelog => [rcs_recentchanges(100)],
732 print $q->header, $template->output;
735 sub userinfo_get ($$) { #{{{
739 eval q{use Storable};
740 my $userdata=eval{ Storable::lock_retrieve("$srcdir/.ikiwiki/userdb") };
741 if (! defined $userdata || ! ref $userdata ||
742 ! exists $userdata->{$user} || ! ref $userdata->{$user}) {
745 return $userdata->{$user}->{$field};
748 sub userinfo_set ($$) { #{{{
752 eval q{use Storable};
753 my $userdata=eval{ Storable::lock_retrieve("$srcdir/.ikiwiki/userdb") };
754 if (! defined $userdata || ! ref $userdata) {
757 $userdata->{$user}=$info;
758 my $oldmask=umask(077);
759 my $ret=Storable::lock_store($userdata, "$srcdir/.ikiwiki/userdb");
764 sub cgi_signin ($$) { #{{{
768 eval q{use CGI::FormBuilder};
769 my $form = CGI::FormBuilder->new(
770 title => "$wikiname signin",
771 fields => [qw(do page from name password confirm_password email)],
775 confirm_password => {
776 perl => q{eq $form->field("password")},
783 action => $q->request_uri,
785 template => (-e "$templatedir/signin.tmpl" ? "$templatedir/signin.tmpl" : "")
788 $form->field(name => "name", required => 0);
789 $form->field(name => "do", type => "hidden");
790 $form->field(name => "page", type => "hidden");
791 $form->field(name => "from", type => "hidden");
792 $form->field(name => "password", type => "password", required => 0);
793 $form->field(name => "confirm_password", type => "password", required => 0);
794 $form->field(name => "email", required => 0);
795 if ($q->param("do") ne "signin") {
796 $form->text("You need to log in before you can edit pages.");
799 if ($form->submitted) {
800 # Set required fields based on how form was submitted.
802 "Login" => [qw(name password)],
803 "Register" => [qw(name password confirm_password email)],
804 "Mail Password" => [qw(name)],
806 foreach my $opt (@{$required{$form->submitted}}) {
807 $form->field(name => $opt, required => 1);
810 # Validate password differently depending on how
811 # form was submitted.
812 if ($form->submitted eq 'Login') {
816 length $form->field("name") &&
817 shift eq userinfo_get($form->field("name"), 'password');
820 $form->field(name => "name", validate => '/^\w+$/');
823 $form->field(name => "password", validate => 'VALUE');
825 # And make sure the entered name exists when logging
826 # in or sending email, and does not when registering.
827 if ($form->submitted eq 'Register') {
833 ! userinfo_get($name, "regdate");
843 userinfo_get($name, "regdate");
849 # First time settings.
850 $form->field(name => "name", comment => "use FirstnameLastName");
851 $form->field(name => "confirm_password", comment => "(only needed");
852 $form->field(name => "email", comment => "for registration)");
853 if ($session->param("name")) {
854 $form->field(name => "name", value => $session->param("name"));
858 if ($form->submitted && $form->validate) {
859 if ($form->submitted eq 'Login') {
860 $session->param("name", $form->field("name"));
861 if (defined $form->field("do") &&
862 $form->field("do") ne 'signin') {
864 "$cgiurl?do=".$form->field("do").
865 "&page=".$form->field("page").
866 "&from=".$form->field("from"));;
869 print $q->redirect($url);
872 elsif ($form->submitted eq 'Register') {
873 my $user_name=$form->field('name');
874 if (userinfo_set($user_name, {
875 'email' => $form->field('email'),
876 'password' => $form->field('password'),
879 $form->field(name => "confirm_password", type => "hidden");
880 $form->field(name => "email", type => "hidden");
881 $form->text("Registration successful. Now you can Login.");
882 print $session->header();
883 print misctemplate($form->title, $form->render(submit => ["Login"]));
886 error("Error saving registration.");
889 elsif ($form->submitted eq 'Mail Password') {
890 my $user_name=$form->field("name");
891 my $template=HTML::Template->new(
892 filename => "$templatedir/passwordmail.tmpl"
895 user_name => $user_name,
896 user_password => userinfo_get($user_name, "password"),
898 wikiname => $wikiname,
899 REMOTE_ADDR => $ENV{REMOTE_ADDR},
902 eval q{use Mail::Sendmail};
903 my ($fromhost) = $cgiurl =~ m!/([^/]+)!;
904 print STDERR "$< $> >>> $cgiurl ".(getpwuid($>))[0]."@".$fromhost."\n";
906 To => userinfo_get($user_name, "email"),
907 From => "$wikiname admin <".(getpwuid($>))[0]."@".$fromhost.">",
908 Subject => "$wikiname information",
909 Message => $template->output,
910 ) or error("Failed to send mail");
912 $form->text("Your password has been emailed to you.");
913 $form->field(name => "name", required => 0);
914 print $session->header();
915 print misctemplate($form->title, $form->render(submit => ["Login", "Register", "Mail Password"]));
919 print $session->header();
920 print misctemplate($form->title, $form->render(submit => ["Login", "Register", "Mail Password"]));
924 sub cgi_editpage ($$) { #{{{
928 eval q{use CGI::FormBuilder};
929 my $form = CGI::FormBuilder->new(
930 fields => [qw(do from page content comments)],
936 required => [qw{content}],
939 action => $q->request_uri,
941 template => "$templatedir/editpage.tmpl"
944 my ($page)=$form->param('page')=~/$wiki_file_regexp/;
945 if (! defined $page || ! length $page || $page ne $q->param('page') ||
946 $page=~/$wiki_file_prune_regexp/ || $page=~/^\//) {
947 error("bad page name");
951 $form->field(name => "do", type => 'hidden');
952 $form->field(name => "from", type => 'hidden');
953 $form->field(name => "page", value => "$page", force => 1);
954 $form->field(name => "comments", type => "text", size => 80);
955 $form->field(name => "content", type => "textarea", rows => 20,
958 if ($form->submitted eq "Cancel") {
959 print $q->redirect("$url/".htmlpage($page));
962 if (! $form->submitted || ! $form->validate) {
963 if ($form->field("do") eq "create") {
964 if (exists $pagesources{lc($page)}) {
965 # hmm, someone else made the page in the
967 print $q->redirect("$url/".htmlpage($page));
972 my ($from)=$form->param('from')=~/$wiki_file_regexp/;
973 if (! defined $from || ! length $from ||
974 $from ne $form->param('from') ||
975 $from=~/$wiki_file_prune_regexp/ || $from=~/^\//) {
981 push @page_locs, $dir.$page;
982 push @page_locs, "$from/$page";
983 while (length $dir) {
985 push @page_locs, $dir.$page;
989 $form->tmpl_param("page_select", 1);
990 $form->field(name => "page", type => 'select',
991 options => \@page_locs);
992 $form->title("creating $page");
994 elsif ($form->field("do") eq "edit") {
996 if (exists $pagesources{lc($page)}) {
997 $content=readfile("$srcdir/$pagesources{lc($page)}");
998 $content=~s/\n/\r\n/g;
1000 $form->tmpl_param("page_select", 0);
1001 $form->field(name => "content", value => $content,
1003 $form->field(name => "page", type => 'hidden');
1004 $form->title("editing $page");
1007 $form->tmpl_param("can_commit", $svn);
1008 $form->tmpl_param("indexlink", indexlink());
1009 print $form->render(submit => ["Save Page", "Cancel"]);
1013 my $file=$page.$default_pagetype;
1015 if (exists $pagesources{lc($page)}) {
1016 $file=$pagesources{lc($page)};
1020 my $content=$form->field('content');
1021 $content=~s/\r\n/\n/g;
1022 $content=~s/\r/\n/g;
1023 writefile("$srcdir/$file", $content);
1025 my $message="web commit ";
1026 if ($session->param("name")) {
1027 $message.="by ".$session->param("name");
1030 $message.="from $ENV{REMOTE_ADDR}";
1032 if (defined $form->field('comments') &&
1033 length $form->field('comments')) {
1034 $message.=": ".$form->field('comments');
1041 # presumably the commit will trigger an update
1043 rcs_commit($message);
1049 # The trailing question mark tries to avoid broken
1050 # caches and get the most recent version of the page.
1051 print $q->redirect("$url/".htmlpage($page)."?updated");
1057 eval q{use CGI::Session};
1061 my $do=$q->param('do');
1062 if (! defined $do || ! length $do) {
1063 error("\"do\" parameter missing");
1066 # This does not need a session.
1067 if ($do eq 'recentchanges') {
1068 cgi_recentchanges($q);
1072 CGI::Session->name("ikiwiki_session");
1074 my $oldmask=umask(077);
1075 my $session = CGI::Session->new("driver:db_file", $q,
1076 { FileName => "$srcdir/.ikiwiki/sessions.db" });
1079 # Everything below this point needs the user to be signed in.
1080 if ((! $anonok && ! defined $session->param("name") ||
1081 ! userinfo_get($session->param("name"), "regdate")) || $do eq 'signin') {
1082 cgi_signin($q, $session);
1084 # Force session flush with safe umask.
1085 my $oldmask=umask(077);
1092 if ($do eq 'create' || $do eq 'edit') {
1093 cgi_editpage($q, $session);
1096 error("unknown do parameter");
1102 if (grep /^-/, @ARGV) {
1103 eval {use Getopt::Long};
1105 "wikiname=s" => \$wikiname,
1106 "verbose|v" => \$verbose,
1107 "rebuild!" => \$rebuild,
1108 "wrapper!" => \$wrapper,
1110 "anonok!" => \$anonok,
1113 "cgiurl=s" => \$cgiurl,
1114 "historyurl=s" => \$historyurl,
1117 usage() unless @ARGV == 3;
1118 ($srcdir) = possibly_foolish_untaint(shift);
1119 ($templatedir) = possibly_foolish_untaint(shift);
1120 ($destdir) = possibly_foolish_untaint(shift);
1122 if ($cgi && ! length $url) {
1123 error("Must specify url to wiki with --url when using --cgi");
1126 gen_wrapper($svn, $rebuild) if $wrapper;
1127 memoize('pagename');
1128 memoize('bestlink');
1129 loadindex() unless $rebuild;
1134 rcs_update() if $svn;