8000 Merge pull request #7 from gnetsys/master · markandrewj/angular-examples@6dad3a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6dad3a1

Browse files
committed
Merge pull request totaljs#7 from gnetsys/master
routing-advanced
2 parents 30a6125 + a3c8753 commit 6dad3a1

File tree

14 files changed

+154
-0
lines changed

14 files changed

+154
-0
lines changed

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# Compiled binary addons (http://nodejs.org/api/addons.html)
20+
build/Release
21+
22+
# Dependency directory
23+
# Commenting this out is preferred by some people, see
24+
# https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25+
node_modules
26+
27+
# Users Environment Variables
28+
.lock-wscript
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
exports.install = function (framework) {
2+
3+
//Sets the controllers route
4+
framework.route('/admin/articles', view_articles);
5+
6+
};
7+
8+
function view_articles() {
9+
10+
var self = this;
11+
self.layout('_adminlayout');
12+
self.view('articles');
13+
14+
}
15+
16+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
exports.install = function (framework) {
2+
3+
//Sets the controllers route
4+
framework.route('/admin/categories', view_categories);
5+
6+
};
7+
8+
function view_categories() {
9+
10+
var self = this;
11+
12+
self.layout('_adminlayout');
13+
self.view('categories');
14+
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
exports.install = function(framework) {
2+
3+
//Sets the controllers route
4+
framework.route('/admin', view_dashboard);
5+
6+
};
7+
8+
function view_dashboard() {
9+
10+
var self = this;
11+
self.layout('_adminlayout');
12+
self.view('dashboard');
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var site = require('./site/index');
2+
3+
4+
/*
5+
or
6+
7+
var site = [
8+
require('./site/A'),
9+
require('./site/B'),
10+
require('./site/C'),
11+
require('./site/D'),
12+
]
13+
14+
15+
*/
16+
exports.install = function (framework) {
17+
18+
//Sets the controllers route
19+
framework.route('/', site.index);
20+
21+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
exports.index = function view_index() {
2+
3+
var self = this;
4+
5+
var model = {
6+
pagetitle: 'Total.js',
7+
}
8+
9+
self.layout('_sitelayout');
10+
self.view('index', model);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
framework.on('controller', function(controller, name) {
2+
3+
// Manage controller default directory for views // first method
4+
if (name.indexOf('admin/') !== -1)
5+
controller.currentView('/admin/');
6+
7+
// Manage controller site-folder/file-name.js associated views // with site.route
8+
if (name.indexOf('/site.route') !== -1)
9+
controller.currentView('/site/');
10+
11+
});

routing-advanced/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var framework = require('total.js');
2+
var http = require('http');
3+
4+
var debug = true;
5+
6+
framework.run(http, debug, 8009);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Total.js - advanced routing</title>
5+
</head>
6+
<body>
7+
8+
@{body}
9+
10+
</body>
11+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Total.js - advanced routing</title>
5+
</head>
6+
<body>
7+
8+
@{body}
9+
10+
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)
0