From d7f0bf6a244e1333d97bc7a20e79b3a0b8b9255c Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Fri, 5 Mar 2010 22:34:04 -0800 Subject: [PATCH] Support root level apps. Reviewed by me. --- Foundation/CPBundle.j | 7 ++++++- Objective-J/Bootstrap.js | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index b2c4fd4e4..5c9a6f812 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -77,9 +77,14 @@ var CPBundlesForPaths = { }; // ??? } +- (CPURL)bundleURL +{ + return _bundle.bundleURL(); +} + - (CPString)bundlePath { - return _bundle.path(); + return [[self bundleURL] path]; } - (CPString)resourcePath diff --git a/Objective-J/Bootstrap.js b/Objective-J/Bootstrap.js index 8f4047e57..4ea0e9155 100644 --- a/Objective-J/Bootstrap.js +++ b/Objective-J/Bootstrap.js @@ -29,6 +29,10 @@ function makeAbsoluteURL(/*CFURL|String*/ aURL) #ifdef COMMONJS var mainBundleURL = new CFURL("file:" + require("file").cwd()); #elif defined(BROWSER) +// This is automatic when importing, but we'd like these important URLs to +// be taken into consideration in the cache as well. +enableCFURLCaching(); + // To determine where our application lives, start with the current URL of the page. var pageURL = new CFURL(window.location.href), @@ -50,9 +54,16 @@ if (DOMBaseElementsCount > 0) var mainFileURL = new CFURL(window.OBJJ_MAIN_FILE || "main.j"), // The main bundle is the containing folder of the main file. - mainBundleURL = new CFURL(".", new CFURL(mainFileURL, pageURL)).absoluteURL(); + mainBundleURL = new CFURL(".", new CFURL(mainFileURL, pageURL)).absoluteURL(), -StaticResource.resourceAtURL(new CFURL("..", mainBundleURL).absoluteURL(), YES); +// We assume the "first part" of the path is completely resolved. + assumedResolvedURL = new CFURL("..", mainBundleURL).absoluteURL(); + +// .. doesn't work if we're already at root, so "go back" one more level to the scheme and authority. +if (mainBundleURL === assumedResolvedURL) + assumedResolvedURL = new CFURL(assumedResolvedURL.schemeAndAuthority()); + +StaticResource.resourceAtURL(assumedResolvedURL, YES); exports.bootstrap = function() { @@ -72,6 +83,7 @@ function resolveMainBundleURL() Executable.fileImporterForURL(mainBundleURL)(mainFileURL.lastPathComponent(), YES, function() { + disableCFURLCaching(); afterDocumentLoad(main); }); });