Skip to content
This repository
Browse code

ss.client.packAssets({cdn: {} }) options can now take functions. Plus…

… annoying changes to lib files as a result of new CoffeeScript version
  • Loading branch information...
commit 2f48e51fb364cc3f6d25536675ce2e3c4c5ab4a7 1 parent d383d44
Owen Barnes authored June 22, 2012

Showing 50 changed files with 419 additions and 189 deletions. Show diff stats Hide diff stats

  1. 1  HISTORY.md
  2. 19  lib/cli/generate.js
  3. 1  lib/cli/index.js
  4. 11  lib/client/asset.js
  5. 6  lib/client/formatters.js
  6. 1  lib/client/formatters/css.js
  7. 1  lib/client/formatters/html.js
  8. 1  lib/client/formatters/javascript.js
  9. 1  lib/client/http.js
  10. 26  lib/client/index.js
  11. 3  lib/client/live_reload.js
  12. 13  lib/client/magic_path.js
  13. 14  lib/client/pack.js
  14. 1  lib/client/serve/dev.js
  15. 5  lib/client/serve/ondemand.js
  16. 1  lib/client/serve/utils.js
  17. 21  lib/client/system/index.js
  18. 7  lib/client/system/modules/socketstream.js
  19. 25  lib/client/template_engine.js
  20. 1  lib/client/template_engines/default.js
  21. 1  lib/client/template_engines/ember.js
  22. 119  lib/client/view.js
  23. 10  lib/client/wrap.js
  24. 17  lib/http/index.js
  25. 9  lib/http/router.js
  26. 3  lib/publish/index.js
  27. 9  lib/publish/transport.js
  28. 1  lib/publish/transports/internal.js
  29. 13  lib/publish/transports/redis.js
  30. 5  lib/request/index.js
  31. 1  lib/request/middleware/index.js
  32. 9  lib/request/middleware/internal.js
  33. 1  lib/request/responders/events/client.js
  34. 1  lib/request/responders/events/index.js
  35. 3  lib/request/responders/rpc/client.js
  36. 5  lib/request/responders/rpc/index.js
  37. 25  lib/request/responders/rpc/request.js
  38. 25  lib/session/channels.js
  39. 13  lib/session/index.js
  40. 13  lib/utils/unique_set.js
  41. 1  lib/websocket/event_dispatcher.js
  42. 1  lib/websocket/index.js
  43. 1  lib/websocket/subscriptions.js
  44. 9  lib/websocket/transport.js
  45. 17  lib/websocket/transports/socketio/index.js
  46. 5  lib/websocket/transports/socketio/wrapper.js
  47. 2  src/cli/generate.coffee
  48. 1  src/client/index.coffee
  49. 121  src/client/view.coffee
  50. 8  src/client/wrap.coffee
1  HISTORY.md
Source Rendered
@@ -9,6 +9,7 @@ Not yet released. These are the changes so far...
9 9
 * IMPORTANT: `ss.client.packAssets()` now tries to use existing pre-packed assets if present
10 10
 * If no assets are found, or you pass the env var `SS_PACK=1`, assets will (re)packed
11 11
 * Static assets now have a cache expiry header of 30 days by default. Configurable with `ss.client.set({static: {maxAge: newValue}})` as before
  12
+* NEW: CDN paths can now be functions. E.g. `ss.client.packAssets({cdn: {js: function(file){ return "http://mycdn.com" + file.path; } }})` 
12 13
 
13 14
 
14 15
 ##### Other
19  lib/cli/generate.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var dir_mode, fs, log, makeRootDirectory, path, success, util;
2 3
 
3 4
 log = console.log;
@@ -10,7 +11,7 @@ path = require('path');
10 11
 
11 12
 util = require('util');
12 13
 
13  
-dir_mode = 0755;
  14
+dir_mode = '0755';
14 15
 
