8000 Fix some examples. · javascriptit/examples-1@ff539e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff539e9

Browse files
committed
Fix some examples.
1 parent 6235d90 commit ff539e9

File tree

16 files changed

+161
-65
lines changed

16 files changed

+161
-65
lines changed

external-compile-sass/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
22
"name": "Example",
3-
"version": "1.0.0",
43
"main": "index.js",
4+
"version": "1.0.0",
5+
"repository": "totaljs/examples",
56
"dependencies": {
6-
"node-sass": "latest",
7-
"total.js": "latest"
7+
"total.js": "latest",
8+
"node-sass": "latest"
89
},
910
"scripts": {
1011
"test": "echo \"Error: no test specified\" && exit 1"
1112
},
13+
"keywords": [
14+
"total.js"
15+
],
1216
"author": "Peter Širka",
1317
"license": "MIT"
1418
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Example",
3+
"main": "index.js",
4+
"version": "1.0.0",
5+
"repository": "totaljs/examples",
6+
"dependencies": {
7+
"total.js": "latest",
8+
"uglify-js": "latest"
9+
},
10+
"scripts": {
11+
"test": "echo \"Error: no test specified\" && exit 1"
12+
},
13+
"keywords": [
14+
"total.js"
15+
],
16+
"author": "Peter Širka",
17+
"license": "MIT"
18+
}

mongodb/controllers/default.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
exports.install = function() {
2-
F.route('/', view_index);
2+
F.route('/', view_index);
33
};
44

55
function view_index() {
6-
var self = this;
7-
var users = DATABASE('users');
6+
var self = this;
7+
var users = DATABASE('users');
88

9-
users.find({}).limit(10).toArray(function(err, docs) {
10-
self.view('index', docs);
11-
});
9+
users.find({}).limit(10).toArray(function(err, docs) {
10+
self.view('index', docs);
11+
});
1212

13-
// or
14-
// users.find().limit(10).toArray(self.callback('index'));
13+
// or
14+
// users.find().limit(10).toArray(self.callback('index'));
1515
}

mongodb/definitions/database.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ var MC = require('mongodb').MongoClient;
22
var DB = null;
33

44
MC.connect(CONFIG('database'), function(err, db) {
5-
if (err)
6-
throw err;
7-
DB = db;
5+
if (err)
6+
throw err;
7+
DB = db;
88
});
99

1010
F.database = function(collection) {
11-
if (collection)
12-
return DB.collection(collection);
13-
return DB;
11+
return collection ? DB.collection(collection) : DB;
1412
};

mongodb/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Example",
3+
"main": "index.js",
4+
"version": "1.0.0",
5+
"repository": "totaljs/examples",
6+
"dependencies": {
7+
"total.js": "latest",
8+
"mongodb": "latest"
9+
},
10+
"scripts": {
11+
"test": "echo \"Error: no test specified\" && exit 1"
12+
},
13+
"keywords": [
14+
"total.js"
15+
],
16+
"author": "Peter Širka",
17+
"license": "MIT"
18+
}

mongodb/views/homepage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<div style="padding:20px;font-family:Arial">
44
<h1>Users</h1>
55
@{foreach m in model}
6-
<div>@{m.alias}</div>
6+
<div>@{m.alias}</div>
77
@{end}
88
</div>

mongodb/views/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<h1>Users</h1>
55

66
@{foreach m in model}
7-
<div>@{m.alias}</div>
7+
<div>@{m.alias}</div>
88
@{end}
99
</div>

mongodb/views/layout.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
@{meta}
5-
<meta charset="utf-8" />
6-
<meta http-equiv="X-UA-Compatible" content="IE=10" />
7-
<meta name="format-detection" content="telephone=no" />
8-
<meta name="viewport" content="width=1024, user-scalable=yes" />
9-
<meta name="robots" content="all,follow" />
10-
@{head}
4+
@{meta}
5+
<meta charset="utf-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=10" />
7+
<meta name="format-detection" content="telephone=no" />
8+
<meta name="viewport" content="width=1024, user-scalable=yes" />
9+
<meta name="robots" content="all,follow" />
10+
@{head}
1111
</head>
1212
<body>
13-
@{body}
13+
@{body}
1414
</body>
1515
</html>

mongoose/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Example",
3+
"main": "index.js",
4+
"version": "1.0.0",
5+
"repository": "totaljs/examples",
6+
"dependencies": {
7+
"total.js": "latest",
8+
"mongoose": "latest"
9+
},
10+
"scripts": {
11+
"test": "echo \"Error: no test specified\" && exit 1"
12+
},
13+
"keywords": [
14+
"total.js"
15+
],
16+
"author": "Peter Širka",
17+
"license": "MIT"
18+
}

mysql/controllers/default.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
exports.install = function() {
2-
F.route('/', view_index);
2+
F.route('/', view_index);
33
};
44

55
function view_index() {
66

7-
var self = this;
7+
var self = this;
88

9-
// definitions/mysql.js
10-
// create a DB connection
11-
DATABASE(function(err, connection){
9+
// definitions/mysql.js
10+
// create a DB connection
11+
DB(function(err, connection){
1212

13-
if(err != null) {
14-
self.throw500(err);
15-
return;
16-
}
13+
if(err != null) {
14+
self.throw500(err);
15+
return;
16+
}
1717

18-
// Table schema = { Id: Number, Age: Number, Name: String };
19-
connection.query('SELECT * FROM users', function(err, rows) {
18+
// Table schema = { Id: Number, Age: Number, Name: String };
19+
connection.query('SELECT * FROM users', function(err, rows) {
2020

21-
// Close connection
22-
connection.release();
21+
// Close connection
22+
connection.release();
2323

24-
if (err != null) {
25-
self.view500(err);
26-
return;
27-
}
24+
if (err != null) {
25+
self.view500(err);
26+
return;
27+
}
2828

29-
// Shows the result on a console window
30-
console.log(rows);
29+
// Shows the result on a console window
30+
console.log(rows);
3131

32-
// Send rows as the model into the view
33-
self.view('index', rows);
34-
});
35-
36-
});
32+
// Send rows as the model into the view
33+
self.view('index', rows);
34+
});
3735

36+
});
3837
}

0 commit comments

Comments
 (0)
0