summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorFrancois Marier <francois@debian.org>2011-03-05 20:33:07 +1300
committerFrancois Marier <francois@debian.org>2011-03-30 20:59:17 +1300
commit7723e94218a8c526fc8d869086c05dd382268649 (patch)
tree8a4e96e7a2768a642e92f5a12d4182c039264562 /IkiWiki/Plugin
parent3e5197c9671e01c73bdd0c281f56a61b67995c22 (diff)
comments: add avatar picture of comment author
Use Libravatar::URL to pull the avatar picture for the comment author if we have an email address for him/her.
Diffstat (limited to 'IkiWiki/Plugin')
-rwxr-xr-x[-rw-r--r--]IkiWiki/Plugin/comments.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 8d46ed579..00ab1c8bd 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,16 @@ sub preprocess {
$commentauthor = $commentuser;
}
+
+ eval 'use Libravatar::URL';
+
+ if (! $@) {
+ my $email = IkiWiki::userinfo_get($commentuser, 'email');
+
+ if (defined $email) {
+ $commentauthoravatar = libravatar_url(email => $email);
+ }
+ }
}
else {
if (defined $params{ip}) {
@@ -200,6 +211,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 +886,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}) {