Skip to content

Commit 833b2a9

Browse files
committed
Fixed Google Classroom and Google Cloud integration.
Note: Seems Google Drive integration get's broken and needs to be fixed.
1 parent 35e468f commit 833b2a9

File tree

22 files changed

+180
-102
lines changed

22 files changed

+180
-102
lines changed

locales/deu/navigation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Locales['deu']['NAVIGATION'] = {
2323
'ABOUT_TEXT': 'Weitere Informationen zur Codierung mit Chrome',
2424
'DEBUG': 'Debuggen',
2525
'DEBUG_TEXT': 'Open Debug',
26+
'EXPORT_TO_GCLOUD': 'Exportieren zu Google Cloud',
27+
'EXPORT_TO_GCLOUD_TEXT': 'Exportieren der Vorschau zu Google Cloud...',
2628
'HELP': 'Hilfe',
2729
'HELP_TEXT': 'Dokumentation öffnen',
2830
'HOME': 'Home',

locales/deu/translation.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ Object.assign(Locales['deu'], {
8181
'Open file': 'Öffne Datei',
8282
'Physics Sprite': 'Physik Sprite',
8383
'Preload': 'Vorrausladen',
84-
'Publish to Google Cloud...': 'Veröffentliche auf Google Cloud...',
8584
'Recent': 'Zuletzt',
8685
'Redo last change': 'Mache die letzte Änderung rückgängig',
8786
'Render': 'Ausgabe',

locales/eng/navigation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Locales['eng']['NAVIGATION'] = {
2323
'ABOUT_TEXT': 'Learn more about Coding with Chrome',
2424
'DEBUG': 'Debug',
2525
'DEBUG_TEXT': 'Open Debug',
26+
'EXPORT_TO_GCLOUD': 'Export to Google Cloud',
27+
'EXPORT_TO_GCLOUD_TEXT': 'Export preview to Google Cloud...',
2628
'HELP': 'Help',
2729
'HELP_TEXT': 'Open documentation',
2830
'HOME': 'Home',

src/addon/message/message.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ cwc.addon.Message = function(helper) {
4545
/** @private {boolean} */
4646
this.chromeApp_ = this.helper.checkChromeFeature('app');
4747

48+
/** @private {!cwc.utils.Events} */
49+
this.events_ = new cwc.utils.Events(this.name, this.prefix);
50+
4851
/** @private {!cwc.utils.Logger} */
4952
this.log_ = new cwc.utils.Logger(this.name);
5053
};
@@ -56,12 +59,11 @@ cwc.addon.Message.prototype.prepare = function() {
5659
}
5760

5861
this.log_.info('Preparing message addon ...');
59-
6062
let modeInstance = this.helper.getInstance('mode');
6163
if (modeInstance) {
62-
goog.events.listen(modeInstance.getEventTarget(),
63-
/** @type {string} */ cwc.mode.Modder.Events.Type.MODE_CHANGE,
64-
this.eventsModder, false, this);
64+
this.events_.listen(modeInstance.getEventTarget(),
65+
cwc.mode.Modder.Events.Type.MODE_CHANGE,
66+
this.eventsModder.bind(this));
6567
}
6668
};
6769

src/addon/workbench/workbench.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ cwc.addon.Workbench.prototype.prepare = async function() {
9191
let selectScreenInstance = this.helper.getInstance('selectScreen');
9292
if (selectScreenInstance) {
9393
goog.events.listen(selectScreenInstance.getEventTarget(),
94-
/** @type {string} */ cwc.ui.SelectScreen.Events.Type.VIEW_CHANGE,
94+
cwc.ui.SelectScreen.Events.Type.VIEW_CHANGE,
9595
this.showRelevantProjects_, false, this);
9696
}
9797
};

src/config/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@ cwc.config.Sample = {
117117

118118

119119
/**
120-
* @return {string}
120+
* @type {string}
121121
*/
122122
cwc.config.Version = '5.10.16';

src/file_format/file_format.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ cwc.fileFormat.File.prototype.setAuthor = function(author) {
126126
* @return {string}
127127
*/
128128
cwc.fileFormat.File.prototype.getAuthor = function() {
129-
return this.getMetadata('author');
129+
return this.getMetadataText('author');
130130
};
131131

132132

@@ -195,7 +195,7 @@ cwc.fileFormat.File.prototype.setDescription = function(description) {
195195
* @return {string}
196196
*/
197197
cwc.fileFormat.File.prototype.getDescription = function() {
198-
return this.getMetadata('description');
198+
return this.getMetadataText('description');
199199
};
200200

201201

@@ -298,7 +298,7 @@ cwc.fileFormat.File.prototype.getFrameworks = function() {
298298
* @param {string} name
299299
* @param {string=} namespace
300300
* @param {boolean=} quiet
301-
* @return {!string|Array}
301+
* @return {!string|Array|Object}
302302
*/
303303
cwc.fileFormat.File.prototype.getMetadata = function(
304304
name, namespace = this.metedataNamespace_, quiet = false) {
@@ -317,6 +317,24 @@ cwc.fileFormat.File.prototype.getMetadata = function(
317317
};
318318

319319

320+
/**
321+
* @param {string} name
322+
* @param {string=} namespace
323+
* @param {boolean=} quiet
324+
* @return {!string}
325+
*/
326+
cwc.fileFormat.File.prototype.getMetadataText = function(
327+
name, namespace = this.metedataNamespace_, quiet = false) {
328+
let data = this.getMetadata(name, namespace, quiet);
329+
if (typeof data === 'string') {
330+
return data;
331+
} else if (typeof data === 'number') {
332+
return String(data);
333+
}
334+
return '';
335+
};
336+
337+
320338
/**
321339
* @param {string} name
322340
* @param {string} value
@@ -364,7 +382,7 @@ cwc.fileFormat.File.prototype.setModel = function(model) {
364382
* @return {string}
365383
*/
366384
cwc.fileFormat.File.prototype.getModel = function() {
367-
return this.getMetadata('model');
385+
return this.getMetadataText('model');
368386
};
369387

370388

@@ -403,7 +421,7 @@ cwc.fileFormat.File.prototype.setTitle = function(title) {
403421
* @return {string}
404422
*/
405423
cwc.fileFormat.File.prototype.getTitle = function() {
406-
return this.getMetadata('title');
424+
return this.getMetadataText('title');
407425
};
408426

409427

@@ -413,7 +431,7 @@ cwc.fileFormat.File.prototype.getTitle = function() {
413431
*/
414432
cwc.fileFormat.File.prototype.getTour = function(language = 'eng') {
415433
let tour = this.getMetadata(language, '__tour__', true);
416-
if (!tour && this.getMetadata(null, '__tour__', true)) {
434+
if (!tour && this.getMetadata('', '__tour__', true)) {
417435
this.log_.warn('Tour is not available in user\'s language', language);
418436
return this.getMetadata('eng', '__tour__', true);
419437
}
@@ -427,7 +445,7 @@ cwc.fileFormat.File.prototype.getTour = function(language = 'eng') {
427445
*/
428446
cwc.fileFormat.File.prototype.getTutorial = function(language = 'eng') {
429447
let tutorial = this.getMetadata(language, '__tutorial__', true);
430-
if (!tutorial && this.getMetadata(null, '__tutorial__', true)) {
448+
if (!tutorial && this.getMetadata('', '__tutorial__', true)) {
431449
this.log_.warn('Tutorial is not available in user\'s language', language);
432450
return this.getMetadata('eng', '__tutorial__', true);
433451
}
@@ -448,7 +466,7 @@ cwc.fileFormat.File.prototype.setVersion = function(version) {
448466
* @return {string}
449467
*/
450468
cwc.fileFormat.File.prototype.getVersion = function() {
451-
return this.getMetadata('version');
469+
return this.getMetadataText('version');
452470
};
453471

454472

@@ -578,7 +596,9 @@ cwc.fileFormat.File.loadJSON = function(file, data) {
578596
// File format version handling
579597
let fileFormatVersion = cwc.fileFormat.File.getFileHeaderVersion(
580598
jsonData['format'], file);
581-
file.log_.info('Loading JSON data with', Object.keys(jsonData).length,
599+
file.log_.info('Loading JSON data with', Object.keys(
600+
/** @type {Object} */ (jsonData)
601+
).length,
582602
'entries');
583603
file.init(true);
584604

src/mode/games/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ cwc.mode.games.Config[cwc.mode.Type.PHASER] = new cwc.mode.Mod({
4343
mod: cwc.mode.phaser.Mod,
4444
name: 'Phaser',
4545
services: [cwc.mode.Service.GAMEPAD],
46+
show_export: true,
4647
template: 'phaser/blank.cwc',
4748
});
4849

@@ -59,6 +60,7 @@ cwc.mode.games.Config[cwc.mode.Type.PHASER_BLOCKLY] = new cwc.mode.Mod({
5960
name: 'Phaser blockly',
6061
services: [cwc.mode.Service.GAMEPAD],
6162
show_blockly: true,
63+
show_export: true,
6264
template: 'phaser/blank-blocks.cwc',
6365
});
6466

src/mode/markup/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ cwc.mode.markup.Config[cwc.mode.Type.HTML5] = new cwc.mode.Mod({
4242
mime_types: [cwc.utils.mime.Type.HTML.type],
4343
mod: cwc.mode.html5.Mod,
4444
name: 'HTML 5',
45+
show_export: true,
4546
template: 'html5/blank.html',
4647
});

src/mode/modder.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ cwc.mode.Modder.prototype.setMode = function(mode) {
103103
if (navigationInstance) {
104104
navigationInstance.enableOverview(true);
105105
navigationInstance.enableSaveFile(true);
106+
navigationInstance.enableOpenGoogleDriveFile(true);
107+
navigationInstance.enableSaveGoogleDriveFile(true);
106108
if (modeConfig.name) {
107109
navigationInstance.setHeader(modeConfig.name, modeConfig.icon);
108110
}
111+
navigationInstance.enableExportGoogleCloud(modeConfig.showExport);
109112
}
110113

111114
// End existing tours.

0 commit comments

Comments
 (0)