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 page is added or removed, so
27 # register a dependency.
28 add_depends($params{page}, $params{pages});
31 foreach my $p (keys %links) {
32 map { $linkedto{bestlink($p, $_)}=1 if length $_ }
37 foreach my $page (pagespec_match_list(
38 [ grep { ! $linkedto{$_} && $_ ne 'index' }
40 $params{pages}, location => $params{page})) {
41 # If the page has a link to some other page, it's
42 # indirectly linked to a page via that page's backlinks.
45 ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
46 bestlink($page, $_) !~ /^(\Q$page\E|)$/
51 return gettext("All pages have other pages linking to them.") unless @orphans;
56 htmllink($params{page}, $params{destpage}, $_,