2006-12-23 02:07:11 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
package IkiWiki::Plugin::mirrorlist;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-12-23 22:34:19 +01:00
|
|
|
use IkiWiki 3.00;
|
2006-12-23 02:07:11 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub import {
|
2008-07-26 00:05:55 +02:00
|
|
|
hook(type => "getsetup", id => "mirrorlist", call => \&getsetup);
|
2006-12-23 02:07:11 +01:00
|
|
|
hook(type => "pagetemplate", id => "mirrorlist", call => \&pagetemplate);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-12-23 02:07:11 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup () {
|
2008-07-26 00:05:55 +02:00
|
|
|
return
|
2008-08-03 22:40:12 +02:00
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 1,
|
|
|
|
},
|
2008-07-26 00:05:55 +02:00
|
|
|
mirrorlist => {
|
|
|
|
type => "string",
|
2008-07-27 03:07:15 +02:00
|
|
|
example => {},
|
2008-07-26 00:05:55 +02:00
|
|
|
description => "list of mirrors",
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 1,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-07-26 00:05:55 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub pagetemplate (@) {
|
2006-12-23 02:07:11 +01:00
|
|
|
my %params=@_;
|
|
|
|
my $template=$params{template};
|
|
|
|
|
2008-08-27 00:04:45 +02:00
|
|
|
if ($template->query(name => "extrafooter")) {
|
|
|
|
my $value=$template->param("extrafooter");
|
|
|
|
$value.=mirrorlist($params{page});
|
|
|
|
$template->param(extrafooter => $value);
|
|
|
|
}
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-12-23 02:07:11 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub mirrorlist ($) {
|
2006-12-23 02:07:11 +01:00
|
|
|
my $page=shift;
|
2006-12-29 05:38:40 +01:00
|
|
|
return "<p>".
|
|
|
|
(keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
|
2006-12-23 02:07:11 +01:00
|
|
|
": ".
|
|
|
|
join(", ",
|
|
|
|
map {
|
|
|
|
qq{<a href="}.
|
2007-04-01 22:21:35 +02:00
|
|
|
$config{mirrorlist}->{$_}."/".urlto($page, "").
|
2006-12-23 02:07:11 +01:00
|
|
|
qq{">$_</a>}
|
|
|
|
} keys %{$config{mirrorlist}}
|
|
|
|
).
|
|
|
|
"</p>";
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-12-23 02:07:11 +01:00
|
|
|
|
|
|
|
1
|