Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r9525: LJSUP-6867 (Twitter auth)

Committer: ailyin
LJSUP-6867 (Twitter auth)
U   trunk/cgi-bin/LJ/Client/Twitter/User.pm
U   trunk/cgi-bin/LJ/Client/Twitter.pm
A   trunk/cgi-bin/LJ/Identity/Twitter.pm
U   trunk/cgi-bin/LJ/Setting/TwitterConnect.pm
A   trunk/cgi-bin/LJ/Talk/Author/Twitter.pm
U   trunk/htdocs/identity/callback-facebook.bml
A   trunk/htdocs/identity/callback-twitter.bml
U   trunk/htdocs/identity/login.bml.text
U   trunk/htdocs/identity/login.bml.text.local
A   trunk/htdocs/identity/twitter-interstitial.bml
A   trunk/htdocs/identity/twitter-interstitial.bml.text.local
U   trunk/htdocs/manage/settings/twitter.bml
U   trunk/htdocs/talkpost.bml.text.local
U   trunk/htdocs/userinfo.bml.text.local
A   trunk/templates/CommentForm/Author-Twitter.tmpl
A   trunk/templates/Identity/Login-twitter.tmpl
A   trunk/templates/Identity/TwitterInterstitial.tmpl
Modified: trunk/cgi-bin/LJ/Client/Twitter/User.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Twitter/User.pm	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/cgi-bin/LJ/Client/Twitter/User.pm	2010-09-21 10:44:56 UTC (rev 9525)
@@ -86,6 +86,10 @@
 $twu->time_zone: the user-specified time zone on Twitter; format of
 this has not yet been investigated.
 
+=item *
+
+$twu->userpic: the URL of the userpic ("profile image") of the user.
+
 =back
 
 =head1 SEE ALSO
@@ -115,6 +119,7 @@
         'bio' => $data->{'description'},
         'protected' => $data->{'protected'},
         'time_zone' => $data->{'time_zone'},
+        'userpic' => $data->{'profile_image_url'},
     }, $class;
 }
 
@@ -172,6 +177,11 @@
     return $self->{'time_zone'};
 }
 
