From ab63de6db42ebf5d04792acd927c3b460d14308b Mon Sep 17 00:00:00 2001 From: Andreas Kalsch Date: Tue, 10 May 2011 23:37:18 +0200 Subject: [PATCH 1/6] push module instead of module.module --- lib/yabble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yabble.js b/lib/yabble.js index 5d1751d..3d4c647 100644 --- a/lib/yabble.js +++ b/lib/yabble.js @@ -207,7 +207,7 @@ args.push(module.exports); } else if (injects[i] == 'module') { - args.push(module.module); + args.push(module); } } From 9a24dac8f44ba6157214c31c524176609185141a Mon Sep 17 00:00:00 2001 From: Andreas Kalsch Date: Tue, 10 May 2011 23:39:13 +0200 Subject: [PATCH 2/6] Add small node.js server for serving static files --- test/server.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/server.js diff --git a/test/server.js b/test/server.js new file mode 100644 index 0000000..c0092a4 --- /dev/null +++ b/test/server.js @@ -0,0 +1,17 @@ +/* +This is a small node.js server, so that you can test Yabble on your OS without using the file:/// protocol. +You need to +- install node.js (nodejs.org) +- install node package manager (npmjs.org) +- Type: npm install connect +- Type: node server.js ROOTDIR & +- Go to http://localhost:3000/index.html +*/ + +var connect = require('connect') + +dir = process.argv[2] + +connect( + connect.static(dir) +).listen(3000) From 043a88ea2e45f4daf97defc90ca0081ee5e6adbc Mon Sep 17 00:00:00 2001 From: Andreas Kalsch Date: Thu, 12 May 2011 13:25:47 +0200 Subject: [PATCH 3/6] resolveModuleUri() with HTTP support --- lib/yabble.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/yabble.js b/lib/yabble.js index 3d4c647..86e212c 100644 --- a/lib/yabble.js +++ b/lib/yabble.js @@ -130,7 +130,10 @@ // Takes a module's ID and resolves a URI according to the module root path var resolveModuleUri = function(moduleId) { - if (moduleId.charAt(0) != '.') { + if (/^http(s?):\/\//.test(moduleId)) { + return moduleId+'.js'; + } + else if (moduleId.charAt(0) != '.') { return _moduleRoot+moduleId+'.js'; } else { @@ -563,4 +566,4 @@ window.require = Yabble; })(function(code) { return (window.eval || eval)(code, null); -}); \ No newline at end of file +}); From d269ff057610e618e9d43bd8c5f333ab9edf1f2e Mon Sep 17 00:00:00 2001 From: Andreas Kalsch Date: Mon, 28 Nov 2011 20:57:00 +0100 Subject: [PATCH 4/6] Some fixes --- lib/yabble.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/yabble.js b/lib/yabble.js index 86e212c..9933045 100644 --- a/lib/yabble.js +++ b/lib/yabble.js @@ -38,6 +38,7 @@ _timeoutLength = 20000, _mainProgram; + var head = document.getElementsByTagName('head')[0]; @@ -186,17 +187,19 @@ // relative require()s var createRequireFunc = function(refPath) { var require = function(relModuleId) { - var moduleId = resolveModuleId(relModuleId, refPath), - module = getModule(moduleId); + var moduleId = resolveModuleId(relModuleId, refPath); + var module = getModule(moduleId); + + console.log(relModuleId, moduleId, refPath, _modules) if (!module) { throw "Module not loaded"; } - else if (module.error) { + /*else if (module.error) { throw "Error loading module"; - } + }*/ - if (!module.exports) { + if (!module.exports && !module.error) { module.exports = {}; var moduleDir = moduleId.substring(0, moduleId.lastIndexOf('/')+1), injects = module.injects, @@ -401,6 +404,8 @@ fireCallbacks(); } } + + // head.removeChild(scriptEl); }; if (useStandard) { @@ -456,9 +461,17 @@ // Set the uri which forms the conceptual module namespace root Yabble.setModuleRoot = function(path) { if (!(/^http(s?):\/\//.test(path))) { - var href = window.location.href; - href = href.substr(0, href.lastIndexOf('/')+1); - path = combinePaths(path, href); + var href = location.protocol+'//'+location.host; + if (path.charAt(0) !== '/') { + href += location.pathname; + path = combinePaths( + path, + href + ); + } + else { + path = href+path; + } } if (path.length && path.charAt(path.length-1) != '/') { @@ -561,6 +574,8 @@ }; Yabble.reset(); + + Yabble._modules = _modules; // Export to the require global window.require = Yabble; From c4137c89a5674e86c268c1ce59a2eccbcf063656 Mon Sep 17 00:00:00 2001 From: Andreas Kalsch Date: Wed, 30 Nov 2011 00:19:29 +0100 Subject: [PATCH 5/6] Fix --- lib/yabble.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/yabble.js b/lib/yabble.js index 9933045..96b1d81 100644 --- a/lib/yabble.js +++ b/lib/yabble.js @@ -190,8 +190,6 @@ var moduleId = resolveModuleId(relModuleId, refPath); var module = getModule(moduleId); - console.log(relModuleId, moduleId, refPath, _modules) - if (!module) { throw "Module not loaded"; } From f32aaaefe2ef1a3ea4ee57e5050071863176c64e Mon Sep 17 00:00:00 2001 From: Andreas Kalsch Date: Fri, 16 Dec 2011 00:45:01 +0100 Subject: [PATCH 6/6] Some fixes --- .gitignore | 4 ++++ index.js | 1 + 2 files changed, 5 insertions(+) create mode 100644 .gitignore create mode 100644 index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc2b62f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +*.pid +node_modules +pids diff --git a/index.js b/index.js new file mode 100644 index 0000000..842992d --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +module.exports = ('at', require('./lib/yabble'))