| 139 | | this.copyFilesForApp(rootDir,projectName,id,obj); |
|---|
| 140 | | |
|---|
| 141 | | //vars for application.ini replace |
|---|
| 142 | | var nameValue = obj.name||projectName; |
|---|
| 143 | | var versionValue = obj.version||"0.1"; |
|---|
| 144 | | var creatorValue = obj.creator||"Lily"; |
|---|
| 145 | | var emailValue = obj.emailAddress||(projectName+".id@"+projectName+".com"); |
|---|
| 146 | | var xulrunnerValue = obj.xulRunnerLocation||""; |
|---|
| 147 | | |
|---|
| 148 | | if(platform=="apple") { |
|---|
| 149 | | |
|---|
| 150 | | //copy the framework |
|---|
| 151 | | var tmpOut = contentsDir.clone(); |
|---|
| 152 | | tmpOut.append("Frameworks"); |
|---|
| 153 | | var xulrunnerFile = LilyUtils.getFileHandle(xulrunnerValue); |
|---|
| 154 | | |
|---|
| 155 | | if(!xulrunnerFile || !xulrunnerFile.exists()) { //if null or n'exist pas |
|---|
| 156 | | LilyDebugWindow.error("XULRunner not found"); |
|---|
| 157 | | var parentDir = fp.file.parent.clone(); |
|---|
| 158 | | parentDir.append(fp.file.leafName+".app"); |
|---|
| 159 | | parentDir.remove(); //delete the file |
|---|
| 160 | | return; |
|---|
| | 139 | var dependencies = Lily.patchObj[id].obj.getPatchDependencies(); |
|---|
| | 140 | var objArr = dependencies["classes"]; |
|---|
| | 141 | |
|---|
| | 142 | //global to this function |
|---|
| | 143 | var contentIn = null; |
|---|
| | 144 | var contentOut = null; |
|---|
| | 145 | var xulIn = null; |
|---|
| | 146 | var xulOut = null; |
|---|
| | 147 | var configIn = null; |
|---|
| | 148 | var configOut = null; |
|---|
| | 149 | |
|---|
| | 150 | var build_func_array = [ |
|---|
| | 151 | |
|---|
| | 152 | function() { |
|---|
| | 153 | //locale |
|---|
| | 154 | var tmp = Lily.installDir.clone(); |
|---|
| | 155 | tmp.append("chrome"); |
|---|
| | 156 | tmp.append("locale"); |
|---|
| | 157 | |
|---|
| | 158 | var tmpOut = rootDir.clone(); |
|---|
| | 159 | tmpOut.append("chrome"); |
|---|
| | 160 | tmp.copyTo(tmpOut,null); |
|---|
| | 161 | }, |
|---|
| | 162 | |
|---|
| | 163 | function() { |
|---|
| | 164 | //components if we need 'em |
|---|
| | 165 | if(objArr.toSource().indexOf("oscreceive")!=-1||objArr.toSource().indexOf("oscsend")!=-1) { |
|---|
| | 166 | var tmp = Lily.installDir.clone(); |
|---|
| | 167 | tmp.append("components"); |
|---|
| | 168 | tmp.copyTo(rootDir,null); |
|---|
| | 169 | } |
|---|
| | 170 | }, |
|---|
| | 171 | |
|---|
| | 172 | function() { |
|---|
| | 173 | //prefs |
|---|
| | 174 | var tmp = Lily.installDir.clone(); |
|---|
| | 175 | tmp.append("platform"); |
|---|
| | 176 | tmp.copyTo(rootDir,null); |
|---|
| | 177 | }, |
|---|
| | 178 | |
|---|
| | 179 | function() { |
|---|
| | 180 | var osArr = ["Darwin","Linux","linux-gnu","WINNT"]; |
|---|
| | 181 | |
|---|
| | 182 | for(var i=0;i<osArr.length;i++) { |
|---|
| | 183 | //prefs.js |
|---|
| | 184 | var tmpOut = rootDir.clone(); |
|---|
| | 185 | tmpOut.append("platform"); |
|---|
| | 186 | tmpOut.append(osArr[i]); |
|---|
| | 187 | tmpOut.append("defaults"); |
|---|
| | 188 | tmpOut.append("preferences"); |
|---|
| | 189 | tmpOut.append("lily.js"); |
|---|
| | 190 | |
|---|
| | 191 | var newPrefs = '\n' + |
|---|
| | 192 | 'pref("toolkit.defaultChromeURI", "chrome://'+projectName+'/content/'+projectName+'.xul");\n' + |
|---|
| | 193 | 'pref("browser. hiddenWindowChromeURL", "chrome://'+projectName+'/content/'+projectName+'.xul");\n' + |
|---|
| | 194 | 'pref("browser.dom.window.dump.enabled", true);\n' + |
|---|
| | 195 | 'pref("javascript.options.showInConsole", true);\n' + |
|---|
| | 196 | 'pref("javascript.options.strict", true);\n' + |
|---|
| | 197 | 'pref("nglayout.debug.disable_xul_cache", true);\n' + |
|---|
| | 198 | 'pref("nglayout.debug.disable_xul_fastload", true);\n'; |
|---|
| | 199 | |
|---|
| | 200 | var data = LilyUtils.readFile(tmpOut); |
|---|
| | 201 | data += newPrefs; |
|---|
| | 202 | LilyUtils.writeFile(tmpOut,data); |
|---|
| | 203 | } |
|---|
| | 204 | }, |
|---|
| | 205 | |
|---|
| | 206 | /* START CONTENT COPYING */ |
|---|
| | 207 | |
|---|
| | 208 | function() { |
|---|
| | 209 | //content |
|---|
| | 210 | contentIn = Lily.installDir.clone(); |
|---|
| | 211 | contentIn.append("chrome"); |
|---|
| | 212 | contentIn.append("content"); |
|---|
| | 213 | contentOut = rootDir.clone(); |
|---|
| | 214 | contentOut.append("chrome"); |
|---|
| | 215 | contentOut.append("content"); |
|---|
| | 216 | |
|---|
| | 217 | if( !contentOut.exists() || !contentOut.isDirectory() ) { // if it doesn't exist, create |
|---|
| | 218 | contentOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 219 | } |
|---|
| | 220 | }, |
|---|
| | 221 | |
|---|
| | 222 | function() { |
|---|
| | 223 | xulIn = contentIn.clone(); |
|---|
| | 224 | xulIn.append("xul"); |
|---|
| | 225 | |
|---|
| | 226 | //create the xul directory |
|---|
| | 227 | xulOut = rootDir.clone(); |
|---|
| | 228 | xulOut.append("chrome"); |
|---|
| | 229 | xulOut.append("content"); |
|---|
| | 230 | xulOut.append("xul"); |
|---|
| | 231 | |
|---|
| | 232 | if( !xulOut.exists() || !xulOut.isDirectory() ) { // if it doesn't exist, create |
|---|
| | 233 | xulOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 234 | } |
|---|
| | 235 | }, |
|---|
| | 236 | |
|---|
| | 237 | function() { |
|---|
| | 238 | configIn = contentIn.clone(); |
|---|
| | 239 | configIn.append("config"); |
|---|
| | 240 | |
|---|
| | 241 | //create the config directory |
|---|
| | 242 | configOut = rootDir.clone(); |
|---|
| | 243 | configOut.append("chrome"); |
|---|
| | 244 | configOut.append("content"); |
|---|
| | 245 | configOut.append("config"); |
|---|
| | 246 | |
|---|
| | 247 | if(!configOut.exists()) { // if it doesn't exist, create |
|---|
| | 248 | configOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 249 | } |
|---|
| | 250 | }, |
|---|
| | 251 | |
|---|
| | 252 | function() { |
|---|
| | 253 | //apikey |
|---|
| | 254 | var tmp = xulIn.clone(); |
|---|
| | 255 | tmp.append("apikey.xul"); |
|---|
| | 256 | tmp.copyTo(xulOut,null); |
|---|
| | 257 | }, |
|---|
| | 258 | |
|---|
| | 259 | function() { |
|---|
| | 260 | //blank.html |
|---|
| | 261 | var tmp = contentIn.clone(); |
|---|
| | 262 | tmp.append("blank.html"); |
|---|
| | 263 | tmp.copyTo(contentOut,null); |
|---|
| | 264 | }, |
|---|
| | 265 | |
|---|
| | 266 | function() { |
|---|
| | 267 | //config.txt- create a config file with an appropriate ext/app id & store the debug win pref |
|---|
| | 268 | var config = {}; |
|---|
| | 269 | config["extID"] = (projectName+".id@"+projectName+".com"); |
|---|
| | 270 | config["openDebugWin"] = (!obj.hideDebugCbx); |
|---|
| | 271 | var tmpOut = configOut.clone(); |
|---|
| | 272 | tmpOut.append("config.txt"); |
|---|
| | 273 | LilyUtils.writeFile(tmpOut,config.toSource()); |
|---|
| | 274 | }, |
|---|
| | 275 | |
|---|
| | 276 | function() { |
|---|
| | 277 | //connection.js |
|---|
| | 278 | var tmp = contentIn.clone(); |
|---|
| | 279 | tmp.append("connection.js"); |
|---|
| | 280 | tmp.copyTo(contentOut,null); |
|---|
| | 281 | }, |
|---|
| | 282 | |
|---|
| | 283 | function() { |
|---|
| | 284 | //debug.js |
|---|
| | 285 | var tmpIn = contentIn.clone(); |
|---|
| | 286 | tmpIn.append("debug.js"); |
|---|
| | 287 | var tmpOut = contentOut.clone(); |
|---|
| | 288 | tmpOut.append("debug.js"); |
|---|
| | 289 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 290 | }, |
|---|
| | 291 | |
|---|
| | 292 | function() { |
|---|
| | 293 | //debug.html |
|---|
| | 294 | var tmp = contentIn.clone(); |
|---|
| | 295 | tmp.append("debug.html"); |
|---|
| | 296 | tmp.copyTo(contentOut,null); |
|---|
| | 297 | }, |
|---|
| | 298 | |
|---|
| | 299 | function() { |
|---|
| | 300 | //debug.xul |
|---|
| | 301 | var tmpIn = xulIn.clone(); |
|---|
| | 302 | tmpIn.append("debug.xul"); |
|---|
| | 303 | var tmpOut = xulOut.clone(); |
|---|
| | 304 | tmpOut.append("debug.xul"); |
|---|
| | 305 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 306 | }, |
|---|
| | 307 | |
|---|
| | 308 | function() { |
|---|
| | 309 | //externals |
|---|
| | 310 | var externalIn = contentIn.clone(); |
|---|
| | 311 | externalIn.append("externals"); |
|---|
| | 312 | var externalOut = contentOut.clone(); |
|---|
| | 313 | externalOut.append("externals"); |
|---|
| | 314 | |
|---|
| | 315 | if( !externalOut.exists() || !externalOut.isDirectory() ) { // if it doesn't exist, create |
|---|
| | 316 | externalOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 317 | } |
|---|
| | 318 | |
|---|
| | 319 | //iterate and copy... |
|---|
| | 320 | for(var i=0;i<objArr.length;i++) { |
|---|
| | 321 | var data = objArr[i].source.replace(/chrome:\/\/lily/g,("chrome://"+projectName)); |
|---|
| | 322 | var tmpOut = externalOut.clone(); |
|---|
| | 323 | tmpOut.append(objArr[i].name+".js"); |
|---|
| | 324 | LilyUtils.writeFile(tmpOut,data); |
|---|
| | 325 | } |
|---|
| | 326 | }, |
|---|
| | 327 | |
|---|
| | 328 | function() { |
|---|
| | 329 | //images |
|---|
| | 330 | var tmp = contentIn.clone(); |
|---|
| | 331 | tmp.append("images"); |
|---|
| | 332 | tmp.copyTo(contentOut,null); |
|---|
| | 333 | }, |
|---|
| | 334 | |
|---|
| | 335 | function() { |
|---|
| | 336 | //inspector.js |
|---|
| | 337 | var tmpIn = contentIn.clone(); |
|---|
| | 338 | tmpIn.append("inspector.js"); |
|---|
| | 339 | var tmpOut = contentOut.clone(); |
|---|
| | 340 | tmpOut.append("inspector.js"); |
|---|
| | 341 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 342 | }, |
|---|
| | 343 | |
|---|
| | 344 | function() { |
|---|
| | 345 | //keys.txt |
|---|
| | 346 | var tmp = configIn.clone(); |
|---|
| | 347 | tmp.append("keys.txt"); |
|---|
| | 348 | tmp.copyTo(configOut,null); |
|---|
| | 349 | }, |
|---|
| | 350 | |
|---|
| | 351 | function() { |
|---|
| | 352 | //keys.js |
|---|
| | 353 | var tmp = contentIn.clone(); |
|---|
| | 354 | tmp.append("keys.js"); |
|---|
| | 355 | tmp.copyTo(contentOut,null); |
|---|
| | 356 | }, |
|---|
| | 357 | |
|---|
| | 358 | function() { |
|---|
| | 359 | //font-compat.txt |
|---|
| | 360 | var tmp = configIn.clone(); |
|---|
| | 361 | tmp.append("font-compat.txt"); |
|---|
| | 362 | tmp.copyTo(configOut,null); |
|---|
| | 363 | }, |
|---|
| | 364 | |
|---|
| | 365 | function() { |
|---|
| | 366 | //lib |
|---|
| | 367 | var tmp = contentIn.clone(); |
|---|
| | 368 | tmp.append("lib"); |
|---|
| | 369 | tmp.copyTo(contentOut,null); |
|---|
| | 370 | }, |
|---|
| | 371 | |
|---|
| | 372 | function() { |
|---|
| | 373 | //lily.js |
|---|
| | 374 | var tmpIn = contentIn.clone(); |
|---|
| | 375 | tmpIn.append("lily.js"); |
|---|
| | 376 | var tmpOut = contentOut.clone(); |
|---|
| | 377 | tmpOut.append("lily.js"); |
|---|
| | 378 | var data = LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName)); |
|---|
| | 379 | data = data.replace(/nameSpace: "lily",/,"nameSpace: \""+projectName+"\","); |
|---|
| | 380 | LilyUtils.writeFile(tmpOut,data); |
|---|
| | 381 | }, |
|---|
| | 382 | |
|---|
| | 383 | function() { |
|---|
| | 384 | //<projectname>.xul |
|---|
| | 385 | var tmpIn = xulIn.clone(); |
|---|
| | 386 | tmpIn.append("export-window.xul"); |
|---|
| | 387 | var tmpOut = contentOut.clone(); |
|---|
| | 388 | tmpOut.append(projectName+".xul"); |
|---|
| | 389 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/<PROJECT-NAME>/g,projectName).replace(/<PATCH-FILE-NAME>/g,obj.patchFileName).replace(/<PATCH-HIDDEN>/g,obj.hideMainCbx)); |
|---|
| | 390 | }, |
|---|
| | 391 | |
|---|
| | 392 | function() { |
|---|
| | 393 | //lily.css |
|---|
| | 394 | var tmp = contentIn.clone(); |
|---|
| | 395 | tmp.append("lily.css"); |
|---|
| | 396 | tmp.copyTo(contentOut,null); |
|---|
| | 397 | }, |
|---|
| | 398 | |
|---|
| | 399 | function() { |
|---|
| | 400 | //menus.js |
|---|
| | 401 | var tmp = contentIn.clone(); |
|---|
| | 402 | tmp.append("menus.js"); |
|---|
| | 403 | tmp.copyTo(contentOut,null); |
|---|
| | 404 | }, |
|---|
| | 405 | |
|---|
| | 406 | function() { |
|---|
| | 407 | //external.js |
|---|
| | 408 | var tmp = contentIn.clone(); |
|---|
| | 409 | tmp.append("externals.js"); |
|---|
| | 410 | tmp.copyTo(contentOut,null); |
|---|
| | 411 | }, |
|---|
| | 412 | |
|---|
| | 413 | function() { |
|---|
| | 414 | //object |
|---|
| | 415 | var tmp = contentIn.clone(); |
|---|
| | 416 | tmp.append("object"); |
|---|
| | 417 | tmp.copyTo(contentOut,null); |
|---|
| | 418 | }, |
|---|
| | 419 | |
|---|
| | 420 | function() { |
|---|
| | 421 | //patch |
|---|
| | 422 | var patchArr = [ |
|---|
| | 423 | "model.js", |
|---|
| | 424 | "base.js", |
|---|
| | 425 | "controller.js", |
|---|
| | 426 | "view.js" |
|---|
| | 427 | ]; |
|---|
| | 428 | |
|---|
| | 429 | var patchOut = contentOut.clone(); |
|---|
| | 430 | patchOut.append("patch"); |
|---|
| | 431 | |
|---|
| | 432 | if( !patchOut.exists() || !patchOut.isDirectory() ) { // if it doesn't exist, create |
|---|
| | 433 | patchOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 434 | } |
|---|
| | 435 | |
|---|
| | 436 | for(var i=0;i<patchArr.length;i++) { |
|---|
| | 437 | var tmpIn = contentIn.clone(); |
|---|
| | 438 | tmpIn.append("patch"); |
|---|
| | 439 | tmpIn.append(patchArr[i]); |
|---|
| | 440 | |
|---|
| | 441 | var tmpOut = contentOut.clone(); |
|---|
| | 442 | tmpOut.append("patch"); |
|---|
| | 443 | tmpOut.append(patchArr[i]); |
|---|
| | 444 | |
|---|
| | 445 | var data = LilyUtils.readFile(tmpIn); |
|---|
| | 446 | data = data.replace(/chrome:\/\/lily/g,("chrome://"+projectName)); |
|---|
| | 447 | LilyUtils.writeFile(tmpOut,data); |
|---|
| | 448 | } |
|---|
| | 449 | }, |
|---|
| | 450 | |
|---|
| | 451 | function() { |
|---|
| | 452 | //patch.xhtml |
|---|
| | 453 | var tmp = contentIn.clone(); |
|---|
| | 454 | tmp.append("patch.xhtml"); |
|---|
| | 455 | tmp.copyTo(contentOut,null); |
|---|
| | 456 | }, |
|---|
| | 457 | |
|---|
| | 458 | function() { |
|---|
| | 459 | //prefs.js |
|---|
| | 460 | var tmpIn = contentIn.clone(); |
|---|
| | 461 | tmpIn.append("prefs.js"); |
|---|
| | 462 | var tmpOut = contentOut.clone(); |
|---|
| | 463 | tmpOut.append("prefs.js"); |
|---|
| | 464 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 465 | }, |
|---|
| | 466 | |
|---|
| | 467 | function() { |
|---|
| | 468 | //prefs.xul |
|---|
| | 469 | var tmpIn = contentIn.clone(); |
|---|
| | 470 | tmpIn.append("prefs.xul"); |
|---|
| | 471 | var tmpOut = contentOut.clone(); |
|---|
| | 472 | tmpOut.append("prefs.xul"); |
|---|
| | 473 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 474 | }, |
|---|
| | 475 | |
|---|
| | 476 | function() { |
|---|
| | 477 | //readonlypatch.xul |
|---|
| | 478 | if(!obj.hideMainCbx) { |
|---|
| | 479 | var tmpIn = xulIn.clone(); |
|---|
| | 480 | tmpIn.append("applicationpatch.xul"); |
|---|
| | 481 | var tmpOut = xulOut.clone(); |
|---|
| | 482 | tmpOut.append("readonlypatch.xul"); |
|---|
| | 483 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 484 | } else { |
|---|
| | 485 | var tmpIn = xulIn.clone(); |
|---|
| | 486 | tmpIn.append("hiddenpatch.xul"); |
|---|
| | 487 | var tmpOut = xulOut.clone(); |
|---|
| | 488 | tmpOut.append("hiddenpatch.xul"); |
|---|
| | 489 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 490 | } |
|---|
| | 491 | }, |
|---|
| | 492 | |
|---|
| | 493 | function() { |
|---|
| | 494 | //copy the resources dir |
|---|
| | 495 | var tmp = contentIn.clone(); |
|---|
| | 496 | tmp.append("resources"); |
|---|
| | 497 | tmp.copyTo(contentOut,null); |
|---|
| | 498 | }, |
|---|
| | 499 | |
|---|
| | 500 | function() { |
|---|
| | 501 | //get a handle on the new resources dir |
|---|
| | 502 | var resourcesDir = contentOut.clone(); |
|---|
| | 503 | resourcesDir.append("resources"); |
|---|
| | 504 | |
|---|
| | 505 | //recurse thru the resources dir converting text files as needed. |
|---|
| | 506 | LilyUtils.directorySearch(resourcesDir,function(file){ |
|---|
| | 507 | if(LilyUtils.isText(file.leafName)) { |
|---|
| | 508 | LilyUtils.writeFile(file,LilyUtils.readFile(file).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 509 | } |
|---|
| | 510 | }) |
|---|
| | 511 | }, |
|---|
| | 512 | |
|---|
| | 513 | function() { |
|---|
| | 514 | //services.js |
|---|
| | 515 | var tmp = contentIn.clone(); |
|---|
| | 516 | tmp.append("services.js"); |
|---|
| | 517 | tmp.copyTo(contentOut,null); |
|---|
| | 518 | }, |
|---|
| | 519 | |
|---|
| | 520 | function() { |
|---|
| | 521 | //utils |
|---|
| | 522 | var utils_files = [ |
|---|
| | 523 | "core.js", |
|---|
| | 524 | "file.js", |
|---|
| | 525 | "font.js", |
|---|
| | 526 | "patch.js", |
|---|
| | 527 | "prefs.js", |
|---|
| | 528 | "string.js", |
|---|
| | 529 | "window.js" |
|---|
| | 530 | ] |
|---|
| | 531 | |
|---|
| | 532 | var utilsOut = contentOut.clone(); |
|---|
| | 533 | utilsOut.append("utils"); |
|---|
| | 534 | |
|---|
| | 535 | if( !utilsOut.exists() || !utilsOut.isDirectory() ) { // if it doesn't exist, create |
|---|
| | 536 | utilsOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 537 | } |
|---|
| | 538 | |
|---|
| | 539 | for(var i=0;i<utils_files.length;i++) { |
|---|
| | 540 | var tmpIn = contentIn.clone(); |
|---|
| | 541 | tmpIn.append("utils"); |
|---|
| | 542 | tmpIn.append(utils_files[i]); |
|---|
| | 543 | |
|---|
| | 544 | var tmpOut = contentOut.clone(); |
|---|
| | 545 | tmpOut.append("utils"); |
|---|
| | 546 | tmpOut.append(utils_files[i]); |
|---|
| | 547 | |
|---|
| | 548 | var data = LilyUtils.readFile(tmpIn); |
|---|
| | 549 | data = data.replace(/chrome:\/\/lily/g,("chrome://"+projectName)); |
|---|
| | 550 | LilyUtils.writeFile(tmpOut,data); |
|---|
| | 551 | } |
|---|
| | 552 | }, |
|---|
| | 553 | |
|---|
| | 554 | function() { |
|---|
| | 555 | //components |
|---|
| | 556 | var component_files = [ |
|---|
| | 557 | "dialog.js", |
|---|
| | 558 | "editor.js", |
|---|
| | 559 | "iframe.js", |
|---|
| | 560 | "xhr.js" |
|---|
| | 561 | ] |
|---|
| | 562 | |
|---|
| | 563 | var componentsOut = contentOut.clone(); |
|---|
| | 564 | componentsOut.append("components"); |
|---|
| | 565 | |
|---|
| | 566 | if( !componentsOut.exists() || !componentsOut.isDirectory() ) { // if it doesn't exist, create |
|---|
| | 567 | componentsOut.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); |
|---|
| | 568 | } |
|---|
| | 569 | |
|---|
| | 570 | for(var i=0;i<component_files.length;i++) { |
|---|
| | 571 | var tmpIn = contentIn.clone(); |
|---|
| | 572 | tmpIn.append("components"); |
|---|
| | 573 | tmpIn.append(component_files[i]); |
|---|
| | 574 | |
|---|
| | 575 | var tmpOut = contentOut.clone(); |
|---|
| | 576 | tmpOut.append("components"); |
|---|
| | 577 | tmpOut.append(component_files[i]); |
|---|
| | 578 | |
|---|
| | 579 | var data = LilyUtils.readFile(tmpIn); |
|---|
| | 580 | data = data.replace(/chrome:\/\/lily/g,("chrome://"+projectName)); |
|---|
| | 581 | LilyUtils.writeFile(tmpOut,data); |
|---|
| | 582 | } |
|---|
| | 583 | }, |
|---|
| | 584 | |
|---|
| | 585 | function() { |
|---|
| | 586 | //bootstrap.js |
|---|
| | 587 | var tmpIn = contentIn.clone(); |
|---|
| | 588 | tmpIn.append("bootstrap.js"); |
|---|
| | 589 | var tmpOut = contentOut.clone(); |
|---|
| | 590 | tmpOut.append("bootstrap.js"); |
|---|
| | 591 | LilyUtils.writeFile(tmpOut,LilyUtils.readFile(tmpIn).replace(/chrome:\/\/lily/g,("chrome://"+projectName))); |
|---|
| | 592 | }, |
|---|
| | 593 | |
|---|
| | 594 | function() { |
|---|
| | 595 | //patch |
|---|
| | 596 | var tmp = contentOut.clone(); |
|---|
| | 597 | tmp.append(obj.patchFileName+".json"); |
|---|
| | 598 | var data=Lily.patchObj[id].obj.patchModel.serializeDom(); |
|---|
| | 599 | data=data.replace(/chrome:\/\/lily/g,("chrome://"+projectName)); |
|---|
| | 600 | Lily.patchObj[id].json=data; //update the patch string. |
|---|
| | 601 | tmp=LilyUtils.writeFile(tmp,data); |
|---|
| | 602 | }, |
|---|
| | 603 | |
|---|
| | 604 | function() { |
|---|
| | 605 | //copy subpatches |
|---|
| | 606 | //******* FIXME ******** won't work with absolute paths, won't work with subfolders. |
|---|
| | 607 | var subPatchArr = dependencies["subPatches"]; |
|---|
| | 608 | for(var i=0;i<subPatchArr.length;i++) { |
|---|
| | 609 | if(!LilyUtils.containsProtocol(subPatchArr[i])) { |
|---|
| | 610 | var tmpIn = LilyUtils.getFileHandle(LilyUtils.getFilePath(subPatchArr[i])); |
|---|
| | 611 | var tmpOut = contentOut.clone(); |
|---|
| | 612 | tmpOut.append(tmpIn.leafName); |
|---|
| | 613 | // LilyDebugWindow.print(tmpIn.leafName+" "+LilyUtils.readFile(tmpIn)); |
|---|
| | 614 | |
|---|