Some fixes to the parent links, I think the link to the index will be right
[ikiwiki.git] / ikiwiki
diff --git a/ikiwiki b/ikiwiki
index 4e64e4031d0d5996f68d072d4bac06e6a3aa4da4..7e140bbecc86b6bcbf85cff2dbeadcaa4aec1709 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -172,7 +172,7 @@ sub findlinks ($) { #{{{
        my $content=shift;
 
        my @links;
-       while ($content =~ /$config{wiki_link_regexp}/g) {
+       while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
                push @links, lc($1);
        }
        return @links;
@@ -247,7 +247,9 @@ sub linkify ($$) { #{{{
        my $content=shift;
        my $file=shift;
 
-       $content =~ s/$config{wiki_link_regexp}/htmllink(pagename($file), $1)/eg;
+       $content =~ s{(\\?)$config{wiki_link_regexp}}{
+               $1 ? "[[$2]]" : htmllink(pagename($file), $2)
+       }eg;
        
        return $content;
 } #}}}
@@ -305,14 +307,14 @@ sub parentlinks ($) { #{{{
        my $skip=1;
        foreach my $dir (reverse split("/", $page)) {
                if (! $skip) {
+                       $path.="../";
                        unshift @ret, { url => "$path$dir.html", page => $dir };
                }
                else {
                        $skip=0;
                }
-               $path.="../";
        }
-       unshift @ret, { url => $path , page => $config{wikiname} };
+       unshift @ret, { url => length $path ? $path : ".", page => $config{wikiname} };
        return @ret;
 } #}}}
 
@@ -1150,14 +1152,28 @@ sub cgi () { #{{{
 
 sub setup () { # {{{
        my $setup=possibly_foolish_untaint($config{setup});
+       delete $config{setup};
        open (IN, $setup) || error("read $setup: $!\n");
        local $/=undef;
        my $code=<IN>;
        ($code)=$code=~/(.*)/s;
        close IN;
+
+       my (%setup);
        eval $code;
        error($@) if $@;
-       print "ikiwiki setup complete\n";
+       
+       gen_wrapper(%config, %setup, %{$setup{cgiwrapper}}) if $setup{cgiwrapper};
+       gen_wrapper(%config, %setup, %{$setup{svnwrapper}}) if $setup{svnwrapper};
+       
+       print "$setup{wikiname} setup complete, now forcing a rebuild\n";
+       foreach my $c (keys %setup) {
+               $config{$c}=possibly_foolish_untaint($setup{$c})
+                       if defined $setup{$c} && ! ref $setup{$c};
+       }
+       $config{rebuild}=1;
+       refresh();
+       saveindex();
        exit;
 } #}}}