Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

RT-MVC: added build init step, copied socket.io into all realtime app…

…s on app creation, got the demo in the bag now
  • Loading branch information...
commit 944267c53f28a5b72fb41fdfa0f4216207a2918e 1 parent 1999c96
Daniel Erickson Techwraith authored
20 lib/init/build.js
View
@@ -0,0 +1,20 @@
+var utils = require('utilities')
+ , fs = require('fs');
+
+exports.init = function (app, callback) {
+ var modelDir = utils.file.readdirR('app/models')
+ , files = []
+ , file
+ , content
+ , built;
+ for (var i in modelDir) {
+ file = modelDir[i].replace('app/models', '').replace('/', '');
+ if (file) {
+ content = fs.readFileSync(modelDir[i], 'utf8');
+ files.push(content);
+ }
+ }
+ built = files.join('\n\n');
+ fs.writeFileSync('public/js/core/models.js', built);
+ return callback();
+};
3  lib/init/index.js
View
@@ -6,7 +6,8 @@
// process
exports.init = function (app, callback) {
var items = [
- 'router'
+ 'build'
+ , 'router'
, 'model'
, 'i18n'
, 'helpers'
5 templates/Jakefile
View
@@ -330,6 +330,11 @@ namespace('gen', function () {
jake.cpR(path.join(__dirname, 'base', cp[0]), path.join(name, cp[1]), {silent: true});
});
+ // one offs
+ if (realtime) {
+ jake.cpR(path.join(__dirname, '..', 'node_modules', 'socket.io' ), path.join(name, 'node_modules'), {silent: true});
+ }
+
text = fs.readFileSync(path.join(__dirname, 'base', 'Jakefile.ejs'), 'utf8').toString();
adapter = new Adapter({engine: 'ejs', template: text});
fs.writeFileSync(path.join(name, 'Jakefile'), adapter.render({appName: name}), 'utf8');
11 templates/base/public/js/core/core.js
View
@@ -1198,9 +1198,14 @@ model.ModelDefinitionBase = function (name) {
assn[name] = true;
reg[self.name].associations[assnKey] = assn;
if (assnKey == 'belongsTo') {
- def = model[name];
- idDatatype = def.autoIncrementId ? 'int' : 'string';
- self.property(utils.string.decapitalize(name) + 'Id', idDatatype);
+ // FIXME: Hack, let other models get defined first
+ // Should probably listen for an event that signals
+ // base models are set up
+ setTimeout(function () {
+ def = model[name];
+ idDatatype = def.autoIncrementId ? 'int' : 'string';
+ self.property(utils.string.decapitalize(name) + 'Id', idDatatype);
+ }, 0);
}
};
});
2  templates/scaffold/realtime/views/ejs/index.html.ejs.ejs
View
@@ -6,7 +6,7 @@
<div id="<%= names.property.plural %>-list">
<@ if (<%= names.property.plural %>) { @>
<@ for (var i = 0, ii = <%= names.property.plural %>.length; i < ii; i++) { @>
- <div class="row list-item" id="item-<@= <%= names.property.plural %>[i].id; @>">
+ <div class="row list-item" id="<%= names.property.singular %>-<@= <%= names.property.plural %>[i].id; @>">
<div class="span8">
<h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.