+sub userpic {
+    my ($self) = @_;
+    return $self->{'userpic'};
+}
+
 # some simple manipulations on the data
 sub url {
     my ($self) = @_;

Modified: trunk/cgi-bin/LJ/Client/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Twitter.pm	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/cgi-bin/LJ/Client/Twitter.pm	2010-09-21 10:44:56 UTC (rev 9525)
@@ -22,7 +22,9 @@
  use LJ::Client::Twitter;
  
  # request an OAuth request token
- my $req_token = LJ::Client::Twitter->request_request_token;
+ my $req_token = LJ::Client::Twitter->request_request_token(
+    'callback' => $LJ::SITEROOT,
+ );
  
  # redirect to Twitter where one can confirm that they trust us
  LJ::Request->redirect( 'https://api.twitter.com/oauth/authorize?' .
@@ -118,14 +120,14 @@
 }
 
 sub request_request_token {
-    my ($class) = @_;
+    my ($class, %opts) = @_;
 
     _ratelog;
 
     my $request = Net::OAuth::RequestTokenRequest->new(
         $class->default_request_params,
         request_url => 'https://api.twitter.com/oauth/request_token',
-        callback => "$LJ::SITEROOT/manage/settings/twitter.bml?act=connect",
+        callback    => $opts{'callback'},
     );
 
     $request->sign;
@@ -421,4 +423,27 @@
     return [ map { LJ::Client::Twitter::Tweet->from_hash($_) } @$res ];
 }
 
+sub get_userinfo {
+    my ($class, %opts) = @_;
+
+    if (my $u = $opts{'user'}) {
+        $opts{'access_token'} = {
+            'public' => $u->prop('twitter_access_token'),
+            'secret' => $u->prop('twitter_access_token_secret'),
+        };
+    }
+
+    my $access_token = $opts{'access_token'};
+    die 'access token not provided' unless $access_token;
+
+    my $userdata = $class->call(
+        'api_method' => 'account/verify_credentials',
+        'access_token' => $access_token,
+    );
+
+    my $twu = LJ::Client::Twitter::User->from_hash($userdata);
+
+    return $twu;
+}
+
 1;

Added: trunk/cgi-bin/LJ/Identity/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Identity/Twitter.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Identity/Twitter.pm	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,125 @@
+=head1 SEE ALSO
+
+LJ::Client::Twitter
+
+=cut
+
+package LJ::Identity::Twitter;
+use strict;
+
+use base qw(LJ::Identity);
+
+use LJ::Client::Twitter;
+
+sub typeid { 'T' }
+sub pretty_type { 'Twitter' }
+sub short_code { 'twitter' }
+
+sub enabled {
+    return LJ::is_enabled('twitter_auth')
+        && $LJ::TWITTER_CONSUMER_KEY &&
+        ( $LJ::IS_DEV_SERVER || LJ::is_enabled('twitter_auth_production') );
+}
+
+sub attempt_login {
+    my ($class, $errs, %opts) = @_;
+
+    my $forwhat = $opts{'forwhat'} || 'login';
+
+    my $callback_url = "$LJ::SITEROOT/identity/callback-twitter.bml?" .
+                       'forwhat=' . $forwhat;
+
+    my $token = LJ::Client::Twitter->request_request_token(
+        'callback' => $callback_url,
+    );
+
+    my $addr  = 'https://api.twitter.com/oauth/authorize?' .
+                'oauth_token=' . $token->{'public'};
+
+    return LJ::Request->redirect($addr);
+}
+
+sub initialize_user {
+    my ($self, $u, $extra) = @_;
+
+    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
+
+    my $token = $extra->{'token'};
+    die "no access token passed" unless $token;
+
+    my $twu = $extra->{'userdata'}
+           || LJ::Client::Twitter->get_userinfo( 'access_token' => $token );
+
+    ## INITIALIZE USER PROFILE
+
+    # these are pretty much essential and cannot be changed by the
+    # user: the access token we're using to communicate on the user's
+    # behalf, their name, and the link to their profile
+    $u->set_prop('twitter_access_token'         => $token->{'public'});
+    $u->set_prop('twitter_access_token_secret'  => $token->{'secret'});
+    $u->set_prop('twitter_name'                 => $twu->screen_name );
+    $u->set_prop('twitter_link'                 => $twu->url );
+
+    # hometown
+    my $city = $twu->location;
+    if ($city) {
+        my $city_parsed = LJ::Identity::Facebook->parse_city($city);
+
+        $u->set_prop( 'city'    => $city_parsed->{'city'} );
+        $u->set_prop( 'state'   => $city_parsed->{'state'} );
+        $u->set_prop( 'country' => $city_parsed->{'country'} );
+    }
+
+    # the name specified in profile; this can actually be changed
+    # by the user later in the profile settings
+    LJ::update_user($u, { 'name' => $twu->name });
+
+    # bio
+    $u->set_bio($twu->bio);
+
+    # userpic
+    my $upidata = $ua->get($twu->userpic)->content;
+
+    my $userpic = eval { LJ::Userpic->create($u, data => \$upidata) };
+    $userpic->make_default if $userpic;
+
+    # website
+    $u->set_prop('url' => $twu->homepage);
+
+    # facebook identities are plus accounts by default
+    $u->add_to_class('plus');
+
+    # until they get notifications set, they don't get anything
+    LJ::update_user($u, { 'opt_gettalkemail' => 'N' });
+}
+
+sub url {
+    my ($self, $u) = @_;
+
+    # the 'url' prop should have been set by the initialization code;
+    # failing that, let's not re-fetch the website from there, and let's
+    # link to their twitter profile instead.
+    return $u->prop('twitter_link');
+}
+
+sub display_name {
+    my ($self, $u) = @_;
+    return $u->prop('twitter_name') || $u->username;
+}
+
+sub ljuser_display_params {
+    my ($self, $u, $opts) = @_;
+
+    return {
+        'journal_url'  => $u->prop('twitter_link') || 'about:blank',
+        'journal_name' => $u->display_name,
+        'userhead'     => 'twitter-profile.gif',
+        'userhead_w'   => 16,
+    };
+}
+
+sub profile_window_title {
+    return LJ::Lang::ml('/userinfo.bml.title.twitterprofile');
+}
+
+1;

Modified: trunk/cgi-bin/LJ/Setting/TwitterConnect.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/TwitterConnect.pm	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/cgi-bin/LJ/Setting/TwitterConnect.pm	2010-09-21 10:44:56 UTC (rev 9525)
@@ -74,7 +74,13 @@
     my ( $class, $u, $args ) = @_;
 
     if ( $class->get_arg( $args, "connect" ) ) {
-        my $token = LJ::Client::Twitter->request_request_token;
+        my $callback =
+            "$LJ::SITEROOT/manage/settings/twitter.bml?act=connect";
+
+        my $token = LJ::Client::Twitter->request_request_token(
+            'callback' => $callback,
+        );
+
         my $addr  = 'https://api.twitter.com/oauth/authorize?' .
                     'oauth_token=' . $token->{'public'};
 

Added: trunk/cgi-bin/LJ/Talk/Author/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk/Author/Twitter.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Talk/Author/Twitter.pm	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,94 @@
+package LJ::Talk::Author::Twitter;
+use strict;
+
+use base qw(LJ::Talk::Author);
+
+sub enabled {
+    return LJ::Identity::Twitter->enabled;
+}
+
+sub display_params {
+    my ($class, $opts) = @_;
+
+    my $remote = LJ::get_remote();
+    my $form = $opts->{'form'};
+    my $is_identity =    $remote
+                      && $remote->is_identity
+                      && $remote->identity->short_code eq 'twitter';
+
+    my $is_trusted_identity = $is_identity && $remote->is_trusted_identity;
+
+    my %whocheck = (
+        'twitter'        => $form->{'usertype'} eq 'twitter',
+        'twitter_cookie' => $form->{'usertype'} eq 'twitter_cookie'
+                                    || $is_identity,
+    );
+
+    return {
+        'is_identity'              => $is_identity,
+        'is_trusted_identity'      => $is_trusted_identity,
+
+        'whocheck_twitter'        => $whocheck{'twitter'},
+        'whocheck_twitter_cookie' => $whocheck{'twitter_cookie'},
+
+        'helpicon_twitter'        => LJ::help_icon_html( "twitter", " " ),
+    };
+}
+
+sub want_user_input {
+    my ($class, $usertype) = @_;
+    return $usertype =~ /^(?:twitter|twitter_cookie)$/;
+}
+
+sub handle_user_input {
+    my ($class, $form, $remote, $need_captcha, $errret, $init) = @_;
+
+    return if @$errret;
+
+    my $journalu = $init->{'journalu'};
+    my $up; # user posting
+
+    my $remote_is_twitter = $remote &&
+                             $remote->is_identity &&
+                             $remote->identity->short_code eq 'twitter';
+
+    if ($remote_is_twitter) {
+        return LJ::get_remote();
+    }
+
+    # Store the entry
+    my $pendcid = LJ::alloc_user_counter($journalu, "C");
+
+    unless ($pendcid) {
+        push @$errret, "Unable to allocate pending id";
+        return;
+    }
+
+    # Since these were gotten from the openid:url and won't
+    # persist in the form data
+    my $penddata = Storable::nfreeze($form);
+
+    unless ($journalu->writer) {
+        push @$errret,
+            "Unable to get database handle to store pending comment";
+        return;
+    }
+
+    $journalu->do(qq{
+        INSERT INTO pendcomments
+        SET jid = ?, pendcid = ?, data = ?, datesubmit = UNIX_TIMESTAMP()
+    }, undef, $journalu->id, $pendcid, $penddata);
+
+    if ($journalu->err) {
+        push @$errret, $journalu->errstr;
+        return;
+    }
+
+    my $journalid = $journalu->id;
+
+    LJ::Identity::Twitter->attempt_login($errret,
+        'forwhat' => "comment-$journalid-$pendcid",
+    );
+}
+
+1;

Modified: trunk/htdocs/identity/callback-facebook.bml
===================================================================
--- trunk/htdocs/identity/callback-facebook.bml	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/htdocs/identity/callback-facebook.bml	2010-09-21 10:44:56 UTC (rev 9525)
@@ -12,21 +12,14 @@
     my $forwhat = LJ::Request->get_param('forwhat') || 'login';
 
     my ($returl, $returl_fail);
-    if ($forwhat eq 'login') {
-        $returl = $LJ::SITEROOT;
-        $returl_fail = "$LJ::SITEROOT/identity/login.bml?type=facebook"
-    } elsif ($forwhat =~ /^comment-(\d+)-(\d+)$/) {
-        my ($journalid, $pendcid) = ($1, $2);
+    eval {
+        ($returl, $returl_fail) =
+        LJ::Identity::Facebook->unpack_forwhat($forwhat);
+    };
 
-        $returl = "$LJ::SITEROOT/talkpost_do.bml?" .
-                  "jid=$journalid&" .
-                  "pendcid=$pendcid";
-        $returl_fail = $returl . '&failed=1';
-    } else {
-        warn "invalid forwhat passed: $forwhat";
-        return LJ::Lang::ml('error.invalidform');
-    }
+    return LJ::Lang::ml('error.invalidform') if $@;
 
+
     unless (LJ::Identity::Facebook->enabled) {
         return 'This feature is disabled.';
     }

Added: trunk/htdocs/identity/callback-twitter.bml
===================================================================
--- trunk/htdocs/identity/callback-twitter.bml	                        (rev 0)
+++ trunk/htdocs/identity/callback-twitter.bml	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,71 @@
+<?page
+body<=
+<?_code
+{
+#line 6
+    use strict;
+    use vars qw($title);
+
+    # user will unlikely ever need to see this
+    $title = 'Twitter Landing Page';
+
+    my $forwhat = LJ::Request->get_param('forwhat') || 'login';
+
+    my ($returl, $returl_fail);
+    eval {
+        ($returl, $returl_fail) =
+        LJ::Identity::Twitter->unpack_forwhat($forwhat);
+    };
+
+    return LJ::Lang::ml('error.invalidform') if $@;
+
+    unless (LJ::Identity::Twitter->enabled) {
+        return 'This feature is disabled.';
+    }
+
+    my $public   = LJ::Request->get_param('oauth_token');
+    my $verifier = LJ::Request->get_param('oauth_verifier');
+
+    unless ( $public && $verifier ) {
+        require Data::Dumper;
+
+        warn 'could not get a token or a verifier from Twitter ' .
+             '(this could be a user cancel) '.
+             Data::Dumper::Dumper(\%GET);
+
+        return LJ::Request->redirect($returl_fail);
+    }
+
+    my $request_token = LJ::Client::Twitter->fetch_request_token($public);
+    my $access_token  = LJ::Client::Twitter->request_access_token(
+        $request_token, $verifier
+    );
+
+    my $twu = LJ::Client::Twitter->get_userinfo(
+        'access_token' => $access_token,
+    );
+
+    my $created;
+
+    my $u = LJ::User::load_identity_user('T', $twu->id, {
+        'token'    => $access_token,
+        'userdata' => $twu,
+    }, \$created);
+
+    $u->make_login_session('long', 0);
+    LJ::set_remote($u);
+
+    return LJ::Request->redirect($returl) unless $created;
+
+    my $redirect_url = "$LJ::SITEROOT/identity/twitter-interstitial.bml?" .
+                       'ret=' . LJ::eurl($returl);
+
+    return LJ::Request->redirect($redirect_url);
+}
+_code?>
+<=body
+title=><?_code return $title; _code?>
+head<=
+<?_code return $headextra; _code?>
+<=head
+page?>

Modified: trunk/htdocs/identity/login.bml.text
===================================================================
--- trunk/htdocs/identity/login.bml.text	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/htdocs/identity/login.bml.text	2010-09-21 10:44:56 UTC (rev 9525)
@@ -1,5 +1,3 @@
-.facebook.desc=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut gravida nunc vitae purus egestas lobortis. Morbi varius ligula vitae diam vehicula a elementum felis sagittis. Morbi in sapien sit amet lectus dignissim consequat nec eu arcu.
-
 .openid.desc=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut gravida nunc vitae purus egestas lobortis. Morbi varius ligula vitae diam vehicula a elementum felis sagittis. Morbi in sapien sit amet lectus dignissim consequat nec eu arcu. Sed in mauris fermentum lacus sodales accumsan condimentum a eros. Quisque fringilla tincidunt mauris, sit amet rutrum magna blandit a. Maecenas arcu quam, ornare ac varius blandit, feugiat ut quam.
 
 .openid.label.url=Your OpenID URL:

Modified: trunk/htdocs/identity/login.bml.text.local
===================================================================
--- trunk/htdocs/identity/login.bml.text.local	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/htdocs/identity/login.bml.text.local	2010-09-21 10:44:56 UTC (rev 9525)
@@ -1,4 +1,10 @@
+.facebook.btn.connect=Connect
+
+.facebook.desc=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut gravida nunc vitae purus egestas lobortis. Morbi varius ligula vitae diam vehicula a elementum felis sagittis. Morbi in sapien sit amet lectus dignissim consequat nec eu arcu.
+
 .tab.facebook=Facebook
 
-.facebook.btn.connect=Connect
+.tab.twitter=Twitter
 
+.twitter.btn.connect=Sign in with Twitter
+

Added: trunk/htdocs/identity/twitter-interstitial.bml
===================================================================
--- trunk/htdocs/identity/twitter-interstitial.bml	                        (rev 0)
+++ trunk/htdocs/identity/twitter-interstitial.bml	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,178 @@
+<?page
+body<=
+<?_code
+{
+#line 6
+    use strict;
+    use vars qw($title);
+
+    use Carp qw();
+
+    $title = LJ::Lang::ml('.title');
+
+    my $remote = LJ::get_remote();
+    unless (    $remote
+             && $remote->is_identity
+             && $remote->identity->short_code eq 'twitter' )
+    {
+        return LJ::Request->redirect("$LJ::SITEROOT/login.bml");
+    }
+
+    my $returl = LJ::Request->get_param('ret') || $LJ::SITEROOT;
+
+    my @errors;
+
+    my $handle_post = sub {
+        if (!LJ::check_form_auth()) {
+            push @errors, LJ::Lang::ml('error.invalidform');
+            return;
+        }
+
+        if (!LJ::Request->post_param('subscribe')) {
+            return LJ::Request->redirect($returl);
+        }
+
+        my $email = LJ::Request->post_param('email');
+
+        return LJ::Request->redirect($returl) unless $email;
+
+        my @email_errors;
+        LJ::check_email($email, \@email_errors);
+
+        if ($LJ::USER_EMAIL and $email =~ /\@\Q$LJ::USER_DOMAIN\E$/i) {
+            push @email_errors,
+                LJ::Lang::ml(
+                    'widget.createaccount.error.email.lj_domain',
+                    { domain => $LJ::USER_DOMAIN }
+                );
+        }
+
+        if (@email_errors) {
+            push @errors, @email_errors;
+            return;
+        }
+
+        my $u = $remote;
+
+        LJ::update_user($remote, {
+            'email' => $email,
+
+            # validated email becomes transitioning, transitioning
+            # or non-validated stay intact
+            'status' => $u->email_status eq 'N' ? 'N' : 'T',
+        });
+
+        # send validation mail
+        my $aa = LJ::register_authaction($u->{'userid'},
+                                         'validateemail', $email);
+
+        LJ::send_mail({
+            'to' => $email,
+            'from' => $LJ::DONOTREPLY_EMAIL,
+            'charset' => 'utf-8',
+            'subject' => LJ::Lang::ml('/editinfo.bml.newemail.subject'),
+            'body' => LJ::Lang::ml(
+                '/editinfo.bml.newemail.body2',
+                { 
+                    username => $u->{user},
+                    sitename => $LJ::SITENAME,
+                    sitelink => $LJ::SITEROOT,
+                    conflink => "$LJ::SITEROOT/confirm/$aa->{'aaid'}." .
+                                $aa->{'authcode'},
+                }
+            ),
+        });
+
+        # copypasta from LJ::Hooks::CreatePage with adjustments
+        # possibly refactor to reduce code duplication?
+
+        # we are not anymore using this. ugh.
+        LJ::update_user($u, {'opt_gettalkemail' => 'N'});
+
+        my @subs = (
+            'CommentReply',
+            'Befriended-u',
+            'UserMessageRecvd-u',
+            'InvitedFriendJoins-u',
+            'NewUserpic',
+            'Birthday',
+            'NewVGift',
+        );
+        
+        my $set = LJ::Subscription::GroupSet->fetch_for_user($u);
+        my $newset = $set->clone;
+
+        my @ntypeids = map { LJ::NotificationMethod->method_to_ntypeid($_) }
+            qw(Inbox Email);
+
+        foreach my $subcode (@subs) {
+            my $journalid = 0;
+
+            if ($subcode =~ /\-u$/) {
+                $journalid = $u->id;
+                $subcode =~ s/\-u$//;
+            }
+
+            my %sub = (
+                'userid' => $u->id,
+                'journalid' => $journalid,
+                'etypeid' => LJ::Event->event_to_etypeid($subcode),
+                'arg1' => 0,
+                'arg2' => 0,
+                'is_dirty' => 0,
+                'ntypeid' => 0,
+                'createtime' => time,
+                'expiretime' => 0,
+                'flags' => 0,
+            );
+
+            foreach my $ntypeid (@ntypeids) {
+                $sub{'ntypeid'} = $ntypeid;
+                $newset->insert_sub(bless({%sub}, 'LJ::Subscription'));
+            }
+        }
+
+        eval {
+            $set->update($newset);
+        };
+
+        if ($@) {
+            # theoretically, we didn't subscribe to any tracking subs yet,
+            # so there shouldn't be any errors, but if there are any,
+            # let's report
+            Carp::cluck "error subscribing user: " . $u->id;
+        }
+
+        return LJ::Request->redirect($returl);
+    };
+
+    if (LJ::Request->did_post) {
+        $handle_post->();
+        return if LJ::Request->redirected;
+    }
+
+    my $template = LJ::HTML::Template->new(
+        { use_expr => 1 }, # force HTML::Template::Pro with Expr support
+        filename => "$ENV{'LJHOME'}/templates/Identity/TwitterInterstitial.tmpl",
+        die_on_bad_params => 0,
+        strict => 0,
+    ) or die "Can't open template: $!";
+
+    $template->param(
+        'errors' => [ map { { 'error' => $_ } } @errors ],
+        'form_intro' => LJ::form_auth(),
+        'form_email' => LJ::ehtml(LJ::Request->post_param('email')),
+        'ml_congrats' => LJ::Lang::ml('.congrats', {
+            'username' => $remote->ljuser_display,
+        }),
+    );
+
+    return $template->output;
+}
+_code?>
+<=body
+title=><?_code return $title; _code?>
+head<=
+<?_code return $headextra; _code?>
+<=head
+page?>

Added: trunk/htdocs/identity/twitter-interstitial.bml.text.local
===================================================================
--- trunk/htdocs/identity/twitter-interstitial.bml.text.local	                        (rev 0)
+++ trunk/htdocs/identity/twitter-interstitial.bml.text.local	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,13 @@
+.btn.proceed=Save and proceed
+
+.congrats=Congratulations, [[username]], your accounts are now connected.
+
+.heading.subscribe=Do you want to receive email notifications?
+
+.label.email=Enter your email:
+
+.label.subscribe.yes=Yes
+
+.label.subscribe.no=No
+
+.title=Log in with OpenID and more

Modified: trunk/htdocs/manage/settings/twitter.bml
===================================================================
--- trunk/htdocs/manage/settings/twitter.bml	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/htdocs/manage/settings/twitter.bml	2010-09-21 10:44:56 UTC (rev 9525)
@@ -58,17 +58,13 @@
             'twitter_access_token_secret' => $access_token->{'secret'},
         );
 
-        my $userdata = LJ::Client::Twitter->call(
-            'api_method' => 'account/verify_credentials',
+        my $twu = LJ::Client::Twitter->get_userinfo(
             'access_token' => $access_token,
         );
 
-        my $screen_name = $userdata->{'screen_name'};
-        my $profile_url = "http://twitter.com/$screen_name";
+        $u->set_prop( 'twitter_name' => $twu->screen_name );
+        $u->set_prop( 'twitter_link' => $twu->url );
 
-        $u->set_prop( 'twitter_name' => $screen_name );
-        $u->set_prop( 'twitter_link' => $profile_url );
-
         LJ::Client::Twitter->remove_request_token($public);
 
         return LJ::Request->redirect($settings_page);

Modified: trunk/htdocs/talkpost.bml.text.local
===================================================================
--- trunk/htdocs/talkpost.bml.text.local	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/htdocs/talkpost.bml.text.local	2010-09-21 10:44:56 UTC (rev 9525)
@@ -1,6 +1,10 @@
 ;; -*- coding: utf-8 -*-
 .error.noreply_deleted=This comment has been deleted. You cannot reply to it.
 
+.facebook.who.you.are=We will figure who you are
+
+.twitter.who.you.are=We will figure who you are
+
 .loginq=Log in?
 
 .opt.friendsonly=- this user has disabled anonymous and non-friend posting.  You may post here if [[username]] lists you as a friend.

Modified: trunk/htdocs/userinfo.bml.text.local
===================================================================
--- trunk/htdocs/userinfo.bml.text.local	2010-09-21 09:18:22 UTC (rev 9524)
+++ trunk/htdocs/userinfo.bml.text.local	2010-09-21 10:44:56 UTC (rev 9525)
@@ -136,6 +136,8 @@
 
 .title.facebookprofile=Profile
 
+.title.twitterprofile=Profile
+
 .userinfo.body2=Below is user information for [[username]]. If you are this user, you can edit your information (or choose what information is considered public) at the <a [[aopts]]>Edit Profile</a> page.
 
 .userinfo.name=Profile

Added: trunk/templates/CommentForm/Author-Twitter.tmpl
===================================================================
--- trunk/templates/CommentForm/Author-Twitter.tmpl	                        (rev 0)
+++ trunk/templates/CommentForm/Author-Twitter.tmpl	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,90 @@
+<TMPL_IF everyone_can_comment>
+    <TMPL_IF is_identity>
+        <tr valign='middle' id='twli' name='twli'>
+        <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' onclick='handleRadios(4);' /></td>
+        <td class="b-postform-radio"><input type='radio' name='usertype' value='twitter_cookie' id='talkpostfromtwli' <TMPL_IF whocheck_twitter_cookie>checked='checked'</TMPL_IF> /></td>
+        <td class="b-postform-data">
+            <label for='talkpostfromfb' onclick='handleRadios(3);return false;' class="i-postform-label"><b>Twitter identity:</b></label>
+            <strong><TMPL_VAR remote_display_name></strong>
+            <TMPL_VAR ml_willscreen>
+        </td>
+        </tr>
+    <TMPL_ELSE>
+        <tr valign='middle' id='twlo' name='twlo'>
+        <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' onclick='handleRadios(3);' /></td>
+        <td class="b-postform-radio"><input type='radio' name='usertype' value='twitter' id='talkpostfromtwlo' <TMPL_IF whocheck_twitter>checked='checked'</TMPL_IF> /></td>
+        <td class="b-postform-data">
+            <label for='talkpostfromtwlo' onclick='handleRadios(3);return false;' class="i-postform-label"><b>Twitter</b></label>
+            <TMPL_VAR helpicon_twitter>
+            <TMPL_VAR ml_willscreen>
+            <span id="fb_more" class="i-bubble b-bubble-lite b-postform-fb"><i class="i-bubble-arrow-border"></i><i class="i-bubble-arrow"></i><TMPL_VAR expr="ml('/talkpost.bml.twitter.who.you.are')"></span>
+        </td>
+        </tr>
+    </TMPL_IF>
+
+<TMPL_ELSIF registered_can_comment>
+    <TMPL_IF is_trusted_identity>
+        <tr valign='middle' id='twli' name='twli'>
+        <TMPL_IF remote_banned>
+            <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' /></td>
+            <td class="b-postform-radio">( )</td>
+            <td class="b-postform-data"><span class='ljdeem'><TMPL_VAR ml_loggedin></font><TMPL_VAR ml_banned></td>
+        <TMPL_ELSE>
+            <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' onclick='handleRadios(4);' /></td>
+            <td class="b-postform-radio"><input type='radio' name='usertype' value='twitter_cookie' id='talkpostfromtwli' <TMPL_IF whocheck_twitter_cookie>checked='checked'</TMPL_IF> /></td>
+            <td class="b-postform-data">
+                <label for='talkpostfromfb' onclick='handleRadios(3);return false;' class="i-postform-label"><b>Twitter identity:</b></label>
+                <strong><TMPL_VAR remote_display_name></strong>
+                <TMPL_VAR ml_willscreen>
+            </td>
+        </TMPL_IF>
+        </tr>
+    <TMPL_ELSE>
+        <tr valign='middle' id='twlo' name='twlo'>
+        <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' onclick='handleRadios(3);' /></td>
+        <td class="b-postform-radio"><input type='radio' name='usertype' value='twitter' id='talkpostfromtwlo' <TMPL_IF whocheck_twitter>checked='checked'</TMPL_IF> /></td>
+        <td class="b-postform-data">
+            <label for='talkpostfromtwlo' onclick='handleRadios(3);return false;' class="i-postform-label"><b>Twitter</b></label>
+            <TMPL_VAR helpicon_twitter>
+            <TMPL_VAR ml_willscreen>
+            <span id="fb_more" class="i-bubble b-bubble-lite b-postform-fb"><i class="i-bubble-arrow-border"></i><i class="i-bubble-arrow"></i><TMPL_VAR expr="ml('/talkpost.bml.twitter.who.you.are')"></span>
+        </td>
+        </tr>
+    </TMPL_IF>
+<TMPL_ELSIF friends_can_comment>
+    <TMPL_IF is_identity>
+        <tr valign='middle' id='twli' name='twli'>
+        <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' onclick='handleRadios(4);' /></td>
+
+        <TMPL_IF remote_can_comment>
+            <td class="b-postform-radio"><input type='radio' name='usertype' value='twitter_cookie' id='talkpostfromtwli' <TMPL_IF whocheck_twitter_cookie>checked='checked'</TMPL_IF> /></td>
+            <td class="b-postform-data">
+                <label for='talkpostfromfb' onclick='handleRadios(3);return false;' class="i-postform-label"><b>Twitter identity:</b></label>
+                <strong><TMPL_VAR remote_display_name></strong>
+                <TMPL_VAR ml_willscreen>
+            </td>
+        <TMPL_ELSE>
+            <td class="b-postform-radio">( )</td>
+            <td class="b-postform-data">
+                <span class="i-postform-label i-postform-disabled"><b>Twitter identity:</b></span>&nbsp;
+                <strong><TMPL_VAR remote_display_name></strong>
+                <TMPL_VAR ml_notafriend>
+                <TMPL_VAR ml_willscreen>
+            </td>
+        </TMPL_IF>
+
+        </tr>
+    <TMPL_ELSE>
+        <tr valign='middle' id='twlo' name='twlo'>
+        <td class="b-postform-icon"><img src='<TMPL_VAR lj_imgprefix>/twitter-profile.gif' onclick='handleRadios(3);' /></td>
+        <td class="b-postform-radio"><input type='radio' name='usertype' value='twitter' id='talkpostfromtwlo' <TMPL_IF whocheck_twitter>checked='checked'</TMPL_IF> /></td>
+        <td class="b-postform-data">
+            <label for='talkpostfromtwlo' onclick='handleRadios(3);return false;' class="i-postform-label"><b>Twitter</b></label>
+            <TMPL_VAR helpicon_twitter>
+            <TMPL_VAR ml_willscreen>
+            <span id="fb_more" class="i-bubble b-bubble-lite b-postform-fb"><i class="i-bubble-arrow-border"></i><i class="i-bubble-arrow"></i><TMPL_VAR expr="ml('/talkpost.bml.twitter.who.you.are')"></span>
+        </td>
+        </tr>
+    </TMPL_IF>
+
+</TMPL_IF>

Added: trunk/templates/Identity/Login-twitter.tmpl
===================================================================
--- trunk/templates/Identity/Login-twitter.tmpl	                        (rev 0)
+++ trunk/templates/Identity/Login-twitter.tmpl	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,7 @@
+<TMPL_IF errors>
+    <TMPL_LOOP errors>
+        <?errorbar <TMPL_VAR error> errorbar?>
+    </TMPL_LOOP>
+</TMPL_IF>
+
+<button type="submit"><TMPL_VAR expr="ml('.twitter.btn.connect')"></button>

Added: trunk/templates/Identity/TwitterInterstitial.tmpl
===================================================================
--- trunk/templates/Identity/TwitterInterstitial.tmpl	                        (rev 0)
+++ trunk/templates/Identity/TwitterInterstitial.tmpl	2010-09-21 10:44:56 UTC (rev 9525)
@@ -0,0 +1,33 @@
+<div><TMPL_VAR ml_congrats></div>++<TMPL_IF errors>+    <TMPL_LOOP errors>+        <?errorbar <TMPL_VAR error> errorbar?>+    </TMPL_LOOP>+</TMPL_IF>++<form action="" method="post">+<TMPL_VAR form_intro>++<div>+<label for="email"><TMPL_VAR expr="ml('.label.email')"></label>+<input type="text" name="email" id="email" value="<TMPL_VAR form_email>">+</div>++<div><TMPL_VAR expr="ml('.heading.subscribe')"></div>++<div>+<input type="radio" name="subscribe" value="1" id="subscribe_yes" checked="checked">+<label for="subscribe_yes"><TMPL_VAR expr="ml('.label.subscribe.yes')"></label>+</div>++<div>+<input type="radio" name="subscribe" value="0" id="subscribe_no">+<label for="subscribe_no"><TMPL_VAR expr="ml('.label.subscribe.no')"></label>+</div>++<div>+<button type="submit"><TMPL_VAR expr="ml('.btn.proceed')"></button>+</div>++</form>
\ No newline at end of file

Tags: andy, bml, ljcom, local, pm, text, tmpl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments