]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki.pm
added a test case for this bug
[git.ikiwiki.info.git] / IkiWiki.pm
index 74d452c502955993635d665ceaaa6f9ac4751b45..0791e1e755911ef4659bd2b509abde467e99a426 100644 (file)
@@ -355,7 +355,7 @@ sub getsetup () {
        },
        wiki_file_prune_regexps => {
                type => "internal",
        },
        wiki_file_prune_regexps => {
                type => "internal",
-               default => [qr/(^|\/)\.\.(\/|$)/, qr/^\./, qr/\/\./,
+               default => [qr/(^|\/)\.\.(\/|$)/, qr/^\//, qr/^\./, qr/\/\./,
                        qr/\.x?html?$/, qr/\.ikiwiki-new$/,
                        qr/(^|\/).svn\//, qr/.arch-ids\//, qr/{arch}\//,
                        qr/(^|\/)_MTN\//, qr/(^|\/)_darcs\//,
                        qr/\.x?html?$/, qr/\.ikiwiki-new$/,
                        qr/(^|\/).svn\//, qr/.arch-ids\//, qr/{arch}\//,
                        qr/(^|\/)_MTN\//, qr/(^|\/)_darcs\//,
@@ -440,10 +440,9 @@ sub getsetup () {
                safe => 0,
                rebuild => 0,
        },
                safe => 0,
                rebuild => 0,
        },
-       getctime => {
+       gettime => {
                type => "internal",
                type => "internal",
-               default => 0,
-               description => "running in getctime mode",
+               description => "running in gettime mode",
                safe => 0,
                rebuild => 0,
        },
                safe => 0,
                rebuild => 0,
        },
@@ -1087,14 +1086,16 @@ sub htmllink ($$$;@) {
                $bestlink=htmlpage($bestlink);
 
                if (! $destsources{$bestlink}) {
                $bestlink=htmlpage($bestlink);
 
                if (! $destsources{$bestlink}) {
-                       return $linktext unless length $config{cgiurl};
-                       return "<span class=\"createlink\"><a href=\"".
-                               cgiurl(
-                                       do => "create",
-                                       page => lc($link),
-                                       from => $lpage
-                               ).
-                               "\" rel=\"nofollow\">?</a>$linktext</span>"
+                       my $cgilink = "";
+                       if (length $config{cgiurl}) {
+                               $cgilink = "<a href=\"".
+                                       cgiurl(
+                                               do => "create",
+                                               page => lc($link),
+                                               from => $lpage
+                                       )."\" rel=\"nofollow\">?</a>";
+                       }
+                       return "<span class=\"createlink\">$cgilink$linktext</span>"
                }
        }
        
                }
        }
        
@@ -1512,6 +1513,7 @@ sub loadindex () {
                        open ($in, "<", "$config{wikistatedir}/indexdb") || return;
                }
                else {
                        open ($in, "<", "$config{wikistatedir}/indexdb") || return;
                }
                else {
+                       $config{gettime}=1; # first build
                        return;
                }
        }
                        return;
                }
        }
@@ -1790,6 +1792,10 @@ sub rcs_getctime ($) {
        $hooks{rcs}{rcs_getctime}{call}->(@_);
 }
 
        $hooks{rcs}{rcs_getctime}{call}->(@_);
 }
 
+sub rcs_getmtime ($) {
+       $hooks{rcs}{rcs_getmtime}{call}->(@_);
+}
+
 sub rcs_receive () {
        $hooks{rcs}{rcs_receive}{call}->();
 }
 sub rcs_receive () {
        $hooks{rcs}{rcs_receive}{call}->();
 }
@@ -1839,15 +1845,8 @@ sub deptype (@) {
 }
 
 my $file_prune_regexp;
 }
 
 my $file_prune_regexp;
