X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/743f69c675de6bdf240a2980e0924ed9d3bb782b..d1061d0094febfc21957554655a8eff4663b00ca:/IkiWiki.pm?ds=sidebyside diff --git a/IkiWiki.pm b/IkiWiki.pm index 67149bc8b..7b1d24c6a 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -29,8 +29,9 @@ our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE our $installdir='/usr'; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE # Page dependency types. -our $DEPEND_EXISTS=1; -our $DEPEND_CONTENT=2; +our $DEPEND_CONTENT=1; +our $DEPEND_PRESENCE=2; +our $DEPEND_LINKS=4; # Optimisation. use Memoize; @@ -1535,18 +1536,18 @@ sub loadindex () { }; } elsif (exists $d->{depends_simple}) { - $depends{$page}=$d->{depends_simple}; + $depends_simple{$page}=$d->{depends_simple}; } if (exists $d->{dependslist}) { # old format $depends{$page}={ - map { $_ => $DEPEND_CONTENT | $DEPEND_EXISTS } + map { $_ => $DEPEND_CONTENT } @{$d->{dependslist}} }; } elsif (exists $d->{depends} && ! ref $d->{depends}) { # old format - $depends{$page}={$d->{depends} => $DEPEND_CONTENT | $DEPEND_EXISTS}; + $depends{$page}={$d->{depends} => $DEPEND_CONTENT }; } elsif (exists $d->{depends}) { $depends{$page}=$d->{depends}; @@ -1771,17 +1772,47 @@ sub add_depends ($$;@) { my $page=shift; my $pagespec=shift; - my $deptype=$DEPEND_CONTENT | $DEPEND_EXISTS; + # Is the pagespec a simple page name? + my $simple=$pagespec =~ /$config{wiki_file_regexp}/ && + $pagespec !~ /[\s*?()!]/; + + my $deptype=0; if (@_) { my %params=@_; - if (defined $params{content} && $params{content} == 0) { - $deptype=$deptype & ~$DEPEND_CONTENT; + + if ($params{presence}) { + # Is the pagespec limited to terms that will continue + # to match pages as long as those pages exist? + my $presence_limited=1; + while ($presence_limited && $pagespec=~m/(\w+)\([^\)]*\)/g) { + $presence_limited = $1 =~ /^(glob|internal|creation_month|creation_day|creation_year|created_before|created_after)$/; + } + if ($presence_limited) { + $deptype=$deptype | $DEPEND_PRESENCE; + } + else { + $deptype=$deptype | $DEPEND_CONTENT; + } + } + if ($params{links}) { + # Is the pagespec limited to terms that will continue + # to match pages as long as those pages exist and + # link to the same places? + my $links_limited=1; + while ($links_limited && $pagespec=~m/(\w+)\([^\)]*\)/g) { + $links_limited = $1 =~ /^(glob|internal|creation_month|creation_day|creation_year|created_before|created_after|backlink)$/; + } + if ($links_limited) { + $deptype=$deptype | $DEPEND_LINKS; + } + else { + $deptype=$deptype | $DEPEND_CONTENT; + } } } + $deptype=$DEPEND_CONTENT unless $deptype; - if ($pagespec =~ /$config{wiki_file_regexp}/ && - $pagespec !~ /[\s*?()!]/) { - # a simple dependency, which can be matched by string eq + if ($simple) { $depends_simple{$page}{lc $pagespec} |= $deptype; return 1; } @@ -1892,7 +1923,7 @@ sub pagespec_translate ($) { [^\s()]+ # any other text ) \s* # ignore whitespace - }igx) { + }gx) { my $word=$1; if (lc $word eq 'and') { $code.=' &&';