2 # Provides a list of broken links.
3 package IkiWiki::Plugin::brokenlinks;
10 hook(type => "getsetup", id => "brokenlinks", call => \&getsetup);
11 hook(type => "preprocess", id => "brokenlinks", call => \&preprocess);
24 $params{pages}="*" unless defined $params{pages};
26 # Needs to update whenever the links on a page change.
27 add_depends($params{page}, $params{pages}, links => 1);
30 foreach my $link (keys %IkiWiki::brokenlinks) {
31 next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion};
34 foreach my $page (@{$IkiWiki::brokenlinks{$link}}) {
36 if pagespec_match($page, $params{pages}, location => $params{page});
40 my $page=$IkiWiki::brokenlinks{$link}->[0];
41 push @broken, sprintf(gettext("%s from %s"),
42 htmllink($page, $params{destpage}, $link, noimageinline => 1),
44 htmllink($params{page}, $params{destpage}, $_, noimageinline => 1)
49 return gettext("There are no broken links!") unless @broken;