15 16
 exports.generate = function(program) {
16 17
   var appjs, codeExtension, cp, mkdir, mods, name, pacakgejs, selectedFormatters, source, viewExtension, write;
@@ -25,7 +26,9 @@ exports.generate = function(program) {
25 26
     viewExtension = program.jade && 'jade' || 'html';
26 27
     selectedFormatters = [];
27 28
     ['coffee', 'jade', 'less', 'stylus'].forEach(function(formatter) {
28  
-      if (program[formatter]) return selectedFormatters.push(formatter);
  29
+      if (program[formatter]) {
  30
+        return selectedFormatters.push(formatter);
  31
+      }
29 32
     });
30 33
     mkdir = function(dir) {
31 34
       return fs.mkdirSync(path.join(name, dir), dir_mode);
@@ -75,7 +78,9 @@ exports.generate = function(program) {
75 78
       cp("/client/views/app.demo." + viewExtension, "/client/views/app." + viewExtension);
76 79
     }
77 80
     appjs = "// My SocketStream app\n\nvar http = require('http')\n  , ss = require('socketstream');\n\n// Define a single-page client\nss.client.define('main', {\n  view: 'app." + viewExtension + "',\n  css:  ['libs', 'app.styl'],\n  code: ['libs', 'app'],\n  tmpl: '*'\n});\n\n// Serve this client on the root URL\nss.http.route('/', function(req, res){\n  res.serveClient('main');\n})\n";
78  
-    if (selectedFormatters.length > 0) appjs += "\n// Code Formatters\n";
  81
+    if (selectedFormatters.length > 0) {
  82
+      appjs += "\n// Code Formatters\n";
  83
+    }
79 84
     selectedFormatters.forEach(function(name) {
80 85
       return appjs += "ss.client.formatters.add(require('ss-" + name + "'));\n";
81 86
     });
@@ -88,7 +93,9 @@ exports.generate = function(program) {
88 93
     pacakgejs = "{\n  \"name\": \"" + name + "\",\n  \"description\": \"An awesome real time application\",\n  \"version\": \"0.0.1\",\n  \"author\": \"Me <me@mydomain.com>\",\n  \"private\": true,\n  \"engines\": { \"node\": \">= 0.6.0\" },\n  \"dependencies\": {\n";
89 94
     pacakgejs += "    \"socketstream\": \"0.3.x\"";
90 95
     mods = selectedFormatters.concat(['hogan']);
91  
-    if (program.repl) mods.push('console');
  96
+    if (program.repl) {
  97
+      mods.push('console');
  98
+    }
92 99
     mods.forEach(function(name, i) {
93 100
       return pacakgejs += ",\n    \"ss-" + name + "\": \"0.1.x\"";
94 101
     });
@@ -110,7 +117,9 @@ exports.generate = function(program) {
110 117
     } else {
111 118
       success("Plain HTML for views", "(-j if you prefer Jade)");
112 119
     }
113  
-    if (program.repl) success("Console Server / REPL");
  120
+    if (program.repl) {
  121
+      success("Console Server / REPL");
  122
+    }
114 123
     log("Next, run the following commands:".yellow);
115 124
     log("   cd " + name);
116 125
     log("   sudo npm install");
1  lib/cli/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 exports.process = function(program) {
3 4
   switch (program.args[0]) {
11  lib/client/asset.js
... ...
@@ -1,5 +1,6 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var formatKb, formatters, fs, jsp, loadFile, log, minifyJSFile, pathlib, pro, uglifyjs, wrap, wrapCode,
2  
-  __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  3
+  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
3 4
 
4 5
 log = console.log;
5 6
 
@@ -30,7 +31,9 @@ module.exports = function(ss, options) {
30 31
     },
31 32
     worker: function(path, opts, cb) {
32 33
       return loadFile(ss.root, options.dirs.workers, path, 'js', opts, function(output) {
33  
-        if (opts.compress) output = minifyJSFile(output, path);
  34
+        if (opts.compress) {
  35
+          output = minifyJSFile(output, path);
  36
+        }
34 37
         return cb(output);
35 38
       });
36 39
     },
@@ -79,7 +82,9 @@ minifyJSFile = function(originalCode, fileName) {
79 82
 wrapCode = function(code, path, pathPrefix) {
80 83
   var modPath, pathAry, sp;
81 84
   pathAry = path.split('/');
82  
-  if (__indexOf.call(pathAry, 'libs') >= 0) return code;
  85
+  if (__indexOf.call(pathAry, 'libs') >= 0) {
  86
+    return code;
  87
+  }
83 88
   if (__indexOf.call(pathAry, 'system') >= 0) {
84 89
     modPath = pathAry[pathAry.length - 1];
85 90
     return wrap.module(modPath, code);
6  lib/client/formatters.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var mods;
2 3
 
3 4
 mods = [];
@@ -8,7 +9,9 @@ exports.init = function(root) {
8 9
   var add;
9 10
   add = function(nameOrModule, config) {
10 11
     var formatter, mod, modPath;
11  
-    if (config == null) config = {};
  12
+    if (config == null) {
  13
+      config = {};
  14
+    }
12 15
     mod = (function() {
13 16
       if (typeof nameOrModule === 'object') {
14 17
         return nameOrModule;
@@ -29,6 +32,7 @@ exports.init = function(root) {
29 32
   add('html');
30 33
   /* RETURN API
31 34
   */
  35
+
32 36
   return {
33 37
     add: add
34 38
   };
1  lib/client/formatters/css.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var fs;
2 3
 
3 4
 fs = require('fs');
1  lib/client/formatters/html.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var fs;
2 3
 
3 4
 fs = require('fs');
1  lib/client/formatters/javascript.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var fs;
2 3
 
3 4
 fs = require('fs');
1  lib/client/http.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var cache, fs, http, pathlib, res, view;
2 3
 
3 4
 fs = require('fs');
26  lib/client/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var clients, formatters, fs, options, packAssets, path, systemAssets, templateEngine;
2 3
 
3 4
 fs = require('fs');
@@ -18,7 +19,7 @@ options = {
18 19
   dirs: {
19 20
     code: '/client/code',
20 21
     css: '/client/css',
21  
-    static: '/client/static',
  22
+    "static": '/client/static',
22 23
     assets: '/client/static/assets',
23 24
     templates: '/client/templates',
24 25
     views: '/client/views',
@@ -36,7 +37,9 @@ module.exports = function(ss, router) {
36 37
       files = fs.readdirSync(path.join(ss.root, options.dirs.assets, client.name));
37 38
       latestId = files.sort().pop();
38 39
       id = latestId.split('.')[0];
39  
-      if (id.length !== 13) throw 'Invalid Client ID length';
  40
+      if (id.length !== 13) {
  41
+        throw 'Invalid Client ID length';
  42
+      }
40 43
       return id;
41 44
     } catch (e) {
42 45
       return false;
@@ -59,13 +62,13 @@ module.exports = function(ss, router) {
59 62
         v = newOption[k];
60 63
         if (v instanceof Object) {
61 64
           _results.push((function() {
62  
-            var _results2;
63  
-            _results2 = [];
  65
+            var _results1;
  66
+            _results1 = [];
64 67
             for (x in v) {
65 68
               y = v[x];
66  
-              _results2.push(options[k][x] = y);
  69
+              _results1.push(options[k][x] = y);
67 70
             }
68  
-            return _results2;
  71
+            return _results1;
69 72
           })());
70 73
         } else {
71 74
           _results.push(options[k] = v);
@@ -90,7 +93,9 @@ module.exports = function(ss, router) {
90 93
       if (paths.view.indexOf('.') === -1) {
91 94
         throw new Error("The '" + paths.view + "' view must have a valid HTML extension (such as .html or .jade)");
92 95
       }
93  
-      if (paths.templates) paths.tmpl = paths.templates;
  96
+      if (paths.templates) {
  97
+        paths.tmpl = paths.templates;
  98
+      }
94 99
       ['css', 'code', 'tmpl'].forEach(function(assetType) {
95 100
         if (!(paths[assetType] instanceof Array)) {
96 101
           return paths[assetType] = [paths[assetType]];
@@ -99,8 +104,7 @@ module.exports = function(ss, router) {
99 104
       return clients[name] = {
100 105
         id: Number(Date.now()),
101 106
         name: name,
102  
-        paths: paths,
103  
-        headers: []
  107
+        paths: paths
104 108
       };
105 109
     },
106 110
     load: function() {
@@ -130,7 +134,9 @@ module.exports = function(ss, router) {
130 134
         }
131 135
       } else {
132 136
         require('./serve/dev')(ss, router, options);
133  
-        if (options.liveReload) require('./live_reload')(ss, options);
  137
+        if (options.liveReload) {
  138
+          require('./live_reload')(ss, options);
  139
+        }
134 140
       }
135 141
       return require('./serve/ondemand')(ss, router, options);
136 142
     }
3  lib/client/live_reload.js
... ...
@@ -1,5 +1,6 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var chokidar, consoleMessage, cssExtensions, lastRun, pathlib,
2  
-  __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  3
+  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
3 4
 
4 5
 require('colors');
5 6
 
13  lib/client/magic_path.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var fileUtils;
2 3
 
3 4
 require('colors');
@@ -6,11 +7,15 @@ fileUtils = require('../utils/file');
6 7
 
7 8
 exports.files = function(prefix, paths) {
8 9
   var files, numRootFolders;
9  
-  if (paths == null) paths = ['*'];
  10
+  if (paths == null) {
  11
+    paths = ['*'];
  12
+  }
10 13
   files = [];
11 14
   prefix = prefix.replace(/\\/g, '/');
12 15
   numRootFolders = prefix.split('/').length;
13  
-  if (!(paths instanceof Array)) paths = [paths];
  16
+  if (!(paths instanceof Array)) {
  17
+    paths = [paths];
  18
+  }
14 19
   paths.forEach(function(path) {
15 20
     var dir, sp, tree;
16 21
     sp = path.split('/');
@@ -18,7 +23,9 @@ exports.files = function(prefix, paths) {
18 23
       return files.push(path);
19 24
     } else {
20 25
       dir = prefix;
21  
-      if (path !== '*') dir += '/' + path;
  26
+      if (path !== '*') {
  27
+        dir += '/' + path;
  28
+      }
22 29
       if (tree = fileUtils.readDirSync(dir)) {
23 30
         return tree.files.sort().forEach(function(file) {
24 31
           return files.push(file.split('/').slice(numRootFolders).join('/'));
14  lib/client/pack.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var cleanCSS, deleteOldFiles, existslib, formatKb, fs, log, magicPath, mkdir, pathlib, system, view;
2 3
 
3 4
 log = console.log;
@@ -34,8 +35,12 @@ module.exports = function(ss, client, options) {
34 35
     };
35 36
     processFiles = function(fileContents, i) {
36 37
       var file, path, _ref;
37  
-      if (fileContents == null) fileContents = [];
38  
-      if (i == null) i = 0;
  38
+      if (fileContents == null) {
  39
+        fileContents = [];
  40
+      }
  41
+      if (i == null) {
  42
+        i = 0;
  43
+      }
39 44
       _ref = filePaths[i], path = _ref.path, file = _ref.file;
40 45
       return asset[assetType](file, {
41 46
         pathPrefix: path,
@@ -65,6 +70,7 @@ module.exports = function(ss, client, options) {
65 70
   };
66 71
   /* PACKER
67 72
   */
  73
+
68 74
   log(("Pre-packing and minifying the '" + client.name + "' client...").yellow);
69 75
   mkdir(containerDir);
70 76
   mkdir(clientDir);
@@ -96,7 +102,9 @@ formatKb = function(size) {
96 102
 };
97 103
 
98 104
 mkdir = function(dir) {
99  
-  if (!existslib.existsSync(dir)) return fs.mkdirSync(dir);
  105
+  if (!existslib.existsSync(dir)) {
  106
+    return fs.mkdirSync(dir);
  107
+  }
100 108
 };
101 109
 
102 110
 deleteOldFiles = function(clientDir) {
1  lib/client/serve/dev.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var qs, system, url, utils;
2 3
 
3 4
 url = require('url');
5  lib/client/serve/ondemand.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var magicPath, pathlib, queryCache, utils;
2 3
 
3 4
 pathlib = require('path');
@@ -36,7 +37,9 @@ module.exports = function(ss, router, options) {
36 37
         compress: options.packAssets
37 38
       }, function(js) {
38 39
         output.push(js);
39  
-        if (output.length === files.length) return cb(output.join("\n"));
  40
+        if (output.length === files.length) {
  41
+          return cb(output.join("\n"));
  42
+        }
40 43
       });
41 44
     });
42 45
   };
1  lib/client/serve/utils.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var serve;
2 3
 
3 4
 exports.serve = {
21  lib/client/system/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var assets, coffee, fs, fsUtils, minifyJS, pathlib, send, uglifyjs, wrap;
2 3
 
3 4
 fs = require('fs');
@@ -6,7 +7,9 @@ pathlib = require('path');
6 7
 
7 8
 uglifyjs = require('uglify-js');
8 9
 
9  
-if (process.env['SS_DEV']) coffee = require('coffee-script');
  10
+if (process.env['SS_DEV']) {
  11
+  coffee = require('coffee-script');
  12
+}
10 13
 
11 14
 wrap = require('../wrap');
12 15
 
@@ -19,8 +22,12 @@ assets = {
19 22
 };
20 23
 
21 24
 exports.send = send = function(type, name, content, options) {
22  
-  if (options == null) options = {};
23  
-  if (coffee && options.coffee) content = coffee.compile(content);
  25
+  if (options == null) {
  26
+    options = {};
  27
+  }
  28
+  if (coffee && options.coffee) {
  29
+    content = coffee.compile(content);
  30
+  }
24 31
   switch (type) {
25 32
     case 'code':
26 33
       return assets.initCode.push(content);
@@ -71,7 +78,9 @@ exports.load = function() {
71 78
 exports.serve = {
72 79
   js: function(options) {
73 80
     var code, mod, name, output, _ref;
74  
-    if (options == null) options = {};
  81
+    if (options == null) {
  82
+      options = {};
  83
+    }
75 84
     output = assets.libs.map(function(code) {
76 85
       return options.compress && !code.options.minified && minifyJS(code.content) || code.content;
77 86
     });
@@ -79,7 +88,9 @@ exports.serve = {
79 88
     for (name in _ref) {
80 89
       mod = _ref[name];
81 90
       code = wrap.module(name, mod.content);
82  
-      if (options.compress && !mod.options.minified) code = minifyJS(code);
  91
+      if (options.compress && !mod.options.minified) {
  92
+        code = minifyJS(code);
  93
+      }
83 94
       output.push(code);
84 95
     }
85 96
     return output.join("\n");
7  lib/client/system/modules/socketstream.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var EventEmitter2, async, message, server, transport;
2 3
 
3 4
 EventEmitter2 = require('eventemitter2').EventEmitter2;
@@ -42,6 +43,7 @@ exports.template = function(name) {
42 43
 /* ON DEMAND LOADING
43 44
 */
44 45
 
  46
+
45 47
 async = {
46 48
   loaded: {},
47 49
   loading: new EventEmitter2
@@ -63,7 +65,9 @@ exports.load = {
63 65
     if (!cb) {
64 66
       return console.error(errorPrefix + 'requires a callback. Specify it as the last argument');
65 67
     }
66  
-    if (async.loaded[nameOrDir]) return cb();
  68
+    if (async.loaded[nameOrDir]) {
  69
+      return cb();
  70
+    }
67 71
     async.loading.once(nameOrDir, cb);
68 72
     if (async.loading.listeners(nameOrDir).length === 1) {
69 73
       onError = function() {
@@ -92,6 +96,7 @@ exports.load = {
92 96
 /* LIVE RELOAD
93 97
 */
94 98
 
  99
+
95 100
 server.on('__ss:reload', function() {
96 101
   return window.location.reload();
97 102
 });
25  lib/client/template_engine.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var client, defaultEngine, formatters, pathlib, selectEngine, suggestedId, templateEngines, wrapTemplate;
2 3
 
3 4
 require('colors');
@@ -17,7 +18,9 @@ exports.init = function(ss, options) {
17 18
   return {
18 19
     use: function(nameOrModule, dirs, config) {
19 20
       var engine, mod, modPath;
20  
-      if (dirs == null) dirs = ['/'];
  21
+      if (dirs == null) {
  22
+        dirs = ['/'];
  23
+      }
21 24
       mod = (function() {
22 25
         if (typeof nameOrModule === 'object') {
23 26
           return nameOrModule;
@@ -31,7 +34,9 @@ exports.init = function(ss, options) {
31 34
         }
32 35
       })();
33 36
       engine = mod.init(ss, config);
34  
-      if (!(dirs instanceof Array)) dirs = [dirs];
  37
+      if (!(dirs instanceof Array)) {
  38
+        dirs = [dirs];
  39
+      }
35 40
       return dirs.forEach(function(dir) {
36 41
         if (dir.substring(0, 1) !== '/') {
37 42
           throw new Error("Directory name '" + dir + "' passed to second argument of ss.client.templateEngine.use() command must start with /");
@@ -46,13 +51,17 @@ exports.generate = function(dir, files, cb) {
46 51
   var prevEngine, templates;
47 52
   prevEngine = null;
48 53
   templates = [];
49  
-  if (!(files && files.length > 0)) cb('');
  54
+  if (!(files && files.length > 0)) {
  55
+    cb('');
  56
+  }
50 57
   return files.forEach(function(path) {
51 58
     var engine, extension, f, formatter, fullPath;
52 59
     fullPath = pathlib.join(dir, path);
53 60
     engine = selectEngine(templateEngines, path.split('/')) || defaultEngine;
54 61
     extension = pathlib.extname(path);
55  
-    if (extension) extension = extension.substring(1);
  62
+    if (extension) {
  63
+      extension = extension.substring(1);
  64
+    }
56 65
     formatter = (f = formatters.byExtension[extension]) && f.assetType === 'html' && f;
57 66
     if (engine.selectFormatter) {
58 67
       formatter = engine.selectFormatter(path, formatters.byExtension, formatter);
@@ -64,7 +73,9 @@ exports.generate = function(dir, files, cb) {
64 73
         prevEngine = engine;
65 74
         if (templates.length === files.length) {
66 75
           output = templates.join('');
67  
-          if (engine !== null && engine.suffix) output += engine.suffix();
  76
+          if (engine !== null && engine.suffix) {
  77
+            output += engine.suffix();
  78
+          }
68 79
           return cb(output);
69 80
         }
70 81
       });
@@ -105,6 +116,8 @@ selectEngine = function(templateEngines, pathAry) {
105 116
 suggestedId = function(path) {
106 117
   var sp;
107 118
   sp = path.split('.');
108  
-  if (path.indexOf('.') > 0) sp.pop();
  119
+  if (path.indexOf('.') > 0) {
  120
+    sp.pop();
  121
+  }
109 122
   return sp.join('.').replace(/\//g, '-');
110 123
 };
1  lib/client/template_engines/default.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 exports.init = function(root, config) {
3 4
   return {
1  lib/client/template_engines/ember.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 exports.init = function(root, config) {
3 4
   return {
119  lib/client/view.js
... ...
@@ -1,4 +1,5 @@
1  
-var engine, headers, magicPath, pathlib, tag, templates;
  1
+// Generated by CoffeeScript 1.3.3
  2
+var engine, magicPath, pathlib, wrap;
2 3
 
3 4
 pathlib = require('path');
4 5
 
@@ -6,11 +7,73 @@ magicPath = require('./magic_path');
6 7
 
7 8
 engine = require('./template_engine');
8 9
 
  10
+wrap = require('./wrap');
  11
+
9 12
 module.exports = function(ss, client, options, cb) {
10  
-  var asset, htmlOptions, includes;
  13
+  var asset, headers, htmlOptions, includes, resolveAssetLink, templates;
  14
+  resolveAssetLink = function(type) {
  15
+    var defaultPath, file, link, _ref, _ref1;
  16
+    defaultPath = "/assets/" + client.name + "/" + client.id + "." + type;
  17
+    if (link = (_ref = options.packedAssets) != null ? (_ref1 = _ref.cdn) != null ? _ref1[type] : void 0 : void 0) {
  18
+      if (typeof link === 'function') {
  19
+        file = {
  20
+          id: client.id,
  21
+          name: client.name,
  22
+          extension: type,
  23
+          path: defaultPath
  24
+        };
  25
+        return link(file);
  26
+      } else if (typeof link === 'string') {
  27
+        return link;
  28
+      } else {
  29
+        throw new Error("CDN " + type + " param must be a Function or String");
  30
+      }
  31
+    } else {
  32
+      return defaultPath;
  33
+    }
  34
+  };
  35
+  templates = function() {
  36
+    var dir, files, output;
  37
+    dir = pathlib.join(ss.root, options.dirs.templates);
  38
+    output = [];
  39
+    if (client.paths.tmpl) {
  40
+      files = [];
  41
+      client.paths.tmpl.forEach(function(tmpl) {
  42
+        return files = files.concat(magicPath.files(dir, tmpl));
  43
+      });
  44
+      engine.generate(dir, files, function(templateHTML) {
  45
+        return output.push(templateHTML);
  46
+      });
  47
+    }
  48
+    return output;
  49
+  };
  50
+  headers = function() {
  51
+    var css, js, output;
  52
+    output = [];
  53
+    if (options.packedAssets) {
  54
+      css = resolveAssetLink('css');
  55
+      js = resolveAssetLink('js');
  56
+      output.push(wrap.htmlTag.css(css));
  57
+      output.push(wrap.htmlTag.js(js));
  58
+    } else {
  59
+      output.push(wrap.htmlTag.js("/_serveDev/system?ts=" + client.id));
  60
+      client.paths.css.forEach(function(path) {
  61
+        return magicPath.files(pathlib.join(root, options.dirs.css), path).forEach(function(file) {
  62
+          return output.push(wrap.htmlTag.css("/_serveDev/css/" + file + "?ts=" + client.id));
  63
+        });
  64
+      });
  65
+      client.paths.code.forEach(function(path) {
  66
+        return magicPath.files(pathlib.join(root, options.dirs.code), path).forEach(function(file) {
  67
+          return output.push(wrap.htmlTag.js("/_serveDev/code/" + file + "?ts=" + client.id + "&pathPrefix=" + path));
  68
+        });
  69
+      });
  70
+      output.push(wrap.htmlTag.js("/_serveDev/start?ts=" + client.id));
  71
+    }
  72
+    return output;
  73
+  };
11 74
   asset = require('./asset')(ss, options);
12  
-  includes = headers(ss.root, client, options);
13  
-  includes = includes.concat(templates(ss.root, client, options));
  75
+  includes = headers();
  76
+  includes = includes.concat(templates());
14 77
   htmlOptions = {
15 78
     headers: includes.join(''),
16 79
     compress: options.packedAssets,
@@ -18,51 +81,3 @@ module.exports = function(ss, client, options, cb) {
18 81
   };
19 82
   return asset.html(client.paths.view, htmlOptions, cb);
20 83
 };
21  
-
22  
-templates = function(root, client, options) {
23  
-  var dir, files, output;
24  
-  dir = pathlib.join(root, options.dirs.templates);
25  
-  output = [];
26  
-  if (client.paths.tmpl) {
27  
-    files = [];
28  
-    client.paths.tmpl.forEach(function(tmpl) {
29  
-      return files = files.concat(magicPath.files(dir, tmpl));
30  
-    });
31  
-    engine.generate(dir, files, function(templateHTML) {
32  
-      return output.push(templateHTML);
33  
-    });
34  
-  }
35  
-  return output;
36  
-};
37  
-
38  
-headers = function(root, client, options) {
39  
-  var output, _ref, _ref2, _ref3, _ref4;
40  
-  output = [];
41  
-  if (options.packedAssets) {
42  
-    output.push(tag.css(((_ref = options.packedAssets) != null ? (_ref2 = _ref.cdn) != null ? _ref2.css : void 0 : void 0) || ("/assets/" + client.name + "/" + client.id + ".css")));
43  
-    output.push(tag.js(((_ref3 = options.packedAssets) != null ? (_ref4 = _ref3.cdn) != null ? _ref4.js : void 0 : void 0) || ("/assets/" + client.name + "/" + client.id + ".js")));
44  
-  } else {
45  
-    output.push(tag.js("/_serveDev/system?ts=" + client.id));
46  
-    client.paths.css.forEach(function(path) {
47  
-      return magicPath.files(pathlib.join(root, options.dirs.css), path).forEach(function(file) {
48  
-        return output.push(tag.css("/_serveDev/css/" + file + "?ts=" + client.id));
49  
-      });
50  
-    });
51  
-    client.paths.code.forEach(function(path) {
52  
-      return magicPath.files(pathlib.join(root, options.dirs.code), path).forEach(function(file) {
53  
-        return output.push(tag.js("/_serveDev/code/" + file + "?ts=" + client.id + "&pathPrefix=" + path));
54  
-      });
55  
-    });
56  
-    output.push(tag.js("/_serveDev/start?ts=" + client.id));
57  
-  }
58  
-  return output;
59  
-};
60  
-
61  
-tag = {
62  
-  css: function(path) {
63  
-    return '<link href="' + path + '" media="screen" rel="stylesheet" type="text/css">';
64  
-  },
65  
-  js: function(path) {
66  
-    return '<script src="' + path + '" type="text/javascript"></script>';
67  
-  }
68  
-};
10  lib/client/wrap.js
... ...
@@ -1,4 +1,14 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 exports.module = function(modPath, code) {
3 4
   return "require.define(\"" + modPath + "\", function (require, module, exports, __dirname, __filename){\n" + code + "\n});";
4 5
 };
  6
+
  7
+exports.htmlTag = {
  8
+  css: function(path) {
  9
+    return '<link href="' + path + '" media="screen" rel="stylesheet" type="text/css">';
  10
+  },
  11
+  js: function(path) {
  12
+    return '<script src="' + path + '" type="text/javascript"></script>';
  13
+  }
  14
+};
17  lib/http/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var app, connect, eventMiddleware, existslib, fileUtils, fs, loadStaticDirs, pathlib, router, settings, staticDirs, staticFiles, transformURL, useAfterStack;
2 3
 
3 4
 fs = require('fs');
@@ -17,7 +18,7 @@ staticDirs = [];
17 18
 staticFiles = [];
18 19
 
19 20
 settings = {
20  
-  static: {
  21
+  "static": {
21 22
     maxAge: 30 * 24 * 60 * 60 * 1000
22 23
   }
23 24
 };
@@ -65,7 +66,7 @@ module.exports = function(root) {
65 66
       useAfterStack.forEach(function(m) {
66 67
         return app.use.apply(app, m);
67 68
       });
68  
-      app.use(eventMiddleware).use(connect.static(staticPath, settings.static));
  69
+      app.use(eventMiddleware).use(connect["static"](staticPath, settings["static"]));
69 70
       return app;
70 71
     },
71 72
     route: function(url, fn) {
@@ -89,16 +90,18 @@ module.exports = function(root) {
89 90
 eventMiddleware = function(req, res, next) {
90 91
   var initialDir;
91 92
   initialDir = req.url.split('/')[1];
92  
-  if (initialDir === '_serveDev') req.url = transformURL(req.url);
  93
+  if (initialDir === '_serveDev') {
  94
+    req.url = transformURL(req.url);
  95
+  }
93 96
   if (staticDirs.indexOf(initialDir) >= 0 || !router.route(req.url, req, res)) {
94 97
     return next();
95 98
   }
96 99
 };
97 100
 
98 101
 transformURL = function(url) {
99  
-  var i, x;
  102
+  var i, x, _i;
100 103
   i = 0;
101  
-  for (x = 0; x <= 1; x++) {
  104
+  for (x = _i = 0; _i <= 1; x = ++_i) {
102 105
     i = url.indexOf('/', i + 1);
103 106
   }
104 107
   if (url[i] === '/') {
@@ -112,7 +115,9 @@ loadStaticDirs = function(path) {
112 115
   var pathLength;
113 116
   if (existslib.existsSync(path)) {
114 117
     staticDirs = fs.readdirSync(path);
115  
-    if (!(staticDirs.indexOf('assets') >= 0)) staticDirs.push('assets');
  118
+    if (!(staticDirs.indexOf('assets') >= 0)) {
  119
+      staticDirs.push('assets');
  120
+    }
116 121
     pathLength = path.length;
117 122
     staticFiles = fileUtils.readDirSync(path).files;
118 123
     return staticFiles = staticFiles.map(function(file) {
9  lib/http/router.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var EventEmitter2;
2 3
 
3 4
 EventEmitter2 = require('eventemitter2').EventEmitter2;
@@ -17,7 +18,9 @@ exports.Router = (function() {
17 18
       this.ee.emit(url, req, res);
18 19
       return true;
19 20
     } else {
20  
-      if (url === '/') return false;
  21
+      if (url === '/') {
  22
+        return false;
  23
+      }
21 24
       if (url.indexOf('?') >= 0) {
22 25
         sr = url.split('?');
23 26
       } else {
@@ -25,7 +28,9 @@ exports.Router = (function() {
25 28
       }
26 29
       sr.pop();
27 30
       newUrl = sr.join('/');
28  
-      if (!(newUrl.length > 0)) newUrl = '/';
  31
+      if (!(newUrl.length > 0)) {
  32
+        newUrl = '/';
  33
+      }
29 34
       return this.route(newUrl, req, res);
30 35
     }
31 36
   };
3  lib/publish/index.js
... ...
@@ -1,5 +1,6 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var isInternal,
2  
-  __slice = Array.prototype.slice;
  3
+  __slice = [].slice;
3 4
 
4 5
 module.exports = function() {
5 6
   return {
9  lib/publish/transport.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 module.exports = function() {
3 4
   var config, transport;
@@ -6,7 +7,9 @@ module.exports = function() {
6 7
   return {
7 8
     use: function(nameOrModule, cfg) {
8 9
       var modPath;
9  
-      if (cfg == null) cfg = {};
  10
+      if (cfg == null) {
  11
+        cfg = {};
  12
+      }
10 13
       config = cfg;
11 14
       return transport = (function() {
12 15
         if (typeof nameOrModule === 'object') {
@@ -22,7 +25,9 @@ module.exports = function() {
22 25
       })();
23 26
     },
24 27
     load: function() {
25  
-      if (transport == null) this.use('internal');
  28
+      if (transport == null) {
  29
+        this.use('internal');
  30
+      }
26 31
       return transport(config);
27 32
     }
28 33
   };
1  lib/publish/transports/internal.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var EventEmitter2, emitter;
2 3
 
3 4
 EventEmitter2 = require('eventemitter2').EventEmitter2;
13  lib/publish/transports/redis.js
... ...
@@ -1,18 +1,25 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var redis;
2 3
 
3 4
 redis = require('redis');
4 5
 
5 6
 module.exports = function(config) {
6 7
   var conn, host, options, port;
7  
-  if (config == null) config = {};
  8
+  if (config == null) {
  9
+    config = {};
  10
+  }
8 11
   port = config.port || 6379;
9 12
   host = config.host || "127.0.0.1";
10 13
   options = config.options || {};
11 14
   conn = {};
12 15
   ['pub', 'sub'].forEach(function(name) {
13 16
     conn[name] = redis.createClient(port, host, options);
14  
-    if (config.pass) conn[name].auth(config.pass);
15  
-    if (config.db) return conn[name].select(config.db);
  17
+    if (config.pass) {
  18
+      conn[name].auth(config.pass);
  19
+    }
  20
+    if (config.db) {
  21
+      return conn[name].select(config.db);
  22
+    }
16 23
   });
17 24
   return {
18 25
     listen: function(cb) {
5  lib/request/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 module.exports = function(ss) {
3 4
   var middleware, responderCount, responders, useDefaults;
@@ -11,7 +12,9 @@ module.exports = function(ss) {
11 12
     },
12 13
     add: function(nameOrModule, config) {
13 14
       var err, id, mod, modPath, responderName;
14  
-      if (config == null) config = null;
  15
+      if (config == null) {
  16
+        config = null;
  17
+      }
15 18
       mod = (function() {
16 19
         if (typeof nameOrModule === 'function') {
17 20
           return nameOrModule;
1  lib/request/middleware/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var apiTree, existslib, pathlib;
2 3
 
3 4
 pathlib = require('path');
9  lib/request/middleware/internal.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 require('colors');
3 4
 
@@ -6,14 +7,18 @@ module.exports = function(ss) {
6 7
   session = require('../../session');
7 8
   return {
8 9
     debug: function(color) {
9  
-      if (color == null) color = 'yellow';
  10
+      if (color == null) {
  11
+        color = 'yellow';
  12
+      }
10 13
       return function(request, response, next) {
11 14
         console.log("Debug incoming message >>\n"[color], request);
12 15
         return next();
13 16
       };
14 17
     },
15 18
     session: function(options) {
16  
-      if (options == null) options = {};
  19
+      if (options == null) {
  20
+        options = {};
  21
+      }
17 22
       return function(request, response, next) {
18 23
         if (request.sessionId) {
19 24
           return session.find(request.sessionId, request.socketId, function(thisSession) {
1  lib/request/responders/events/client.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var EventEmitter2, ss;
2 3
 
3 4
 EventEmitter2 = require('eventemitter2').EventEmitter2;
1  lib/request/responders/events/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var fs;
2 3
 
3 4
 fs = require('fs');
3  lib/request/responders/rpc/client.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var cbStack, defaultCallback, numRequests, ss;
2 3
 
3 4
 ss = require('socketstream');
@@ -28,7 +29,7 @@ module.exports = function(responderId, config, send) {
28 29
     cbStack[obj.id] = cb;
29 30
     msg = JSON.stringify(obj);
30 31
     send(msg);
31  
-    return;
  32
+    return void 0;
32 33
   });
33 34
   return ss.message.on(responderId, function(msg) {
34 35
     var cb, obj;
5  lib/request/responders/rpc/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var fs;
2 3
 
3 4
 fs = require('fs');
@@ -52,7 +53,9 @@ module.exports = function(responderId, config, ss) {
52 53
               }
53 54
             };
54 55
             ss.log('↩'.red, msgLogName, req.method, e.message.red);
55  
-            if (e.stack) ss.log(e.stack.split("\n").splice(1).join("\n"));
  56
+            if (e.stack) {
  57
+              ss.log(e.stack.split("\n").splice(1).join("\n"));
  58
+            }
56 59
             return send(JSON.stringify(obj));
57 60
           }
58 61
         },
25  lib/request/responders/rpc/request.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var apiTree, getBranchFromTree, pathlib;
2 3
 
3 4
 pathlib = require('path');
@@ -29,7 +30,9 @@ module.exports = function(ss, middleware) {
29 30
     methodAry = req.method.split('.');
30 31
     methodName = methodAry.pop();
31 32
     file = getBranchFromTree(api, methodAry);
32  
-    if (!file) throw new Error("Unable to find '" + req.method + "' file");
  33
+    if (!file) {
  34
+      throw new Error("Unable to find '" + req.method + "' file");
  35
+    }
33 36
     if (!file.actions) {
34 37
       throw new Error("Unable to find an 'exports.actions' function for '" + req.method + "'");
35 38
     }
@@ -55,7 +58,9 @@ module.exports = function(ss, middleware) {
55 58
     };
56 59
     stack.push(main);
57 60
     exec = function(request, res, i) {
58  
-      if (i == null) i = 0;
  61
+      if (i == null) {
  62
+        i = 0;
  63
+      }
59 64
       return stack[i].call(stack, req, res, function() {
60 65
         return exec(req, res, i + 1);
61 66
       });
@@ -65,9 +70,17 @@ module.exports = function(ss, middleware) {
65 70
 };
66 71
 
67 72
 getBranchFromTree = function(tree, ary, index, i) {
68  
-  if (index == null) index = null;
69  
-  if (i == null) i = 0;
70  
-  if (index == null) index = ary.length;
71  
-  if (i === index) return tree;
  73
+  if (index == null) {
  74
+    index = null;
  75
+  }
  76
+  if (i == null) {
  77
+    i = 0;
  78
+  }
  79
+  if (index == null) {
  80
+    index = ary.length;
  81
+  }
  82
+  if (i === index) {
  83
+    return tree;
  84
+  }
72 85
   return arguments.callee(tree[ary[i]], ary, index, ++i);
73 86
 };
25  lib/session/channels.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var forceArray, subscriptions;
2 3
 
3 4
 require('colors');
@@ -10,8 +11,12 @@ module.exports = function(session, socketId) {
10 11
       return session.channels || [];
11 12
     },
12 13
     subscribe: function(names, cb) {
13  
-      if (cb == null) cb = function() {};
14  
-      if (!session.channels) session.channels = [];
  14
+      if (cb == null) {
  15
+        cb = function() {};
  16
+      }
  17
+      if (!session.channels) {
  18
+        session.channels = [];
  19
+      }
15 20
       forceArray(names).forEach(function(name) {
16 21
         if (!(session.channels.indexOf(name) >= 0)) {
17 22
           session.channels.push(name);
@@ -23,8 +28,12 @@ module.exports = function(session, socketId) {
23 28
     },
24 29
     unsubscribe: function(names, cb) {
25 30
       var _this = this;
26  
-      if (cb == null) cb = function() {};
27  
-      if (!session.channels) session.channels = [];
  31
+      if (cb == null) {
  32
+        cb = function() {};
  33
+      }
  34
+      if (!session.channels) {
  35
+        session.channels = [];
  36
+      }
28 37
       forceArray(names).forEach(function(name) {
29 38
         var i;
30 39
         if ((i = session.channels.indexOf(name)) >= 0) {
@@ -36,11 +45,15 @@ module.exports = function(session, socketId) {
36 45
       return session.save(cb);
37 46
     },
38 47
     reset: function(cb) {
39  
-      if (cb == null) cb = function() {};
  48
+      if (cb == null) {
  49
+        cb = function() {};
  50
+      }
40 51
       return this.unsubscribe(this.list(), cb);
41 52
     },
42 53
     _bindToSocket: function() {
43  
-      if (!session.channels) session.channels = [];
  54
+      if (!session.channels) {
  55
+        session.channels = [];
  56
+      }
44 57
       return forceArray(session.channels).forEach(function(name) {
45 58
         return subscriptions.channel.add(name, socketId);
46 59
       });
13  lib/session/index.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var channels, connect, create, sessionStore, subscriptions;
2 3
 
3 4
 connect = require('connect');
@@ -31,16 +32,22 @@ exports.create = function() {
31 32
 
32 33
 exports.find = function(sessionId, socketId, cb) {
33 34
   return sessionStore.load(sessionId, function(err, session) {
34  
-    if (!session) session = create(sessionId);
  35
+    if (!session) {
  36
+      session = create(sessionId);
  37
+    }
35 38
     session.channel = channels(session, socketId);
36 39
     session.setUserId = function(userId, cb) {
37  
-      if (cb == null) cb = function() {};
  40
+      if (cb == null) {
  41
+        cb = function() {};
  42
+      }
38 43
       this.userId = userId;
39 44
       this._bindToSocket();
40 45
       return this.save(cb);
41 46
     };
42 47
     session._bindToSocket = function() {
43  
-      if (session.userId != null) subscriptions.user.add(session.userId, socketId);
  48
+      if (session.userId != null) {
  49
+        subscriptions.user.add(session.userId, socketId);
  50
+      }
44 51
       if ((session.channels != null) && session.channels.length > 0) {
45 52
         session.channel._bindToSocket();
46 53
       }
13  lib/utils/unique_set.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 
2 3
 exports.UniqueSet = (function() {
3 4
 
@@ -7,9 +8,13 @@ exports.UniqueSet = (function() {
7 8
 
8 9
   UniqueSet.prototype.add = function(key, value) {
9 10
     var set;
10  
-    if (!((key != null) && (value != null))) return false;
  11
+    if (!((key != null) && (value != null))) {
  12
+      return false;
  13
+    }
11 14
     if (set = this.data[key]) {
12  
-      if (!(set.indexOf(value) >= 0)) return set.push(value);
  15
+      if (!(set.indexOf(value) >= 0)) {
  16
+        return set.push(value);
  17
+      }
13 18
     } else {
14 19
       return this.data[key] = [value];
15 20
     }
@@ -19,7 +24,9 @@ exports.UniqueSet = (function() {
19 24
     var i;
20 25
     if ((i = this.data[key].indexOf(value)) >= 0) {
21 26
       this.data[key].splice(i, 1);
22  
-      if (this.data[key].length === 0) return delete this.data[key];
  27
+      if (this.data[key].length === 0) {
  28
+        return delete this.data[key];
  29
+      }
23 30
     }
24 31
   };
25 32
 
1  lib/websocket/event_dispatcher.js
... ...
@@ -1,3 +1,4 @@
  1
+// Generated by CoffeeScript 1.3.3
1 2
 var sendToMultiple, subscriptions;
2 3
 
3 4
 subscriptions = require('./subscriptions');