_comment directive: if the user looks like an OpenID, store that
authorSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Thu, 18 Dec 2008 19:56:36 +0000 (19:56 +0000)
committerSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Sat, 20 Dec 2008 17:34:54 +0000 (17:34 +0000)
IkiWiki/Plugin/comments.pm

index c50729a34cfe431cbac062a57c63174991db4ec5..336ed1a823c6937b2c79b063fd8fc2aaf3209533 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;