Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f06609

Browse files
committed
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
}
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>

sitemap/views/privacy.html

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

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

sitemap/views/terms.html

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

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

static-crossdomain/config-debug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
static-url : http://static.yourdomain.com
2-
static-url-js : http://static.yourdomain.com/js/
3-
static-url-css : http://static.yourdomain.com/css/
2+
static-url-script : //static.yourdomain.com/js/
3+
static-url-style : http://static.yourdomain.com/css/
44
static-url-image : http://static.yourdomain.com/img/
55
static-url-video : http://static.yourdomain.com/video/
66
static-url-font : http://static.yourdomain.com/font/

static-file-handling/controllers/default.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
exports.install = function() {
22
F.route('/');
3-
F.file('All (.jpg, .png, .gif) images', image_resize);
3+
F.file('/*.*', image_resize, ['.jpg', '.png', '.gif']);
44
};
55

6-
function image_resize(req, res, isValidation) {
7-
8-
if (isValidation)
9-
return req.extension.contains(['jpg', 'png', 'gif']);
10-
11-
// this === framework
12-
framework.image(F.path.public(req.url), function(image) {
6+
function image_resize(req, res) {
7+
res.image(F.path.public(req.url), function(image) {
138
// image === FrameworkImage
14-
image.resize('50%');
9+
image.resize('80%');
1510
image.quality(80);
1611
image.minify();
1712
});

static-version/definitions/version.js

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

static-version/public/img/logo.png

5.72 KB
Loading

static-version/versions

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// WHY?
44
// You can change a name of static file without replacement all names in all project files.
55

6-
// @{route...} or controller.route... or framework.route...
6+
// The files below must exists
7+
/js/script.js : /js/script023.js
8+
/css/style.css : /css/style001.css
79

8-
script.js : script023.js
9-
style.css : style001.css
10-
logo.png : logo003.png
11-
12-
// From CSS background(url()):
10+
// The framework creates mapping
11+
/img/logo.png --> /img/logo003.png
1312

13+
// The framework prepares CSS background(url()):
1414
/img/bg.png : /img/bg002.png

static-version/views/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="format-detection" content="telephone=no"/>
88
<meta name="viewport" content="width=1024, user-scalable=yes" />
99
<meta name="robots" content="all,follow" />
10-
@{css('style.css')}
10+
@{import('style.css')}
1111
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
1212
</head>
1313
<body>

streamer/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
require('total.js');
22

33
U.download('http://www.w3schools.com/xml/cd_catalog.xml', ['get'], null, function(err, response) {
4-
response.on('data', U.streamer('</CD>', function(value, index) {
5-
if (index === 0)
6-
value = value.substring(value.indexOf('<CD'));
4+
response.on('data', U.streamer('<CD>', '</CD>', function(value, index) {
75
var xml = value.parseXML();
86
xml.index = index;
97
console.log(xml);

views-current/controllers/default.js

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

views-current/index.js

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

views-current/public/img/01.gif

-636 Bytes
Binary file not shown.
-503 Bytes
Binary file not shown.
-672 Bytes
Binary file not shown.

views-current/views/index.html

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

views-current/views/layout.html

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

views-current/views/subpage.html

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

views-custom-helper/views/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
<br />
88
<br />
9-
@{helper('say', '<b>WARNING: XSS</b>')}
9+
@{helpers.say('<b>WARNING: XSS</b>')}
1010
<br />
1111
<br />
12-
@{say('<b>WARNING: XSS</b>', true)}
12+
@{helpers.say('<b>WARNING: XSS</b>', true)}
1313
<br />
1414
<h2>Inline helper</h2>
1515
<br />

views-javascript-compress/views/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- Look into the HTML source code in your web browser -->
88

9-
<script type="text/javascript">
9+
<script>
1010

1111
var obj = {
1212
name: 'Peter',

0 commit comments

Comments
 (0)