From 3df7d143469d8d659a9a70cae24b71ddcb73f70e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 27 Nov 2011 14:14:47 +0000 Subject: Support private, group, public as values for umask These are equivalent to octal 077, 027 and 022, but easier to get from YAML. Signed-off-by: Simon McVittie --- IkiWiki.pm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 637d56c73..59fefc699 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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->() }); -- cgit v1.2.3 From 5333c113d62acd0b82551e499863abaf749a6a1f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 12 Nov 2011 15:11:02 +0000 Subject: Add path and path_natural sort orders (cherry picked from commit 272e0b2f17c33c625b494b07f581da400066a216) --- IkiWiki.pm | 1 + IkiWiki/Plugin/sortnaturally.pm | 5 +++++ doc/ikiwiki/pagespec/sorting.mdwn | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 59fefc699..08e242a1f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2808,6 +2808,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} } diff --git a/IkiWiki/Plugin/sortnaturally.pm b/IkiWiki/Plugin/sortnaturally.pm index b038b2f9a..108b489f8 100644 --- a/IkiWiki/Plugin/sortnaturally.pm +++ b/IkiWiki/Plugin/sortnaturally.pm @@ -30,4 +30,9 @@ sub cmp_title_natural { IkiWiki::pagetitle(IkiWiki::basename($b))) } +sub cmp_path_natural { + Sort::Naturally::ncmp(IkiWiki::pagetitle($a), + IkiWiki::pagetitle($b)) +} + 1; diff --git a/doc/ikiwiki/pagespec/sorting.mdwn b/doc/ikiwiki/pagespec/sorting.mdwn index ccd7f7eaa..0c6cc74c7 100644 --- a/doc/ikiwiki/pagespec/sorting.mdwn +++ b/doc/ikiwiki/pagespec/sorting.mdwn @@ -7,10 +7,14 @@ orders can be specified. * `mtime` - List pages with the most recently modified first. -* `title` - Order by title (page name). +* `title` - Order by title (page name), e.g. "z/a a/b a/c" + +* `path` - Order by page name including parents, e.g. "a/b a/c z/a" [[!if test="enabled(sortnaturally)" then=""" * `title_natural` - Orders by title, but numbers in the title are treated as such, ("1 2 9 10 20" instead of "1 10 2 20 9") + +* `path_natural` - Like `path`, but numbers in the title are treated as such """]] [[!if test="enabled(meta)" then=""" * `meta(title)` - Order according to the `\[[!meta title="foo" sortas="bar"]]` -- cgit v1.2.3 From 17fb0cf9f9897121d9996e8c23ac0056d29acd7b Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 13 Jan 2012 11:02:11 +0100 Subject: backlink(.) should behave like backlink() Since commit c4d4cad3befbbd444d094cbeb0b6ebba3910a025, the single dot in a pagespec can be used to mean the current page. While this worked correctly in link() it didn't work in backlink(). Fix this by explicitly checking the testpage in backlink against . and replacing it with the current location if necessary. --- IkiWiki.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 08e242a1f..bc56501da 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2647,8 +2647,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; } -- cgit v1.2.3 From a78126c55ecbe014ab2a214f324b32762e6a268d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Jan 2012 15:08:50 -0400 Subject: calendar, prettydate: Fix strftime encoding bug strftime is a C function, it does not return decoded utf8. Several places in ikiwiki manually decoded it, but at least two forgot to. Also, strftime might not return even encoded utf8, if LC_TIME is set to a non-utf8 value. Went ahead and supported decoding whatever encoding it uses. The remaining direct calls to strftime() are all ones that first set LC_TIME=C, in order to get times that are not for human display. --- IkiWiki.pm | 16 +++++++++++++--- IkiWiki/Plugin/calendar.pm | 15 +++++++-------- IkiWiki/Plugin/comments.pm | 3 +-- IkiWiki/Plugin/prettydate.pm | 4 ++-- debian/changelog | 1 + doc/bugs/Encoding_problem_in_calendar_plugin.mdwn | 4 ++++ ...Encoding_problem_in_french_with_ikiwiki-calendar.mdwn | 3 +++ 7 files changed, 31 insertions(+), 15 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index bc56501da..0a788f35b 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 @@ -1148,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 ($) { diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c7d2b7c01..fc497b3c7 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -22,7 +22,6 @@ use warnings; use strict; use IkiWiki 3.00; use Time::Local; -use POSIX (); my $time=time; my @now=localtime($time); @@ -123,10 +122,10 @@ sub format_month (@) { } # Find out month names for this, next, and previous months - my $monthabbrev=POSIX::strftime("%b", @monthstart); - my $monthname=POSIX::strftime("%B", @monthstart); - my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900))); - my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900))); + my $monthabbrev=strftime_utf8("%b", @monthstart); + my $monthname=strftime_utf8("%B", @monthstart); + my $pmonthname=strftime_utf8("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900))); + my $nmonthname=strftime_utf8("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900))); my $archivebase = 'archives'; $archivebase = $config{archivebase} if defined $config{archivebase}; @@ -182,7 +181,7 @@ EOF my %dowabbr; for my $dow ($week_start_day..$week_start_day+6) { my @day=localtime(timelocal(0,0,0,$start_day++,$params{month}-1,$params{year}-1900)); - my $downame = POSIX::strftime("%A", @day); + my $downame = strftime_utf8("%A", @day); my $dowabbr = substr($downame, 0, 1); $downame{$dow % 7}=$downame; $dowabbr{$dow % 7}=$dowabbr; @@ -329,8 +328,8 @@ EOF for (my $month = 1; $month <= 12; $month++) { my @day=localtime(timelocal(0,0,0,15,$month-1,$params{year}-1900)); my $murl; - my $monthname = POSIX::strftime("%B", @day); - my $monthabbr = POSIX::strftime("%b", @day); + my $monthname = strftime_utf8("%B", @day); + my $monthabbr = strftime_utf8("%b", @day); $calendar.=qq{\t\n} if ($month % $params{months_per_row} == 1); my $tag; my $mtag=sprintf("%02d", $month); diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 3ad2a0e13..91a482ed6 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -9,7 +9,6 @@ use warnings; use strict; use IkiWiki 3.00; use Encode; -use POSIX qw(strftime); use constant PREVIEW => "Preview"; use constant POST_COMMENT => "Post comment"; @@ -460,7 +459,7 @@ sub editcomment ($$) { } $content .= " subject=\"$subject\"\n"; - $content .= " date=\"" . decode_utf8(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime)) . "\"\n"; + $content .= " date=\"" . strftime_utf8('%Y-%m-%dT%H:%M:%SZ', gmtime) . "\"\n"; my $editcontent = $form->field('editcontent'); $editcontent="" if ! defined $editcontent; diff --git a/IkiWiki/Plugin/prettydate.pm b/IkiWiki/Plugin/prettydate.pm index 82d8a3df3..b0931cb55 100644 --- a/IkiWiki/Plugin/prettydate.pm +++ b/IkiWiki/Plugin/prettydate.pm @@ -118,10 +118,10 @@ sub IkiWiki::formattime ($;$) { } } - $t=~s{\%A-}{my @yest=@t; $yest[6]--; strftime("%A", \@yest)}eg; + $t=~s{\%A-}{my @yest=@t; $yest[6]--; strftime_utf8("%A", \@yest)}eg; $format=~s/\%X/$t/g; - return strftime($format, \@t); + return strftime_utf8($format, \@t); } 1 diff --git a/debian/changelog b/debian/changelog index 1765142a4..57fe7861c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ ikiwiki (3.20120116) UNRELEASED; urgency=low * Switch to YAML::XS to work around insanity in YAML::Mo. Closes: #657533 * cvs: Ensure non-text files are added in binary mode. (Amitai Schlair) * cvs: Various cleanups and testing. (Amitai Schlair) + * calendar, prettydate: Fix strftime encoding bug. -- Joey Hess Mon, 16 Jan 2012 13:41:14 -0400 diff --git a/doc/bugs/Encoding_problem_in_calendar_plugin.mdwn b/doc/bugs/Encoding_problem_in_calendar_plugin.mdwn index 2ccc43c03..80e9f2c82 100644 --- a/doc/bugs/Encoding_problem_in_calendar_plugin.mdwn +++ b/doc/bugs/Encoding_problem_in_calendar_plugin.mdwn @@ -11,6 +11,10 @@ The problem is that I do not know Perl, encoding is one of the thing I would be Cheers, Louis +> Yes, this seems basically right. I've applied a modified version of this. +> [[done]] +> --[[Joey]] + diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c7d2b7c..1345939 100644 diff --git a/doc/forum/Encoding_problem_in_french_with_ikiwiki-calendar.mdwn b/doc/forum/Encoding_problem_in_french_with_ikiwiki-calendar.mdwn index 7e21644ac..472412de1 100644 --- a/doc/forum/Encoding_problem_in_french_with_ikiwiki-calendar.mdwn +++ b/doc/forum/Encoding_problem_in_french_with_ikiwiki-calendar.mdwn @@ -15,3 +15,6 @@ Is someone could test it and verify if it works or not? Thanks. Zut + +> This was discussed in [[bugs/Encoding_problem_in_calendar_plugin]] +> and is now fixed. --[[Joey]] -- cgit v1.2.3 From 3200515b3d447eea032f96ebff17d9bfa8ea255b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 1 Feb 2012 22:47:21 -0400 Subject: fix typo in LC_TIME locale lookup --- IkiWiki.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 0a788f35b..2a83777e6 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1156,7 +1156,7 @@ sub strftime_utf8 { # strftime doesn't know about encodings, so make sure # 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#\.([^@]+)# + ($strftime_encoding) = POSIX::setlocale(&POSIX::LC_TIME) =~ m#\.([^@]+)# unless defined $strftime_encoding; $strftime_encoding ? Encode::decode($strftime_encoding, POSIX::strftime(@_)) -- cgit v1.2.3