Skip to content

Commit 0a53752

Browse files
author
Matt Karl
committed
Fixed fatal captions bug
1 parent a93c19a commit 0a53752

File tree

7 files changed

+94
-69
lines changed

7 files changed

+94
-69
lines changed

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.0-alpha.4",
3+
"version": "0.2.0-alpha.5",
44
"private": true,
55
"dependencies": {
66
"jqueryui": "*",

Diff for: deploy/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@
4141
Remote Trace
4242
</a>
4343
</div>
44-
<footer class="version">Version <span id="version">0.2.0-alpha.4</span></footer>
44+
<footer class="version">Version <span id="version">0.2.0-alpha.5</span></footer>
4545
</body>
4646
</html>

Diff for: deploy/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"description": "Application for SpringRoll projects",
4-
"version": "0.2.0-alpha.4",
4+
"version": "0.2.0-alpha.5",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/SpringRoll/SpringRollStudio"

Diff for: package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "SpringRollStudio",
3-
"private": true,
4-
"version": "0.2.0-alpha.4",
5-
"dependencies": {
6-
"grunt": "~0.4.5",
7-
"grunt-contrib-copy": "^0.7.0",
8-
"grunt-exec": "~0.4.6",
9-
"grunt-node-webkit-builder": "~1.0.0",
10-
"lodash": "~3.0.0",
11-
"project-grunt": "*"
12-
}
13-
}
2+
"name": "SpringRollStudio",
3+
"private": true,
4+
"version": "0.2.0-alpha.5",
5+
"dependencies": {
6+
"grunt": "~0.4.5",
7+
"grunt-contrib-copy": "^0.7.0",
8+
"grunt-exec": "~0.4.6",
9+
"grunt-node-webkit-builder": "~1.0.0",
10+
"lodash": "~3.0.0",
11+
"project-grunt": "*"
12+
}
13+
}

Diff for: project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.0-alpha.4",
3+
"version": "0.2.0-alpha.5",
44
"main": [
55
"components/node-webkit-app/src/utils/UpdateChecker.js",
66
"components/node-webkit-app/src/utils/Browser.js",

Diff for: src/springroll/captions/data/Project.js

+77-52
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,20 @@
122122

123123
data = parseJSON(file);
124124

125+
// Make sure we have some data
125126
if (!data)
126127
{
127128
callback(null);
128129
return;
129130
}
131+
132+
// Check that there's a captions object
133+
if (!data.captions)
134+
{
135+
this.create(file, callback);
136+
return;
137+
}
138+
130139
this.onProjectLoaded(data, callback);
131140
}
132141
if (WEB)
@@ -202,12 +211,6 @@
202211
*/
203212
p.onProjectLoaded = function(data, callback)
204213
{
205-
// No projects file!
206-
if (!data || !data.captions)
207-
{
208-
callback(null);
209-
return;
210-
}
211214
this.locales = data.captions.locales;
212215
this.assets = data.captions.assets;
213216
this.setLocale('default', function(project){
@@ -223,70 +226,92 @@
223226
*/
224227
p.create = function(file, callback)
225228
{
226-
var self = this,
227-
dir = path.dirname(file);
229+
var dir = path.dirname(file);
230+
this.modal.open(dir,
231+
this.onModalClosed.bind(this, file, dir, callback)
232+
);
233+
};
228234

229-
this.modal.open(dir, function(result){
235+
/**
236+
* When the modal project dialog is closed
237+
* @method onModalClosed
238+
* @private
239+
* @param {string} file The project file to save
240+
* @param {string} dir Project main path
241+
* @param {function} callback The result when we're done
242+
* @param {object} result
243+
*/
244+
p.onModalClosed = function(file, dir, callback, result)
245+
{
246+
// Failed!
247+
if (!result)
248+
{
249+
callback(null);
250+
return;
251+
}
252+
253+
var audioPath = result.audioPath,
254+
exportPath = result.exportPath,
255+
cwd = path.join(dir, audioPath),
256+
self = this;
257+
258+
// Select all OGG file from the audio folder
259+
glob('**/*.ogg', {cwd:cwd}, function(err, files) {
230260

231-
// Failed!
232-
if (!result)
261+
if (err)
233262
{
234263
callback(null);
235-
return;
264+
throw err;
236265
}
237266

238-
var audioPath = result.audioPath,
239-
exportPath = result.exportPath,
240-
cwd = path.join(dir, audioPath);
241-
242-
// Select all OGG file from the audio folder
243-
glob('**/*.ogg', {cwd:cwd}, function(err, files) {
267+
var assets = [];
244268

245-
if (err)
246-
{
247-
callback(null);
248-
throw err;
249-
}
250-
251-
var assets = [];
252-
253-
_.each(files, function(file){
254-
assets.push({
255-
id : path.basename(file, '.ogg'),
256-
src : file
257-
});
269+
_.each(files, function(file){
270+
assets.push({
271+
id : path.basename(file, '.ogg'),
272+
src : file
258273
});
274+
});
259275

260-
// Add an empty export file if there isn't one
261-
var exportFile = path.join(dir, exportPath);
262-
if (!fs.existsSync(exportFile))
276+
// Add an empty export file if there isn't one
277+
var exportFile = path.join(dir, exportPath);
278+
if (!fs.existsSync(exportFile))
279+
{
280+
if (DEBUG)
263281
{
264-
if (DEBUG)
265-
{
266-
console.log("Save empty captions file " + exportFile);
267-
}
268-
fs.writeFileSync(exportFile, "{}");
282+
console.log("Save empty captions file " + exportFile);
269283
}
284+
fs.writeFileSync(exportFile, "{}");
285+
}
270286

271-
// Dummy project file
272-
var data = {
273-
"captions" : {
274-
"assets" : assets,
275-
"locales" : {
276-
"default" : {
277-
"path" : audioPath,
278-
"export" : exportPath
279-
}
287+
// Dummy project file
288+
var data = {
289+
"captions" : {
290+
"assets" : assets,
291+
"locales" : {
292+
"default" : {
293+
"path" : audioPath,
294+
"export" : exportPath
280295
}
281296
}
282-
};
297+
}
298+
};
283299

300+
// File already exists, but no captions data
301+
if (fs.existsSync(file))
302+
{
303+
var projectData = parseJSON(file);
304+
projectData.captions = data.captions;
305+
writeJSON(file, projectData);
306+
}
307+
else
308+
{
284309
// Write the project to file
285310
writeJSON(file, data);
311+
}
286312

287-
// Continue with loading the new created project
288-
self.onProjectLoaded(data, callback);
289-
});
313+
// Continue with loading the new created project
314+
self.onProjectLoaded(data, callback);
290315
});
291316
};
292317

Diff for: src/springroll/captions/ui/ProjectModal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
*/
195195
p._onHide = function()
196196
{
197-
if (!this._confirmed)
197+
if (!this._confirmed && this._callback)
198198
{
199199
this.close(false);
200200
}

0 commit comments

Comments
 (0)