X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/002d9e3cb52eadc8c2feb6bfac020b0651c6e0b7..bfca8345ea7d49df6a4f6521f1db416d28671f35:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 2cad6a3ef..6d3b6c606 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -355,7 +355,7 @@ sub getsetup () { }, 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\//, @@ -440,10 +440,9 @@ sub getsetup () { safe => 0, rebuild => 0, }, - getctime => { + gettime => { type => "internal", - default => 0, - description => "running in getctime mode", + description => "running in gettime mode", safe => 0, rebuild => 0, }, @@ -1512,6 +1511,7 @@ sub loadindex () { open ($in, "<", "$config{wikistatedir}/indexdb") || return; } else { + $config{gettime}=1; # first build return; } } @@ -1790,6 +1790,10 @@ sub rcs_getctime ($) { $hooks{rcs}{rcs_getctime}{call}->(@_); } +sub rcs_getmtime ($) { + $hooks{rcs}{rcs_getmtime}{call}->(@_); +} + sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } @@ -1839,15 +1843,8 @@ sub deptype (@) { } my $file_prune_regexp; -sub file_pruned ($;$) { +sub file_pruned ($) { 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}/; @@ -1951,8 +1948,9 @@ sub add_link ($$;$) { } } -sub sortspec_translate ($) { +sub sortspec_translate ($$) { my $spec = shift; + my $reverse = shift; my $code = ""; my @data; @@ -2007,6 +2005,10 @@ sub sortspec_translate ($) { return sub { 0 }; } + if ($reverse) { + $code="-($code)"; + } + no warnings; return eval 'sub { '.$code.' }'; } @@ -2097,6 +2099,8 @@ sub pagespec_match_list ($$;@) { 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}) { @@ -2109,20 +2113,19 @@ sub pagespec_match_list ($$;@) { ? grep { ! $params{filter}->($_) } keys %pagesources : keys %pagesources; } - - if (defined $params{sort}) { - @candidates = IkiWiki::SortSpec::sort_pages($params{sort}, - @candidates); - } - - @candidates=reverse(@candidates) if $params{reverse}; - - $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT); # clear params, remainder is passed to pagespec + $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT); my $num=$params{num}; 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( + $sort, @candidates); + } + my @matches; my $firstfail; my $count=0; @@ -2144,7 +2147,15 @@ sub pagespec_match_list ($$;@) { $depends_simple{$page}{lc $k} |= $i->{$k}; } - return @matches; + # when all matches will be returned, it's efficient to + # sort after matching + if (! defined $num && defined $sort) { + return IkiWiki::SortSpec::sort_pages( + $sort, @matches); + } + else { + return @matches; + } } sub pagespec_valid ($) { @@ -2437,9 +2448,8 @@ 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 { - my $f = IkiWiki::sortspec_translate(shift); - - return sort $f @_; + my $f=shift; + sort $f @_ } sub cmp_title {