diff options
author | Joey Hess <joey@kitenet.net> | 2010-06-23 20:12:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-06-23 20:16:01 -0400 |
commit | 9a32451986c710d1f1ce71217c1f7ab3b84f72bf (patch) | |
tree | c3bf789d7d0e247327d94e5ff696ba50aba81526 /IkiWiki/Plugin | |
parent | a4f381ace837a032bc202cc6b2a98e922d4b7cfc (diff) |
finializing openid nickname support
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.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/comments.pm | 8 | ||||
-rw-r--r-- | IkiWiki/Plugin/git.pm | 16 | ||||
-rw-r--r-- | IkiWiki/Plugin/openid.pm | 14 | ||||
-rw-r--r-- | IkiWiki/Plugin/recentchanges.pm | 2 |
4 files changed, 24 insertions, 16 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 41c6948e8..d34951570 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -177,7 +177,7 @@ sub preprocess { if (defined $oiduser) { # looks like an OpenID $commentauthorurl = $commentuser; - $commentauthor = $oiduser; + $commentauthor = (defined $params{nickname} && length $params{nickname}) ? $params{nickname} : $oiduser; $commentopenid = $commentuser; } else { @@ -396,12 +396,16 @@ sub editcomment ($$) { 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/"/"/g; $content .= " username=\"$username\"\n"; } + if (defined $session->param('nickname')) { + my $nickname = $session->param('nickname'); + $nickname =~ s/"/"/g; + $content .= " nickname=\"$nickname\"\n"; + } elsif (defined $session->remote_addr()) { my $ip = $session->remote_addr(); if ($ip =~ m/^([.0-9]+)$/) { diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 3e289e0c3..8d210cb5d 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -606,12 +606,16 @@ sub rcs_recentchanges ($) { 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>/); - - 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 @@ -626,7 +630,7 @@ sub rcs_recentchanges ($) { push @rets, { rev => $sha1, user => $user, - usershort => $usershort, + nickname => $nickname, committype => $web_commit ? "web" : "git", when => $when, message => [@messages], diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index f19a559a9..d393afd23 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -187,16 +187,16 @@ sub auth ($$) { $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}); - if (! defined $username && + if (! defined $nickname && $ext->{$field}=~/(.+)@.+/) { - $username = $1; + $nickname = $1; } last; } @@ -205,14 +205,14 @@ sub auth ($$) { if (exists $ext->{$field} && defined $ext->{$field} && length $ext->{$field}) { - $username=$ext->{$field}; + $nickname=$ext->{$field}; last; } } } - if (defined $username) { - $username=~s/\s+/_/g; - $session->param(username => $username); + if (defined $nickname) { + $nickname=~s/\s+/_/g; + $session->param(nickname => $nickname); } } else { diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 9f188cbff..758b98348 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -118,7 +118,7 @@ sub store ($$$) { 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( |