From 793e9332c3fc6db6733dce6783d6ac9c8058bb8d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 9 Mar 2009 13:52:51 -0400 Subject: avoid uninitialized value warnings --- IkiWiki/Plugin/404.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/404.pm b/IkiWiki/Plugin/404.pm index 5550ea7d1..bae9e15d1 100644 --- a/IkiWiki/Plugin/404.pm +++ b/IkiWiki/Plugin/404.pm @@ -67,7 +67,8 @@ sub cgi_page_from_404 ($$$) { sub cgi ($) { my $cgi=shift; - if ($ENV{REDIRECT_STATUS} eq '404') { + if (exists $ENV{REDIRECT_STATUS} && + $ENV{REDIRECT_STATUS} eq '404') { my $page = cgi_page_from_404($ENV{REDIRECT_URL}, $config{url}, $config{usedirs}); IkiWiki::Plugin::goto::cgi_goto($cgi, $page); -- cgit v1.2.3 From 7bd0d536442493a8898981a8a784bf16126085c5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 9 Mar 2009 14:01:40 -0400 Subject: git: Fix utf-8 encoding of author names. I guess what's happening here is that since the name is passed to git via an environment variable, perl's normal utf-8 IO layer stuff doesn't work. So we have to explicitly decode the string from perl's internal representation into utf-8. --- IkiWiki/Plugin/git.pm | 2 +- debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 042c69f5a..12f3a74cb 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -447,7 +447,7 @@ sub rcs_commit_staged ($$$) { # Set the commit author and email to the web committer. my %env=%ENV; if (defined $user || defined $ipaddr) { - my $u=defined $user ? $user : $ipaddr; + my $u=encode_utf8(defined $user ? $user : $ipaddr); $ENV{GIT_AUTHOR_NAME}=$u; $ENV{GIT_AUTHOR_EMAIL}="$u\@web"; } diff --git a/debian/changelog b/debian/changelog index c66db85a2..a7e7544c6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.08) UNRELEASED; urgency=low + + * git: Fix utf-8 encoding of author names. + + -- Joey Hess Mon, 09 Mar 2009 14:00:21 -0400 + ikiwiki (3.07) unstable; urgency=low * Updated German translation (Kai Wasserbäch). Closes: #518377 -- cgit v1.2.3 From 4ac0b2953131d7a53562ab8918c8e5a49952d8ac Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 9 Mar 2009 14:18:55 -0400 Subject: git: Manually decode git output from utf-8, avoids warning messages on invalidly encoded output. --- IkiWiki/Plugin/git.pm | 12 +++++++----- debian/changelog | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 12f3a74cb..b386ab71b 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -136,14 +136,16 @@ sub safe_git (&@) { } # In parent. + # git output is probably utf-8 encoded, but may contain + # other encodings or invalidly encoded stuff. So do not rely + # on the normal utf-8 IO layer, decode it by hand. + binmode($OUT); + my @lines; while (<$OUT>) { + $_=decode_utf8($_, 0); + chomp; - - # check for invalid utf-8, and toss it back to avoid crashes - if (! utf8::valid($_)) { - $_=encode_utf8($_); - } push @lines, $_; } diff --git a/debian/changelog b/debian/changelog index a7e7544c6..77b5d9fa6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ ikiwiki (3.08) UNRELEASED; urgency=low * git: Fix utf-8 encoding of author names. + * git: Manually decode git output from utf-8, avoids + warning messages on invalidly encoded output. -- Joey Hess Mon, 09 Mar 2009 14:00:21 -0400 -- cgit v1.2.3 From 55b83cb7bd1cd7c60bb45dc22c3745dd80a63fed Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 17 Mar 2009 20:19:11 +0100 Subject: implement sort=title_natural for inline adds a new sorting order, title_natural, that uses Sort::Naturally's ncmp function to provide better sorting for inlines --- IkiWiki/Plugin/inline.pm | 4 ++++ doc/ikiwiki/directive/inline.mdwn | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 2205ebffc..a89e827c1 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -194,6 +194,10 @@ sub preprocess_inline (@) { if (exists $params{sort} && $params{sort} eq 'title') { @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list; } + elsif (exists $params{sort} && $params{sort} eq 'title_natural') { + require Sort::Naturally; + @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @list; + } elsif (exists $params{sort} && $params{sort} eq 'mtime') { @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list; } diff --git a/doc/ikiwiki/directive/inline.mdwn b/doc/ikiwiki/directive/inline.mdwn index 40670e1e7..3f9a9ede5 100644 --- a/doc/ikiwiki/directive/inline.mdwn +++ b/doc/ikiwiki/directive/inline.mdwn @@ -87,7 +87,10 @@ Here are some less often needed parameters: inlining page. * `sort` - Controls how inlined pages are sorted. The default, "age" is to sort newest created pages first. Setting it to "title" will sort pages by - title, and "mtime" sorts most recently modified pages first. + title, and "mtime" sorts most recently modified pages first. If + [Sort::Naturally](http://search.cpan.org/dist/Sort-Naturally/lib/Sort/Naturally.pm) + is installed, `sort` can be set to "title_natural" to sort by title with + numbers treated as such ("1 2 9 10 20" instead of "1 10 2 20 9"). * `reverse` - If set to "yes", causes the sort order to be reversed. * `feedshow` - Specify the maximum number of matching pages to include in the rss/atom feeds. The default is the same as the `show` value above. -- cgit v1.2.3 From bb258b56b29cb01f27bdc0dfd0bced55a88574ed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 19 Mar 2009 15:35:57 -0400 Subject: avoid crashing if Sort::Naturally is not installed --- IkiWiki/Plugin/inline.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a89e827c1..218fd7515 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -195,7 +195,10 @@ sub preprocess_inline (@) { @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list; } elsif (exists $params{sort} && $params{sort} eq 'title_natural') { - require Sort::Naturally; + eval q{use Sort::Naturally}; + if ($@) { + error(gettext("Sort::Naturally needed for title_natural sort")); + } @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @list; } elsif (exists $params{sort} && $params{sort} eq 'mtime') { -- cgit v1.2.3 From a1c8520ce8798dcd2d6b16a59da93afbd4bbf86b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 19 Mar 2009 16:01:23 -0400 Subject: inline: Fix urls to feed when feedfile is used on an index page. It would be better to use urlto() here, but will_render has not yet been called on the feed files at this point, so it won't work. (And reorganizing so it can be is tricky.) --- IkiWiki/Plugin/inline.pm | 4 ++-- debian/changelog | 1 + doc/bugs/feedfile_does_the_wrong_thing_from_index.mdwn2.mdwn | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 218fd7515..9d7d4b0fd 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -281,8 +281,8 @@ sub preprocess_inline (@) { } } - my $rssurl=basename($feedbase."rss".$feednum) if $feeds && $rss; - my $atomurl=basename($feedbase."atom".$feednum) if $feeds && $atom; + my $rssurl=abs2rel($feedbase."rss".$feednum, dirname(htmlpage($params{destpage}))) if $feeds && $rss; + my $atomurl=abs2rel($feedbase."atom".$feednum, dirname(htmlpage($params{destpage}))) if $feeds && $atom; my $ret=""; diff --git a/debian/changelog b/debian/changelog index 8266afa09..06707a83c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ ikiwiki (3.09) UNRELEASED; urgency=low * inline: Add title_natural sort order, using Sort::Naturally (chrysn) + * inline: Fix urls to feed when feedfile is used on an index page. -- Joey Hess Thu, 19 Mar 2009 15:32:49 -0400 diff --git a/doc/bugs/feedfile_does_the_wrong_thing_from_index.mdwn2.mdwn b/doc/bugs/feedfile_does_the_wrong_thing_from_index.mdwn2.mdwn index 1653e0b02..6b8781a8c 100644 --- a/doc/bugs/feedfile_does_the_wrong_thing_from_index.mdwn2.mdwn +++ b/doc/bugs/feedfile_does_the_wrong_thing_from_index.mdwn2.mdwn @@ -3,3 +3,5 @@ When I put the following !inline in my index.mdwn, it generate a file called index/graphics.rss. However, the link in the RSS button is to graphics.rss (i.e., not in the index/ directory). `\[[!inline pages="link(tags/graphics) and ./posts/* and !*/Discussion" show="10" feedfile=graphics feedonly=yes]]` + +[[done]] --[[Joey]] -- cgit v1.2.3 From 2c86616a6a10397e47017cbccf0cbfd7992a497b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 20 Mar 2009 16:24:19 -0400 Subject: fix rcs_getctime to return first, not last, change time This was being buggy and returning the file's last change time, not its creation time. --- IkiWiki/Plugin/mercurial.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index 6c4855e57..11fdec529 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -236,7 +236,7 @@ sub rcs_getctime ($) { # XXX filename passes through the shell here, should try to avoid # that just in case - my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", '1', + my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "--style", "default", "$config{srcdir}/$file"); open (my $out, "@cmdline |"); @@ -249,7 +249,7 @@ sub rcs_getctime ($) { eval q{use Date::Parse}; error($@) if $@; - my $ctime = str2time($log[0]->{"date"}); + my $ctime = str2time($log[$#log]->{"date"}); return $ctime; } -- cgit v1.2.3 From a2c0423e541006f5d1c0c99f4bb07aadfb0cc733 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 20 Mar 2009 16:32:37 -0400 Subject: fix rcs_getctime to return first, not last, change time This was being buggy and returning the file's last change time, not its creation time. (I checked all the others (except tla) and they're ok.) --- IkiWiki/Plugin/git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index b386ab71b..68b114a73 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -594,8 +594,8 @@ sub rcs_getctime ($) { # Remove srcdir prefix $file =~ s/^\Q$config{srcdir}\E\/?//; - my $sha1 = git_sha1($file); - my $ci = git_commit_info($sha1, 1); + my @sha1s = run_or_non('git', 'rev-list', 'HEAD', '--', $file); + my $ci = git_commit_info($sha1s[$#sha1s], 1); my $ctime = $ci->{'author_epoch'}; debug("ctime for '$file': ". localtime($ctime)); -- cgit v1.2.3 From 503d83ffbc358714ad84e46ce523b8702268edb6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Mar 2009 14:04:28 -0400 Subject: comments: Fix too loose test for comments pages that matched normal pages with "comment_" in their name. Closes: #521322 --- IkiWiki/Plugin/comments.pm | 2 +- debian/changelog | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index ee53dbc91..5782d9083 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -672,7 +672,7 @@ sub previewcomment ($$$) { sub commentsshown ($) { my $page=shift; - return ! pagespec_match($page, "*/$config{comments_pagename}*", + return ! pagespec_match($page, "internal(*/$config{comments_pagename}*)", location => $page) && pagespec_match($page, $config{comments_pagespec}, location => $page); diff --git a/debian/changelog b/debian/changelog index 01404a2b4..4ba32c8d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ ikiwiki (3.09) UNRELEASED; urgency=low not last commit time. * Updated French translation (Jean-Luc Coulon). Closes: #521072 * css: Add clear: both to inlinefooter. + * comments: Fix too loose test for comments pages that matched + normal pages with "comment_" in their name. Closes: #521322 -- Joey Hess Thu, 19 Mar 2009 15:32:49 -0400 -- cgit v1.2.3 From 10822a22b3d8872afb31e1847ee7448af86c574d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Mar 2009 16:45:53 -0400 Subject: comments: Fix anchor ids to be legal xhtml. Closes: #521339 Well, that was a PITA. Luckily, this doesn't break guids to comments in rss feeds, though it does change the links. I haven't put in a warning about needing to rebuild to get this fix. It's probably good enough for new comments to get the fix, without a lot of mass rebuilding. --- IkiWiki/Plugin/comments.pm | 24 ++++++++++++++++++++++-- debian/changelog | 1 + templates/comment.tmpl | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 5782d9083..2ad422f5f 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -224,7 +224,7 @@ sub preprocess { if ($params{page} =~ m/\/(\Q$config{comments_pagename}\E\d+)$/) { $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page}), undef, 1). - "#".$params{page}; + "#".page_to_id($params{page}); } eval q{use Date::Parse}; @@ -490,7 +490,8 @@ sub editcomment ($$) { # Jump to the new comment on the page. # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - IkiWiki::redirect($cgi, urlto($page, undef, 1)."?updated#$location"); + IkiWiki::redirect($cgi, urlto($page, undef, 1). + "?updated#".page_to_id($location)); } else { @@ -759,6 +760,10 @@ sub pagetemplate (@) { if (!exists $commentstate{$page}) { return; } + + if ($template->query(name => 'commentid')) { + $template->param(commentid => page_to_id($page)); + } if ($template->query(name => 'commentuser')) { $template->param(commentuser => @@ -808,6 +813,21 @@ sub unique_comment_location ($) { return $location; } +sub page_to_id ($) { + # Converts a comment page name into a unique, legal html id + # addtibute value, that can be used as an anchor to link to the + # comment. + my $page=shift; + + # It needs to start with a letter. + $page="comment_".$page; + + # Encode any illegal characters. + $page=~s/([^A-Za-z0-9-_:.])/"__".ord($1)."__"/eg; + + return $page; +} + package IkiWiki::PageSpec; sub match_postcomment ($$;@) { diff --git a/debian/changelog b/debian/changelog index 4ba32c8d6..158db9a4d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ ikiwiki (3.09) UNRELEASED; urgency=low * css: Add clear: both to inlinefooter. * comments: Fix too loose test for comments pages that matched normal pages with "comment_" in their name. Closes: #521322 + * comments: Fix anchor ids to be legal xhtml. Closes: #521339 -- Joey Hess Thu, 19 Mar 2009 15:32:49 -0400 diff --git a/templates/comment.tmpl b/templates/comment.tmpl index 1b9064ea0..fb76ea004 100644 --- a/templates/comment.tmpl +++ b/templates/comment.tmpl @@ -1,4 +1,4 @@ -
+
-- cgit v1.2.3 From 260ee2a28368691a5f1a7dee918717a28d28ed2e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 27 Mar 2009 13:44:31 -0400 Subject: use md5sum for page_to_id The munged ids were looking pretty nasty, and were not completly guaranteed to be unique. So a md5sum seems like a better approach. (Would have used sha1, but md5 is in perl core.) --- IkiWiki/Plugin/comments.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 2ad422f5f..98f9f8b3d 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -819,13 +819,10 @@ sub page_to_id ($) { # comment. my $page=shift; - # It needs to start with a letter. - $page="comment_".$page; - - # Encode any illegal characters. - $page=~s/([^A-Za-z0-9-_:.])/"__".ord($1)."__"/eg; + eval q{use Digest::MD5 'md5_hex'}; + error($@) if $@; - return $page; + return "comment-".md5_hex($page); } package IkiWiki::PageSpec; -- cgit v1.2.3