Permalink
Browse files

RT-MVC: Real time app generation and resource scaffolding is working

  • Loading branch information...
1 parent 741bb80 commit 057bd49b31544ef3b046fc79347cfc2e06856077 Techwraith committed Oct 27, 2012
Showing with 803 additions and 32 deletions.
  1. +13 −3 bin/cli.js
  2. +1 −1 examples/socket_io/config/environment.js
  3. +1 −1 lib/app.js
  4. +23 −10 templates/Jakefile
  5. +1 −1 templates/base/development.js
  6. +0 −5 templates/base/environment.js
  7. +1 −1 templates/base/production.js
  8. +10 −5 templates/base/public/js/core/core.js
  9. +5 −0 templates/base/realtime/environment.js
  10. +53 −0 templates/base/realtime/views/ejs/layouts/application.html.ejs
  11. +6 −0 templates/base/realtime/views/ejs/main/index.html.ejs
  12. +51 −0 templates/base/realtime/views/handlebars/layouts/application.html.hbs
  13. +6 −0 templates/base/realtime/views/handlebars/main/index.html.hbs
  14. +46 −0 templates/base/realtime/views/jade/layouts/application.html.jade
  15. +6 −0 templates/base/realtime/views/jade/main/index.html.jade
  16. +51 −0 templates/base/realtime/views/mustache/layouts/application.html.hbs
  17. +6 −0 templates/base/realtime/views/mustache/main/index.html.hbs
  18. +10 −5 templates/build/build.js
  19. +50 −0 templates/scaffold/realtime/views/ejs/add.html.ejs.ejs
  20. +56 −0 templates/scaffold/realtime/views/ejs/edit.html.ejs.ejs
  21. +66 −0 templates/scaffold/realtime/views/ejs/index.html.ejs.ejs
  22. +54 −0 templates/scaffold/realtime/views/ejs/layout.html.ejs.ejs
  23. +18 −0 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
  24. +6 −0 templates/scaffold/realtime/views/handlebars/add.html.hbs.ejs
  25. +6 −0 templates/scaffold/realtime/views/handlebars/edit.html.hbs.ejs
  26. +6 −0 templates/scaffold/realtime/views/handlebars/index.html.hbs.ejs
  27. +51 −0 templates/scaffold/realtime/views/handlebars/layout.html.hbs.ejs
  28. +6 −0 templates/scaffold/realtime/views/handlebars/show.html.hbs.ejs
  29. +40 −0 templates/scaffold/realtime/views/jade/add.html.jade.ejs
  30. +45 −0 templates/scaffold/realtime/views/jade/edit.html.jade.ejs
  31. +13 −0 templates/scaffold/realtime/views/jade/index.html.jade.ejs
  32. +46 −0 templates/scaffold/realtime/views/jade/layout.html.jade.ejs
  33. +14 −0 templates/scaffold/realtime/views/jade/show.html.jade.ejs
  34. +6 −0 templates/scaffold/realtime/views/mustache/add.html.ms.ejs
  35. +6 −0 templates/scaffold/realtime/views/mustache/edit.html.ms.ejs
  36. +6 −0 templates/scaffold/realtime/views/mustache/index.html.ms.ejs
  37. +12 −0 templates/scaffold/realtime/views/mustache/layout.html.ms.ejs
  38. +6 −0 templates/scaffold/realtime/views/mustache/show.html.ms.ejs
