Skip to content

Commit 44d7c2d

Browse files
committed
Fixed file library sync.
Fixed raw .txt mod. Moved simple/ to basic/ folder and adjusted corresponding references.
1 parent 2419b8b commit 44d7c2d

File tree

47 files changed

+110
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+110
-218
lines changed

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"jsdoc": "^3.5.5",
1313
"karma": "^1.7.1",
1414
"karma-chrome-launcher": "^2.2.0",
15+
"karma-closure": "^0.1.3",
1516
"npm-check-updates": "^2.14.1",
1617
"nw": "^0.29.0",
1718
"nw-builder": "^3.5.1",
@@ -41,7 +42,6 @@
4142
"test-core": "echo Starting core tests ... && karma start test/core_tests.conf",
4243
"pretest-mode": "npm run build && npm run build-cwc-main-debug",
4344
"test-mode": "echo Starting mode tests ... && karma start test/mode_tests.conf",
44-
4545
"prebuild-cwc-soy": "npm run clean-soy_files",
4646
"prebuild-cwc-gss": "npm run clean-gss_files",
4747
"build-cwc": "npm run build-cwc-deps && npm run build-cwc-main",
@@ -62,7 +62,6 @@
6262
"build-external-frameworks": "node build/external/frameworks.js",
6363
"build-external-static": "node build/external/static_files.js",
6464
"build-framework-files": "npm run build-external-frameworks && npm run build-cwc-frameworks",
65-
6665
"prebuild-core": "npm run clean-core",
6766
"prebuild-chrome-app": "npm run clean-chrome_app",
6867
"prebuild-chrome-app-debug": "npm run clean-chrome_app",
@@ -78,27 +77,23 @@
7877
"build-nw_app_debug": "npm run clean-nw_app && node build/app/nw_app_debug.js",
7978
"build-third_party": "npm run clean-third_party && npm run build-external-frameworks && npm run build-external-extra && npm run build-external-static",
8079
"build-web_app": "npm run clean-web_app && node build/app/web_app.js",
81-
8280
"publish-chrome_app": "npm run build-chrome_app",
8381
"publish-nw_app": "npm run publish-nw_app-win && npm run publish-nw_app-mac && npm run publish-nw_app-linux",
8482
"publish-nw_app-win": "nwbuild --platforms win --buildDir genfiles/ dist/nw_app/",
8583
"publish-nw_app-mac": "nwbuild --platforms osx64 --buildDir genfiles/ dist/nw_app/",
8684
"publish-nw_app-linux": "nwbuild --platforms linux --buildDir genfiles/ dist/nw_app/",
87-
8885
"chrome-app": "npm run build-core && npm run build-cwc-main && npm run build-chrome_app && npm run launch",
8986
"chrome-app-debug": "npm run build-core && npm run build-cwc-main-debug && npm run build-chrome_app && npm run launch",
9087
"nw-app": "npm run build-core && npm run build-cwc-main && npm run build-nw_app && npm run launch-nw",
9188
"nw-app-debug": "npm run build-core && npm run build-cwc-main-debug && npm run build-nw_app && npm run launch-nw",
9289
"web-app": "npm run build-core && npm run build-cwc-main && npm run build-web_app && npm run launch-web",
9390
"web-app-debug": "npm run build-core && npm run build-cwc-main-debug && npm run build-web_app && npm run launch-web",
94-
95-
"launch": "echo Lauching app. Please wait ... && npm run launch-linux --silent || npm run launch-mac --silent || npm run launch-win --silent",
91+
"launch": "echo Lauching app. Please wait ... && npm run launch-linux --silent || npm run launch-mac --silent || npm run launch-win --silent",
9692
"launch-nw": "nw dist/nw_app",
9793
"launch-linux": "google-chrome --load-and-launch-app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
9894
"launch-mac": "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" --load-and-launch-app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
9995
"launch-web": "http-server dist/web_app",
10096
"launch-win": "echo && \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --load-and-launch-app=%CD%\\dist\\chrome_os --enable-logging --v=1 --no-first-run --enable-experimental-web-platform-features",
101-
10297
"clean": "npm run clean-npm && npm run clean-chrome_app && npm run clean-core && npm run clean-soy_files && npm run clean-test && npm run clean-third_party",
10398
"clean-chrome_app": "echo Cleaning up Chrome app dist files. Please wait ... && rimraf dist/chrome_os/*",
10499
"clean-core": "echo Cleaning up core genfiles. Please wait ... && rimraf genfiles/core/*",
@@ -110,7 +105,6 @@
110105
"clean-nw_app": "echo Cleaning up NW.js app dist files. Please wait ... && rimraf dist/nw_app/*",
111106
"clean-web_app": "echo Cleaning up Web app dist files. Please wait ... && rimraf dist/web_app/*",
112107
"clean-build": "npm run clean && npm run build",
113-
114108
"documentation": "jsdoc src -r -c documentation.json -d docs",
115109
"deploy": "npm test && git push",
116110
"lint": "eslint .",

