summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/comments.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-20 17:58:56 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-20 17:58:56 -0500
commit0f03af381625bc16d51140a949ded304c3686e7b (patch)
tree4b3d2794ab490e279176337e32e416e6a4879ef7 /IkiWiki/Plugin/comments.pm
parent92b48bab99e04e7c041434e106179822bd2b1e88 (diff)
parentf94665800c9353f2b0f190190c0490f51a897973 (diff)
Merge commit 'smcv/comments'
Diffstat (limited to 'IkiWiki/Plugin/comments.pm')
-rw-r--r--IkiWiki/Plugin/comments.pm52
1 files changed, 27 insertions, 25 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});