aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-03-30 10:44:38 -0400
committerJoey Hess <joey@kitenet.net>2011-03-30 10:44:38 -0400
commitea166ca334934a5950ee4756a7291fc69961e77c (patch)
tree47e78e5ee426fc3c19eb8052b04e1b7556788c20
parent080a4cb57947a7991ea5781342af5756ed7213ae (diff)
parente2e1b1cd20928e2b80871e5daffaea60738d054e (diff)
downloadikiwiki-ea166ca334934a5950ee4756a7291fc69961e77c.tar
ikiwiki-ea166ca334934a5950ee4756a7291fc69961e77c.tar.gz
Merge remote-tracking branch 'remotes/fmarier/libravatar-in-comments'
-rwxr-xr-x[-rw-r--r--]IkiWiki/Plugin/comments.pm18
-rw-r--r--doc/style.css3
-rw-r--r--templates/comment.tmpl5
3 files changed, 26 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}) {
diff --git a/doc/style.css b/doc/style.css
index fa413cf24..fcf39be6a 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -247,6 +247,9 @@ span.color {
.comment-subject {
font-weight: bold;
}
+.comment-avatar {
+ float: right;
+}
.comment {
border: 1px solid #aaa;
padding: 3px;
diff --git a/templates/comment.tmpl b/templates/comment.tmpl
index c2ee5a371..c16ca7c81 100644
--- a/templates/comment.tmpl
+++ b/templates/comment.tmpl
@@ -1,6 +1,10 @@
<TMPL_IF HTML5><article class="comment" id="<TMPL_VAR COMMENTID>">
<TMPL_ELSE><div class="comment" id="<TMPL_VAR COMMENTID>"></TMPL_IF>
+<TMPL_IF COMMENTAUTHORAVATAR><div class="comment-avatar">
+<img src="<TMPL_VAR COMMENTAUTHORAVATAR>" alt="" />
+</div></TMPL_IF>
+
<TMPL_IF HTML5><header class="comment-subject"><TMPL_ELSE><div class="comment-subject"></TMPL_IF>
<TMPL_IF PERMALINK>
<a href="<TMPL_VAR PERMALINK>"><TMPL_VAR TITLE></a>
@@ -58,4 +62,5 @@ Comment by
<TMPL_IF HTML5></nav><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
+<div style="clear: both"></div>
<TMPL_IF HTML5></article><TMPL_ELSE></div></TMPL_IF>