Skip to content

Commit

Permalink
new examples
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed May 28, 2014
1 parent dc500ca commit 8279a9e
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 3 deletions.
6 changes: 6 additions & 0 deletions controller-mail/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Mail settings
mail.smtp : smtp.gmail.com
mail.smtp.options : {"secure":true,"port":465,"user":"YOUR_EMAIL_GMAIL","password":"YOUR_PASSWORD_GMAIL","timeout":10000}
mail.address.from : [email protected]
mail.address.reply : [email protected]
mail.address.bcc :
19 changes: 19 additions & 0 deletions controller-mail/controllers/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports.install = function(framework) {
framework.route('/', view_homepage);
framework.route('/mail/', redirect_mail);
};

function view_homepage() {
var self = this;
self.view('homepage');
}

function redirect_mail() {

var self = this;

// This function automatically reads view: email.html
self.mail('[email protected]', 'Test e-mail', '~email', { name: 'MODEL NAME' });
self.redirect('/?success=1');

}
File renamed without changes.
2 changes: 2 additions & 0 deletions controller-mail/views/email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>@{model.name}</h1>
<div>This is message.</div>
8 changes: 8 additions & 0 deletions controller-mail/views/homepage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@{layout('')}

@{if get.success}
<div style="background-color:#E0E0E0;padding:10px">E-mail was sent.</div>
<br />
@{endif}

<a href="/mail/">Send e-mail</a>
File renamed without changes.
5 changes: 5 additions & 0 deletions views-place-sections/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var framework = require('total.js');
var http = require('http');
var debug = true;

framework.run(http, debug);
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
<meta name="format-detection" content="telephone=no"/>
<meta name="viewport" content="width=1024, user-scalable=yes" />
<meta name="robots" content="all,follow" />

@{head}

</head>
<body>

<!-- RENDER HEADER -->
@{section('header')}

@{place('header')}

<div>@{body}</div>

<!-- RENDER CONTENT -->
@{place('scripts')}

<!-- RENDER SECTION -->
@{section('footer')}

</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!-- IMPORTANT: -->
<!-- A place can be modified in the controller. This is the different between a place and section. -->

@{section header}
<div>SECTION: header</div>
@{end}

@{place('scripts', '<script>alert("FROM VIEW");</script>')}

Expand All @@ -8,4 +14,8 @@
Welcome!
</div>

@{place('header', '<h1>PLACE HOLDER</h1>')}
@{place('header', '<h1>PLACE HOLDER</h1>')}

@{section footer}
<div>SECTION: footer</div>
@{end}
3 changes: 3 additions & 0 deletions views/views/_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
<div style="height:20px"><a href="/users/">USERS &rarr;</a></div>
<div style="height:20px"><a href="/users/admin/">ADMIN &rarr;</a></div>
<div style="height:20px"><a href="/products/">PRODUCTS &rarr;</a></div>

@{section('footer')}

</body>
</html>
7 changes: 6 additions & 1 deletion views/views/admin.html
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<h1>~ADMIN</h1>
<h1>~ADMIN</h1>

@{section footer}
<br />
<div style="background-color:#E0E0E0;padding:10px">ADMINISTRATOR FOOTER</div>
@{end}
5 changes: 5 additions & 0 deletions views/views/homepage.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@{section footer}
<br />
<div style="background-color:#E0E0E0;padding:10px">THIS IS FOOTER IN LAYOUT</div>
@{end}

@{helper address(city, street)}
<address>
@{city}<br />
Expand Down

0 comments on commit 8279a9e

Please sign in to comment.