Avoid %links accumulating duplicates. (For TOVA)
[ikiwiki.git] / IkiWiki.pm
index e260fffea7aad7802e673541533056ad6960a118..e6efe18891069f128ff19ab87de717218b0a8797 100644 (file)
@@ -21,12 +21,12 @@ our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
                  pagespec_match_list bestlink htmllink readfile writefile
                 pagetype srcfile pagename displaytime will_render gettext urlto
                 targetpage add_underlay pagetitle titlepage linkpage
-                newpagefile inject
+                newpagefile inject add_link
                  %config %links %pagestate %wikistate %renderedfiles
                  %pagesources %destsources);
 our $VERSION = 3.00; # plugin interface version, next is ikiwiki version
 our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
-our $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
+our $installdir='/usr'; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
 
 # Optimisation.
 use Memoize;
@@ -1757,6 +1757,14 @@ sub inject {
        use warnings;
 }
 
+sub add_link ($$) {
+       my $page=shift;
+       my $link=shift;
+
+       push @{$links{$page}}, $link
+               unless grep { $_ eq $link } @{$links{$page}};
+}
+
 sub pagespec_merge ($$) {
        my $a=shift;
        my $b=shift;