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"));
31 my @orphans=pagespec_match_list($params{page}, $params{pages},
32 # update when orphans are added/removed
33 deptype => deptype("presence"),
37 # Filter out pages that other pages link to.
38 return 1 if IkiWiki::backlink_pages($page);
40 # Toplevel index is assumed to never be orphaned.
41 return 1 if $page eq 'index';
43 # If the page has a link to some other page, it's
44 # indirectly linked via that page's backlinks.
47 ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
48 bestlink($page, $_) !~ /^(\Q$page\E|)$/
55 return gettext("All pages have other pages linking to them.") unless @orphans;
60 htmllink($params{page}, $params{destpage}, $_,