]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/brokenlinks.pm
po(nicepagetitle): append translation status to links to translated pages
[git.ikiwiki.info.git] / IkiWiki / Plugin / brokenlinks.pm
index ef5837a5876c44b1082a3556d5cabe75cd24c7ef..1c52099bf9be94360e7f6fde85befdd6e22ca4b4 100644 (file)
@@ -6,11 +6,20 @@ use warnings;
 use strict;
 use IkiWiki 2.00;
 
 use strict;
 use IkiWiki 2.00;
 
-sub import { #{{{
+sub import {
+       hook(type => "getsetup", id => "brokenlinks", call => \&getsetup);
        hook(type => "preprocess", id => "brokenlinks", call => \&preprocess);
        hook(type => "preprocess", id => "brokenlinks", call => \&preprocess);
-} # }}}
+}
 
 
-sub preprocess (@) { #{{{
+sub getsetup {
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+}
+
+sub preprocess (@) {
        my %params=@_;
        $params{pages}="*" unless defined $params{pages};
        
        my %params=@_;
        $params{pages}="*" unless defined $params{pages};
        
@@ -22,7 +31,10 @@ sub preprocess (@) { #{{{
        foreach my $page (keys %links) {
                if (pagespec_match($page, $params{pages}, location => $params{page})) {
                        my $discussion=gettext("discussion");
        foreach my $page (keys %links) {
                if (pagespec_match($page, $params{pages}, location => $params{page})) {
                        my $discussion=gettext("discussion");
+                       my %seen;
                        foreach my $link (@{$links{$page}}) {
                        foreach my $link (@{$links{$page}}) {
+                               next if $seen{$link};
+                               $seen{$link}=1;
                                next if $link =~ /.*\/\Q$discussion\E/i && $config{discussion};
                                my $bestlink=bestlink($page, $link);
                                next if length $bestlink;
                                next if $link =~ /.*\/\Q$discussion\E/i && $config{discussion};
                                my $bestlink=bestlink($page, $link);
                                next if length $bestlink;
@@ -49,6 +61,6 @@ sub preprocess (@) { #{{{
                        }
                        sort @broken)
                ."</ul>\n";
                        }
                        sort @broken)
                ."</ul>\n";
-} # }}}
+}
 
 1
 
 1