From 9e7346f1e86e222f8a581cc4ed19869317762b51 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Fri, 2 Aug 2013 17:49:45 -0400 Subject: [PATCH] New: new index.html with loading progress by default. Previously, the index[-debug].html in the default capp templates did not include a loading progress function. We just had the plain spinner, which gave no visible sign of progress. Now the capp templates include a progress function and a nice iOS7-ish progress thermometer is displayed during loading (except when run directly from source). 'jake debug' and 'jake release' will now generate the application/image sizes needed to display loading progress. The old spinner.gif has been removed. In addition, the message displayed when JavaScript is unavailable has been simplified and shows a link to www.enable-javascript.com instead of the missing link to our old site. --- .../Resources/Templates/Application/Jakefile | 110 ++++++++++-- .../Application/Resources/spinner.gif | Bin 1434 -> 0 bytes .../Templates/Application/index-debug.html | 156 ++++++++++++----- .../Templates/Application/index.html | 155 ++++++++++++----- .../Templates/NibApplication/Jakefile | 110 ++++++++++-- .../NibApplication/Resources/spinner.gif | Bin 1434 -> 0 bytes .../Templates/NibApplication/index-debug.html | 154 ++++++++++++----- .../Templates/NibApplication/index.html | 154 ++++++++++++----- .../ThemeDescriptor/Resources/spinner.gif | Bin 1434 -> 0 bytes .../ThemeDescriptor/index-debug.html | 161 +++++++++++++----- .../Templates/ThemeDescriptor/index.html | 158 ++++++++++++----- 11 files changed, 898 insertions(+), 260 deletions(-) delete mode 100644 Tools/capp/Resources/Templates/Application/Resources/spinner.gif delete mode 100644 Tools/capp/Resources/Templates/NibApplication/Resources/spinner.gif delete mode 100644 Tools/capp/Resources/Templates/ThemeDescriptor/Resources/spinner.gif diff --git a/Tools/capp/Resources/Templates/Application/Jakefile b/Tools/capp/Resources/Templates/Application/Jakefile index 90649110e..6207c9b34 100644 --- a/Tools/capp/Resources/Templates/Application/Jakefile +++ b/Tools/capp/Resources/Templates/Application/Jakefile @@ -13,9 +13,10 @@ var ENV = require("system").env, FileList = JAKE.FileList, app = require("cappuccino/jake").app, configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", - OS = require("os"); + OS = require("os"), + projectName = "__project.nameasidentifier__"; -app ("__project.nameasidentifier__", function(task) +app (projectName, function(task) { ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks"; @@ -42,12 +43,15 @@ app ("__project.nameasidentifier__", function(task) task.setCompilerFlags("-O"); }); -task ("default", ["__project.nameasidentifier__"], function() +task ("default", [projectName], function() { printResults(configuration); }); -task ("build", ["default"]); +task ("build", ["default"], function() +{ + updateApplicationSize(); +}); task ("debug", function() { @@ -63,36 +67,118 @@ task ("release", function() task ("run", ["debug"], function() { - OS.system(["open", FILE.join("Build", "Debug", "__project.nameasidentifier__", "index.html")]); + OS.system(["open", FILE.join("Build", "Debug", projectName, "index.html")]); }); task ("run-release", ["release"], function() { - OS.system(["open", FILE.join("Build", "Release", "__project.nameasidentifier__", "index.html")]); + OS.system(["open", FILE.join("Build", "Release", projectName, "index.html")]); }); task ("deploy", ["release"], function() { - FILE.mkdirs(FILE.join("Build", "Deployment", "__project.nameasidentifier__")); - OS.system(["press", "-f", FILE.join("Build", "Release", "__project.nameasidentifier__"), FILE.join("Build", "Deployment", "__project.nameasidentifier__")]); + FILE.mkdirs(FILE.join("Build", "Deployment", projectName)); + OS.system(["press", "-f", FILE.join("Build", "Release", projectName), FILE.join("Build", "Deployment", projectName)]); printResults("Deployment") }); task ("desktop", ["release"], function() { - FILE.mkdirs(FILE.join("Build", "Desktop", "__project.nameasidentifier__")); - require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "__project.nameasidentifier__"), FILE.join("Build", "Desktop", "__project.nameasidentifier__", "__project.nameasidentifier__.app")); + FILE.mkdirs(FILE.join("Build", "Desktop", projectName)); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", projectName), FILE.join("Build", "Desktop", projectName, "__project.nameasidentifier__.app")); printResults("Desktop") }); task ("run-desktop", ["desktop"], function() { - OS.system([FILE.join("Build", "Desktop", "__project.nameasidentifier__", "__project.nameasidentifier__.app", "Contents", "MacOS", "NativeHost"), "-i"]); + OS.system([FILE.join("Build", "Desktop", projectName, "__project.nameasidentifier__.app", "Contents", "MacOS", "NativeHost"), "-i"]); }); function printResults(configuration) { print("----------------------------"); - print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__")); + print(configuration+" app built at path: "+FILE.join("Build", configuration, projectName)); print("----------------------------"); } + +function updateApplicationSize() +{ + print("Calculating application file sizes..."); + + var contents = FILE.read(FILE.join("Build", ENV["CONFIGURATION"], projectName, "Info.plist"), { charset:"UTF-8" }), + format = CFPropertyList.sniffedFormatOfString(contents), + plist = CFPropertyList.propertyListFromString(contents), + totalBytes = {executable:0, data:0, mhtml:0}; + + // Get the size of all framework executables and sprite data + var frameworksDir = "Frameworks"; + + if (ENV["CONFIGURATION"] === "Debug") + frameworksDir = FILE.join(frameworksDir, "Debug"); + + var frameworks = FILE.list(frameworksDir); + + frameworks.forEach(function(framework) + { + if (framework !== "Source") + addBundleFileSizes(FILE.join(frameworksDir, framework), totalBytes); + }); + + // Read in the default theme name, and attempt to get its size + var themeName = plist.valueForKey("CPDefaultTheme") || "Aristo2", + themePath = nil; + + if (themeName === "Aristo" || themeName === "Aristo2") + themePath = FILE.join(frameworksDir, "AppKit", "Resources", themeName + ".blend"); + else + themePath = FILE.join("Frameworks", "Resources", themeName + ".blend"); + + if (FILE.isDirectory(themePath)) + addBundleFileSizes(themePath, totalBytes); + + // Add sizes for the app + addBundleFileSizes(FILE.join("Build", ENV["CONFIGURATION"], projectName), totalBytes); + + print("Executables: " + totalBytes.executable + ", sprite data: " + totalBytes.data + ", total: " + (totalBytes.executable + totalBytes.data)); + + var dict = new CFMutableDictionary(); + + dict.setValueForKey("executable", totalBytes.executable); + dict.setValueForKey("data", totalBytes.data); + dict.setValueForKey("mhtml", totalBytes.mhtml); + + plist.setValueForKey("CPApplicationSize", dict); + + FILE.write(FILE.join("Build", ENV["CONFIGURATION"], projectName, "Info.plist"), CFPropertyList.stringFromPropertyList(plist, format), { charset:"UTF-8" }); +} + +function addBundleFileSizes(bundlePath, totalBytes) +{ + var bundleName = FILE.basename(bundlePath), + environment = bundleName === "Foundation" ? "Objj" : "Browser", + bundlePath = FILE.join(bundlePath, environment + ".environment"); + + if (FILE.isDirectory(bundlePath)) + { + var filename = bundleName + ".sj", + filePath = new FILE.Path(FILE.join(bundlePath, filename)); + + if (filePath.exists()) + totalBytes.executable += filePath.size(); + + filePath = new FILE.Path(FILE.join(bundlePath, "dataURLs.txt")); + + if (filePath.exists()) + totalBytes.data += filePath.size(); + + filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLData.txt")); + + if (filePath.exists()) + totalBytes.mhtml += filePath.size(); + + filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLPaths.txt")); + + if (filePath.exists()) + totalBytes.mhtml += filePath.size(); + } +} diff --git a/Tools/capp/Resources/Templates/Application/Resources/spinner.gif b/Tools/capp/Resources/Templates/Application/Resources/spinner.gif deleted file mode 100644 index a5e705f6cbdf914e5e714c35a8dfef807f19e3c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1434 zcmZvbdrVVj7{t$-UNOu86#VHu^|s&3rWfwHBbPG_8{SrlB{Tv1uvvj4t6zP!)#d!Ogc zP^62J^$0+~?-ZcXXpBaq%jFsw8L`=H2?+@R02Yg-*Xw;gACBV^i3CMahr>Z667S!? zk3LDe>VLEsU;sWo$Py~o!gWuaIAnaG3Sv``&tvc+8DJO!| zt4fcbQ8tW}a&xZfgtQ9BnFYLvGG|PvCNlg&uh@Q^w9Pz}+I^hCj`vu9JQADPqdkyk zR40xycD9geUgJu1e;$L`Fpa)?Wl-2&6hO@U*KrPqK(I1H=1h?2fce}6GhhP1oBZC# z1e@gt-qFa6lZrl%s1>bdxg*W)Ebt__O(4sj6(*2X@ciUClwHH#U(NRM7XAjS z+scDZ32J*PCoslsgS~#ZlCCGo`r>S6F)Ghw5wVlqHioFaw?ucD(XoLJ0j;28oPoPV z9A}dR$0SKn>uExfkl#j09o;v$BZ909R=*p{ATNq8BJW;YduX2QMOU7$a$_L5e!G^g zpbkx5G4&FZ%7m14rTN}5YB(;x7$5XOc_hf3E|Hw$TVg)P#qf~}nOn03uqsp>UG>vi zWThIoO)-1Q#@u#O;fMC#WAf@Xj70-0g9YZ;dA$HH1fW1q=9-c>>_yA0S$7M*5?}vi z)8MU`Q%P!7sEBBnd$DrKgFQ2?O%6LpdaC%F8Pn-)EC2t=j~ zoaLamla$FX!GQqWi!%s>sj-#5SJX0IF!TP=r21Z}s)k#btN0?=I7uD9C)Gb$fZ#sm zaVq7g`LwZ%PfNpN^_N-IGLHj@AV`s#4&va7_{Hw63G6BkSGXHdogTZ%QOiRb bDpZ@qYcJKM>x%b%*HX74c8MnqfHi*u-bC?g diff --git a/Tools/capp/Resources/Templates/Application/index-debug.html b/Tools/capp/Resources/Templates/Application/index-debug.html index 746b7ef83..3553a0e4d 100644 --- a/Tools/capp/Resources/Templates/Application/index-debug.html +++ b/Tools/capp/Resources/Templates/Application/index-debug.html @@ -27,12 +27,36 @@ __project.name__ + + + - + - - - - -
-
- - -