Permalink
Browse files

ADDEdD - Support for templates anywhere in production mode.

  • Loading branch information...
1 parent 9c8cc4c commit fc100751da4302bac3575c29d16a29fb054ada7b @glesperance committed Jul 4, 2012
Showing with 37 additions and 64 deletions.
  1. +2 −0 .gitignore
  2. +26 −55 lib/client/client.js
  3. +8 −8 lib/controller.js
  4. +1 −1 package.json
View
@@ -3,3 +3,5 @@ npm-debug.log
.DS_Store
.project
.settings
+.DS_Store
+___*
View
@@ -138,7 +138,7 @@ function compileViews() {
]
- , function(err) { if (err) { throw err; } top_callback(err)}
+ , function(err) { if (err) { throw err; } top_callback(err); }
);
@@ -261,8 +261,7 @@ function optimizeDir(dir_path, dst_tmpdir, options_tmpdir, callback) {
, options_file_path = path.join(options_tmpdir.path, options_filename)
- , options = {
- appDir : dir_path
+ , options = { appDir : options_tmpdir.path
, baseUrl : './'
, dir : dst_tmpdir.path
, modules : []
@@ -336,6 +335,10 @@ function optimizeDir(dir_path, dst_tmpdir, options_tmpdir, callback) {
});
}
+
+ , function (callback) {
+ compileViews(dir_path, options_tmpdir.path, options.paths, callback);
+ }
, async.apply(fs.readdir, dir_path)
@@ -347,61 +350,29 @@ function optimizeDir(dir_path, dst_tmpdir, options_tmpdir, callback) {
, function iterator(filename, callback) {
- var module_path = path.join(dir_path, filename)
- , symlink_path = path.join(options_tmpdir.path, filename)
- , module_name
+ var module_name
;
if (filename === REQUIRE_JS_CONFIG_FILE_NAME) {
-
callback(null);
return;
+ }
+
+ var suffix = '_client.js';
- } else if (filename === CLIENT_VIEWS_DIR_NAME) {
+ if (filename.substr(-suffix.length) === suffix) {
+ module_name = filename.substr(0, filename.length - 3);
- views = true;
-
- async.waterfall(
- [
- function(callback) { fs.mkdir(symlink_path, '0755', callback); }
- , function(callback) { compileViews(module_path, symlink_path, options.paths, callback); }
- ]
- , callback
+ options.modules.push(
+ { name : module_name
+ , exclude : external_modules
+ }
);
-
- return;
-
}
-
- fs.symlink(module_path, symlink_path, function(err) {
- if (err) {
-
- callback(err);
- return;
-
- }
-
- var suffix = '_client.js';
-
- if (filename.substr(-suffix.length) === suffix) {
-
- module_name = filename.substr(0, filename.length - 3);
-
- options.modules.push(
- { name : module_name
- , exclude : external_modules
- }
- );
-
- }
-
- callback(null);
-
- });
-
+ callback(null);
}
-
+
, callback
)
@@ -446,20 +417,20 @@ function optimizeDir(dir_path, dst_tmpdir, options_tmpdir, callback) {
*/
function watchAndOptimize(path, dst_tmpdir, options_tmpdir, callback) {
- var tree_event_emitter = asyncFs.watchTree(path);
- ;
+ // var tree_event_emitter = asyncFs.watchTree(path);
+ // ;
- tree_event_emitter.on('change', function() {
+ // tree_event_emitter.on('change', function() {
- process.stdout.write('\n-- Change in tree detected');
+ // process.stdout.write('\n-- Change in tree detected');
- optimizeDir(path, dst_tmpdir, options_tmpdir, function(err) {
+ // optimizeDir(path, dst_tmpdir, options_tmpdir, function(err) {
- if (err) { throw err; }
+ // if (err) { throw err; }
- });
+ // });
- });
+ // });
optimizeDir(path, dst_tmpdir, options_tmpdir, function(err) {
View
@@ -32,14 +32,6 @@ var rocket_tmpl = {};
, require_configuration = global.require_configuration || {}
;
- header.push("<script>");
- header.push("var _b = " + JSON.stringify(args) + "; ");
- header.push("var require = " + JSON.stringify(require_configuration) + ";");
- header.push("require.deps || (require.deps = []);");
- header.push("require.deps.push('" + controller_name + "_client" + "')");
- header.push("require.callback = " + "function() { require(['" + controller_name + "_client" + "'], function(m) { m && m.init && m.init.apply(m, _b); })}");
- header.push("</script>")
-
return header.join('\n');
};
@@ -50,9 +42,17 @@ var rocket_tmpl = {};
, controller_name = args.shift().replace(/[.,-;\s]+/g, '_')
, footer = []
+
+ , require_configuration = global.require_configuration || {}
;
footer.push("<script>");
+ footer.push("var _b = " + JSON.stringify(args) + "; ");
+ footer.push("var require = " + JSON.stringify(require_configuration) + ";");
+ footer.push("require.deps || (require.deps = []);");
+ footer.push("require.deps.push('" + controller_name + "_client" + "')");
+ footer.push("require.callback = " + "function() { require(['" + controller_name + "_client" + "'], function(m) { m && m.init && m.init.apply(m, _b); })}");
+
footer.push("document.write('<script src=\"/js/rocket/vendors/require.min.js\"><\\/script>')");
footer.push("</script>");
View
@@ -2,7 +2,7 @@
"name": "rocket"
, "description": "The rapid development framework for node.js"
, "keywords": ["mvc", "model view controller", "comet","rapid development", "Rocket", "framework"]
-, "version": "0.4.1"
+, "version": "0.4.2"
, "homepage": "http://wavo.me"
, "repository":
{ "type" : "git"

0 comments on commit fc10075

Please sign in to comment.