summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mirrorlist.pm
blob: 34a97cc0bc02b655e9cd5f8c045fd95ca4eab4fe (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::mirrorlist;
  3. use warnings;
  4. use strict;
  5. use IkiWiki;
  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