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