]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/mirrorlist.pm
inline: Ignore parent dirs when sorting pages by title.
[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                 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         $template->param(extrafooter => mirrorlist($params{page}))
33                 if $template->query(name => "extrafooter");
34 } # }}}
36 sub mirrorlist ($) { #{{{
37         my $page=shift;
38         return "<p>".
39                 (keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
40                 ": ".
41                 join(", ",
42                         map { 
43                                 qq{<a href="}.
44                                 $config{mirrorlist}->{$_}."/".urlto($page, "").
45                                 qq{">$_</a>}
46                         } keys %{$config{mirrorlist}}
47                 ).
48                 "</p>";
49 } # }}}
51 1