X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/c0e938e972dee09c2e70c0a8e57351ec85e69c14..fd43e83fcf7bf24493ecfff54111c1c5f1cab573:/IkiWiki.pm?ds=sidebyside
diff --git a/IkiWiki.pm b/IkiWiki.pm
index b8e599928..00eadfd98 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -20,7 +20,7 @@ use Exporter q{import};
our @EXPORT = qw(hook debug error template htmlpage deptype
add_depends pagespec_match pagespec_match_list bestlink
htmllink readfile writefile pagetype srcfile pagename
- displaytime will_render gettext urlto targetpage
+ displaytime will_render gettext ngettext urlto targetpage
add_underlay pagetitle titlepage linkpage newpagefile
inject add_link
%config %links %pagestate %wikistate %renderedfiles
@@ -409,6 +409,13 @@ sub getsetup () {
safe => 0,
rebuild => 0,
},
+ clean => {
+ type => "internal",
+ default => 0,
+ description => "running in clean mode",
+ safe => 0,
+ rebuild => 0,
+ },
refresh => {
type => "internal",
default => 0,
@@ -941,7 +948,12 @@ sub linkpage ($) {
sub cgiurl (@) {
my %params=@_;
- return $config{cgiurl}."?".
+ my $cgiurl=$config{cgiurl};
+ if (exists $params{cgiurl}) {
+ $cgiurl=$params{cgiurl};
+ delete $params{cgiurl};
+ }
+ return $cgiurl."?".
join("&", map $_."=".uri_escape_utf8($params{$_}), keys %params);
}
@@ -1090,6 +1102,11 @@ sub htmllink ($$$;@) {
return "$linktext";
}
+sub userpage ($) {
+ my $user=shift;
+ return length $config{userdir} ? "$config{userdir}/$user" : $user;
+}
+
sub openiduser ($) {
my $user=shift;
@@ -1098,11 +1115,10 @@ sub openiduser ($) {
my $display;
if (Net::OpenID::VerifiedIdentity->can("DisplayOfURL")) {
- # this works in at least 2.x
$display = Net::OpenID::VerifiedIdentity::DisplayOfURL($user);
}
else {
- # this only works in 1.x
+ # backcompat with old version
my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
$display=$oid->display;
}
@@ -1125,23 +1141,6 @@ sub openiduser ($) {
return;
}
-sub userlink ($) {
- my $user=shift;
-
- my $oiduser=eval { openiduser($user) };
- if (defined $oiduser) {
- return "$oiduser";
- }
- else {
- eval q{use CGI 'escapeHTML'};
- error($@) if $@;
-
- return htmllink("", "", escapeHTML(
- length $config{userdir} ? $config{userdir}."/".$user : $user
- ), noimageinline => 1);
- }
-}
-
sub htmlize ($$$$) {
my $page=shift;
my $destpage=shift;
@@ -1228,7 +1227,7 @@ sub preprocess ($$$;$$) {
(?:
"""(.*?)""" # 2: triple-quoted value
|
- "([^"]+)" # 3: single-quoted value
+ "([^"]*?)" # 3: single-quoted value
|
(\S+) # 4: unquoted value
)
@@ -1314,7 +1313,7 @@ sub preprocess ($$$;$$) {
(?:
""".*?""" # triple-quoted value
|
- "[^"]+" # single-quoted value
+ "[^"]*?" # single-quoted value
|
[^"\s\]]+ # unquoted value
)
@@ -1337,7 +1336,7 @@ sub preprocess ($$$;$$) {
(?:
""".*?""" # triple-quoted value
|
- "[^"]+" # single-quoted value
+ "[^"]*?" # single-quoted value
|
[^"\s\]]+ # unquoted value
)
@@ -1828,27 +1827,38 @@ sub file_pruned ($;$) {
sub define_gettext () {
# If translation is needed, redefine the gettext function to do it.
# Otherwise, it becomes a quick no-op.
- no warnings 'redefine';
+ my $gettext_obj;
+ my $getobj;
if ((exists $ENV{LANG} && length $ENV{LANG}) ||
(exists $ENV{LC_ALL} && length $ENV{LC_ALL}) ||
(exists $ENV{LC_MESSAGES} && length $ENV{LC_MESSAGES})) {
- *gettext=sub {
- my $gettext_obj=eval q{
+ $getobj=sub {
+ $gettext_obj=eval q{
use Locale::gettext q{textdomain};
Locale::gettext->domain('ikiwiki')
};
-
- if ($gettext_obj) {
- $gettext_obj->get(shift);
- }
- else {
- return shift;
- }
};
}
- else {
- *gettext=sub { return shift };
- }
+
+ no warnings 'redefine';
+ *gettext=sub {
+ $getobj->() if $getobj;
+ if ($gettext_obj) {
+ $gettext_obj->get(shift);
+ }
+ else {
+ return shift;
+ }
+ };
+ *ngettext=sub {
+ $getobj->() if $getobj;
+ if ($gettext_obj) {
+ $gettext_obj->nget(@_);
+ }
+ else {
+ return ($_[2] == 1 ? $_[0] : $_[1])
+ }
+ };
}
sub gettext {
@@ -1856,6 +1866,11 @@ sub gettext {
gettext(@_);
}
+sub ngettext {
+ define_gettext();
+ ngettext(@_);
+}
+
sub yesno ($) {
my $val=shift;
@@ -2274,11 +2289,13 @@ sub match_user ($$;@) {
my $user=shift;
my %params=@_;
+ my $regexp=IkiWiki::glob2re($user);
+
if (! exists $params{user}) {
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");
}
elsif (! defined $params{user}) {