]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Merge commit 'smcv/comments'
authorJoey Hess <joey@gnu.kitenet.net>
Sat, 20 Dec 2008 22:58:56 +0000 (17:58 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Sat, 20 Dec 2008 22:58:56 +0000 (17:58 -0500)
IkiWiki/Plugin/comments.pm
doc/wikiicons/anonymous.png [new file with mode: 0644]
doc/wikiicons/openid.png [new file with mode: 0644]
doc/wikiicons/signedin.png [new file with mode: 0644]
templates/comment.tmpl
templates/page.tmpl

index c50729a34cfe431cbac062a57c63174991db4ec5..4f3b76db3dcb09850c607436632b1887af4f19c6 100644 (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});
diff --git a/doc/wikiicons/anonymous.png b/doc/wikiicons/anonymous.png
new file mode 100644 (file)
index 0000000..df22152
Binary files /dev/null and b/doc/wikiicons/anonymous.png differ
diff --git a/doc/wikiicons/openid.png b/doc/wikiicons/openid.png
new file mode 100644 (file)
index 0000000..c5535c3
Binary files /dev/null and b/doc/wikiicons/openid.png differ
diff --git a/doc/wikiicons/signedin.png b/doc/wikiicons/signedin.png
new file mode 100644 (file)
index 0000000..969908d
Binary files /dev/null and b/doc/wikiicons/signedin.png differ
index 19698cd3352c3575b0412cd9c3ae87ed45087108..2fb54fe7d2f1c2d9c26f1d296a6a25101da6b93b 100644 (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=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>
index 21abc979dc71f66d9ac3aa886a2e2b44e14429b7..f75491127bfd33a921c97bbc1177f48d11874282 100644 (file)
 <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>