-sub file_pruned ($;$) {
+sub file_pruned ($) {
        my $file=shift;
        my $file=shift;
-       if (@_) {
-               require File::Spec;
-               $file=File::Spec->canonpath($file);
-               my $base=File::Spec->canonpath(shift);
-               return if $file eq $base;
-               $file =~ s#^\Q$base\E/+##;
-       }
 
        if (defined $config{include} && length $config{include}) {
                return 0 if $file =~ m/$config{include}/;
 
        if (defined $config{include} && length $config{include}) {
                return 0 if $file =~ m/$config{include}/;
@@ -2102,6 +2101,8 @@ sub pagespec_match_list ($$;@) {
        my $sub=pagespec_translate($pagespec);
        error "syntax error in pagespec \"$pagespec\""
                if ! defined $sub;
        my $sub=pagespec_translate($pagespec);
        error "syntax error in pagespec \"$pagespec\""
                if ! defined $sub;
+       my $sort=sortspec_translate($params{sort}, $params{reverse})
+               if defined $params{sort};
 
        my @candidates;
        if (exists $params{list}) {
 
        my @candidates;
        if (exists $params{list}) {
@@ -2115,21 +2116,18 @@ sub pagespec_match_list ($$;@) {
                        : keys %pagesources;
        }
        
                        : keys %pagesources;
        }
        
+       # clear params, remainder is passed to pagespec
+       $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT);
        my $num=$params{num};
        my $num=$params{num};
-       my $sort=$params{sort};
-       my $reverse=$params{reverse};
+       delete @params{qw{num deptype reverse sort filter list}};
+       
        # when only the top matches will be returned, it's efficient to
        # sort before matching to pagespec,
        if (defined $num && defined $sort) {
                @candidates=IkiWiki::SortSpec::sort_pages(
        # when only the top matches will be returned, it's efficient to
        # sort before matching to pagespec,
        if (defined $num && defined $sort) {
                @candidates=IkiWiki::SortSpec::sort_pages(
-                       $sort, $reverse, @candidates);
+                       $sort, @candidates);
        }
        
        }
        
-       $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT);
-       
-       # clear params, remainder is passed to pagespec
-       delete @params{qw{num deptype reverse sort filter list}};
-       
        my @matches;
        my $firstfail;
        my $count=0;
        my @matches;
        my $firstfail;
        my $count=0;
@@ -2155,7 +2153,7 @@ sub pagespec_match_list ($$;@) {
        # sort after matching
        if (! defined $num && defined $sort) {
                return IkiWiki::SortSpec::sort_pages(
        # sort after matching
        if (! defined $num && defined $sort) {
                return IkiWiki::SortSpec::sort_pages(
-                       $sort, $reverse, @matches);
+                       $sort, @matches);
        }
        else {
                return @matches;
        }
        else {
                return @matches;
@@ -2223,7 +2221,7 @@ sub merge_influences {
        my $anded=shift;
 
        if (! $anded || (($this || %{$this->[1]}) &&
        my $anded=shift;
 
        if (! $anded || (($this || %{$this->[1]}) &&
-                       ($other || %{$other->[1]}))) {
+                        ($other || %{$other->[1]}))) {
                foreach my $influence (keys %{$other->[1]}) {
                        $this->[1]{$influence} |= $other->[1]{$influence};
                }
                foreach my $influence (keys %{$other->[1]}) {
                        $this->[1]{$influence} |= $other->[1]{$influence};
                }
@@ -2247,7 +2245,7 @@ sub derel ($$) {
        if ($path =~ m!^\./!) {
                $from=~s#/?[^/]+$## if defined $from;
                $path=~s#^\./##;
        if ($path =~ m!^\./!) {
                $from=~s#/?[^/]+$## if defined $from;
                $path=~s#^\./##;
-               $path="$from/$path" if length $from;
+               $path="$from/$path" if defined $from && length $from;
        }
 
        return $path;
        }
 
        return $path;
@@ -2452,7 +2450,7 @@ package IkiWiki::SortSpec;
 # This is in the SortSpec namespace so that the $a and $b that sort() uses
 # are easily available in this namespace, for cmp functions to use them.
 sub sort_pages {
 # This is in the SortSpec namespace so that the $a and $b that sort() uses
 # are easily available in this namespace, for cmp functions to use them.
 sub sort_pages {
-       my $f=IkiWiki::sortspec_translate(shift, shift);
+       my $f=shift;
        sort $f @_
 }
 
        sort $f @_
 }