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 foreach my $page (keys %renderedfiles) {
29 next if $linkedto{$page};
30 next unless pagespec_match($page, $params{pages});
31 # If the page has a link to some other page, it's
32 # indirectly linked to a page via that page's backlinks.
35 ($_ !~ /\/Discussion$/i || ! $config{discussion}) &&
36 bestlink($page, $_) !~ /^($page|)$/
41 return "All pages are linked to by other pages." unless @orphans;
42 return "<ul>\n".join("\n", map { "<li>".htmllink($params{page}, $params{destpage}, $_, 1)."</li>" } sort @orphans)."</ul>\n";