summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mirrorlist.pm
blob: f7c78fdee33769584278b131955b8eac28291716 (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 => "getsetup", id => "mirrorlist", call => \&getsetup);
  8. hook(type => "pagetemplate", id => "mirrorlist", call => \&pagetemplate);
  9. } # }}}
  10. sub getsetup () { #{{{
  11. return
  12. mirrorlist => {
  13. type => "string",
  14. example => {},
  15. description => "list of mirrors",
  16. safe => 1,
  17. rebuild => 1,
  18. },
  19. } #}}}
  20. sub pagetemplate (@) { #{{{
  21. my %params=@_;
  22. my $template=$params{template};
  23. $template->param(extrafooter => mirrorlist($params{page}))
  24. if $template->query(name => "extrafooter");
  25. } # }}}
  26. sub mirrorlist ($) { #{{{
  27. my $page=shift;
  28. return "<p>".
  29. (keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
  30. ": ".
  31. join(", ",
  32. map {
  33. qq{<a href="}.
  34. $config{mirrorlist}->{$_}."/".urlto($page, "").
  35. qq{">$_</a>}
  36. } keys %{$config{mirrorlist}}
  37. ).
  38. "</p>";
  39. } # }}}
  40. 1