pagespec_match_list: change limit to filter
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 9 Oct 2009 17:20:41 +0000 (13:20 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 9 Oct 2009 17:20:41 +0000 (13:20 -0400)
IkiWiki.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/orphans.pm
IkiWiki/Plugin/postsparkline.pm
doc/plugins/write.mdwn

index f959d868b1e659926577874b1404545184037182..49c76c4d4cb08901b6d102bd6e466ebb9f2f8a8c 100644 (file)
@@ -1986,8 +1986,8 @@ sub pagespec_match_list ($$;@) {
                if $@ || ! defined $sub;
 
        my @candidates;
-       if (exists $params{limit}) {
-               @candidates=grep { $params{limit}->($_) } keys %pagesources;
+       if (exists $params{filter}) {
+               @candidates=grep { ! $params{filter}->($_) } keys %pagesources;
        }
        else {
                @candidates=keys %pagesources;
@@ -2023,7 +2023,7 @@ sub pagespec_match_list ($$;@) {
        
        # clear params, remainder is passed to pagespec
        my $num=$params{num};
-       delete @params{qw{num deptype reverse sort limit}};
+       delete @params{qw{num deptype reverse sort filter}};
        
        my @matches;
        my $firstfail;
index 815a3783841b7b1017d82d51d754041f1be13f34..0fe0bd2e108a444b6b85c2ded93840f10e4fd2fc 100644 (file)
@@ -218,7 +218,7 @@ sub preprocess_inline (@) {
 
                @list = pagespec_match_list($params{page}, $params{pages},
                        deptype => deptype($quick ? "presence" : "content"),
-                       limit => sub { $_[0] ne $params{page} },
+                       filter => sub { $_[0] eq $params{page} },
                        sort => exists $params{sort} ? $params{sort} : "age",
                        reverse => yesno($params{reverse}),
                        num => $num,
index b1ebd1b9d8489cd5d0a5971b7c9943ea2d4dfef7..702943f87d1cb96927270a2b609de192a7488aa7 100644 (file)
@@ -31,24 +31,24 @@ sub preprocess (@) {
        my @orphans=pagespec_match_list($params{page}, $params{pages},
                # update when orphans are added/removed
                deptype => deptype("presence"),
-               limit => sub {
+               filter => sub {
                        my $page=shift;
 
                        # Filter out pages that other pages link to.
-                       return 0 if IkiWiki::backlink_pages($page);
+                       return 1 if IkiWiki::backlink_pages($page);
 
                        # Toplevel index is assumed to never be orphaned.
-                       return 0 if $page eq 'index';
+                       return 1 if $page eq 'index';
 
                        # If the page has a link to some other page, it's
                        # indirectly linked via that page's backlinks.
-                       return 0 if grep {
+                       return 1 if grep {
                                length $_ &&
                                ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
                                bestlink($page, $_) !~ /^(\Q$page\E|)$/ 
                        } @{$links{$page}};
                        
-                       return 1;
+                       return 0;
                },
        );
        
index 1d4532366e4f2d12eac17f65e5cdf56bb6e7308b..0d5a12e33c5c2f918181784b2dd8784f54353ff7 100644 (file)
@@ -56,7 +56,7 @@ sub preprocess (@) {
        my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } 
                pagespec_match_list($params{page}, $params{pages},
                        deptype => $deptype,
-                       limit => sub { $_[0] ne $params{page} },
+                       filter => sub { $_[0] eq $params{page} },
                );
 
        my @data=eval qq{IkiWiki::Plugin::postsparkline::formula::$formula(\\\%params, \@list)};
index 9661bf4def17e3fbbdb0db80611e45c1bac5f114..2254d70257dbeb17b58a4a5df6da2d42eea6901a 100644 (file)
@@ -643,8 +643,8 @@ Additional named parameters can be specified:
 
 * `deptype` optionally specifies the type of dependency to add. Use the
   `deptype` function to generate a dependency type.
-* `limit` is a reference to a function, that is called and passed a page,
-  and must return true for the page to be included.
+* `filter` is a reference to a function, that is called and passed a page,
+  and returns true if the page should be filtered out of the list.
 * `sort` specifies a sort order for the list. See
   [[ikiwiki/PageSpec/sorting]] for the avilable sort methods.
 * `reverse` if true, sorts in reverse.