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);
25 $params{pages}="*" unless defined $params{pages};
27 # Needs to update whenever a link changes, on any page
28 # since any page could link to one of the pages we're
29 # considering as orphans.
30 add_depends($params{page}, "*", deptype("links"));
32 my @orphans=pagespec_match_list($params{page}, $params{pages},
33 # update when orphans are added/removed
34 deptype => deptype("presence"),
38 # Filter out pages that other pages link to.
39 return 1 if IkiWiki::backlink_pages($page);
41 # Toplevel index is assumed to never be orphaned.
42 return 1 if $page eq 'index';
44 # If the page has a link to some other page, it's
45 # indirectly linked via that page's backlinks.
48 ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
49 bestlink($page, $_) !~ /^(\Q$page\E|)$/
56 return gettext("All pages have other pages linking to them.") unless @orphans;
61 htmllink($params{page}, $params{destpage}, $_,