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 a page is changed,
27 # added or removed, in order to see the link changes.
28 add_depends($params{page}, $params{pages});
31 foreach my $link (keys %IkiWiki::brokenlinks) {
32 next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion};
35 foreach my $page (@{$IkiWiki::brokenlinks{$link}}) {
37 if pagespec_match($page, $params{pages}, location => $params{page});
41 my $page=$IkiWiki::brokenlinks{$link}->[0];
42 push @broken, sprintf(gettext("%s from %s"),
43 htmllink($page, $params{destpage}, $link, noimageinline => 1),
45 htmllink($params{page}, $params{destpage}, $_, noimageinline => 1)
50 return gettext("There are no broken links!") unless @broken;