2 # Provides a list of pages no other page links to.
3 package IkiWiki::Plugin::orphans;
10 hook(type => "getsetup", id => "orphans", call => \&getsetup);
11 hook(type => "preprocess", id => "orphans", call => \&preprocess);
24 $params{pages}="*" unless defined $params{pages};
26 # Needs to update whenever a link changes, on any page
27 # since any page could link to one of the pages we're
28 # considering as orphans.
29 add_depends($params{page}, "*", deptype("links"));
30 # Also needs to update whenever potential orphans are added or
32 add_depends($params{page}, $params{pages}, deptype("presence"));
35 foreach my $page (pagespec_match_list(
36 [ grep { ! IkiWiki::backlink_pages($_) && $_ ne 'index' }
38 $params{pages}, location => $params{page})) {
39 # If the page has a link to some other page, it's
40 # indirectly linked to a page via that page's backlinks.
43 ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
44 bestlink($page, $_) !~ /^(\Q$page\E|)$/
49 return gettext("All pages have other pages linking to them.") unless @orphans;
54 htmllink($params{page}, $params{destpage}, $_,