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);
14 sub getsetup () { #{{{
22 sub 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=gettext("discussion");
38 foreach my $page (keys %pagesources) {
39 next if $linkedto{$page} || $page eq 'index';
40 next unless pagespec_match($page, $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$discussion\E$/i || ! $config{discussion}) &&
46 bestlink($page, $_) !~ /^($page|)$/
51 return gettext("All pages are linked to by other pages.") unless @orphans;
56 htmllink($params{page}, $params{destpage}, $_,