summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-08 22:56:12 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-08 22:56:12 -0400
commit3be7a02e7d0a4f19ffba3566d9aedee2885387d4 (patch)
treef8e9c2e14a9827996a35d6b41bd7c788148d9956 /IkiWiki/Plugin
parent57d04ed892588cbb49bfa81e2453e88388e67441 (diff)
orphans: switch to use_pagespec
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/orphans.pm40
1 files changed, 23 insertions, 17 deletions
diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm
index 93b8ec440..607239500 100644
--- a/IkiWiki/Plugin/orphans.pm
+++ b/IkiWiki/Plugin/orphans.pm
@@ -27,24 +27,30 @@ sub preprocess (@) {
# since any page could link to one of the pages we're
# considering as orphans.
add_depends($params{page}, "*", deptype("links"));
- # Also needs to update whenever potential orphans are added or
- # removed.
- add_depends($params{page}, $params{pages}, deptype("presence"));
- my @orphans;
- foreach my $page (pagespec_match_list(
- [ grep { ! IkiWiki::backlink_pages($_) && $_ ne 'index' }
- keys %pagesources ],
- $params{pages}, location => $params{page})) {
- # If the page has a link to some other page, it's
- # indirectly linked to a page via that page's backlinks.
- next if grep {
- length $_ &&
- ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
- bestlink($page, $_) !~ /^(\Q$page\E|)$/
- } @{$links{$page}};
- push @orphans, $page;
- }
+ my @orphans=use_pagespec($params{page}, $params{pages},
+ # update when orphans are added/removed
+ deptype => deptype("presence"),
+ limit => sub {
+ my $page=shift;
+
+ # Filter out pages that other pages link to.
+ return 0 if IkiWiki::backlink_pages($page);
+
+ # Toplevel index is assumed to never be orphaned.
+ return 0 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 {
+ length $_ &&
+ ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
+ bestlink($page, $_) !~ /^(\Q$page\E|)$/
+ } @{$links{$page}};
+
+ return 1;
+ },
+ );
return gettext("All pages have other pages linking to them.") unless @orphans;
return "<ul>\n".