diff options
Diffstat (limited to 'IkiWiki')
-rwxr-xr-x[-rw-r--r--] | IkiWiki/Plugin/comments.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 8d46ed579..bccb977e3 100644..100755 --- 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; } @@ -874,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}) { |