X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6d01db205f41f16755fe7fbe49694b3bba2121c8..40ad087b339942c677728518587f99c9d3b723d1:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 8a66dcedb..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 ($) { @@ -1394,7 +1420,8 @@ sub preprocess ($$$;$$) { | '''(.*?)''' # 4: triple-single-quote | - <<(?[a-zA-Z]+)\n(?.*?)\n\k # 5, 6: heredoc'd value. + <<([a-zA-Z]+)\n # 5: heredoc start + (.*?)\n\5 # 6: heredoc value | (\S+) # 7: unquoted value ) @@ -1417,8 +1444,8 @@ sub preprocess ($$$;$$) { elsif (defined $7) { $val=$7; } - elsif (defined $+{heredoc}) { - $val=$+{heredoc}; + elsif (defined $6) { + $val=$6; } if (defined $key) { @@ -1488,9 +1515,10 @@ sub preprocess ($$$;$$) { | "[^"]*?" # single-quoted value | - <<(?[a-zA-Z]+)\n(?.*?)\n\k # heredoc'd value. + '''.*?''' # triple-single-quote | - '''.*?''' # triple-single-quoted value + <<([a-zA-Z]+)\n # 5: heredoc start + (?:.*?)\n\5 # heredoc value | [^"\s\]]+ # unquoted value ) @@ -1515,9 +1543,10 @@ sub preprocess ($$$;$$) { | "[^"]*?" # single-quoted value | - '''.*?''' # triple-single-quoted value + '''.*?''' # triple-single-quote | - <<(?[a-zA-Z]+)\n(?.*?)\n\k # heredoc'd value. + <<([a-zA-Z]+)\n # 5: heredoc start + (?:.*?)\n\5 # heredoc value | [^"\s\]]+ # unquoted value ) @@ -2628,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; } @@ -2789,6 +2824,7 @@ sub cmp_title { IkiWiki::pagetitle(IkiWiki::basename($b)) } +sub cmp_path { IkiWiki::pagetitle($a) cmp IkiWiki::pagetitle($b) } sub cmp_mtime { $IkiWiki::pagemtime{$b} <=> $IkiWiki::pagemtime{$a} } sub cmp_age { $IkiWiki::pagectime{$b} <=> $IkiWiki::pagectime{$a} }