Commit 576850a5 authored by ellen.spertus's avatar ellen.spertus

Automatic commit Fri Jan 31 03:00:02 PST 2014

parent 6ee38cde
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -287,6 +287,28 @@ class Gen_compressed(threading.Thread): ...@@ -287,6 +287,28 @@ class Gen_compressed(threading.Thread):
code = HEADER + '\n' + json_data['compiledCode'] code = HEADER + '\n' + json_data['compiledCode']
code = code.replace(remove, '') code = code.replace(remove, '')
# Trim down Google's Apache licences.
LICENSE = re.compile("""/\\*
[\w ]+
(Copyright \\d+ Google Inc.)
https://blockly.googlecode.com/
Licensed under the Apache License, Version 2.0 \(the "License"\);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\\*/""")
code = re.sub(LICENSE, r"\n// \1 Apache License 2.0", code)
stats = json_data['statistics'] stats = json_data['statistics']
original_b = stats['originalSize'] original_b = stats['originalSize']
compressed_b = stats['compressedSize'] compressed_b = stats['compressedSize']
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -113,6 +113,8 @@ rtclient.getOption = function(options, key, defaultValue) { ...@@ -113,6 +113,8 @@ rtclient.getOption = function(options, key, defaultValue) {
* these are: * these are:
* *
* 1. "clientId", the Client ID from the console * 1. "clientId", the Client ID from the console
* 2. "authButtonElementId", the is of the dom element to use for
* authorizing.
*/ */
rtclient.Authorizer = function(options) { rtclient.Authorizer = function(options) {
this.clientId = rtclient.getOption(options, 'clientId'); this.clientId = rtclient.getOption(options, 'clientId');
...@@ -161,7 +163,6 @@ rtclient.Authorizer.prototype.authorize = function(onAuthComplete) { ...@@ -161,7 +163,6 @@ rtclient.Authorizer.prototype.authorize = function(onAuthComplete) {
user_id: userId, user_id: userId,
immediate: false immediate: false
}, handleAuthResult); }, handleAuthResult);
console.log(clientId);
}; };
// Try with no popups first. // Try with no popups first.
gapi.auth.authorize({ gapi.auth.authorize({
......
...@@ -436,7 +436,7 @@ Blockly.Realtime.afterAuth_ = function() { ...@@ -436,7 +436,7 @@ Blockly.Realtime.afterAuth_ = function() {
/** /**
* Add "Anyone with the link" permissions to the file. * Add "Anyone with the link" permissions to the file.
* @param fileId the file id * @param {string} fileId the file id
*/ */
Blockly.Realtime.afterCreate_ = function(fileId) { Blockly.Realtime.afterCreate_ = function(fileId) {
var resource = { var resource = {
...@@ -453,21 +453,49 @@ Blockly.Realtime.afterCreate_ = function(fileId) { ...@@ -453,21 +453,49 @@ Blockly.Realtime.afterCreate_ = function(fileId) {
// If we have an error try to just set the permission for all users // If we have an error try to just set the permission for all users
// of the domain. // of the domain.
if (resp.error) { if (resp.error) {
var resource = { Blockly.Realtime.getUserDomain(fileId, function(domain) {
'type': 'domain', var resource = {
'role': 'writer', 'type': 'domain',
'value': item.domain, 'role': 'writer',
'withLink': true 'value': domain,
}; 'withLink': true
request = gapi.client.drive.permissions.insert({ };
'fileId': fileId, request = gapi.client.drive.permissions.insert({
'resource': resource 'fileId': fileId,
'resource': resource
});
request.execute(function(resp) { });
}); });
request.execute(function(resp) { });
} }
}); });
} };
/**
* Get the domain (if it exists) associated with a realtime file. The callback
* will be called with the domain, if it exists.
* @param fileId {string} the id of the file
* @param callback {function(string)} a function to call back with the domain
*/
Blockly.Realtime.getUserDomain = function (fileId, callback) {
/**
* Note that there may be a more direct way to get the domain by, for example,
* using the Google profile API but this way we don't need any additional
* APIs or scopes. But if it turns out that the permissions API stops
* providing the domain this might have to change.
*/
var request = gapi.client.drive.permissions.list({
'fileId': fileId
});
request.execute(function(resp) {
for (var i = 0; i < resp.items.length; i++) {
var item = resp.items[i];
if (item.role == 'owner') {
callback(item.domain);
return;
}
}
});
};
/** /**
* Options for the Realtime loader. * Options for the Realtime loader.
...@@ -476,7 +504,8 @@ Blockly.Realtime.realtimeOptions_ = { ...@@ -476,7 +504,8 @@ Blockly.Realtime.realtimeOptions_ = {
/** /**
* Client ID from the console. * Client ID from the console.
*/ */
clientId: 'INSERT YOUR CLIENT ID HERE', // clientId: 'INSERT YOUR CLIENT ID HERE',
clientId: '922110111899.apps.googleusercontent.com',
/** /**
* The ID of the button to click to authorize. Must be a DOM element ID. * The ID of the button to click to authorize. Must be a DOM element ID.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment