Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Closes #250, Add realtime code generation to the other template langu…

…ages.

Also fix a big where mustache and handlebars scaffold generators would fail because there wasn't a form template to read from(relate to issue #246).
  • Loading branch information...
commit 315f77e9679f95e4edb7ecfb9023b0fcd024de36 1 parent 54509eb
@larzconwell larzconwell authored
Showing with 339 additions and 253 deletions.
  1. +6 −1 templates/Jakefile
  2. +2 −3 templates/base/realtime/views/ejs/layouts/application.html.ejs
  3. +1 −1  templates/base/realtime/views/ejs/main/index.html.ejs
  4. +5 −4 templates/base/realtime/views/handlebars/layouts/application.html.hbs
  5. +6 −5 templates/base/realtime/views/jade/layouts/application.html.jade
  6. +1 −1  templates/base/realtime/views/jade/main/index.html.jade
  7. +5 −4 templates/base/realtime/views/mustache/layouts/application.html.hbs
  8. +3 −4 templates/base/views/ejs/layouts/application.html.ejs
  9. +1 −1  templates/base/views/ejs/main/index.html.ejs
  10. +6 −4 templates/base/views/handlebars/layouts/application.html.hbs
  11. +7 −5 templates/base/views/jade/layouts/application.html.jade
  12. +1 −1  templates/base/views/jade/main/index.html.jade
  13. +6 −4 templates/base/views/mustache/layouts/application.html.hbs
  14. +2 −4 templates/scaffold/realtime/views/ejs/index.html.ejs.ejs
  15. +1 −38 templates/scaffold/realtime/views/ejs/layout.html.ejs.ejs
  16. +3 −4 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
  17. +43 −0 templates/scaffold/realtime/views/handlebars/index.html.hbs.ejs
  18. +4 −38 templates/scaffold/realtime/views/handlebars/layout.html.hbs.ejs
  19. +23 −0 templates/scaffold/realtime/views/handlebars/show.html.hbs.ejs
  20. +2 −28 templates/scaffold/realtime/views/jade/add.html.jade.ejs
  21. +2 −32 templates/scaffold/realtime/views/jade/edit.html.jade.ejs
  22. +32 −0 templates/scaffold/realtime/views/jade/form.html.jade.ejs
  23. +52 −9 templates/scaffold/realtime/views/jade/index.html.jade.ejs
  24. +3 −36 templates/scaffold/realtime/views/jade/layout.html.jade.ejs
  25. +25 −3 templates/scaffold/realtime/views/jade/show.html.jade.ejs
  26. +43 −0 templates/scaffold/realtime/views/mustache/index.html.ms.ejs
  27. +5 −0 templates/scaffold/realtime/views/mustache/layout.html.ms.ejs
  28. +23 −0 templates/scaffold/realtime/views/mustache/show.html.ms.ejs
  29. +9 −7 templates/scaffold/views/ejs/index.html.ejs.ejs
  30. +4 −4 templates/scaffold/views/ejs/show.html.ejs.ejs
  31. +10 −9 templates/scaffold/views/jade/index.html.jade.ejs
  32. +3 −3 templates/scaffold/views/jade/show.html.jade.ejs
