X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b34d31142b9fed28ec9cf77fe0c5d9f405d48c84..ea166ca334934a5950ee4756a7291fc69961e77c:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm old mode 100644 new mode 100755 index 8f475aa56..bccb977e3 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -167,6 +167,7 @@ sub preprocess { my $commentip; my $commentauthor; my $commentauthorurl; + my $commentauthoravatar; my $commentopenid; if (defined $params{username}) { $commentuser = $params{username}; @@ -187,6 +188,17 @@ sub preprocess { $commentauthor = $commentuser; } + + eval 'use Libravatar::URL'; + + if (! $@) { + if (defined $commentopenid) { + $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $ENV{HTTPS}); + } + elsif (my $email = IkiWiki::userinfo_get($commentuser, 'email')) { + $commentauthoravatar = libravatar_url(email => $email, https => $ENV{HTTPS}); + } + } } else { if (defined $params{ip}) { @@ -200,6 +212,7 @@ sub preprocess { $commentstate{$page}{commentip} = $commentip; $commentstate{$page}{commentauthor} = $commentauthor; $commentstate{$page}{commentauthorurl} = $commentauthorurl; + $commentstate{$page}{commentauthoravatar} = $commentauthoravatar; if (! defined $pagestate{$page}{meta}{author}) { $pagestate{$page}{meta}{author} = $commentauthor; } @@ -755,10 +768,8 @@ sub previewcomment ($$$) { sub commentsshown ($) { my $page=shift; - return ! pagespec_match($page, "comment(*)", - location => $page) && - pagespec_match($page, $config{comments_pagespec}, - location => $page); + return pagespec_match($page, $config{comments_pagespec}, + location => $page); } sub commentsopen ($) { @@ -785,7 +796,7 @@ sub pagetemplate (@) { my $comments = undef; if ($shown) { $comments = IkiWiki::preprocess_inline( - pages => "comment($page)", + pages => "comment($page) and !comment($page/*)", template => 'comment', show => 0, reverse => 'yes', @@ -876,6 +887,11 @@ sub pagetemplate (@) { $commentstate{$page}{commentauthorurl}); } + if ($template->query(name => 'commentauthoravatar')) { + $template->param(commentauthoravatar => + $commentstate{$page}{commentauthoravatar}); + } + if ($template->query(name => 'removeurl') && IkiWiki::Plugin::remove->can("check_canremove") && length $config{cgiurl}) { @@ -957,8 +973,7 @@ sub match_comment ($$;@) { } } - return match_glob($page, "$glob/*", internal => 1, @_) && - ! match_glob($page, "$glob/*/*", internal => 1, @_); + return match_glob($page, "$glob/*", internal => 1, @_); } sub match_comment_pending ($$;@) { @@ -973,8 +988,7 @@ sub match_comment_pending ($$;@) { return IkiWiki::FailReason->new("$page is not a pending comment"); } - return match_glob($page, "$glob/*", internal => 1, @_) && - ! match_glob($page, "$glob/*/*", internal => 1, @_); + return match_glob($page, "$glob/*", internal => 1, @_); } 1