forked from totaljs/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialize.js
More file actions
80 lines (63 loc) · 1.8 KB
/
initialize.js
File metadata and controls
80 lines (63 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var assert = require('assert');
F.register(F.path.root('default.resource'));
framework.onMeta = function(a,b) {
return a + b;
};
framework.onSettings = function(a,b) {
return a + b;
};
framework.onPictureDimension = function(dimension) {
switch(dimension) {
case 'small':
return { width: 128, height: 96 };
case 'middle':
return { width: 320, height: 240 };
}
return null;
};
framework.on('load', function() {
var self = this;
self.log = function(value) {
assert.ok(value === 'test', 'framework: log()');
return self;
};
self.helpers.property = 'OK';
self.helpers.fn = function(a) {
return a;
};
self.global.header = 0;
self.global.middleware = 0;
self.global.timeout = 0;
self.global.file = 0;
self.global.all = 0;
/*
REMOVED
self.middleware(function(next) {
self.global.header++;
next();
});
*/
self.middleware('each', function(req, res, next) {
self.global.all++;
next();
});
self.middleware('middleware', function(req, res, next) {
self.global.middleware++;
next();
});
self.middleware('file', function(req, res, next) {
self.global.file++;
assert.ok(req.isStaticFile === true, 'file middleware problem');
next();
});
self.use('each');
});
framework.onPictureUrl = function(dimension, id, width, height, alt) {
return dimension + '-' + id + '.jpg';
};
framework.onValidate = function(name, value) {
return name + value;
};
// Is read from http://www.totaljs.com/framework/include.js
//framework.precompile('precompile.layout', 'http://www.totaljs.com/framework/_layout.html');
//framework.precompile('precompile.homepage', 'http://www.totaljs.com/framework/homepage.html');