aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2012-03-18 15:31:41 +0000
committerSimon McVittie <smcv@debian.org>2012-03-18 15:31:41 +0000
commit4e54fa1144065b7ff99e88e6c61ff1fdcf6175c9 (patch)
tree6759b80b8722ea532385c9a3ccc74897b784967d /IkiWiki.pm
parentd70ba7cff3fc6cc78ea2f8eb0713212478ab6ba7 (diff)
parent0a9bb3edc2a9819ba87de1b6e57155120b6aba44 (diff)
downloadikiwiki-4e54fa1144065b7ff99e88e6c61ff1fdcf6175c9.tar
ikiwiki-4e54fa1144065b7ff99e88e6c61ff1fdcf6175c9.tar.gz
Merge tag '3.20120202' into trail3-integrated
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm50
1 files changed, 41 insertions, 9 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 3d13cb106..2a83777e6 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -20,7 +20,7 @@ use Exporter q{import};
our @EXPORT = qw(hook debug error htmlpage template template_depends
deptype add_depends pagespec_match pagespec_match_list bestlink
htmllink readfile writefile pagetype srcfile pagename
- displaytime will_render gettext ngettext urlto targetpage
+ displaytime strftime_utf8 will_render gettext ngettext urlto targetpage
add_underlay pagetitle titlepage linkpage newpagefile
inject add_link add_autofile
%config %links %pagestate %wikistate %renderedfiles
@@ -305,9 +305,9 @@ sub getsetup () {
rebuild => 0,
},
umask => {
- type => "integer",
- example => "022",
- description => "force ikiwiki to use a particular umask",
+ type => "string",
+ example => "public",
+ description => "force ikiwiki to use a particular umask (keywords public, group or private, or a number)",
advanced => 1,
safe => 0, # paranoia
rebuild => 0,
@@ -587,7 +587,23 @@ sub checkconfig () {
unless exists $config{wikistatedir} && defined $config{wikistatedir};
if (defined $config{umask}) {
- umask(possibly_foolish_untaint($config{umask}));
+ my $u = possibly_foolish_untaint($config{umask});
+
+ if ($u =~ m/^\d+$/) {
+ umask($u);
+ }
+ elsif ($u eq 'private') {
+ umask(077);
+ }
+ elsif ($u eq 'group') {
+ umask(027);
+ }
+ elsif ($u eq 'public') {
+ umask(022);
+ }
+ else {
+ error(sprintf(gettext("unsupported umask setting %s"), $u));
+ }
}
run_hooks(checkconfig => sub { shift->() });
@@ -1132,9 +1148,19 @@ sub formattime ($;$) {
$format=$config{timeformat};
}
+ return strftime_utf8($format, localtime($time));
+}
+
+my $strftime_encoding;
+sub strftime_utf8 {
# strftime doesn't know about encodings, so make sure
- # its output is properly treated as utf8
- return decode_utf8(POSIX::strftime($format, localtime($time)));
+ # its output is properly treated as utf8.
+ # Note that this does not handle utf-8 in the format string.
+ ($strftime_encoding) = POSIX::setlocale(&POSIX::LC_TIME) =~ m#\.([^@]+)#
+ unless defined $strftime_encoding;
+ $strftime_encoding
+ ? Encode::decode($strftime_encoding, POSIX::strftime(@_))
+ : POSIX::strftime(@_);
}
sub date_3339 ($) {
@@ -2631,8 +2657,14 @@ sub match_link ($$;@) {
}
sub match_backlink ($$;@) {
- my $ret=match_link($_[1], $_[0], @_);
- $ret->influences($_[1] => $IkiWiki::DEPEND_LINKS);
+ my $page=shift;
+ my $testpage=shift;
+ my %params=@_;
+ if ($testpage eq '.') {
+ $testpage = $params{'location'}
+ }
+ my $ret=match_link($testpage, $page, @_);
+ $ret->influences($testpage => $IkiWiki::DEPEND_LINKS);
return $ret;
}