<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
package IkiWiki::Plugin::mirrorlist;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type =&gt; "getsetup", id =&gt; "mirrorlist", call =&gt; \&amp;getsetup);
	hook(type =&gt; "pagetemplate", id =&gt; "mirrorlist", call =&gt; \&amp;pagetemplate);
}

sub getsetup () {
	return
		plugin =&gt; {
			safe =&gt; 1,
			rebuild =&gt; 1,
		},
		mirrorlist =&gt; {
			type =&gt; "string",
			example =&gt; {},
			description =&gt; "list of mirrors",
			safe =&gt; 1,
			rebuild =&gt; 1,
		},
}

sub pagetemplate (@) {
	my %params=@_;
        my $template=$params{template};
	
	if ($template-&gt;query(name =&gt; "extrafooter") &amp;&amp;
	    keys %{$config{mirrorlist}} &gt; 0) {
		my $value=$template-&gt;param("extrafooter");
		$value.=mirrorlist($params{page});
		$template-&gt;param(extrafooter =&gt; $value);
	}
}

sub mirrorlist ($) {
	my $page=shift;
	return "&lt;p&gt;".
		(keys %{$config{mirrorlist}} &gt; 1 ? gettext("Mirrors") : gettext("Mirror")).
		": ".
		join(", ",
			map { 
				qq{&lt;a href="}.
				$config{mirrorlist}-&gt;{$_}."/".urlto($page, "").
				qq{"&gt;$_&lt;/a&gt;}
			} keys %{$config{mirrorlist}}
		).
		"&lt;/p&gt;";
}

1
</pre></body></html>