Merge commit 'smcv/comments'

master
Joey Hess 2008-12-20 17:58:56 -05:00
commit 0f03af3816
6 changed files with 60 additions and 42 deletions

View File

@ -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});

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

View File

@ -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=COMMENTAUTHOR>
</TMPL_IF>
</TMPL_IF>
</span>
<TMPL_ELSE><!-- !COMMENTUSER -->
<TMPL_IF NAME=COMMENTIP>
<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>
<TMPL_VAR NAME=AUTHOR>
</TMPL_IF>
</span>
<TMPL_ELSE>
<TMPL_IF NAME=COMMENTIP>
<span class="author">
<TMPL_VAR NAME=COMMENTIP>
</span>
<TMPL_ELSE>
unknown IP address
</TMPL_IF>
<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>

View File

@ -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>