Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9f06609

Browse files
New changes.
1 parent f3334e6 commit 9f06609

File tree

33 files changed

+67
-175
lines changed

33 files changed

+67
-175
lines changed

‎paypal/controllers/default.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@ exports.install = function() {
99

1010
function redirect_payment() {
1111
var self = this;
12-
var payment = paypal.init(CONFIG('paypal-user'), CONFIG('paypal-password'), CONFIG('paypal-signature'), CONFIG('paypal-return'), CONFIG('paypal-cancel'), F.isDebug);
12+
var payment = paypal.init(CONFIG('paypal-user'), CONFIG('paypal-password'), CONFIG('paypal-signature'), CONFIG('paypal-return'), CONFIG('paypal-cancel'), DEBUG);
1313

1414
var orderNumber = 100;
1515
var price = 12.23;
1616

1717
payment.pay(orderNumber, price, 'support', 'EUR', function(err, url) {
18-
19-
if (err) {
18+
if (err)
2019
self.throw500(err);
21-
return;
22-
}
23-
24-
self.redirect(url);
20+
else
21+
self.redirect(url);
2522
});
2623
};
2724

2825
function view_payment() {
2926
var self = this;
30-
var payment = paypal.init(CONFIG('paypal-user'), CONFIG('paypal-password'), CONFIG('paypal-signature'), CONFIG('paypal-return'), CONFIG('paypal-cancel'), F.isDebug);
27+
var payment = paypal.init(CONFIG('paypal-user'), CONFIG('paypal-password'), CONFIG('paypal-signature'), CONFIG('paypal-return'), CONFIG('paypal-cancel'), DEBUG);
3128

3229
payment.detail(self, function(err, data) {
3330

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
F.onAuthorization = function(req, res, flags, callback) {
1+
F.onAuthorize = function(req, res, flags, callback) {
22

33
// http://localhost:8000/?user=admin
44
// or
55
// http://localhost:8000/?user=moderator
66

7-
var get = req.query;
8-
9-
if (get.user === 'admin' || get.user === 'moderator') {
10-
11-
// I add role flag
12-
flags.push('@' + get.user);
7+
if (req.query.user === 'admin' || req.query.user === 'moderator') {
8+
flags.push('@' + req.query.user);
139
callback(true);
14-
}
15-
else
10+
} else
1611
callback(false);
1712
};
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
var Fs = require('fs');
2+
13
exports.install = function() {
24
F.route('/', view_index);
35
};
46

57
function *view_index() {
68
var self = this;
7-
var users = yield sync(DATABASE('users').$$all(n => n.age > 28 && n.age < 40))();
9+
var users = yield sync(Fs.readFile)(F.path.databases('users.json'));
10+
11+
users = JSON.parse(users.toString('utf8'));
12+
813
self.view(users);
914
}

‎routing-generators/databases/users.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"name":"Peter","age":30},{"name":"Lucia","age":33},{"name":"Jozef","age":28},{"name":"Alojz","age":92}]

‎routing-generators/databases/users.nosql

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎routing-subdomain/controllers/default.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ exports.install = function() {
2020

2121
// hidden for subdomain
2222
F.route('[]/contact/', contact);
23+
24+
// wildcard subdomain routing
25+
F.route('[api*]/', api);
2326
};
2427

2528
function subdomain() {
@@ -36,4 +39,8 @@ function contact() {
3639

3740
function root() {
3841
this.plain('root');
42+
}
43+
44+
function api() {
45+
this.plain('api');
3946
}

‎routing/controllers/default.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,22 @@ exports.install = function() {
1313

1414
// route: all txt files
1515
// Try: http://127.0.0.4/test.txt
16-
F.file('All *.txt', static_txt);
16+
F.file('*.txt', static_txt);
1717

1818
// route: all jpg files
1919
// all images will resized about 50%
2020
// Try: http://127.0.0.4/header.jpg
21-
F.file('All *.jpg', static_jpg);
21+
F.file('*.jpg', static_jpg);
2222
}
2323

24-
function static_txt(req, res, isValidation) {
25-
26-
if (isValidation)
27-
return req.extension === 'txt';
28-
29-
// generate response
24+
function static_txt(req, res) {
25+
// responds
3026
// this === framework
31-
// Documentation: http://docs.totaljs.com/Framework/#framework.responsContent
3227
res.content(200, 'Server time: ' + new Date().toString(), 'text/plain');
3328
}
3429

35-
function static_jpg(req, res, isValidation) {
36-
37-
if (isValidation)
38-
return req.extension === 'jpg';
39-
40-
// generate response
30+
function static_jpg(req, res) {
31+
// responds
4132
// this === framework
4233
res.image(F.path.public(req.url), function (image) {
4334
// image === FrameworkImage
@@ -51,7 +42,7 @@ function view_homepage(category) {
5142

5243
category = category || '';
5344

54-
if (category.length>0)
45+
if (category.length)
5546
category = ' -> ' + category;
5647

5748
this.plain('homepage{0}'.format(category));
@@ -66,10 +57,10 @@ function view_products(category, subcategory) {
6657
category = category || '';
6758
subcategory = subcategory || '';
6859

69-
if (category.length>0)
60+
if (category.length)
7061
category = ' -> ' + category;
7162

72-
if (subcategory.length>0)
63+
if (subcategory.length)
7364
subcategory = ' -> ' + subcategory;
7465

7566
this.plain('products{0}{1}'.format(category, subcategory));

‎sitemap/views/contact.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@{sitemap('#contact')}
1+
@{sitemap('contact')}
22

33
<h1>@{title}</h1>

‎sitemap/views/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@{sitemap('#homepage')}
1+
@{sitemap('homepage')}
22

33
<h1>@{title}</h1>

‎sitemap/views/layout.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
<div style="padding:20px 0;border-bottom:1px solid #E0E0E0;">
2727
Breadcrumb:
28-
@{foreach m in sitemap()}
29-
<a href="@{m.url}">@{m.name}</a>
30-
@{if !m.last}
31-
&nbsp; &gt; &nbsp;
32-
@{fi}
33-
@{end}
28+
@{foreach m in sitemap()}
29+
<a href="@{m.url}">@{m.name}</a>
30+
@{if !m.last}
31+
&nbsp; &gt; &nbsp;
32+
@{fi}
33+
@{end}
3434
</div>
3535

3636
<div>@{body}</div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /