finializing openid nickname support
authorJoey Hess <joey@kitenet.net>
Thu, 24 Jun 2010 00:12:26 +0000 (20:12 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 24 Jun 2010 00:16:01 +0000 (20:16 -0400)
Renamed usershort => nickname.

Note that this means existing user login sessions will not have the nickname
recorded, and so it won't be used for those.

IkiWiki/Plugin/comments.pm
IkiWiki/Plugin/git.pm
IkiWiki/Plugin/openid.pm
IkiWiki/Plugin/recentchanges.pm
debian/changelog
doc/ikiwiki/directive/comment.mdwn
doc/plugins/write.mdwn

index 41c6948e846557703717cb7ad83f1e41ca477c82..d34951570da77d1f9a423b874d362bd1b800aec8 100644 (file)
@@ -177,7 +177,7 @@ sub preprocess {
                if (defined $oiduser) {
                        # looks like an OpenID
                        $commentauthorurl = $commentuser;
                if (defined $oiduser) {
                        # looks like an OpenID
                        $commentauthorurl = $commentuser;
-                       $commentauthor = $oiduser;
+                       $commentauthor = (defined $params{nickname} && length $params{nickname}) ? $params{nickname} : $oiduser;
                        $commentopenid = $commentuser;
                }
                else {
                        $commentopenid = $commentuser;
                }
                else {
@@ -396,12 +396,16 @@ sub editcomment ($$) {
 
        my $content = "[[!comment format=$type\n";
 
 
        my $content = "[[!comment format=$type\n";
 
-       # FIXME: handling of double quotes probably wrong?
        if (defined $session->param('name')) {
                my $username = $session->param('name');
                $username =~ s/"/&quot;/g;
                $content .= " username=\"$username\"\n";
        }
        if (defined $session->param('name')) {
                my $username = $session->param('name');
                $username =~ s/"/&quot;/g;
                $content .= " username=\"$username\"\n";
        }
+       if (defined $session->param('nickname')) {
+               my $nickname = $session->param('nickname');
+               $nickname =~ s/"/&quot;/g;
+               $content .= " nickname=\"$nickname\"\n";
+       }
        elsif (defined $session->remote_addr()) {
                my $ip = $session->remote_addr();
                if ($ip =~ m/^([.0-9]+)$/) {
        elsif (defined $session->remote_addr()) {
                my $ip = $session->remote_addr();
                if ($ip =~ m/^([.0-9]+)$/) {
index 3e289e0c3f630adb9f0284f81f7233338fb70e38..8d210cb5d9d2d916897a48eb281289be34f088ae 100644 (file)
@@ -606,12 +606,16 @@ sub rcs_recentchanges ($) {
                        push @messages, { line => $line };
                }
 
                        push @messages, { line => $line };
                }
 
-               my $user=$ci->{'author_name'};
-               my $usershort=$ci->{'author_username'};
+               my $user=$ci->{'author_username'};
                my $web_commit = ($ci->{'author'} =~ /\@web>/);
                my $web_commit = ($ci->{'author'} =~ /\@web>/);
-
-               if ($usershort =~ /:\/\//) {
-                       $usershort=undef; # url; not really short
+               my $nickname;
+
+               # Set nickname only if a non-url author_username is available,
+               # and author_name is an url.
+               if ($user !~ /:\/\// && defined $ci->{'author_name'} &&
+                   $ci->{'author_name'} =~ /:\/\//) {
+                       $nickname=$user;
+                       $user=$ci->{'author_name'};
                }
 
                # compatability code for old web commit messages
                }
 
                # compatability code for old web commit messages
@@ -626,7 +630,7 @@ sub rcs_recentchanges ($) {
                push @rets, {
                        rev        => $sha1,
                        user       => $user,
                push @rets, {
                        rev        => $sha1,
                        user       => $user,
-                       usershort  => $usershort,
+                       nickname   => $nickname,
                        committype => $web_commit ? "web" : "git",
                        when       => $when,
                        message    => [@messages],
                        committype => $web_commit ? "web" : "git",
                        when       => $when,
                        message    => [@messages],
index f19a559a9e325d2bac6e1309a124e9ed22ed7ac1..d393afd2363be34a455d76f9b4442a54d00366ce 100644 (file)
@@ -187,16 +187,16 @@ sub auth ($$) {
                                        $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
                                );
                        }
                                        $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
                                );
                        }
-                       my $username;
+                       my $nickname;
                        foreach my $ext (@extensions) {
                                foreach my $field (qw{value.email email}) {
                                        if (exists $ext->{$field} &&
                                            defined $ext->{$field} &&
                                            length $ext->{$field}) {
                                                $session->param(email => $ext->{$field});
                        foreach my $ext (@extensions) {
                                foreach my $field (qw{value.email email}) {
                                        if (exists $ext->{$field} &&
                                            defined $ext->{$field} &&
                                            length $ext->{$field}) {
                                                $session->param(email => $ext->{$field});
-                                               if (! defined $username &&
+                                               if (! defined $nickname &&
                                                    $ext->{$field}=~/(.+)@.+/) {
                                                    $ext->{$field}=~/(.+)@.+/) {
-                                                       $username = $1;
+                                                       $nickname = $1;
                                                }
                                                last;
                                        }
                                                }
                                                last;
                                        }
@@ -205,14 +205,14 @@ sub auth ($$) {
                                        if (exists $ext->{$field} &&
                                            defined $ext->{$field} &&
                                            length $ext->{$field}) {
                                        if (exists $ext->{$field} &&
                                            defined $ext->{$field} &&
                                            length $ext->{$field}) {
-                                               $username=$ext->{$field};
+                                               $nickname=$ext->{$field};
                                                last;
                                        }
                                }
                        }
                                                last;
                                        }
                                }
                        }
-                       if (defined $username) {
-                               $username=~s/\s+/_/g;
-                               $session->param(username => $username);
+                       if (defined $nickname) {
+                               $nickname=~s/\s+/_/g;
+                               $session->param(nickname => $nickname);
                        }
                }
                else {
                        }
                }
                else {
index 9f188cbffab91b626f3f61ba6ad5b123ed492a30..758b98348d126aa572a537f9f0b359e5baffbb5e 100644 (file)
@@ -118,7 +118,7 @@ sub store ($$$) {
        my $oiduser=eval { IkiWiki::openiduser($change->{user}) };
        if (defined $oiduser) {
                $change->{authorurl}=$change->{user};
        my $oiduser=eval { IkiWiki::openiduser($change->{user}) };
        if (defined $oiduser) {
                $change->{authorurl}=$change->{user};
-               $change->{user}=defined $change->{usershort} ? $change->{usershort} : $oiduser;
+               $change->{user}=defined $change->{nickname} ? $change->{nickname} : $oiduser;
        }
        elsif (length $config{cgiurl}) {
                $change->{authorurl} = IkiWiki::cgiurl(
        }
        elsif (length $config{cgiurl}) {
                $change->{authorurl} = IkiWiki::cgiurl(
index dfa862e5b65f785bd9a6f34f5016a78e24ad2ead..e41de638f1218d2c771732606cd97e659f97dfac 100644 (file)
@@ -1,12 +1,16 @@
 ikiwiki (3.20100624) UNRELEASED; urgency=low
 
 ikiwiki (3.20100624) UNRELEASED; urgency=low
 
-  * API: Add new optional field usershort to rcs_recentchanges.
+  * Changes to avoid display of ugly google openids, by displaying
+    a username taken from openid.
+  * API: Add new optional field nickname to rcs_recentchanges.
   * API: rcs_commit and rcs_commit_staged are now passed named
     parameters.
   * API: rcs_commit and rcs_commit_staged are now passed named
     parameters.
+  * openid: Store nickname based on username or email provided from
+    openid provider.
+  * git: Record the nickname from openid in the git author email.
+  * comment: Record the username from openid in the comment page.
   * Fixed some confusion and bugginess about whether
     rcs_getctime/rcs_getmtime were passed absolute or relative filenames.
   * Fixed some confusion and bugginess about whether
     rcs_getctime/rcs_getmtime were passed absolute or relative filenames.
-  * git: Record the username from openid in the git author email.
-    (This avoids display of ugly google openids.)
 
  -- Joey Hess <joeyh@debian.org>  Wed, 23 Jun 2010 15:30:04 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Wed, 23 Jun 2010 15:30:04 -0400
 
index 693a927706f605ffa50b3e57c42d4006316f6884..398130e2e820059f7498d71b2ce89d4246649dc4 100644 (file)
@@ -29,6 +29,8 @@ metadata of the comment.
   nearly any format, since it's parsed by [[!cpan TimeDate]]
 * `username` - Used to record the username (or OpenID)
   of a logged in commenter.
   nearly any format, since it's parsed by [[!cpan TimeDate]]
 * `username` - Used to record the username (or OpenID)
   of a logged in commenter.
+* `nickname` - Name to display for a logged in commenter.
+  (Optional; used for OpenIDs.)
 * `ip` - Can be used to record the IP address of a commenter,
   if they posted anonymously.
 * `claimedauthor` - Records the name that the user entered,
 * `ip` - Can be used to record the IP address of a commenter,
   if they posted anonymously.
 * `claimedauthor` - Records the name that the user entered,
index a2b954bd43115677d23680e77d3e219cdc88c15e..a921b9a0272098e191987c80066c6e7931cafa2e 100644 (file)
@@ -1108,7 +1108,7 @@ The data structure returned for each change is:
        {
                rev => # the RCSs id for this commit
                user => # user who made the change (may be an openid),
        {
                rev => # the RCSs id for this commit
                user => # user who made the change (may be an openid),
-               usershort => # short name of user (optional; not an openid),
+               nickname => # short name for user (optional; not an openid),
                
                committype => # either "web" or the name of the rcs,
                when => # time when the change was made,
                
                committype => # either "web" or the name of the rcs,
                when => # time when the change was made,