<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::anonok;

use warnings;
use strict;
use IkiWiki 3.00;

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

sub getsetup () {
	return
		plugin =&gt; {
			safe =&gt; 1,
			rebuild =&gt; 0,
			section =&gt; "auth",
		},
		anonok_pagespec =&gt; {
			type =&gt; "pagespec",
			example =&gt; "*/discussion",
			description =&gt; "PageSpec to limit which pages anonymous users can edit",
			link =&gt; "ikiwiki/PageSpec",
			safe =&gt; 1,
			rebuild =&gt; 0,
		},
}

sub canedit ($$$) {
	my $page=shift;
	my $cgi=shift;
	my $session=shift;

	my $ret;

	if (exists $config{anonok_pagespec} &amp;&amp; length $config{anonok_pagespec}) {
		if (pagespec_match($page, $config{anonok_pagespec},
		                   location =&gt; $page)) {
			return "";
		}
		else {
			return undef;
		}
	}
	else {
		return "";
	}
}

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