View
7 templates/Jakefile
@@ -659,6 +659,7 @@ namespace('gen', function () {
, layoutViewPath
, actions
, addActionView
+ , viewPath
, text
, adapter
, templContent;
@@ -689,7 +690,11 @@ namespace('gen', function () {
// Function to compile the template
addActionView = function (action) {
- text = fs.readFileSync(path.join(templateViewDir, action + ext + '.ejs')).toString();
+ viewPath = path.join(templateViewDir, action + ext + '.ejs');
+ if (!utils.file.existsSync(viewPath)) {
+ return;
+ }
+ text = fs.readFileSync(viewPath).toString();
// Compile template text
adapter = new Adapter({engine: 'ejs', template: text});
View
5 templates/base/realtime/views/ejs/layouts/application.html.ejs
@@ -5,12 +5,11 @@
<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>
+ <%- scriptLink('http://html5shim.googlecode.com/svn/trunk/html5.js', {type:'text/javascript'}) %>
<![endif]-->
<%- scriptLink('/js/jquery.min.js', {type:'text/javascript'}) %>
@@ -35,7 +34,7 @@
<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' }) %>
+ <%- linkTo('Geddy App', '/', {class: 'brand'}) %>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><%- linkTo('Home', '/') %></li>
View
2  templates/base/realtime/views/ejs/main/index.html.ejs
@@ -2,5 +2,5 @@
<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>
+ <p><%- linkTo('Lets get you started »', 'http://geddyjs.org/tutorial.html', {class: 'btn btn-primary btn-large'}) %></p>
</div>
View
9 templates/base/realtime/views/handlebars/layouts/application.html.hbs
@@ -5,7 +5,6 @@
<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 -->
@@ -15,6 +14,8 @@
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
+ <script type="text/javascript" src="/js/core/core.js"></script>
+ <script type="text/javascript" src="/js/core/models.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
@@ -36,9 +37,9 @@
<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>-->
+ <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>
View
11 templates/base/realtime/views/jade/layouts/application.html.jade
@@ -1,12 +1,11 @@
!!! html
-
html(lang="en")
head
meta(charset="utf-8")
+ title Geddy App | This app uses Geddy.js
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
@@ -14,6 +13,8 @@ html(lang="en")
!= 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'})
@@ -38,9 +39,9 @@ html(lang="en")
li.active
!= linkTo('Home', '/')
li
- != linkTo('Tutorial', 'http://geddyjs.org/tutorial.html')
- //li
- != linkTo('Docs', 'http://geddyjs.org/docs.html')
+ != linkTo('Tutorial', 'http://geddyjs.org/tutorial')
+ li
+ != linkTo('Docs', 'http://geddyjs.org/documentation')
.container
!= yield()
View
2  templates/base/realtime/views/jade/main/index.html.jade
@@ -3,4 +3,4 @@
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 »
+ != linkTo('Lets get you started »', 'http://geddyjs.org/tutorial.html', {class: 'btn btn-primary btn-large'})
View
9 templates/base/realtime/views/mustache/layouts/application.html.hbs
@@ -5,7 +5,6 @@
<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 -->
@@ -15,6 +14,8 @@
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
+ <script type="text/javascript" src="/js/core/core.js"></script>
+ <script type="text/javascript" src="/js/core/models.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
@@ -36,9 +37,9 @@
<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>-->
+ <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>
View
7 templates/base/views/ejs/layouts/application.html.ejs
@@ -5,18 +5,17 @@
<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>
+ <%- scriptLink('http://html5shim.googlecode.com/svn/trunk/html5.js', {type:'text/javascript'}) %>
<![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/models/your_model.js', {type:'text/javascript'}) %> -->
<%- scriptLink('/js/config/init.js', {type: 'text/javascript'}) %>
<%- styleLink('/css/bootstrap.min.css', {rel:'stylesheet'}) %>
@@ -36,7 +35,7 @@
<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' }) %>
+ <%- linkTo('Geddy App', '/', {class: 'brand'}) %>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><%- linkTo('Home', '/') %></li>
View
2  templates/base/views/ejs/main/index.html.ejs
@@ -2,5 +2,5 @@
<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>
+ <p><%- linkTo('Lets get you started »', 'http://geddyjs.org/tutorial.html', {class: 'btn btn-primary btn-large'}) %></p>
</div>
View
10 templates/base/views/handlebars/layouts/application.html.hbs
@@ -5,7 +5,6 @@
<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 -->
@@ -15,6 +14,9 @@
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
+ <script type="text/javascript" src="/js/core/core.js"></script>
+ <!-- <script type="text/javascript" src="/js/models/your_model.js"></script> -->
+ <script type="text/javascript" src="/js/config/init.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
@@ -36,9 +38,9 @@
<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>-->
+ <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>
View
12 templates/base/views/jade/layouts/application.html.jade
@@ -1,12 +1,11 @@
!!! html
-
html(lang="en")
head
meta(charset="utf-8")
+ title Geddy App | This app uses Geddy.js
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
@@ -14,6 +13,9 @@ html(lang="en")
!= 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/models/your_model.js', {type:'text/javascript'})
+ != scriptLink('/js/config/init.js', {type: 'text/javascript'})
!= styleLink('/css/bootstrap.min.css', {rel:'stylesheet'})
!= styleLink('/css/style.css', {rel:'stylesheet'})
@@ -38,9 +40,9 @@ html(lang="en")
li.active
!= linkTo('Home', '/')
li
- != linkTo('Tutorial', 'http://geddyjs.org/tutorial.html')
- //li
- != linkTo('Docs', 'http://geddyjs.org/docs.html')
+ != linkTo('Tutorial', 'http://geddyjs.org/tutorial')
+ li
+ != linkTo('Docs', 'http://geddyjs.org/documentation')
.container
!= yield()
View
2  templates/base/views/jade/main/index.html.jade
@@ -3,4 +3,4 @@
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 »
+ != linkTo('Lets get you started »', 'http://geddyjs.org/tutorial.html', {class: 'btn btn-primary btn-large'})
View
10 templates/base/views/mustache/layouts/application.html.hbs
@@ -5,7 +5,6 @@
<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 -->
@@ -15,6 +14,9 @@
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
+ <script type="text/javascript" src="/js/core/core.js"></script>
+ <!-- <script type="text/javascript" src="/js/models/your_model.js"></script> -->
+ <script type="text/javascript" src="/js/config/init.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
@@ -36,9 +38,9 @@
<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>-->
+ <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>
View
6 templates/scaffold/realtime/views/ejs/index.html.ejs.ejs
@@ -19,8 +19,7 @@
</div>
<script type="text/javascript">
-$(function(){
-
+$(function () {
geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
var renderTemplate = function (<%= names.property.singular %>) {
@@ -34,11 +33,11 @@ $(function(){
, ' </div>'
, '</div>'
].join('');
+
return $(template);
}
var <%= names.constructor.plural %>Controller = function (opts) {
-
this.options = opts || {};
this.create = function (<%= names.property.singular %>) {
@@ -54,7 +53,6 @@ $(function(){
};
};
-
geddy.<%= names.constructor.plural %> = new <%= names.constructor.plural %>Controller();
geddy.model.<%= names.constructor.singular %>.on('save' , geddy.<%= names.constructor.plural %>.create);
View
39 templates/scaffold/realtime/views/ejs/layout.html.ejs.ejs
@@ -3,50 +3,13 @@
<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/models/your_model.js', {type:'text/javascript'}) %> -->
<%- 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>
View
7 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
@@ -18,13 +18,12 @@
<%% } -%>
<script type="text/javascript">
-$(function(){
-
+$(function () {
var pageId = window.location.pathname.split('/')[2];
geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
- geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>){
+ geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>) {
if (<%= names.property.singular %>.id == pageId) {
var properties = <%= names.property.singular %>.toData();
for (var i in properties) {
@@ -33,7 +32,7 @@ $(function(){
}
});
- geddy.model.<%= names.constructor.singular %>.on('remove', function (id){
+ geddy.model.<%= names.constructor.singular %>.on('remove', function (id) {
if (id == pageId) {
window.location = '/<%= names.property.plural %>';
}
View
43 templates/scaffold/realtime/views/handlebars/index.html.hbs.ejs
@@ -4,3 +4,46 @@
<p>{{action}} action on {{controller}} controller.</p>
{{/params}}
</div>
+
+<script type="text/javascript">
+$(function () {
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ 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
42 templates/scaffold/realtime/views/handlebars/layout.html.hbs.ejs
@@ -3,49 +3,15 @@
<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">
+ <script type="text/javascript" src="/js/core/core.js"></script>
+ <!-- <script type="text/javascript" src="/js/models/your_model.js"></script> -->
+ <script type="text/javascript" src="/js/config/init.js"></script>
</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>
+</html>
View
23 templates/scaffold/realtime/views/handlebars/show.html.hbs.ejs
@@ -4,3 +4,26 @@
<p>{{action}} action on {{controller}} controller.</p>
{{/params}}
</div>
+
+<script type="text/javascript">
+$(function () {
+ var pageId = window.location.pathname.split('/')[2];
+
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>) {
+ if (<%= names.property.singular %>.id == pageId) {
+ var properties = <%= names.property.singular %>.toData();
+ for (var i in properties) {
+ $('.'+i).text(properties[i]);
+ }
+ }
+ });
+
+ geddy.model.<%= names.constructor.singular %>.on('remove', function (id) {
+ if (id == pageId) {
+ window.location = '/<%= names.property.plural %>';
+ }
+ });
+});
+</script>
View
30 templates/scaffold/realtime/views/jade/add.html.jade.ejs
@@ -8,33 +8,7 @@
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 %>
-<% } -%>
-<% } -%>
-<% } -%>
+ != partial('form', {<%= names.property.singular %>: {}})
+
.form-actions
!= contentTag('input', 'Add', {type: 'submit', class: 'btn btn-primary'})
View
34 templates/scaffold/realtime/views/jade/edit.html.jade.ejs
@@ -8,38 +8,8 @@
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 %>
-<% } -%>
-<% } -%>
-<% } -%>
+ != partial('form', {<%= names.property.singular %>: <%= names.property.singular %>})
+
.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
32 templates/scaffold/realtime/views/jade/form.html.jade.ejs
@@ -0,0 +1,32 @@
+<% 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 %>
+<% } -%>
+<% } -%>
+<% } -%>
View
61 templates/scaffold/realtime/views/jade/index.html.jade.ejs
@@ -2,12 +2,55 @@
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
+div#<%= names.property.plural %>-list
+ if <%= names.property.plural %>
+ each <%= names.property.singular %> in <%= names.property.plural %>
+ .row.list-item(id="<%= names.property.singular %>-" + <%= names.property.singular %>.id)
+ .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
+
+script(type="text/javascript")
+ $(function () {
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ 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);
+ });
View
39 templates/scaffold/realtime/views/jade/layout.html.jade.ejs
@@ -1,46 +1,13 @@
!!! 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")
-
+ != scriptLink('/js/core/core.js', {type: 'text/javascript'})
+ //- != scriptLink('/js/models/your_model.js', {type:'text/javascript'})
+ != scriptLink('/js/config/init.js', {type: 'text/javascript'})
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
28 templates/scaffold/realtime/views/jade/show.html.jade.ejs
@@ -6,9 +6,31 @@ h2 <%= names.constructor.singular %> Properties
each property, key in <%= names.property.singular %>
if key !== 'saved'
.row.list-item
- .span8
- h3= key
.span4
+ h3= key
+ .span8
h3
i.icon-list-alt
- = property
+ span(class=key)= property
+
+script(type="text/javascript")
+ $(function () {
+ var pageId = window.location.pathname.split('/')[2];
+
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>) {
+ if (<%= names.property.singular %>.id == pageId) {
+ var properties = <%= names.property.singular %>.toData();
+ for (var i in properties) {
+ $('.'+i).text(properties[i]);
+ }
+ }
+ });
+
+ geddy.model.<%= names.constructor.singular %>.on('remove', function (id) {
+ if (id == pageId) {
+ window.location = '/<%= names.property.plural %>';
+ }
+ });
+ });
View
43 templates/scaffold/realtime/views/mustache/index.html.ms.ejs
@@ -4,3 +4,46 @@
<p>{{action}} action on {{controller}} controller.</p>
{{/params}}
</div>
+
+<script type="text/javascript">
+$(function () {
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ 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
5 templates/scaffold/realtime/views/mustache/layout.html.ms.ejs
@@ -3,6 +3,11 @@
<head>
<meta charset="utf-8">
<title>Geddy App | This app uses Geddy.js</title>
+
+ <script type="text/javascript" src="/js/jquery.min.js"></script>
+ <script type="text/javascript" src="/js/core/core.js"></script>
+ <!-- <script type="text/javascript" src="/js/models/your_model.js"></script> -->
+ <script type="text/javascript" src="/js/config/init.js"></script>
</head>
<body>
<div class="container">
View
23 templates/scaffold/realtime/views/mustache/show.html.ms.ejs
@@ -4,3 +4,26 @@
<p>{{action}} action on {{controller}} controller.</p>
{{/params}}
</div>
+
+<script type="text/javascript">
+$(function () {
+ var pageId = window.location.pathname.split('/')[2];
+
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>) {
+ if (<%= names.property.singular %>.id == pageId) {
+ var properties = <%= names.property.singular %>.toData();
+ for (var i in properties) {
+ $('.'+i).text(properties[i]);
+ }
+ }
+ });
+
+ geddy.model.<%= names.constructor.singular %>.on('remove', function (id) {
+ if (id == pageId) {
+ window.location = '/<%= names.property.plural %>';
+ }
+ });
+});
+</script>
View
16 templates/scaffold/views/ejs/index.html.ejs.ejs
@@ -3,15 +3,17 @@
<@- linkTo('Create a new <%= names.constructor.singular %>', add<%= names.constructor.singular %>Path, {class: 'btn pull-right'}); @>
</div>
+<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">
- <div class="span8">
- <h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
+ <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>
+ <div class="span4">
+ <h3><i class="icon-list-alt"></i><@= <%= names.property.plural %>[i].id; @></h3>
+ </div>
</div>
- <div class="span4">
- <h3><i class="icon-list-alt"></i><@= <%= names.property.plural %>[i].id; @></h3>
- </div>
-</div>
<%% } %>
<%% } %>
+</div>
View
8 templates/scaffold/views/ejs/show.html.ejs.ejs
@@ -1,5 +1,5 @@
<div class="hero-unit">
- <h2><@= <%= names.property.singular %>.<%= properties['default'].name %> @></h2>
+ <h2 class="<%= properties['default'].name %>"><@= <%= 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>
@@ -7,11 +7,11 @@
<@ for(var i in <%= names.property.singular %>) { -@>
<@ if(i !== 'saved') { -@>
<div class="row list-item">
- <div class="span8">
+ <div class="span4">
<h3><@= i @></h3>
</div>
- <div class="span4">
- <h3><i class="icon-list-alt"></i><@= <%= names.property.singular %>[i] @></h3>
+ <div class="span8">
+ <h3><i class="icon-list-alt"></i><span class="<@= i @>"><@= <%= names.property.singular %>[i] @></span></h3>
</div>
</div>
<%% } -%>
View
19 templates/scaffold/views/jade/index.html.jade.ejs
@@ -2,12 +2,13 @@
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
+div#<%= names.property.plural %>-list
+ if <%= names.property.plural %>
+ each <%= names.property.singular %> in <%= names.property.plural %>
+ .row.list-item(id="<%= names.property.singular %>-" + <%= names.property.singular %>.id)
+ .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
6 templates/scaffold/views/jade/show.html.jade.ejs
@@ -6,9 +6,9 @@ h2 <%= names.constructor.singular %> Properties
each property, key in <%= names.property.singular %>
if key !== 'saved'
.row.list-item
- .span8
- h3= key
.span4
+ h3= key
+ .span8
h3
i.icon-list-alt
- = property
+ span(class=key)= property
Please sign in to comment.
Something went wrong with that request. Please try again.