summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/comments.pm52
-rw-r--r--doc/wikiicons/anonymous.pngbin0 -> 302 bytes
-rw-r--r--doc/wikiicons/openid.pngbin0 -> 297 bytes
-rw-r--r--doc/wikiicons/signedin.pngbin0 -> 370 bytes
-rw-r--r--templates/comment.tmpl37
-rw-r--r--templates/page.tmpl9
6 files changed, 58 insertions, 40 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index c50729a34..4f3b76db3 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -151,11 +151,28 @@ sub preprocess {
my $commentip;
my $commentauthor;
my $commentauthorurl;
+ my $commentopenid;
if (defined $params{username}) {
$commentuser = $params{username};
- ($commentauthorurl, $commentauthor) =
- linkuser($params{username});
+
+ my $oiduser = eval { IkiWiki::openiduser($commentuser) };
+
+ if (defined $oiduser) {
+ # looks like an OpenID
+ $commentauthorurl = $commentuser;
+ $commentauthor = $oiduser;
+ $commentopenid = $commentuser;
+ }
+ else {
+ $commentauthorurl = IkiWiki::cgiurl(
+ do => 'commenter',
+ page => (length $config{userdir}
+ ? "$config{userdir}/$commentuser"
+ : "$commentuser"));
+
+ $commentauthor = $commentuser;
+ }
}
else {
if (defined $params{ip}) {
@@ -165,6 +182,7 @@ sub preprocess {
}
$pagestate{$page}{comments}{commentuser} = $commentuser;
+ $pagestate{$page}{comments}{commentopenid} = $commentopenid;
$pagestate{$page}{comments}{commentip} = $commentip;
$pagestate{$page}{comments}{commentauthor} = $commentauthor;
$pagestate{$page}{comments}{commentauthorurl} = $commentauthorurl;
@@ -236,27 +254,6 @@ sub linkcgi ($) {
}
}
-# FIXME: basically the same logic as recentchanges
-# returns (author URL, pretty-printed version)
-sub linkuser ($) {
- my $user = shift;
- my $oiduser = eval { IkiWiki::openiduser($user) };
-
- if (defined $oiduser) {
- return ($user, $oiduser);
- }
- # FIXME: it'd be good to avoid having such a link for anonymous
- # posts
- else {
- return (IkiWiki::cgiurl(
- do => 'commenter',
- page => (length $config{userdir}
- ? "$config{userdir}/$user"
- : "$user")
- ), $user);
- }
-}
-
# Mostly cargo-culted from IkiWiki::plugin::editpage
sub sessioncgi ($$) {
my $cgi=shift;
@@ -551,9 +548,9 @@ sub pagetemplate (@) {
}
if ($shown && commentsopen($page)) {
- my $commenturl = IkiWiki::cgiurl(do => 'comment',
+ my $addcommenturl = IkiWiki::cgiurl(do => 'comment',
page => $page);
- $template->param(commenturl => $commenturl);
+ $template->param(addcommenturl => $addcommenturl);
}
}
@@ -576,6 +573,11 @@ sub pagetemplate (@) {
$pagestate{$page}{comments}{commentuser});
}
+ if ($template->query(name => 'commentopenid')) {
+ $template->param(commentopenid =>
+ $pagestate{$page}{comments}{commentopenid});
+ }
+
if ($template->query(name => 'commentip')) {
$template->param(commentip =>
$pagestate{$page}{comments}{commentip});
diff --git a/doc/wikiicons/anonymous.png b/doc/wikiicons/anonymous.png
new file mode 100644
index 000000000..df22152e6
--- /dev/null
+++ b/doc/wikiicons/anonymous.png
Binary files differ
diff --git a/doc/wikiicons/openid.png b/doc/wikiicons/openid.png
new file mode 100644
index 000000000..c5535c3de
--- /dev/null
+++ b/doc/wikiicons/openid.png
Binary files differ
diff --git a/doc/wikiicons/signedin.png b/doc/wikiicons/signedin.png
new file mode 100644
index 000000000..969908d39
--- /dev/null
+++ b/doc/wikiicons/signedin.png
Binary files differ
diff --git a/templates/comment.tmpl b/templates/comment.tmpl
index 19698cd33..2fb54fe7d 100644
--- a/templates/comment.tmpl
+++ b/templates/comment.tmpl
@@ -2,27 +2,44 @@
<div class="comment-header">
Posted by
+
<TMPL_IF NAME="COMMENTUSER">
<span class="author">
+<TMPL_IF NAME="COMMENTOPENID">
+
+<img src="/wikiicons/openid.png" width="20" height="15" alt="[OpenID]"
+ title="Signed in with OpenID" />
+<a href="<TMPL_VAR NAME=COMMENTOPENID>"><TMPL_VAR NAME=COMMENTAUTHOR></a>
+
+<TMPL_ELSE>
+
+<img src="/wikiicons/signedin.png" width="15" height="15" alt="[Signed in]"
+ title="Signed in directly" />
<TMPL_IF NAME="COMMENTAUTHORURL">
<a href="<TMPL_VAR NAME=COMMENTAUTHORURL>"><TMPL_VAR NAME=COMMENTAUTHOR></a>
<TMPL_ELSE>
-<TMPL_VAR NAME=AUTHOR>
+<TMPL_VAR NAME=COMMENTAUTHOR>
+</TMPL_IF>
+
</TMPL_IF>
</span>
-<TMPL_ELSE>
+
+<TMPL_ELSE><!-- !COMMENTUSER -->
+
<TMPL_IF NAME=COMMENTIP>
-<span class="author">
-<TMPL_VAR NAME=COMMENTIP>
-</span>
+<span class="author" title="Unauthenticated, from <TMPL_VAR NAME=COMMENTIP>">
+<TMPL_ELSE><!-- !COMMENTIP -->
+<span class="author" title="Unauthenticated, from unknown IP address">
+</TMPL_IF>
+<img src="/wikiicons/anonymous.png" width="15" height="15" alt="[Unauthenticated]" />
+<TMPL_IF NAME="AUTHORURL">
+<a href="<TMPL_VAR NAME=AUTHORURL>"><TMPL_VAR NAME=AUTHOR></a>
<TMPL_ELSE>
-unknown IP address
+<TMPL_VAR NAME=AUTHOR>
</TMPL_IF>
+</span>
-<TMPL_IF NAME=AUTHOR>
-(<span class="claimedauthor"><TMPL_IF NAME="AUTHORURL"><a href="<TMPL_VAR NAME=AUTHORURL>"><TMPL_VAR NAME=AUTHOR></a><TMPL_ELSE><TMPL_VAR NAME=AUTHOR></TMPL_IF></span>)
-</TMPL_IF>
-</TMPL_IF>
+</TMPL_IF><!-- !COMMENTUSER -->
(<TMPL_VAR CTIME>)
</div>
diff --git a/templates/page.tmpl b/templates/page.tmpl
index 21abc979d..f75491127 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -74,13 +74,12 @@
<TMPL_IF COMMENTS>
<div id="comments">
<TMPL_VAR COMMENTS>
-<TMPL_UNLESS COMMENTURL>
-<div class="addcomment">Comments on this page are closed.</div>
-</TMPL_UNLESS>
-<TMPL_IF COMMENTURL>
+<TMPL_IF ADDCOMMENTURL>
<div class="addcomment">
-<a href="<TMPL_VAR COMMENTURL>">Add a comment</a>
+<a href="<TMPL_VAR ADDCOMMENTURL>">Add a comment</a>
</div>
+<TMPL_ELSE>
+<div class="addcomment">Comments on this page are closed.</div>
</TMPL_IF>
</div>
</TMPL_IF>