summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mirrorlist.pm
blob: 104587f3a881ab8526ce79ef9c762d3624fe32af (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>Mirror".
  18. (keys %{$config{mirrorlist}} > 1 ? "s" : "").
  19. ": ".
  20. join(", ",
  21. map {
  22. qq{<a href="}.
  23. $config{mirrorlist}->{$_}."/".$page.
  24. qq{">$_</a>}
  25. } keys %{$config{mirrorlist}}
  26. ).
  27. "</p>";
  28. } # }}}
  29. 1