src/file_handler/file_handler.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ cwc.fileHandler.File.prototype.setFile = function(file) {
9393
* @param {string=} filename
9494
*/
9595
cwc.fileHandler.File.prototype.setRawFile = function(content, filename) {
96-
console.log('Set raw content to:', content);
9796
this.clear(true);
9897
this.rawFile_ = content;
9998
this.filename_ = filename || '';

src/file_handler/file_loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ cwc.fileHandler.FileLoader.prototype.loadGDriveFileData = function(id,
139139
cwc.fileHandler.FileLoader.prototype.handleFileData = function(data,
140140
filename = '', fileHandler = null, gDriveId = undefined) {
141141
return new Promise((resolve) => {
142-
this.log_.info('Handle file data:', data);
142+
this.log_.info('Handle file data ... (', data.length, ')');
143143
let fileInstance = this.helper.getInstance('file', true);
144144
let modeInstance = this.helper.getInstance('mode', true);
145145
let mimeType = cwc.file.getMimeTypeByNameAndContent(filename || '', data);

src/mode/default/mod.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ cwc.mode.default.Mod.prototype.decorate = function() {
158158
};
159159

160160

161+
/**
162+
* Decorates standard Editor.
163+
*/
164+
cwc.mode.default.Mod.prototype.decorateRaw = function() {
165+
let layoutInstance = this.helper.getInstance('layout', true);
166+
layoutInstance.decorateBlank();
167+
layoutInstance.renderContent(cwc.soy.mode.default.Layout.editor);
168+
this.decorateEditor();
169+
};
170+
171+
161172
/**
162173
* Decorates Blockly
163174
*/

src/mode/modder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cwc.mode.Modder = function(helper) {
5757
/** @private {!goog.events.EventTarget} */
5858
this.eventHandler_ = new goog.events.EventTarget();
5959

60-
/** @type {string} */
60+
/** @private {string} */
6161
this.templatePath_ = '../resources/templates/';
6262
};
6363

@@ -134,6 +134,7 @@ cwc.mode.Modder.prototype.setFilename = function(filename) {
134134
* @param {cwc.mode.Type} mode
135135
*/
136136
cwc.mode.Modder.prototype.postMode = function(mode) {
137+
this.log_.info('Post handling for', mode);
137138
let modeConfig = cwc.mode.Config.get(mode);
138139

139140
// Preview Handling
@@ -144,7 +145,7 @@ cwc.mode.Modder.prototype.postMode = function(mode) {
144145
}
145146

146147
// File handling
147-
let fileHandlerInstance = this.helper.getInstance('fileHandler');
148+
let fileHandlerInstance = this.helper.getInstance('file');
148149
if (fileHandlerInstance) {
149150
if (fileHandlerInstance.hasLibraryFiles()) {
150151
this.syncLibrary();
@@ -221,9 +222,8 @@ cwc.mode.Modder.prototype.showBlockly = function() {
221222
* Syncs the library with the existing files.
222223
*/
223224
cwc.mode.Modder.prototype.syncLibrary = function() {
224-
let fileInstance = this.helper.getInstance('file');
225225
let libraryInstance = this.helper.getInstance('library');
226-
if (fileInstance && libraryInstance) {
226+
if (libraryInstance) {
227227
libraryInstance.syncFiles();
228228
}
229229
};

src/mode/text/mod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cwc.mode.text.Mod = function(helper) {
3737
*/
3838
cwc.mode.text.Mod.prototype.decorate = function() {
3939
this.mod.setRenderer(null);
40-
this.mod.decorate();
40+
this.mod.decorateRaw();
4141
this.mod.editor.enableModeSelect(true);
4242
this.mod.editor.showEditorViews(false);
4343
this.mod.editor.showExpandButton(false);

src/protocol/low-level/default/device.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ cwc.protocol.default.Device = function() {
5858
/** @type {!cwc.utils.Logger} */
5959
this.log = new cwc.utils.Logger();
6060

61-
/** @private {!goog.events.EventTarget} */
61+
/** @type {!goog.events.EventTarget} */
6262
this.eventHandler = new goog.events.EventTarget();
6363
};
6464

src/ui/layout/layout.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,15 @@ cwc.ui.Layout.prototype.handleResizeEvent = function() {
439439
};
440440

441441

442+
/**
443+
* @param {!function ({prefix: string}, null=): soydata.SanitizedHtml} template
444+
* @param {string=} prefix
445+
*/
446+
cwc.ui.Layout.prototype.renderContent = function(template, prefix = '') {
447+
this.renderContent_(template, this.getNode('content'), prefix);
448+
};
449+
450+
442451
/**
443452
* @param {!function ({prefix: string}, null=): soydata.SanitizedHtml} template
444453
* @param {string=} prefix

src/ui/library/library.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,18 @@ cwc.ui.Library.prototype.updateLibraryFileList = function(files = null,
179179
* Syncs the files with the library.
180180
*/
181181
cwc.ui.Library.prototype.syncFiles = function() {
182-
let blocklyInstance = this.helper.getInstance('blockly');
183-
let editorInstance = this.helper.getInstance('editor');
184182
let fileInstance = this.helper.getInstance('file');
185-
this.numOfFiles_ = 0;
186-
187183
if (fileInstance) {
184+
this.numOfFiles_ = 0;
188185
let files = this.getFiles();
189186
if (files && fileInstance.getFiles().getSize() > 0) {
190187
this.log_.info('Syncing library ', fileInstance.getFiles().getSize(),
191188
' files...');
189+
let blocklyInstance = this.helper.getInstance('blockly');
192190
if (blocklyInstance) {
193191
blocklyInstance.setToolboxFiles(files);
194192
}
193+
let editorInstance = this.helper.getInstance('editor');
195194
if (editorInstance) {
196195
editorInstance.updateLibraryButton(fileInstance.getFiles().hasFiles());
197196
}

src/ui/select_screen/advanced/basic/basic.soy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,39 @@
5555
{call cwc.soy.SelectScreenTemplate.fileCard data="all"}
5656
{param title: 'Hello World' /}
5757
{param text: 'Hello World example' /}
58-
{param file: 'simple/script/Hello-World.cwc' /}
58+
{param file: 'basic/script/Hello-World.cwc' /}
5959
{param opt_color_class: 'bg-blue' /}
6060
{param opt_icon: 'speaker_notes' /}
6161
{/call}
6262

6363
{call cwc.soy.SelectScreenTemplate.fileCard data="all"}
6464
{param title: 'Text loop' /}
6565
{param text: 'Text loop example' /}
66-
{param file: 'simple/script/Text-Loop.cwc' /}
66+
{param file: 'basic/script/Text-Loop.cwc' /}
6767
{param opt_color_class: 'bg-blue' /}
6868
{param opt_icon: 'repeat' /}
6969
{/call}
7070

7171
{call cwc.soy.SelectScreenTemplate.fileCard data="all"}
7272
{param title: 'Line loop' /}
7373
{param text: 'Draw lines with loops' /}
74-
{param file: 'simple/script/Line-Loop.cwc' /}
74+
{param file: 'basic/script/Line-Loop.cwc' /}
7575
{param opt_color_class: 'bg-blue' /}
7676
{param opt_icon: 'repeat' /}
7777
{/call}
7878

7979
{call cwc.soy.SelectScreenTemplate.fileCard data="all"}
8080
{param title: 'Point loop' /}
8181
{param text: 'Draw points with random colors and loops' /}
82-
{param file: 'simple/script/Point-Loop.cwc' /}
82+
{param file: 'basic/script/Point-Loop.cwc' /}
8383
{param opt_color_class: 'bg-blue' /}
8484
{param opt_icon: 'repeat' /}
8585
{/call}
8686

8787
{call cwc.soy.SelectScreenTemplate.fileCard data="all"}
8888
{param title: 'Draw Portal Turret' /}
8989
{param text: 'Draw a Portal Turret' /}
90-
{param file: 'simple/script/Draw-Portal-Turret.cwc' /}
90+
{param file: 'basic/script/Draw-Portal-Turret.cwc' /}
9191
{param opt_color_class: 'bg-blue' /}
9292
{param opt_icon: 'palette' /}
9393
{/call}

0 commit comments

Comments
 (0)