summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mirrorlist.pm
blob: c7630d81f0b60911fed26b32baba015e3ea9757c (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. default => "",
  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