summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mirrorlist.pm
blob: 3997e6fefcd31c15a8fa6df7e559a6ffdf84e863 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::mirrorlist;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import { #{{{
  7. hook(type => "pagetemplate", id => "mirrorlist", call => \&pagetemplate);
  8. } # }}}
  9. sub pagetemplate (@) { #{{{
  10. my %params=@_;
  11. my $template=$params{template};
  12. $template->param(extrafooter => mirrorlist($params{page}))
  13. if $template->query(name => "extrafooter");
  14. } # }}}
  15. sub mirrorlist ($) { #{{{
  16. my $page=shift;
  17. return "<p>".
  18. (keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
  19. ": ".
  20. join(", ",
  21. map {
  22. qq{<a href="}.
  23. $config{mirrorlist}->{$_}."/".urlto($page, "").
  24. qq{">$_</a>}
  25. } keys %{$config{mirrorlist}}
  26. ).
  27. "</p>";
  28. } # }}}
  29. 1