]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/mirrorlist.pm
add missing setup options, tweak others' display
[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 2.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                 mirrorlist => {
16                         type => "string",
17                         default => {},
18                         description => "list of mirrors",
19                         safe => 1,
20                         rebuild => 1,
21                 },
22 } #}}}
24 sub pagetemplate (@) { #{{{
25         my %params=@_;
26         my $template=$params{template};
27         
28         $template->param(extrafooter => mirrorlist($params{page}))
29                 if $template->query(name => "extrafooter");
30 } # }}}
32 sub mirrorlist ($) { #{{{
33         my $page=shift;
34         return "<p>".
35                 (keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
36                 ": ".
37                 join(", ",
38                         map { 
39                                 qq{<a href="}.
40                                 $config{mirrorlist}->{$_}."/".urlto($page, "").
41                                 qq{">$_</a>}
42                         } keys %{$config{mirrorlist}}
43                 ).
44                 "</p>";
45 } # }}}
47 1