View
16 bin/cli.js
@@ -17,6 +17,7 @@ var cwd = process.cwd()
, usage
, cmd
, engineCmd
+ , rtCmd
, modelCmd
, filepath
, die
@@ -39,6 +40,7 @@ usage = [
, ' --workers, -w Number of worker processes to start (default: 1)'
, ' --debug, -d Sets the log level to output debug messages to'
, ' the console'
+ , ' --realtime, -r When generating or scaffolding, take realtime into account'
, ' --jade, -j When generating views this will create Jade'
, ' templates(Default: EJS)'
, ' --handle, -H When generating views this will create Handlebars'
@@ -92,6 +94,7 @@ optsMap = [
, { full: 'handle', abbr: 'H', args: false }
, { full: 'handlebars', abbr: 'H', args: false }
, { full: 'mustache', abbr: 'm', args: false }
+ , { full: 'realtime', abbr: 'r', args: false}
];
// Parse optsMap and generate options and cmd commands
@@ -144,7 +147,14 @@ if (cmds.length) {
engineCmd = ',' + 'handlebars';
} else if (opts.mustache) {
engineCmd = ',' + 'mustache';
- } else engineCmd = '';
+ } else engineCmd = ',default';
+
+ if (opts.realtime) {
+ rtCmd = ',' + 'realtime';
+ }
+ else {
+ rtCmd = ',default';
+ }
// Get the model properties
if (cmds.slice(2).length > 0) {
@@ -171,15 +181,15 @@ if (cmds.length) {
break;
case 'app':
// Generating application
- cmd += 'gen:app[' + cmds[1] + engineCmd + ']';
+ cmd += 'gen:app[' + cmds[1] + engineCmd + rtCmd + ']';
break;
case 'resource':
// Generating resource
cmd += 'gen:resource[' + cmds[1] + modelCmd + ']';
break;
case 'scaffold':
// Generating application
- cmd += 'gen:scaffold[' + cmds[1] + engineCmd + modelCmd + ']';
+ cmd += 'gen:scaffold[' + cmds[1] + rtCmd + engineCmd + modelCmd + ']';
break;
case 'controller':
// Generating controller
View
2 examples/socket_io/config/environment.js
@@ -5,7 +5,7 @@ var config = {
}
*/
- socketIo: true
+ realtime: true
};
View
2 lib/app.js
@@ -236,7 +236,7 @@ var App = function () {
// Load socket.io if it's enabled. This gets run after
// the server starts listening for requests. Socket.io
// won't work if we start it before.
- if (geddy.config.socketIo) {
+ if (geddy.config.realtime) {
geddy.io = utils.file.requireLocal('socket.io').listen(geddy.server, {'log level': 0});
// add event listeners to all the models
// set up socket.io emitters for each event
View
33 templates/Jakefile
@@ -282,7 +282,7 @@ namespace('gen', function () {
};
// Creates a new Geddy app scaffold
- task('app', function (name, engine) {
+ task('app', function (name, engine, realtime) {
var mkdirs
, cps
, text
@@ -291,9 +291,13 @@ namespace('gen', function () {
if (!name) {
throw new Error('No app name specified.');
}
- if (!engine) {
+ if (!engine || engine == 'default') {
engine = 'ejs';
}
+ if (realtime == 'default') {
+ realtime = false;
+ }
+
mkdirs = [
''
@@ -307,11 +311,11 @@ namespace('gen', function () {
, 'test'
];
cps = [
- ['views/' + engine, 'app/views']
+ (realtime) ? ['realtime/views/' + engine, 'app/views'] : ['views/' + engine, 'app/views']
, ['public', '']
, ['router.js', 'config']
, ['init.js', 'config']
- , ['environment.js', 'config']
+ , (realtime) ? ['realtime/environment.js', 'config'] : ['environment.js', 'config']
, ['development.js', 'config']
, ['production.js', 'config']
, ['main.js', 'app/controllers']
@@ -357,19 +361,22 @@ namespace('gen', function () {
// Creates a full scaffold with views, a model, controller and a resource route
- task('scaffold', function (name, engine, modelProperties) {
+ task('scaffold', function (name, realtime, engine, modelProperties) {
var modelTask = jake.Task['gen:model'];
- if (!modelProperties && engine) {
+ /*if (!modelProperties && engine) {
modelProperties = engine;
engine = '';
- }
+ }*/
if (!name) {
throw new Error('No scaffold name specified.');
}
- if (!engine) {
+ if (!engine || engine == 'default') {
engine = 'ejs';
}
+ if (!realtime || realtime == 'default') {
+ realtime = false;
+ }
modelTask.on('complete', function () {
jake.Task['gen:test'].invoke(name,
@@ -378,7 +385,7 @@ namespace('gen', function () {
{properties: modelProperties});
jake.Task['gen:route'].invoke(name);
jake.Task['gen:viewsScaffold'].invoke(name,
- {engine: engine, properties: modelProperties});
+ {engine: engine, properties: modelProperties, realtime: realtime});
complete();
});
modelTask.invoke(name, modelProperties, 'scaffold');
@@ -611,10 +618,11 @@ namespace('gen', function () {
var names = utils.string.getInflections(name)
, engine = options.engine
, appViewDir = path.join('app', 'views', names.filename.plural)
- , templateViewDir = path.join(__dirname, 'scaffold', 'views', engine)
+ , templateViewDir
, cmds = []
, ext = '.html'
, appLayoutPath
+ , layoutViewPath
, actions
, addActionView
, text
@@ -637,6 +645,11 @@ namespace('gen', function () {
break;
}
+ templateViewDir = options.realtime ?
+ path.join(__dirname, 'scaffold', 'realtime', 'views', engine) :
+ path.join(__dirname, 'scaffold', 'views', engine);
+
+
// Set application layout path
appLayoutPath = path.join('app', 'views', 'layouts', 'application');
View
2 templates/base/development.js
@@ -19,7 +19,7 @@
var config = {
detailedErrors: true
, debug: true
-, hostname: null
+, hostname: 'localhost'
, port: 4000
, model: {
defaultAdapter: 'memory'
View
5 templates/base/environment.js
@@ -1,9 +1,4 @@
var config = {
- /*
- metrics: {
- port: 4001
- }
- */
};
module.exports = config;
View
2 templates/base/production.js
@@ -20,7 +20,7 @@ var config = {
detailedErrors: false
, hostname: null
, port: 4000
-/* TODO: Define a defaultAdapter. You can use postgresdb, memory, mongo or riak.
+/* TODO: Define a defaultAdapter. You can use postgresdb, memory, mongo or riak.
, model: {
defaultAdapter: 'mongo'
}
View
15 templates/base/public/js/core/core.js
@@ -12649,7 +12649,7 @@ utilities.mixin(geddy, utilities);
// require socket.io-client
geddy.io = require('socket.io-client');
-geddy.socket = geddy.io.connect('http://localhost');
+geddy.socket = geddy.io.connect('http://localhost:4000');
geddy.io.listenForModelEvents = function (model) {
var events = [
@@ -12659,18 +12659,21 @@ geddy.io.listenForModelEvents = function (model) {
];
for (var e in events) {
- geddy.socket.on(model.modelName + ':' + events[e], function (data) {
- (function (event) {
+ (function (event) {
+ geddy.socket.on(model.modelName + ':' + event, function (data) {
var instance;
if (typeof data != 'string') {
instance = model.create(data);
}
else {
instance = data;
}
+ if (geddy.debug == true) {
+ console.log(event, instance);
+ }
model.emit(event, instance);
- })(events[e]);
- });
+ });
+ })(events[e]);
};
}
@@ -12683,6 +12686,8 @@ geddy.io.addListenersForModels = function (models) {
}
+
+
});
require("/templates/build/build.js");
})();
View
5 templates/base/realtime/environment.js
@@ -0,0 +1,5 @@
+var config = {
+ realtime: true
+};
+
+module.exports = config;
View
53 templates/base/realtime/views/ejs/layouts/application.html.ejs
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Geddy App | This app uses Geddy.js</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <meta name="viewport" content="width=device-width" />
+
+ <!-- The HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <%- scriptLink('/js/jquery.min.js', {type:'text/javascript'}) %>
+ <%- scriptLink('/js/bootstrap.min.js', {type:'text/javascript'}) %>
+ <%- scriptLink('/js/core/core.js', {type: 'text/javascript'}) %>
+ <%- scriptLink('/js/core/models.js', {type: 'text/javascript'}) %>
+
+ <%- styleLink('/css/bootstrap.min.css', {rel:'stylesheet'}) %>
+ <%- styleLink('/css/style.css', {rel:'stylesheet'}) %>
+ <%- styleLink('/css/bootstrap.responsive.min.css', {rel:'stylesheet'}) %>
+
+ <!-- The fav and touch icons -->
+ <link rel="shortcut icon" href="/images/favicon.ico">
+ <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
+ </head>
+ <body>
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="i-bar"><i class="icon-chevron-down icon-white"></i></span>
+ </a>
+ <%- linkTo('Geddy App', '/', { class: 'brand' }) %>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li class="active"><%- linkTo('Home', '/') %></li>
+ <li><%- linkTo('Tutorial', 'http://geddyjs.org/tutorial') %></li>
+ <li><%- linkTo('Docs', 'http://geddyjs.org/documentation') %></li>
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ <%- yield(); %>
+ </div>
+ </body>
+</html>
View
6 templates/base/realtime/views/ejs/main/index.html.ejs
@@ -0,0 +1,6 @@
+<!-- Lets talk about geddy -->
+<div class="hero-unit geddy-welcome-box">
+ <h1>Hello, World!</h1>
+ <p>You've created a Geddy app and your server is running. If you already know what you're doing, feel free to jump into your app logic, if not...</p>
+ <p><a href="http://geddyjs.org/tutorial.html" class="btn btn-primary btn-large">Lets get you started »</a></p>
+</div>
View
51 templates/base/realtime/views/handlebars/layouts/application.html.hbs
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Geddy App | This app uses Geddy.js</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <meta name="viewport" content="width=device-width" />
+
+ <!-- The HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <script type="text/javascript" src="/js/jquery.min.js"></script>
+ <script type="text/javascript" src="/js/bootstrap.min.js"></script>
+
+ <link rel="stylesheet" href="/css/bootstrap.min.css">
+ <link rel="stylesheet" href="/css/style.css">
+ <link rel="stylesheet" href="/css/bootstrap.responsive.min.css">
+
+ <!-- The fav and touch icons -->
+ <link rel="shortcut icon" href="/images/favicon.ico">
+ <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
+ </head>
+ <body>
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="i-bar"><i class="icon-chevron-down icon-white"></i></span>
+ </a>
+ <a class="brand" href="/">Geddy App</a>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li class="active"><a href="/">Home</a></li>
+ <li><a href="http://geddyjs.org/tutorial.html">Tutorial</a></li>
+ <!--<li><a href="http://geddyjs.org/docs.html">Docs</a></li>-->
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ {{{yield}}}
+ </div>
+ </body>
+</html>
View
6 templates/base/realtime/views/handlebars/main/index.html.hbs
@@ -0,0 +1,6 @@
+<!-- Lets talk about geddy -->
+<div class="hero-unit geddy-welcome-box">
+ <h1>Hello, World!</h1>
+ <p>You've created a Geddy app and your server is running. If you already know what you're doing, feel free to jump into your app logic, if not...</p>
+ <p><a href="http://geddyjs.org/tutorial.html" class="btn btn-primary btn-large">Lets get you started »</a></p>
+</div>
View
46 templates/base/realtime/views/jade/layouts/application.html.jade
@@ -0,0 +1,46 @@
+!!! html
+
+html(lang="en")
+ head
+ meta(charset="utf-8")
+ meta(name="description", content="")
+ meta(name="author", content="")
+ meta(name="viewport", content="width=device-width")
+ title Geddy App | This app uses Geddy.js
+
+ // The HTML5 shim, for IE6-8 support of HTML elements
+ //if lt IE 9
+ script(src="http://html5shim.googlecode.com/svn/trunk/html5.js")
+
+ != scriptLink('/js/jquery.min.js', {type:'text/javascript'})
+ != scriptLink('/js/bootstrap.min.js', {type:'text/javascript'})
+
+ != styleLink('/css/bootstrap.min.css', {rel:'stylesheet'})
+ != styleLink('/css/style.css', {rel:'stylesheet'})
+ != styleLink('/css/bootstrap.responsive.min.css', {rel:'stylesheet'})
+
+ // The fav and touch icons
+ link(rel="shortcut icon", href="/images/favicon.ico")
+ link(rel="apple-touch-icon", href="images/apple-touch-icon.png")
+ link(rel="apple-touch-icon", sizes="72x72", href="images/apple-touch-icon-72x72.png")
+ link(rel="apple-touch-icon", sizes="114x114", href="images/apple-touch-icon-114x114.png")
+
+ body
+ .navbar.navbar-fixed-top
+ .navbar-inner
+ .container
+ a.btn.btn-navbar(data-toggle="collapse", data-target=".nav-collapse")
+ span.i-bar
+ i.icon-chevron-down.icon-white
+ != linkTo('Geddy App', '/', { class: 'brand' })
+ .nav-collapse
+ ul.nav
+ li.active
+ != linkTo('Home', '/')
+ li
+ != linkTo('Tutorial', 'http://geddyjs.org/tutorial.html')
+ //li
+ != linkTo('Docs', 'http://geddyjs.org/docs.html')
+
+ .container
+ != yield()
View
6 templates/base/realtime/views/jade/main/index.html.jade
@@ -0,0 +1,6 @@
+// Lets talk about geddy
+.hero-unit.geddy-welcome-box
+ h1 Hello, World!
+ p You've created a Geddy app and your server is running. If you already know what you're doing, feel free to jump into your app logic, if not...
+ p
+ a.btn.btn-primary.btn-large(href="http://geddyjs.org/tutorial.html") Lets get you started »
View
51 templates/base/realtime/views/mustache/layouts/application.html.hbs
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Geddy App | This app uses Geddy.js</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <meta name="viewport" content="width=device-width" />
+
+ <!-- The HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <script type="text/javascript" src="/js/jquery.min.js"></script>
+ <script type="text/javascript" src="/js/bootstrap.min.js"></script>
+
+ <link rel="stylesheet" href="/css/bootstrap.min.css">
+ <link rel="stylesheet" href="/css/style.css">
+ <link rel="stylesheet" href="/css/bootstrap.responsive.min.css">
+
+ <!-- The fav and touch icons -->
+ <link rel="shortcut icon" href="/images/favicon.ico">
+ <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
+ </head>
+ <body>
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="i-bar"><i class="icon-chevron-down icon-white"></i></span>
+ </a>
+ <a class="brand" href="/">Geddy App</a>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li class="active"><a href="/">Home</a></li>
+ <li><a href="http://geddyjs.org/tutorial.html">Tutorial</a></li>
+ <!--<li><a href="http://geddyjs.org/docs.html">Docs</a></li>-->
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ {{{yield}}}
+ </div>
+ </body>
+</html>
View
6 templates/base/realtime/views/mustache/main/index.html.hbs
@@ -0,0 +1,6 @@
+<!-- Lets talk about geddy -->
+<div class="hero-unit geddy-welcome-box">
+ <h1>Hello, World!</h1>
+ <p>You've created a Geddy app and your server is running. If you already know what you're doing, feel free to jump into your app logic, if not...</p>
+ <p><a href="http://geddyjs.org/tutorial.html" class="btn btn-primary btn-large">Lets get you started »</a></p>
+</div>
View
15 templates/build/build.js
@@ -9,7 +9,7 @@ utilities.mixin(geddy, utilities);
// require socket.io-client
geddy.io = require('socket.io-client');
-geddy.socket = geddy.io.connect('http://localhost');
+geddy.socket = geddy.io.connect('http://localhost:4000');
geddy.io.listenForModelEvents = function (model) {
var events = [
@@ -19,18 +19,21 @@ geddy.io.listenForModelEvents = function (model) {
];
for (var e in events) {
- geddy.socket.on(model.modelName + ':' + events[e], function (data) {
- (function (event) {
+ (function (event) {
+ geddy.socket.on(model.modelName + ':' + event, function (data) {
var instance;
if (typeof data != 'string') {
instance = model.create(data);
}
else {
instance = data;
}
+ if (geddy.debug == true) {
+ console.log(event, instance);
+ }
model.emit(event, instance);
- })(events[e]);
- });
+ });
+ })(events[e]);
};
}
@@ -42,3 +45,5 @@ geddy.io.addListenersForModels = function (models) {
}
}
+
+
View
50 templates/scaffold/realtime/views/ejs/add.html.ejs.ejs
@@ -0,0 +1,50 @@
+<div class="hero-unit">
+ <form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>" method="POST">
+ <fieldset>
+ <legend>Create a new <%= names.constructor.singular %></legend>
+ <@ if(params.errors) { @>
+ <div class="control-group">
+ <ul>
+ <@ for(var err in params.errors) { @>
+ <li><@= params.errors[err]; @></li>
+ <%% } %>
+ </ul>
+ </div>
+ <%% } %>
+<% for(var i in properties) { -%>
+<% if(properties[i].name !== 'id') { -%>
+ <div class="control-group">
+ <label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
+ <div class="controls">
+<% if(properties[i].type === 'string') { -%>
+<% if(properties[i].name === 'password') { -%>
+ <@- contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'}) @>
+<% } else { -%>
+ <@- contentTag('input', '', {type:'text', class:'span6', name:'<%= properties[i].name %>'}) @>
+<% } -%>
+<% } else if(properties[i].type === 'text') { -%>
+ <@- contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10}) @>
+<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
+ <@- contentTag('input', '', {type:'number', class:'span2', name:'<%= properties[i].name %>'}) @>
+<% } else if(properties[i].type === 'boolean') { -%>
+ <select name="<%= properties[i].name %>", class="span1">
+ <option selected>false</option>
+ <option>true</option>
+ </select>
+<% } else if(properties[i].type === 'datetime') { -%>
+ <@- contentTag('input', '', {type:'datetime', class:'span3', name:'<%= properties[i].name %>'}) @>
+<% } else if(properties[i].type === 'date') { -%>
+ <@- contentTag('input', '', {type:'date', class:'span2', name:'<%= properties[i].name %>'}) @>
+<% } else { -%>
+ <%= properties[i].type %>
+<% } -%>
+ </div>
+ </div>
+<% } -%>
+<% } -%>
+ <div class="form-actions">
+ <@- contentTag('input', 'Add', {type: 'submit', class: 'btn btn-primary'}) @>
+ </div>
+ </fieldset>
+ </form>
+</div>
View
56 templates/scaffold/realtime/views/ejs/edit.html.ejs.ejs
@@ -0,0 +1,56 @@
+<div class="hero-unit">
+ <form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>/<@= params.id @>?_method=PUT" method="POST">
+ <fieldset>
+ <legend>Update this <%= names.constructor.singular %></legend>
+ <@ if(params.errors) { @>
+ <div class="control-group">
+ <ul>
+ <@ for(var err in params.errors) { @>
+ <li><@= params.errors[err]; @></li>
+ <%% } %>
+ </ul>
+ </div>
+ <%% } %>
+<% for(var i in properties) { -%>
+<% if(properties[i].name !== 'id') { -%>
+ <div class="control-group">
+ <label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
+ <div class="controls">
+<% if(properties[i].type === 'string') { -%>
+<% if(properties[i].name === 'password') { -%>
+ <@- contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'}) @>
+<% } else { -%>
+ <@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'text', class:'span6', name:'<%= properties[i].name %>'}) @>
+<% } -%>
+<% } else if(properties[i].type === 'text') { -%>
+ <@- contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10}) @>
+<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
+ <@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'number', class:'span2', name:'<%= properties[i].name %>'}) @>
+<% } else if(properties[i].type === 'boolean') { -%>
+ <select name="<%= properties[i].name %>", class="span1">
+ <@ if(<%= names.property.singular %>.<%= properties[i].name %>) { -@>
+ <option>false</option>
+ <option selected>true</option>
+ <@ } else { -@>
+ <option selected>false</option>
+ <option>true</option>
+ <@ } -@>
+ </select>
+<% } else if(properties[i].type === 'datetime') { -%>
+ <@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'datetime', class:'span3', name:'<%= properties[i].name %>'}) @>
+<% } else if(properties[i].type === 'date') { -%>
+ <@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'date', class:'span2', name:'<%= properties[i].name %>'}) @>
+<% } else { -%>
+ <%= properties[i].type %>
+<% } -%>
+ </div>
+ </div>
+<% } -%>
+<% } -%>
+ <div class="form-actions">
+ <@- contentTag('input', 'Save', {type: 'submit', class: 'btn btn-primary'}) @>
+ <@- contentTag('button', 'Remove', {type: 'submit', formaction: '/<%= names.filename.plural %>/' + params.id + '?_method=DELETE', formmethod: 'POST', class: 'btn btn-danger'}) @>
+ </div>
+ </fieldset>
+ </form>
+</div>
View
66 templates/scaffold/realtime/views/ejs/index.html.ejs.ejs
@@ -0,0 +1,66 @@
+<div class="hero-unit">
+ <h2>All <%= names.constructor.plural %></h2>
+ <@- linkTo('Create a new <%= names.constructor.singular %>', add<%= names.constructor.singular %>Path, {class: 'btn pull-right'}); @>
+</div>
+
+<div id="<%= names.property.plural %>-list">
+<@ if (items) { @>
+<@ 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="span8">
+ <h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
+ </div>
+ <div class="span4">
+ <h3><i class="icon-list-alt"></i><@= <%= names.property.plural %>[i].id; @></h3>
+ </div>
+ </div>
+<%% } %>
+<%% } %>
+</div>
+
+<script type="text/javascript">
+$(function(){
+
+ // listen for events on the Item model
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ // render the template if we need to
+ var renderTemplate = function (<%= names.property.singular %>) {
+ var template = [ ''
+ , '<div class="row list-item" id="<%= names.property.singular %>-' + <%= names.property.singular %>.id + '">'
+ , ' <div class="span8">'
+ , ' <h3><a href="/<%= names.property.plural %>/' + <%= names.property.singular %>.id + '">' + <%= names.property.singular %>.<%= properties['default'].name %> + '</a></h3>'
+ , ' </div>'
+ , ' <div class="span4">'
+ , ' <h3><i class="icon-list-alt"></i>' + <%= names.property.singular %>.id + '</h3>'
+ , ' </div>'
+ , '</div>'
+ ].join('');
+ return $(template);
+ }
+
+ var <%= names.constructor.plural %>Controller = function (opts) {
+
+ this.options = opts || {};
+
+ this.create = function (<%= names.property.singular %>) {
+ $('#<%= names.property.plural %>-list').append(renderTemplate(<%= names.property.singular %>));
+ };
+
+ this.update = function (<%= names.property.singular %>) {
+ $('#<%= names.property.singular %>-' + <%= names.property.singular %>.id).replaceWith(renderTemplate(<%= names.property.singular %>));
+ };
+
+ this.remove = function (id) {
+ $('#<%= names.property.singular %>-' + id).remove();
+ };
+
+ };
+
+ geddy.<%= names.constructor.plural %> = new <%= names.constructor.plural %>Controller();
+
+ geddy.model.<%= names.constructor.singular %>.on('save' , geddy.<%= names.constructor.plural %>.create);
+ geddy.model.<%= names.constructor.singular %>.on('update' , geddy.<%= names.constructor.plural %>.update);
+ geddy.model.<%= names.constructor.singular %>.on('remove' , geddy.<%= names.constructor.plural %>.remove);
+});
+</script>
View
54 templates/scaffold/realtime/views/ejs/layout.html.ejs.ejs
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Geddy App | This app uses Geddy.js</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <meta name="viewport" content="width=device-width" />
+
+ <!-- The HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <%- scriptLink('/js/jquery.min.js', {type:'text/javascript'}) %>
+ <%- scriptLink('/js/bootstrap.min.js', {type:'text/javascript'}) %>
+ <%- scriptLink('/js/core/core.js', {type: 'text/javascript'}) %>
+ <!-- <script src="/js/models/your_model.js" type="text/javascript"></script> -->
+ <%- scriptLink('/js/config/init.js', {type: 'text/javascript'}) %>
+
+ <%- styleLink('/css/bootstrap.min.css', {rel:'stylesheet'}) %>
+ <%- styleLink('/css/style.css', {rel:'stylesheet'}) %>
+ <%- styleLink('/css/bootstrap.responsive.min.css', {rel:'stylesheet'}) %>
+
+ <!-- The fav and touch icons -->
+ <link rel="shortcut icon" href="/images/favicon.ico">
+ <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
+ </head>
+ <body>
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="i-bar"><i class="icon-chevron-down icon-white"></i></span>
+ </a>
+ <%- linkTo('Geddy App', '/', { class: 'brand' }) %>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li class="active"><%- linkTo('Home', '/') %></li>
+ <li><%- linkTo('Tutorial', 'http://geddyjs.org/tutorial') %></li>
+ <li><%- linkTo('Docs', 'http://geddyjs.org/documentation') %></li>
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ <%- yield(); %>
+ </div>
+ </body>
+</html>
View
18 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
@@ -0,0 +1,18 @@
+<div class="hero-unit">
+ <h2><@= <%= names.property.singular %>.<%= properties['default'].name %> @></h2>
+ <@- linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'}); @>
+</div>
+
+<h2><%= names.constructor.singular %> Properties</h2>
+<@ for(var i in <%= names.property.singular %>) { -@>
+<@ if(i !== 'saved') { -@>
+<div class="row list-item">
+ <div class="span8">
+ <h3><@= i @></h3>
+ </div>
+ <div class="span4">
+ <h3><i class="icon-list-alt"></i><@= <%= names.property.singular %>[i] @></h3>
+ </div>
+</div>
+<%% } -%>
+<%% } -%>
View
6 templates/scaffold/realtime/views/handlebars/add.html.hbs.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
6 templates/scaffold/realtime/views/handlebars/edit.html.hbs.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
6 templates/scaffold/realtime/views/handlebars/index.html.hbs.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
51 templates/scaffold/realtime/views/handlebars/layout.html.hbs.ejs
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Geddy App | This app uses Geddy.js</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <meta name="viewport" content="width=device-width" />
+
+ <!-- The HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <script type="text/javascript" src="/js/jquery.min.js"></script>
+ <script type="text/javascript" src="/js/bootstrap.min.js"></script>
+
+ <link rel="stylesheet" href="/css/bootstrap.min.css">
+ <link rel="stylesheet" href="/css/style.css">
+ <link rel="stylesheet" href="/css/bootstrap.responsive.min.css">
+
+ <!-- The fav and touch icons -->
+ <link rel="shortcut icon" href="/images/favicon.ico">
+ <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
+ </head>
+ <body>
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="i-bar"><i class="icon-chevron-down icon-white"></i></span>
+ </a>
+ <a class="brand" href="/">Geddy App</a>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li class="active"><a href="/">Home</a></li>
+ <li><a href="http://geddyjs.org/tutorial.html">Tutorial</a></li>
+ <!--<li><a href="http://geddyjs.org/docs.html">Docs</a></li>-->
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ {{{yield}}}
+ </div>
+ </body>
+</html>
View
6 templates/scaffold/realtime/views/handlebars/show.html.hbs.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
40 templates/scaffold/realtime/views/jade/add.html.jade.ejs
@@ -0,0 +1,40 @@
+.hero-unit
+ form#<%= names.property.singular %>-form.form-horizontal(action="/<%= names.filename.plural %>", method="POST")
+ fieldset
+ legend Create a new <%= names.constructor.singular %>
+ if params.errors
+ .control-group
+ ul
+ for err in params.errors
+ li= err
+
+<% for(var i in properties) { -%>
+<% if(properties[i].name !== 'id') { -%>
+ .control-group
+ label(for="<%= properties[i].name %>", class="control-label") <%= properties[i].name %>
+ .controls
+<% if(properties[i].type === 'string') { -%>
+<% if(properties[i].name === 'password') { -%>
+ != contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'})
+<% } else { -%>
+ != contentTag('input', '', {type:'text', class:'span6', name:'<%= properties[i].name %>'})
+<% } -%>
+<% } else if(properties[i].type === 'text') { -%>
+ != contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10})
+<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
+ != contentTag('input', '', {type:'number', class:'span2', name:'<%= properties[i].name %>'})
+<% } else if(properties[i].type === 'boolean') { -%>
+ select.span1(name="<%= properties[i].name %>")
+ option(selected) false
+ option true
+<% } else if(properties[i].type === 'datetime') { -%>
+ != contentTag('input', '', {type:'datetime', class:'span3', name:'<%= properties[i].name %>'})
+<% } else if(properties[i].type === 'date') { -%>
+ != contentTag('input', '', {type:'date', class:'span2', name:'<%= properties[i].name %>'})
+<% } else { -%>
+ | <%= properties[i].type %>
+<% } -%>
+<% } -%>
+<% } -%>
+ .form-actions
+ != contentTag('input', 'Add', {type: 'submit', class: 'btn btn-primary'})
View
45 templates/scaffold/realtime/views/jade/edit.html.jade.ejs
@@ -0,0 +1,45 @@
+.hero-unit
+ form#<%= names.property.singular %>-form.form-horizontal(action="/<%= names.filename.plural %>/" + params.id + "?_method=PUT", method="POST")
+ fieldset
+ legend Update this <%= names.constructor.singular %>
+ if params.errors
+ .control-group
+ ul
+ for err in params.errors
+ li= err
+
+<% for(var i in properties) { -%>
+<% if(properties[i].name !== 'id') { -%>
+ .control-group
+ label(for="<%= properties[i].name %>", class="control-label") <%= properties[i].name %>
+ .controls
+<% if(properties[i].type === 'string') { -%>
+<% if(properties[i].name === 'password') { -%>
+ != contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'})
+<% } else { -%>
+ != contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'text', class:'span6', name:'<%= properties[i].name %>'})
+<% } -%>
+<% } else if(properties[i].type === 'text') { -%>
+ != contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10})
+<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
+ != contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'number', class:'span2', name:'<%= properties[i].name %>'})
+<% } else if(properties[i].type === 'boolean') { -%>
+ select.span1(name="<%= properties[i].name %>")
+ if <%= names.property.singular %>.<%= properties[i].name %>
+ option false
+ option(selected) true
+ else
+ option(selected) false
+ option true
+<% } else if(properties[i].type === 'datetime') { -%>
+ != contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'datetime', class:'span3', name:'<%= properties[i].name %>'})
+<% } else if(properties[i].type === 'date') { -%>
+ != contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'date', class:'span2', name:'<%= properties[i].name %>'})
+<% } else { -%>
+ | <%= properties[i].type %>
+<% } -%>
+<% } -%>
+<% } -%>
+ .form-actions
+ != contentTag('input', 'Save', {type: 'submit', class: 'btn btn-primary'})
+ != contentTag('button', 'Remove', {type: 'submit', formaction: '/<%= names.filename.plural %>/' + params.id + '?_method=DELETE', formmethod: 'POST', class: 'btn btn-danger'})
View
13 templates/scaffold/realtime/views/jade/index.html.jade.ejs
@@ -0,0 +1,13 @@
+.hero-unit
+ h2 All <%= names.constructor.plural %>
+ != linkTo('Create a new <%= names.constructor.singular %>', add<%= names.constructor.singular %>Path, {class: 'btn pull-right'})
+
+if <%= names.property.plural %>
+ each <%= names.property.singular %> in <%= names.property.plural %>
+ .row.list-item
+ .span8
+ h3!= linkTo(<%= names.property.singular %>.<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.singular %>.id))
+ .span4
+ h3
+ i.icon-list-alt
+ = <%= names.property.singular %>.id
View
46 templates/scaffold/realtime/views/jade/layout.html.jade.ejs
@@ -0,0 +1,46 @@
+!!! html
+
+html(lang="en")
+ head
+ meta(charset="utf-8")
+ meta(name="description", content="")
+ meta(name="author", content="")
+ meta(name="viewport", content="width=device-width")
+ title Geddy App | This app uses Geddy.js
+
+ // The HTML5 shim, for IE6-8 support of HTML elements
+ //if lt IE 9
+ script(src="http://html5shim.googlecode.com/svn/trunk/html5.js")
+
+ != scriptLink('/js/jquery.min.js', {type:'text/javascript'})
+ != scriptLink('/js/bootstrap.min.js', {type:'text/javascript'})
+
+ != styleLink('/css/bootstrap.min.css', {rel:'stylesheet'})
+ != styleLink('/css/style.css', {rel:'stylesheet'})
+ != styleLink('/css/bootstrap.responsive.min.css', {rel:'stylesheet'})
+
+ // The fav and touch icons
+ link(rel="shortcut icon", href="/images/favicon.ico")
+ link(rel="apple-touch-icon", href="images/apple-touch-icon.png")
+ link(rel="apple-touch-icon", sizes="72x72", href="images/apple-touch-icon-72x72.png")
+ link(rel="apple-touch-icon", sizes="114x114", href="images/apple-touch-icon-114x114.png")
+
+ body
+ .navbar.navbar-fixed-top
+ .navbar-inner
+ .container
+ a.btn.btn-navbar(data-toggle="collapse", data-target=".nav-collapse")
+ span.i-bar
+ i.icon-chevron-down.icon-white
+ != linkTo('Geddy App', '/', { class: 'brand' })
+ .nav-collapse
+ ul.nav
+ li.active
+ != linkTo('Home', '/')
+ li
+ != linkTo('Tutorial', 'http://geddyjs.org/tutorial.html')
+ //li
+ != linkTo('Docs', 'http://geddyjs.org/docs.html')
+
+ .container
+ != yield()
View
14 templates/scaffold/realtime/views/jade/show.html.jade.ejs
@@ -0,0 +1,14 @@
+.hero-unit
+ h2= <%= names.property.singular %>.<%= properties['default'].name %>
+ != linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'})
+
+h2 <%= names.constructor.singular %> Properties
+each property, key in <%= names.property.singular %>
+ if key !== 'saved'
+ .row.list-item
+ .span8
+ h3= key
+ .span4
+ h3
+ i.icon-list-alt
+ = property
View
6 templates/scaffold/realtime/views/mustache/add.html.ms.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
6 templates/scaffold/realtime/views/mustache/edit.html.ms.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
6 templates/scaffold/realtime/views/mustache/index.html.ms.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>
View
12 templates/scaffold/realtime/views/mustache/layout.html.ms.ejs
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Geddy App | This app uses Geddy.js</title>
+ </head>
+ <body>
+ <div class="container">
+ {{{yield}}}
+ </div>
+ </body>
+</html>
View
6 templates/scaffold/realtime/views/mustache/show.html.ms.ejs
@@ -0,0 +1,6 @@
+<div class="hero-unit">
+ <h3>Params</h3>
+ {{#params}}
+ <p>{{action}} action on {{controller}} controller.</p>
+ {{/params}}
+</div>

0 comments on commit 057bd49

Please sign in to comment.