2 # Provides a list of pages no other page links to.
3 package IkiWiki::Plugin::orphans;
10 hook(type => "preprocess", id => "orphans", call => \&preprocess);
13 sub preprocess (@) { #{{{
15 $params{pages}="*" unless defined $params{pages};
17 # Needs to update whenever a page is added or removed, so
18 # register a dependency.
19 add_depends($params{page}, $params{pages});
22 foreach my $p (keys %links) {
23 map { $linkedto{bestlink($p, $_)}=1 if length $_ }
28 my $discussion=gettext("discussion");
29 foreach my $page (keys %renderedfiles) {
30 next if $linkedto{$page};
31 next unless pagespec_match($page, $params{pages}, $params{page});
32 # If the page has a link to some other page, it's
33 # indirectly linked to a page via that page's backlinks.
36 ($_ !~ /\/\Q$discussion\E$/i || ! $config{discussion}) &&
37 bestlink($page, $_) !~ /^($page|)$/
42 return gettext("All pages are linked to by other pages.") unless @orphans;
47 htmllink($params{page}, $params{destpage}, $_,