Skip to content

Commit 5a40a05

Browse files
committed
more G+ stuff
1 parent 03a7017 commit 5a40a05

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

v3/bottle_server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
@route('/<filepath:path>')
2424
def index(filepath):
25+
# special-case for testing name_lookup.py ...
26+
if 'name_lookup.py' in filepath:
27+
return json.dumps(dict(name='TEST NAME', email='TEST EMAIL'))
2528
return static_file(filepath, root='.')
2629

2730
@get('/exec')

v3/composingprograms.html

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@
7676
<table id="experimentalHeader" style="margin-bottom: 15pt;">
7777

7878

79-
<div id="gplusDiv" style="margin-bottom: 10pt;">
79+
<div id="gplusDiv" style="margin-bottom: 10pt; margin-left: 5px;">
8080

8181
<div id="signinButton" style="font-size: 8pt;">
82-
<button
82+
<span
8383
class="g-signin"
8484
data-callback="signinCallback"
8585
data-clientid="639826413051-n4c566bfu9jnee6893qolvbt8od9kiaf.apps.googleusercontent.com"
8686
data-cookiepolicy="single_host_origin"
8787
data-requestvisibleactions="http://schemas.google.com/AddActivity"
8888
data-scope="https://www.googleapis.com/auth/plus.profile.emails.read">
89-
</button>
89+
</span>
9090

91-
Sign in with either your UC Berkeley email or personal Google+
92-
account.
91+
Use either your UC Berkeley account or personal Google account to
92+
identify yourself when chatting.
9393

9494
</div>
9595

@@ -101,24 +101,8 @@
101101
</div>
102102

103103

104-
<div id="authOps" style="display:none">
105-
<h2>User is now signed in to the app using Google+</h2>
106-
<p>If the user chooses to disconnect, the app must delete all stored
107-
information retrieved from Google for the given user.</p>
108-
<button id="disconnect" >Disconnect your Google account from this app</button>
109-
110-
<h2>User's profile information</h2>
111-
<div id="profile"></div>
112-
113-
<h2>Authentication Logs</h2>
114-
<pre id="authResult"></pre>
115-
</div>
116-
117-
118-
119104
<tr>
120105
<td valign="top">
121-
<div style="font-size: 8pt; color: #666; margin-left: 2px;">Experimental features</div>
122106

123107
<div>
124108
<button id="sharedSessionBtn" type="button" class="togetherjsBtn">

v3/js/composingprograms.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ $(document).ready(function() {
8686
});
8787

8888

89+
var chatDisplayName = null; // sign in with Google account to get your real chat name
90+
8991
// for Google+ Web signin:
9092
// https://developers.google.com/+/web/signin/add-button
91-
9293
function signinCallback(authResult) {
9394
if (authResult) {
9495
if (authResult['error'] == undefined){
@@ -117,21 +118,19 @@ function signinCallback(authResult) {
117118
// if we can actually grab the display name (e.g., from a
118119
// Google+ account), then use it
119120
if (resp.displayName) {
120-
$("#loggedInNameDisplay").html("Hello, " + resp.displayName);
121+
chatDisplayName = resp.displayName;
122+
showChatName();
121123
}
122124

123125
// otherwise try to look up the email address on the server to
124126
// find a real name mapping on the server
125-
else if (email){
127+
else if (email) {
126128
$.get('name_lookup.py',
127129
{email : email},
128130
function(data) {
129-
if (data.name) {
130-
$("#loggedInNameDisplay").html("Hello, " + data.name);
131-
}
132-
else {
133-
$("#loggedInNameDisplay").html("Hello, " + email);
134-
}
131+
// fall back on email address
132+
chatDisplayName = data.name ? data.name : email;
133+
showChatName();
135134
},
136135
"json");
137136
}
@@ -146,6 +145,10 @@ function signinCallback(authResult) {
146145
}
147146
}
148147

148+
function showChatName() {
149+
$("#loggedInNameDisplay").html("Welcome, " + chatDisplayName);
150+
}
151+
149152
// adapted from https://developers.google.com/+/quickstart/javascript
150153
/**
151154
* Calls the OAuth2 endpoint to disconnect the app for the user.
@@ -171,7 +174,6 @@ function signout() {
171174
});
172175
}
173176
else {
174-
$('#signinButton').show();
175-
$('#loggedInDiv').hide();
177+
console.log('signout failed :(');
176178
}
177179
}

v3/js/opt-frontend-common.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,12 @@ function populateTogetherJsShareUrl() {
426426
$("#togetherjsStatus").html('<div>\
427427
Copy and send this URL to let someone (e.g., a tutor or friend) join your live session:\
428428
</div>\
429-
<input type="text" style="font-size: 11pt; \
430-
font-weight: bold; padding: 5px;\
429+
<input type="text" style="font-size: 10pt; \
430+
font-weight: bold; padding: 3px;\
431431
margin-bottom: 6pt;" \
432432
id="togetherjsURL" size="80" readonly="readonly"/>\
433433
<button id="syncBtn" type="button" style="font-size: 8pt;">Force sync</button>');
434-
$("#togetherjsURL").val(urlToShare).attr('size', urlToShare.length + 25);
434+
$("#togetherjsURL").val(urlToShare).attr('size', urlToShare.length + 20);
435435
$("#syncBtn").click(requestSync);
436436
}
437437

@@ -603,6 +603,11 @@ function genericOptFrontendReady() {
603603
return; // get out early
604604
}
605605

606+
// ugh other idiosyncratic stuff
607+
if (settings.url.indexOf('name_lookup.py') > -1) {
608+
return; // get out early
609+
}
610+
606611
setFronendError(["Server error! Your code might be too long to properly visualize (e.g., over 100 lines),",
607612
"so try again with a smaller piece of code.",
608613
"Or report a bug to [email protected] by clicking on the 'Generate URL'",

0 commit comments

Comments
 (0)