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 my $discussion=lc(gettext("Discussion"));
38 foreach my $page (pagespec_match_list(
39 [ grep { ! $linkedto{$_} && $_ ne 'index' }
41 $params{pages}, location => $params{page})) {
42 # If the page has a link to some other page, it's
43 # indirectly linked to a page via that page's backlinks.
46 ($_ !~ /\/\Q$discussion\E$/i || ! $config{discussion}) &&
47 bestlink($page, $_) !~ /^(\Q$page\E|)$/
52 return gettext("All pages are linked to by other pages.") unless @orphans;
57 htmllink($params{page}, $params{destpage}, $_,