]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/mirrorlist.pm
calendar: Add title attributes for all links in the calendars.
[git.ikiwiki.info.git] / IkiWiki / Plugin / mirrorlist.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::mirrorlist;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9         hook(type => "getsetup", id => "mirrorlist", call => \&getsetup);
10         hook(type => "pagetemplate", id => "mirrorlist", call => \&pagetemplate);
11 }
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => 1,
18                 },
19                 mirrorlist => {
20                         type => "string",
21                         example => {},
22                         description => "list of mirrors",
23                         safe => 1,
24                         rebuild => 1,
25                 },
26 }
28 sub pagetemplate (@) {
29         my %params=@_;
30         my $template=$params{template};
31         
32         if ($template->query(name => "extrafooter") &&
33             keys %{$config{mirrorlist}} > 0) {
34                 my $value=$template->param("extrafooter");
35                 $value.=mirrorlist($params{page});
36                 $template->param(extrafooter => $value);
37         }
38 }
40 sub mirrorlist ($) {
41         my $page=shift;
42         return "<p>".
43                 (keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
44                 ": ".
45                 join(", ",
46                         map { 
47                                 qq{<a href="}.
48                                 $config{mirrorlist}->{$_}."/".urlto($page, "").
49                                 qq{">$_</a>}
50                         } keys %{$config{mirrorlist}}
51                 ).
52                 "</p>";
53 }
55 1