]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
img: use presence dependency when linking to a page
[ikiwiki.git] / IkiWiki.pm
index 475e278c3b3ef5ad7a434f0cf84bc3117b340436..232d3e77b6a240860adfb38447dd92586a5ce22e 100644 (file)
@@ -1986,11 +1986,15 @@ sub pagespec_match_list ($$;@) {
                if $@ || ! defined $sub;
 
        my @candidates;
-       if (exists $params{limit}) {
-               @candidates=grep { $params{limit}->($_) } keys %pagesources;
+       if (exists $params{list}) {
+               @candidates=exists $params{filter}
+                       ? grep { ! $params{filter}->($_) } @{$params{list}}
+                       : @{$params{list}};
        }
        else {
-               @candidates=keys %pagesources;
+               @candidates=exists $params{filter}
+                       ? grep { ! $params{filter}->($_) } keys %pagesources
+                       : keys %pagesources;
        }
 
        if (defined $params{sort}) {
@@ -2019,21 +2023,25 @@ sub pagespec_match_list ($$;@) {
 
        @candidates=reverse(@candidates) if $params{reverse};
        
+       $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT);
+       
+       # clear params, remainder is passed to pagespec
+       my $num=$params{num};
+       delete @params{qw{num deptype reverse sort filter list}};
+       
        my @matches;
        my $firstfail;
        my $count=0;
        foreach my $p (@candidates) {
-               my $r=$sub->($p, location => $page);
+               my $r=$sub->($p, %params, location => $page);
                if ($r) {
                        push @matches, [$p, $r];
-                       last if defined $params{num} && ++$count == $params{num};
+                       last if defined $num && ++$count == $num;
                }
                elsif (! defined $firstfail) {
                        $firstfail=$r;
                }
        }
-       
-       $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT);
 
        my @ret;
        if (@matches) {