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.
master
Joey Hess 2010-06-23 20:12:26 -04:00
parent a4f381ace8
commit 9a32451986
7 changed files with 33 additions and 19 deletions

View File

@ -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]+)$/) {

View File

@ -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>/);
my $nickname;
if ($usershort =~ /:\/\//) {
$usershort=undef; # url; not really short
# 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],

View File

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

View File

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

10
debian/changelog vendored
View File

@ -1,12 +1,16 @@
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.
* 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.
* 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

View 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.
* `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,

View 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),
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,