Allow globs to be used in user() pagespecs.
parent
7af18f2a1e
commit
c923e0ba33
|
@ -2266,11 +2266,13 @@ sub match_user ($$;@) {
|
||||||
my $user=shift;
|
my $user=shift;
|
||||||
my %params=@_;
|
my %params=@_;
|
||||||
|
|
||||||
|
my $regexp=IkiWiki::glob2re($user);
|
||||||
|
|
||||||
if (! exists $params{user}) {
|
if (! exists $params{user}) {
|
||||||
return IkiWiki::ErrorReason->new("no user specified");
|
return IkiWiki::ErrorReason->new("no user specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $params{user} && lc $params{user} eq lc $user) {
|
if (defined $params{user} && $params{user}=~/^$regexp$/i) {
|
||||||
return IkiWiki::SuccessReason->new("user is $user");
|
return IkiWiki::SuccessReason->new("user is $user");
|
||||||
}
|
}
|
||||||
elsif (! defined $params{user}) {
|
elsif (! defined $params{user}) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ ikiwiki (3.20100123) UNRELEASED; urgency=low
|
||||||
a button on the login form to use it.
|
a button on the login form to use it.
|
||||||
* httpauth: Add httpauth_pagespec setting that can be used to limit
|
* httpauth: Add httpauth_pagespec setting that can be used to limit
|
||||||
pages to only being edited via users authed with httpauth.
|
pages to only being edited via users authed with httpauth.
|
||||||
|
* Allow globs to be used in user() pagespecs.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Tue, 26 Jan 2010 22:25:33 -0500
|
-- Joey Hess <joeyh@debian.org> Tue, 26 Jan 2010 22:25:33 -0500
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ Some more elaborate limits can be added to what matches using these functions:
|
||||||
metadata, matching the specified glob.
|
metadata, matching the specified glob.
|
||||||
* "`user(username)`" - tests whether a modification is being made by a
|
* "`user(username)`" - tests whether a modification is being made by a
|
||||||
user with the specified username. If openid is enabled, an openid can also
|
user with the specified username. If openid is enabled, an openid can also
|
||||||
be put here.
|
be put here. Glob patterns can be used in the username. For example,
|
||||||
|
to match all openid users, use `user(*://.*)`
|
||||||
* "`admin()`" - tests whether a modification is being made by one of the
|
* "`admin()`" - tests whether a modification is being made by one of the
|
||||||
wiki admins.
|
wiki admins.
|
||||||
* "`ip(address)`" - tests whether a modification is being made from the
|
* "`ip(address)`" - tests whether a modification is being made from the
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Test::More tests => 64;
|
use Test::More tests => 70;
|
||||||
|
|
||||||
BEGIN { use_ok("IkiWiki"); }
|
BEGIN { use_ok("IkiWiki"); }
|
||||||
|
|
||||||
|
@ -40,6 +40,13 @@ ok(! pagespec_match("foo", "foo and bar"), "foo and bar");
|
||||||
ok(pagespec_match("{f}oo", "{*}*"), "curly match");
|
ok(pagespec_match("{f}oo", "{*}*"), "curly match");
|
||||||
ok(! pagespec_match("foo", "{*}*"), "curly !match");
|
ok(! pagespec_match("foo", "{*}*"), "curly !match");
|
||||||
|
|
||||||
|
ok(pagespec_match("somepage", "user(frodo)", user => "frodo"));
|
||||||
|
ok(pagespec_match("somepage", "user(frodo)", user => "Frodo"));
|
||||||
|
ok(! pagespec_match("somepage", "user(frodo)", user => "Sam"));
|
||||||
|
ok(pagespec_match("somepage", "user(*o)", user => "Bilbo"));
|
||||||
|
ok(pagespec_match("somepage", "user(*o)", user => "frodo"));
|
||||||
|
ok(! pagespec_match("somepage", "user(*o)", user => "Sam"));
|
||||||
|
|
||||||
# The link and backlink stuff needs this.
|
# The link and backlink stuff needs this.
|
||||||
$config{userdir}="";
|
$config{userdir}="";
|
||||||
$links{foo}=[qw{bar baz}];
|
$links{foo}=[qw{bar baz}];
|
||||||
|
|
Loading…
Reference in New Issue