Skip to content

Commit 129d8f0

Browse files
committed
Added new improvements.
1 parent 817fa51 commit 129d8f0

9 files changed

+33
-16
lines changed

builders.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var restbuilderupgrades = [];
1212
function Options(ctrl, error) {
1313
var t = this;
1414
t.controller = ctrl;
15-
t.error = error;
15+
t.error = error || new ErrorBuilder();
1616
t.response = {};
1717
}
1818

@@ -153,7 +153,7 @@ Options.prototype.redirect = function(url) {
153153
};
154154

155155
Options.prototype.audit = function(message, type) {
156-
F.audit(this, this.variables(message), type);
156+
F.audit(this, message ? this.variables(message) : '', type);
157157
};
158158

159159
Options.prototype.success = function(value) {
@@ -257,7 +257,11 @@ ErrorBuilder.prototype = {
257257

258258
ErrorBuilder.prototype.push = function(err, path, index) {
259259
var self = this;
260-
if (err > 400) {
260+
261+
if (!err)
262+
err = 401;
263+
264+
if (err > 399) {
261265
self.status = err;
262266
self.items.push({ error: F.TUtils.httpstatus(err) });
263267
} else

controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ function multipart(ctrl) {
926926

927927
function authorize(ctrl) {
928928
if (DEF.onAuthorize) {
929-
var opt = new F.TBuilders.AuthOptions(ctrl);
929+
var opt = new F.TBuilders.Options(ctrl);
930930
opt.next = opt.callback = function(user) {
931931
let auth = user ? 1 : 2;
932932
ctrl.user = user;

error.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>@{model.code}: @{model.status}</title>
4+
<title>@{model.status}</title>
55
<meta charset="utf-8" />
66
<meta name="format-detection" content="telephone=no" />
77
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />

flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ FS.init = function(directory, callback) {
8989
F.Fs.readdir(directory, function(err, files) {
9090

9191
if (err) {
92-
callback();
92+
callback && callback();
9393
return;
9494
}
9595

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ global.DEF = {};
5959
F.workers = {};
6060
F.config = CONF;
6161
F.def = DEF;
62+
F.repo = REPO;
6263
F.timeouts = [];
6364
F.errors = [];
6465
F.paused = [];
@@ -870,10 +871,11 @@ F.load = async function(types = [], callback) {
870871
F.stats.compiled = files.length;
871872
F.isloaded = true;
872873
DEBUG && F.TSourceMap.refresh();
873-
874874
process.send && process.send('total:ready');
875-
876875
callback && callback();
876+
877+
F.emit('ready');
878+
F.emit('load');
877879
};
878880

879881
F.require = function(name) {
@@ -2509,6 +2511,7 @@ process.on('message', function(msg, h) {
25092511
F.websocketclient = F.TWebSocket.createclient;
25102512
F.image = F.TImages.load;
25112513
F.sourcemap = F.TSourceMap.create;
2514+
F.tmpdir = F.Os.tmpdir();
25122515

25132516
// Needed "F"
25142517
F.TFlow = require('./flow');

routing.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ function Route(url, action, size) {
3838
index = url.length;
3939

4040
t.url2 = url.substring(0, index);
41+
42+
if (t.url2[0] === '@') {
43+
// @TODO: missing WAPI implementation
44+
// link to existing API
45+
return;
46+
}
47+
4148
t.url = exports.split(t.url2, true);
4249
url = url.substring(index + 1);
4350
t.id = t.method + '/' + t.url.join('/');
@@ -91,7 +98,10 @@ function Route(url, action, size) {
9198
t.url.splice(index, 1);
9299

93100
url = url.replace(/<\d+/g, function(text) {
94-
t.size = +text.substring(1);
101+
if (text.indexOf('s') === -1)
102+
t.size = (+(text.substring(1))) / 1024;
103+
else
104+
t.timeout = +(text.replace('s', '').substring(1));
95105
return '';
96106
});
97107

utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ SP.ROOT = function(noremap) {
21352135
return '';
21362136
});
21372137

2138-
if (!noremap && CONF.default_root)
2138+
if (!noremap && F.config.$root)
21392139
str = str.replace(REG_REMAP, $urlremap).replace(REG_AJAX, $urlajax);
21402140

21412141
return str.replace(REG_ROOT, $urlmaker);
@@ -2145,16 +2145,16 @@ function $urlremap(text) {
21452145
var plus = text[0] == ' ' ? 1 : 0;
21462146
var pos = (text[plus] === 'h' ? 6 : 5) + plus;
21472147
var url = text.substring(pos, text.length - 1);
2148-
return REG_URLEXT.test(url) ? text : ((text[plus] === 'h' ? 'href' : 'src') + '="' + CONF.default_root + (text[pos] === '/' ? text.substring(pos + 1) : text));
2148+
return REG_URLEXT.test(url) ? text : ((text[plus] === 'h' ? 'href' : 'src') + '="' + F.config.$root + (text[pos] === '/' ? text.substring(pos + 1) : text));
21492149
}
21502150

21512151
function $urlajax(text) {
2152-
return text.substring(0, text.length - 1) + CONF.default_root;
2152+
return text.substring(0, text.length - 1) + F.config.$root;
21532153
}
21542154

21552155
function $urlmaker(text) {
21562156
var c = text[4];
2157-
return CONF.default_root ? CONF.default_root : (c || '');
2157+
return F.config.$root ? F.config.$root : (c || '');
21582158
}
21592159

21602160
if (!SP.trim) {

viewengine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports.compile = function(name, content, debug = true) {
1717
content = meta.body;
1818
}
1919

20-
content = F.TMinificators.htmlremovecomments(content);
20+
content = F.TMinificators.htmlremovecomments(content).ROOT();
2121

2222
var nocompressHTML = false;
2323
var nocompressJS = false;
@@ -259,7 +259,7 @@ exports.compile = function(name, content, debug = true) {
259259
builder = builder.replace(/(\+\$EMPTY\+)/g, '+').replace(/(\$output=\$EMPTY\+)/g, '$output=').replace(/(\$output\+=\$EMPTY\+)/g, '$output+=').replace(/(\}\$output\+=\$EMPTY)/g, '}').replace(/(\{\$output\+=\$EMPTY;)/g, '{').replace(/(\+\$EMPTY\+)/g, '+').replace(/(>'\+'<)/g, '><').replace(/'\+'/g, '');
260260

261261
var fn = ('(function(self){var model=self.model;var ctrl=self.controller;var query=ctrl?.query || EMPTYOBJECT,repository=self.repository,files=ctrl?.files || EMPTYARRAY,user=ctrl?.user,session=ctrl?.session,body=ctrl?.body,language=ctrl?.language || \'\'' + (isCookie ? ',cookie=name=>ctrl?ctrl.cookie(name):\'\'' : '') + ';' + builder + ';return $output;})');
262-
262+
console.log(fn);
263263
try {
264264
fn = eval(fn);
265265
} catch (e) {

websocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ WebSocket.prototype.autodestroy = function(callback) {
804804

805805
function authorize(ctrl) {
806806
if (DEF.onAuthorize) {
807-
var opt = new F.TBuilders.AuthOptions(ctrl);
807+
var opt = new F.TBuilders.Options(ctrl);
808808
opt.$callback = function(user) {
809809
let auth = user ? 1 : 2;
810810
ctrl.user = user;

0 commit comments

Comments
 (0)