total5 0.0.1-9 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.js +18 -10
- package/bin/flow5 +142 -0
- package/bin/total5 +166 -905
- package/builders.js +90 -35
- package/changelog.txt +3 -1
- package/cluster.js +1 -1
- package/cms.js +185 -51
- package/controller.js +233 -70
- package/cron.js +1 -1
- package/debug.js +12 -5
- package/edit.js +26 -33
- package/filestorage.js +38 -17
- package/flow-flowstream.js +199 -68
- package/flow.js +16 -10
- package/flowstream.js +4 -3
- package/global.js +84 -1
- package/htmlparser.js +41 -29
- package/http.js +3 -1
- package/image.js +4 -0
- package/images.js +1 -1
- package/index.js +246 -117
- package/jsonschema.js +21 -17
- package/macros.js +222 -0
- package/mail.js +11 -27
- package/markdown.js +21 -11
- package/minificators.js +1 -1
- package/nosql-querybuilder.js +4 -0
- package/nosql.js +8 -0
- package/openclient.js +1 -1
- package/package.json +4 -3
- package/pause.html +1 -1
- package/release.js +1 -1
- package/routing.js +118 -35
- package/sourcemap.js +6 -3
- package/test.js +9 -2
- package/tms.js +11 -14
- package/uibuilder.js +59 -23
- package/utils.js +147 -102
- package/viewengine.js +19 -8
- package/websocket.js +10 -6
- package/503.html +0 -65
- package/CONTRIBUTING.md +0 -55
- package/helpers/index.js +0 -32
- package/templates.json +0 -74
- package/tests/bundles/index.js +0 -25
- package/tests/cron.js +0 -0
- package/tests/htmlparser.js +0 -0
- package/tests/minifactors.js +0 -17
- package/tests/nosql.js +0 -18
- package/tests/proxy/index.js +0 -21
- package/tests/routing/index.js +0 -27
- package/tests/schemas.js +0 -17
- package/tests/server/index.js +0 -24
- package/tests/staticfiles/index.js +0 -24
- package/tests/utils.js +0 -17
- package/tmsclient.js +0 -125
- package/todo.txt +0 -11
- package/tools/beta.sh +0 -6
- package/tools/release.sh +0 -6
package/builders.js
CHANGED
|
@@ -24,7 +24,11 @@ Options.prototype = {
|
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
get websocket() {
|
|
27
|
-
return this.controller.
|
|
27
|
+
return this.controller && this.controller.iswebsocket ? this.controller : null;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
get sessionid() {
|
|
31
|
+
return this.controller ? this.controller.sessionid : null;
|
|
28
32
|
},
|
|
29
33
|
|
|
30
34
|
get value() {
|
|
@@ -52,15 +56,15 @@ Options.prototype = {
|
|
|
52
56
|
},
|
|
53
57
|
|
|
54
58
|
get path() {
|
|
55
|
-
return
|
|
59
|
+
return this.controller ? this.controller.pathname : EMPTYARRAY;
|
|
56
60
|
},
|
|
57
61
|
|
|
58
62
|
get split() {
|
|
59
|
-
return
|
|
63
|
+
return this.controller ? this.controller.split : EMPTYARRAY;
|
|
60
64
|
},
|
|
61
65
|
|
|
62
66
|
get split2() {
|
|
63
|
-
return
|
|
67
|
+
return this.controller ? this.controller.split2 : EMPTYARRAY;
|
|
64
68
|
},
|
|
65
69
|
|
|
66
70
|
get language() {
|
|
@@ -92,6 +96,17 @@ Options.prototype = {
|
|
|
92
96
|
}
|
|
93
97
|
};
|
|
94
98
|
|
|
99
|
+
Options.prototype.unauthorized = function() {
|
|
100
|
+
var args = [this];
|
|
101
|
+
for (let i = 0; i < arguments.length; i++)
|
|
102
|
+
args.push(arguments[i]);
|
|
103
|
+
return F.unauthorized.apply(global, args);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
Options.prototype.transform = function(name, value, callback) {
|
|
107
|
+
return F.transform(name, value, callback, this.controller);
|
|
108
|
+
};
|
|
109
|
+
|
|
95
110
|
Options.prototype.action = function(schema, payload) {
|
|
96
111
|
return F.action(schema, payload, this.controller);
|
|
97
112
|
};
|
|
@@ -149,8 +164,14 @@ Options.prototype.cancel = function() {
|
|
|
149
164
|
};
|
|
150
165
|
|
|
151
166
|
Options.prototype.redirect = function(url) {
|
|
152
|
-
this
|
|
153
|
-
|
|
167
|
+
var self = this;
|
|
168
|
+
self.$callback = null;
|
|
169
|
+
if (self.controller) {
|
|
170
|
+
self.controller.redirect(url);
|
|
171
|
+
self.controller.destroyed = true;
|
|
172
|
+
}
|
|
173
|
+
self.cancel();
|
|
174
|
+
return self;
|
|
154
175
|
};
|
|
155
176
|
|
|
156
177
|
Options.prototype.audit = function(message, type) {
|
|
@@ -160,11 +181,21 @@ Options.prototype.audit = function(message, type) {
|
|
|
160
181
|
Options.prototype.success = function(value) {
|
|
161
182
|
var self = this;
|
|
162
183
|
if (self.TYPE === 'auth')
|
|
163
|
-
self.callback(value);
|
|
184
|
+
self.callback(value || EMPTYOBJECT);
|
|
164
185
|
else
|
|
165
186
|
self.callback(DEF.onSuccess(value));
|
|
166
187
|
};
|
|
167
188
|
|
|
189
|
+
Options.prototype.successful = function(callback) {
|
|
190
|
+
var self = this;
|
|
191
|
+
return function(err, a, b, c) {
|
|
192
|
+
if (err)
|
|
193
|
+
self.invalid(err);
|
|
194
|
+
else
|
|
195
|
+
callback.call(self, a, b, c);
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
|
|
168
199
|
Options.prototype.callback = function(value) {
|
|
169
200
|
|
|
170
201
|
var self = this;
|
|
@@ -183,8 +214,8 @@ Options.prototype.done = function(arg) {
|
|
|
183
214
|
var self = this;
|
|
184
215
|
return function(err, response) {
|
|
185
216
|
if (err) {
|
|
186
|
-
|
|
187
|
-
self.callback();
|
|
217
|
+
self.error.push(err);
|
|
218
|
+
self.callback(null);
|
|
188
219
|
} else {
|
|
189
220
|
if (self.TYPE === 'auth')
|
|
190
221
|
self.callback(arg === true ? response : arg);
|
|
@@ -194,10 +225,19 @@ Options.prototype.done = function(arg) {
|
|
|
194
225
|
};
|
|
195
226
|
};
|
|
196
227
|
|
|
228
|
+
Options.prototype.output = function(name) {
|
|
229
|
+
// @name {String} json, html, xml, text, redirect, binary, jsonstring, empty, file
|
|
230
|
+
var self = this;
|
|
231
|
+
if (self.controller)
|
|
232
|
+
self.controller.response.output = name;
|
|
233
|
+
return self;
|
|
234
|
+
};
|
|
235
|
+
|
|
197
236
|
Options.prototype.invalid = function(error, path, index) {
|
|
198
237
|
var self = this;
|
|
199
238
|
self.error.push(error, path, index);
|
|
200
239
|
self.$callback(true);
|
|
240
|
+
return self;
|
|
201
241
|
};
|
|
202
242
|
|
|
203
243
|
Options.prototype.cookie = function(name, value, expire, options) {
|
|
@@ -471,7 +511,7 @@ RESTP.promise = function($) {
|
|
|
471
511
|
if ($ && $.invalid)
|
|
472
512
|
$.invalid(err);
|
|
473
513
|
else
|
|
474
|
-
reject(
|
|
514
|
+
reject(F.TUtils.toError(err));
|
|
475
515
|
} else
|
|
476
516
|
resolve(response);
|
|
477
517
|
});
|
|
@@ -718,6 +758,9 @@ RESTP.callback = function(fn) {
|
|
|
718
758
|
|
|
719
759
|
var self = this;
|
|
720
760
|
|
|
761
|
+
if (fn instanceof Options)
|
|
762
|
+
fn = fn.callback();
|
|
763
|
+
|
|
721
764
|
if (typeof(fn) === 'function') {
|
|
722
765
|
setImmediate(execrestbuilder, self, fn);
|
|
723
766
|
return self;
|
|
@@ -907,10 +950,13 @@ function restbuilder_callback(err, response) {
|
|
|
907
950
|
break;
|
|
908
951
|
case 'application/json':
|
|
909
952
|
case 'text/json':
|
|
953
|
+
case 'text/plain':
|
|
910
954
|
output.value = response.body ? response.body.parseJSON(true) : null;
|
|
911
955
|
break;
|
|
912
956
|
default:
|
|
913
|
-
|
|
957
|
+
if (response.body instanceof Buffer && response.body.length)
|
|
958
|
+
response.body = response.body.toString('utf8');
|
|
959
|
+
output.value = response.body ? (response.body.isJSON() ? response.body.parseJSON(true) : response.body) : null;
|
|
914
960
|
break;
|
|
915
961
|
}
|
|
916
962
|
}
|
|
@@ -1130,10 +1176,7 @@ exports.newaction = function(name, obj) {
|
|
|
1130
1176
|
if (obj.route) {
|
|
1131
1177
|
if (obj.route.indexOf('-->') === -1)
|
|
1132
1178
|
obj.route = obj.route + ' ' + (obj.input ? '+' : '-') + obj.$url + ' --> ' + name;
|
|
1133
|
-
|
|
1134
|
-
if (obj.encrypt)
|
|
1135
|
-
flags = '@encrypt';
|
|
1136
|
-
obj.route = F.route(obj.route, flags || []);
|
|
1179
|
+
obj.route = F.route(obj.route + (obj.encrypt ? ' @encrypt' : ''));
|
|
1137
1180
|
}
|
|
1138
1181
|
|
|
1139
1182
|
if (obj.permissions && typeof(obj.permissions) === 'string')
|
|
@@ -1244,6 +1287,9 @@ ActionCaller.prototype.exec = function() {
|
|
|
1244
1287
|
} else {
|
|
1245
1288
|
$.response[$.id] = response;
|
|
1246
1289
|
meta.response && self.finish && self.finish(response);
|
|
1290
|
+
var key = '@' + $.id;
|
|
1291
|
+
if (F.$events[key])
|
|
1292
|
+
F.emit(key, $, response);
|
|
1247
1293
|
self.exec();
|
|
1248
1294
|
}
|
|
1249
1295
|
};
|
|
@@ -1315,8 +1361,10 @@ ActionCaller.prototype.exec = function() {
|
|
|
1315
1361
|
ActionCaller.prototype.finish = function(value) {
|
|
1316
1362
|
var self = this;
|
|
1317
1363
|
self.finish = null;
|
|
1318
|
-
self.options.callback
|
|
1319
|
-
|
|
1364
|
+
if (self.options.callback) {
|
|
1365
|
+
self.options.callback(self.error.length ? self.error : null, value === undefined ? self.$.response : value);
|
|
1366
|
+
self.options.callback = null;
|
|
1367
|
+
}
|
|
1320
1368
|
};
|
|
1321
1369
|
|
|
1322
1370
|
ActionCaller.prototype.cancel = function() {
|
|
@@ -1387,20 +1435,18 @@ ActionCaller.prototype.promise = function($) {
|
|
|
1387
1435
|
|
|
1388
1436
|
ActionCaller.prototype.autorespond = function() {
|
|
1389
1437
|
var self = this;
|
|
1390
|
-
self.options.callback = function(err, response) {
|
|
1438
|
+
self.options.callback = function(err, response, a, b) {
|
|
1391
1439
|
if (err)
|
|
1392
1440
|
self.controller.invalid(err);
|
|
1393
1441
|
else
|
|
1394
|
-
self.controller.
|
|
1442
|
+
self.controller.respond(response, a, b);
|
|
1395
1443
|
};
|
|
1396
1444
|
return self;
|
|
1397
1445
|
};
|
|
1398
1446
|
|
|
1399
1447
|
ActionCaller.prototype.controller = function(ctrl) {
|
|
1400
|
-
|
|
1401
1448
|
if (ctrl instanceof Options)
|
|
1402
1449
|
ctrl = ctrl.controller;
|
|
1403
|
-
|
|
1404
1450
|
this.options.controller = ctrl;
|
|
1405
1451
|
return this;
|
|
1406
1452
|
};
|
|
@@ -1440,10 +1486,8 @@ exports.newschema = function(name, callback) {
|
|
|
1440
1486
|
if (name[0] === '@')
|
|
1441
1487
|
name = name.substring(1);
|
|
1442
1488
|
|
|
1443
|
-
if (typeof(callback) === 'string')
|
|
1444
|
-
F.jsonschemas[name] = F.TUtils.jsonschema(callback, true);
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1489
|
+
if (typeof(callback) === 'string')
|
|
1490
|
+
return F.jsonschemas[name] = F.TUtils.jsonschema(callback, true);
|
|
1447
1491
|
|
|
1448
1492
|
var $ = {};
|
|
1449
1493
|
$.name = name;
|
|
@@ -1451,6 +1495,7 @@ exports.newschema = function(name, callback) {
|
|
|
1451
1495
|
$.action = function(aname, meta) {
|
|
1452
1496
|
return $.actions[aname] = F.newaction(name + '/' + aname, meta);
|
|
1453
1497
|
};
|
|
1498
|
+
|
|
1454
1499
|
callback($);
|
|
1455
1500
|
};
|
|
1456
1501
|
|
|
@@ -1491,16 +1536,22 @@ exports.builtinauth = function(opt) {
|
|
|
1491
1536
|
if (typeof(id) === 'object')
|
|
1492
1537
|
id = $.sessionid;
|
|
1493
1538
|
|
|
1539
|
+
var ctrl = $.controller;
|
|
1540
|
+
|
|
1541
|
+
if (ctrl && !id)
|
|
1542
|
+
id = ctrl.sessionid;
|
|
1543
|
+
|
|
1494
1544
|
if (id) {
|
|
1495
1545
|
for (var key in opt.sessions) {
|
|
1496
1546
|
var session = opt.sessions[key];
|
|
1497
1547
|
if (session.sessionid === id) {
|
|
1498
1548
|
delete opt.sessions[key];
|
|
1499
1549
|
opt.onlogout && opt.onlogout(session);
|
|
1500
|
-
opt.cookie &&
|
|
1550
|
+
opt.cookie && ctrl && !ctrl.parent && ctrl.cookie && ctrl.cookie(opt.cookie, '', '-1 year', opt.options);
|
|
1501
1551
|
return true;
|
|
1502
1552
|
}
|
|
1503
1553
|
}
|
|
1554
|
+
opt.onremove && opt.onremove(id);
|
|
1504
1555
|
}
|
|
1505
1556
|
};
|
|
1506
1557
|
|
|
@@ -1536,7 +1587,9 @@ exports.builtinauth = function(opt) {
|
|
|
1536
1587
|
if (!options)
|
|
1537
1588
|
options = opt.options;
|
|
1538
1589
|
var ctrl = $.controller ? $.controller : $;
|
|
1539
|
-
|
|
1590
|
+
var token = opt.sign(sessionid, userid);
|
|
1591
|
+
ctrl.cookie && !ctrl.parent && $.cookie(opt.cookie, token, expiration, options);
|
|
1592
|
+
return token;
|
|
1540
1593
|
};
|
|
1541
1594
|
|
|
1542
1595
|
if (!opt.expire)
|
|
@@ -1560,10 +1613,12 @@ exports.builtinauth = function(opt) {
|
|
|
1560
1613
|
if (!sessionid && opt.header)
|
|
1561
1614
|
sessionid = $.controller.headers[opt.header];
|
|
1562
1615
|
|
|
1616
|
+
var localize = opt.locale || opt.localize;
|
|
1617
|
+
|
|
1563
1618
|
if (!sessionid) {
|
|
1564
1619
|
|
|
1565
|
-
if (
|
|
1566
|
-
$.controller.language =
|
|
1620
|
+
if (localize)
|
|
1621
|
+
$.controller.language = localize(null, $.controller);
|
|
1567
1622
|
|
|
1568
1623
|
$.invalid();
|
|
1569
1624
|
return;
|
|
@@ -1584,14 +1639,14 @@ exports.builtinauth = function(opt) {
|
|
|
1584
1639
|
$.controller.session = session;
|
|
1585
1640
|
$.controller.sessionid = session.sessionid;
|
|
1586
1641
|
if (!opt.onsession || !opt.onsession(session, $)) {
|
|
1587
|
-
if (
|
|
1588
|
-
$.controller.language =
|
|
1642
|
+
if (localize)
|
|
1643
|
+
$.controller.language = localize(session.data, $.controller);
|
|
1589
1644
|
$.success(session.data);
|
|
1590
1645
|
}
|
|
1591
1646
|
} else {
|
|
1592
1647
|
|
|
1593
|
-
if (
|
|
1594
|
-
$.controller.language =
|
|
1648
|
+
if (localize)
|
|
1649
|
+
$.controller.language = localize(null, $.controller);
|
|
1595
1650
|
|
|
1596
1651
|
$.invalid();
|
|
1597
1652
|
sessionid = null;
|
|
@@ -1639,8 +1694,8 @@ exports.builtinauth = function(opt) {
|
|
|
1639
1694
|
$.controller.session = opt.sessions[meta.sessionid] = { sessionid: meta.sessionid, userid: meta.userid, data: data, ua: $.controller.ua, expire: NOW.add(opt.expire) };
|
|
1640
1695
|
$.controller.sessionid = meta.sessionid;
|
|
1641
1696
|
|
|
1642
|
-
if (
|
|
1643
|
-
$.controller.language =
|
|
1697
|
+
if (localize)
|
|
1698
|
+
$.controller.language = localize(data, $.controller);
|
|
1644
1699
|
|
|
1645
1700
|
if (!opt.onsession || !opt.onsession($.controller.session, $, true))
|
|
1646
1701
|
$.success(data);
|
package/changelog.txt
CHANGED
package/cluster.js
CHANGED
package/cms.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
-
const SKIP_CLASSES = { CMS_hidden: 1, CMS_mv: 1, CMS_mh: 1, CMS_expression: 1, CMS_multiple: 1 };
|
|
7
|
+
const SKIP_CLASSES = { CMS_hidden: 1, CMS_mv: 1, CMS_mh: 1, CMS_expression: 1, CMS_multiple: 1, CMS_keyword: 1, CMS_monospace: 1 };
|
|
8
8
|
const VERSION = 1;
|
|
9
9
|
|
|
10
10
|
function clean(html) {
|
|
@@ -22,12 +22,20 @@ function expressions_multiple(body) {
|
|
|
22
22
|
while (true) {
|
|
23
23
|
|
|
24
24
|
index = body.indexOf('CMS_multiple', index + 12);
|
|
25
|
-
|
|
26
25
|
if (index === -1)
|
|
27
26
|
break;
|
|
28
27
|
|
|
29
|
-
var b = body
|
|
30
|
-
|
|
28
|
+
var b = findstart(body, index);
|
|
29
|
+
if (b === -1)
|
|
30
|
+
break;
|
|
31
|
+
|
|
32
|
+
var end = body.indexOf(' ', b);
|
|
33
|
+
if (end === -1) {
|
|
34
|
+
index += 13;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var tag = body.substring(b + 1, end);
|
|
31
39
|
|
|
32
40
|
var e = body.indexOf('</' + tag + '>', index);
|
|
33
41
|
var size = e + 3 + tag.length;
|
|
@@ -53,6 +61,23 @@ function expressions_multiple(body) {
|
|
|
53
61
|
return arr;
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
function findstart(body, index) {
|
|
65
|
+
|
|
66
|
+
var notallowed = [';', '.', '>', ':', '\n', '\r', '\t'];
|
|
67
|
+
|
|
68
|
+
for (let i = index; i > -1; i--) {
|
|
69
|
+
|
|
70
|
+
let c = body[i];
|
|
71
|
+
if (c === '<')
|
|
72
|
+
return i;
|
|
73
|
+
|
|
74
|
+
if (notallowed.includes(c))
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return -1;
|
|
79
|
+
}
|
|
80
|
+
|
|
56
81
|
function expressions(body) {
|
|
57
82
|
|
|
58
83
|
var index = 0;
|
|
@@ -65,9 +90,17 @@ function expressions(body) {
|
|
|
65
90
|
if (index === -1)
|
|
66
91
|
break;
|
|
67
92
|
|
|
68
|
-
var b = body
|
|
69
|
-
|
|
93
|
+
var b = findstart(body, index);
|
|
94
|
+
if (b === -1)
|
|
95
|
+
break;
|
|
96
|
+
|
|
97
|
+
var end = body.indexOf(' ', b);
|
|
98
|
+
if (end === -1) {
|
|
99
|
+
index += 15;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
70
102
|
|
|
103
|
+
var tag = body.substring(b + 1, end);
|
|
71
104
|
var e = body.indexOf('</' + tag + '>', index);
|
|
72
105
|
var size = e + 3 + tag.length;
|
|
73
106
|
var obj = {};
|
|
@@ -90,12 +123,27 @@ function trash(body) {
|
|
|
90
123
|
|
|
91
124
|
index = body.indexOf(t, index + t.length);
|
|
92
125
|
|
|
93
|
-
if (index === -1)
|
|
126
|
+
if (index === -1)
|
|
94
127
|
break;
|
|
128
|
+
|
|
129
|
+
var b = findstart(body, index);
|
|
130
|
+
if (b === -1)
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
var end = body.indexOf(' ', b);
|
|
134
|
+
|
|
135
|
+
if (end === -1) {
|
|
136
|
+
index += t.length + 1;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var tag = body.substring(b + 1, end);
|
|
141
|
+
|
|
142
|
+
if (tag.length > 10) {
|
|
143
|
+
index += tag.length;
|
|
144
|
+
continue;
|
|
95
145
|
}
|
|
96
146
|
|
|
97
|
-
var b = body.lastIndexOf('<', index);
|
|
98
|
-
var tag = body.substring(b + 1, body.indexOf(' ', b));
|
|
99
147
|
var e = body.indexOf('</' + tag + '>', index);
|
|
100
148
|
var size = e + 3 + tag.length;
|
|
101
149
|
body = body.replace(body.substring(b, size), '');
|
|
@@ -221,8 +269,7 @@ function tidy(body) {
|
|
|
221
269
|
var arr = text.substring(is ? 8 : 7, text.length - 1).split(' ');
|
|
222
270
|
var builder = '';
|
|
223
271
|
|
|
224
|
-
for (
|
|
225
|
-
var cls = arr[i];
|
|
272
|
+
for (let cls of arr) {
|
|
226
273
|
if (cls[0] === 'C' && cls[1] === 'M' && cls[2] === 'S' && !SKIP_CLASSES[cls])
|
|
227
274
|
continue;
|
|
228
275
|
builder += (builder ? ' ' : '') + cls;
|
|
@@ -233,14 +280,101 @@ function tidy(body) {
|
|
|
233
280
|
}).replace(/<div\s>/g, '<div>');
|
|
234
281
|
}
|
|
235
282
|
|
|
283
|
+
exports.widgets = function(html) {
|
|
284
|
+
|
|
285
|
+
let arr = html.match(/data-cms=".*?"/g) || EMPTYARRAY;
|
|
286
|
+
let response = [];
|
|
287
|
+
let indexer = 0;
|
|
288
|
+
let index;
|
|
289
|
+
let beg;
|
|
290
|
+
let end;
|
|
291
|
+
|
|
292
|
+
for (let attr of arr) {
|
|
293
|
+
|
|
294
|
+
if (html.indexOf(attr) === -1)
|
|
295
|
+
continue;
|
|
296
|
+
|
|
297
|
+
let w = attr.substring(10);
|
|
298
|
+
index = w.indexOf('__');
|
|
299
|
+
let id = w.substring(0, index);
|
|
300
|
+
|
|
301
|
+
index = html.lastIndexOf('<', html.indexOf(attr));
|
|
302
|
+
beg = '<div';
|
|
303
|
+
end = '</div>';
|
|
304
|
+
|
|
305
|
+
let pos = index + 1;
|
|
306
|
+
let count = 0;
|
|
307
|
+
let counter = 0;
|
|
308
|
+
|
|
309
|
+
while (true) {
|
|
310
|
+
|
|
311
|
+
if (counter++ > 100)
|
|
312
|
+
break;
|
|
313
|
+
|
|
314
|
+
let a = html.indexOf(beg, pos);
|
|
315
|
+
let b = html.indexOf(end, pos);
|
|
316
|
+
|
|
317
|
+
if (a !== -1 && a < b) {
|
|
318
|
+
count++;
|
|
319
|
+
pos = html.indexOf('>', a);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (a === -1 || b < a) {
|
|
324
|
+
|
|
325
|
+
pos = b + 6;
|
|
326
|
+
|
|
327
|
+
if (count) {
|
|
328
|
+
count--;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let body = html.substring(index, pos);
|
|
337
|
+
html = html.replace(body, clean(body));
|
|
338
|
+
index = body.indexOf('>');
|
|
339
|
+
body = body.substring(0, index + 1) + '~BEG~' + body.substring(index + 1);
|
|
340
|
+
index = body.lastIndexOf('<');
|
|
341
|
+
body = body.substring(0, index) + '~END~' + body.substring(index);
|
|
342
|
+
|
|
343
|
+
index = w.indexOf('__');
|
|
344
|
+
|
|
345
|
+
let config = decodeURIComponent(w.substring(index + 2, w.length - 1)).parseJSON(true);
|
|
346
|
+
let opt = {};
|
|
347
|
+
|
|
348
|
+
opt.id = id;
|
|
349
|
+
opt.indexer = indexer;
|
|
350
|
+
opt.body = tidy(clean(body));
|
|
351
|
+
opt.html = body.substring(body.lastIndexOf('~BEG~') + 5, body.lastIndexOf('~END~'));
|
|
352
|
+
opt.config = config || EMPTYOBJECT;
|
|
353
|
+
opt.beg = opt.body.substring(0, opt.body.indexOf('>') + 1);
|
|
354
|
+
opt.end = opt.body.substring(opt.body.lastIndexOf('<'));
|
|
355
|
+
|
|
356
|
+
index = opt.beg.indexOf('data-cms-id="');
|
|
357
|
+
|
|
358
|
+
if (index === -1)
|
|
359
|
+
opt.uid = opt.beg.makeid();
|
|
360
|
+
else
|
|
361
|
+
opt.uid = opt.beg.substring(index + 13, opt.beg.indexOf('"', index + 14));
|
|
362
|
+
|
|
363
|
+
response.push(opt);
|
|
364
|
+
indexer++;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return response;
|
|
368
|
+
};
|
|
369
|
+
|
|
236
370
|
exports.compile = function(html, widgets, used) {
|
|
237
371
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
372
|
+
let arr = html.match(/data-cms=".*?"/g) || EMPTYARRAY;
|
|
373
|
+
let response = new CMSRender();
|
|
374
|
+
let indexer = 0;
|
|
375
|
+
let index;
|
|
376
|
+
let beg;
|
|
377
|
+
let end;
|
|
244
378
|
|
|
245
379
|
response.css = [];
|
|
246
380
|
response.js = [];
|
|
@@ -249,7 +383,7 @@ exports.compile = function(html, widgets, used) {
|
|
|
249
383
|
response.tangular = [];
|
|
250
384
|
|
|
251
385
|
if (!used) {
|
|
252
|
-
for (
|
|
386
|
+
for (let widget of widgets) {
|
|
253
387
|
if (widget.css)
|
|
254
388
|
response.css.push(F.TUtils.minify_css(widget.css));
|
|
255
389
|
if (widget.js)
|
|
@@ -261,30 +395,30 @@ exports.compile = function(html, widgets, used) {
|
|
|
261
395
|
}
|
|
262
396
|
}
|
|
263
397
|
|
|
264
|
-
for (
|
|
398
|
+
for (let attr of arr) {
|
|
265
399
|
|
|
266
400
|
if (html.indexOf(attr) === -1)
|
|
267
401
|
continue;
|
|
268
402
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
403
|
+
let w = attr.substring(10);
|
|
404
|
+
index = w.indexOf('__');
|
|
405
|
+
let id = w.substring(0, index);
|
|
272
406
|
|
|
273
407
|
index = html.lastIndexOf('<', html.indexOf(attr));
|
|
274
408
|
beg = '<div';
|
|
275
409
|
end = '</div>';
|
|
276
410
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
411
|
+
let pos = index + 1;
|
|
412
|
+
let count = 0;
|
|
413
|
+
let counter = 0;
|
|
280
414
|
|
|
281
415
|
while (true) {
|
|
282
416
|
|
|
283
417
|
if (counter++ > 100)
|
|
284
418
|
break;
|
|
285
419
|
|
|
286
|
-
|
|
287
|
-
|
|
420
|
+
let a = html.indexOf(beg, pos);
|
|
421
|
+
let b = html.indexOf(end, pos);
|
|
288
422
|
|
|
289
423
|
if (a !== -1 && a < b) {
|
|
290
424
|
count++;
|
|
@@ -305,8 +439,8 @@ exports.compile = function(html, widgets, used) {
|
|
|
305
439
|
}
|
|
306
440
|
}
|
|
307
441
|
|
|
308
|
-
|
|
309
|
-
|
|
442
|
+
let widget = widgets instanceof Array ? widgets.findItem('id', id) : widgets[id];
|
|
443
|
+
let body = html.substring(index, pos);
|
|
310
444
|
|
|
311
445
|
// Widget not found
|
|
312
446
|
if (!widget) {
|
|
@@ -341,13 +475,13 @@ exports.compile = function(html, widgets, used) {
|
|
|
341
475
|
body = body.substring(0, index) + '~END~' + body.substring(index);
|
|
342
476
|
|
|
343
477
|
index = w.indexOf('__');
|
|
344
|
-
var config = decodeURIComponent(w.substring(index + 2, w.length - 1)).parseJSON(true);
|
|
345
478
|
|
|
346
|
-
|
|
479
|
+
let config = decodeURIComponent(w.substring(index + 2, w.length - 1)).parseJSON(true);
|
|
480
|
+
let opt = {};
|
|
347
481
|
opt.id = id;
|
|
348
482
|
opt.indexer = indexer;
|
|
349
483
|
opt.body = tidy(clean(body));
|
|
350
|
-
opt.
|
|
484
|
+
opt.html = body.substring(body.lastIndexOf('~BEG~') + 5, body.lastIndexOf('~END~'));
|
|
351
485
|
opt.config = config || EMPTYOBJECT;
|
|
352
486
|
opt.render = widget.render;
|
|
353
487
|
opt.beg = opt.body.substring(0, opt.body.indexOf('>') + 1);
|
|
@@ -373,17 +507,17 @@ exports.compile = function(html, widgets, used) {
|
|
|
373
507
|
if (index === -1)
|
|
374
508
|
break;
|
|
375
509
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
510
|
+
let begindex = html.lastIndexOf('<script', index);
|
|
511
|
+
let endindex = html.indexOf('</script>', index);
|
|
512
|
+
let endhead = html.indexOf('>', index);
|
|
513
|
+
let head = html.substring(begindex, endhead);
|
|
514
|
+
let name = head.match(/name=".*?"/i)[0];
|
|
515
|
+
let template = html.substring(html.indexOf('>', endhead) + 1, endindex);
|
|
382
516
|
|
|
383
517
|
name = name.substring(6, name.length - 1);
|
|
384
|
-
html = html.replace(html.substring(
|
|
518
|
+
html = html.replace(html.substring(begindex, endindex + 9), '~WIDGET#' + response.tangular.length + '~');
|
|
385
519
|
response.tangular.push({ id: HASH(name).toString(36), name: name, type: 'nav', template: Tangular.compile(template) });
|
|
386
|
-
index =
|
|
520
|
+
index = begindex;
|
|
387
521
|
|
|
388
522
|
}
|
|
389
523
|
|
|
@@ -396,26 +530,26 @@ exports.compile = function(html, widgets, used) {
|
|
|
396
530
|
if (index === -1)
|
|
397
531
|
break;
|
|
398
532
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
html = html.replace(html.substring(
|
|
533
|
+
let begindex = html.lastIndexOf('<script', index);
|
|
534
|
+
let endindex = html.indexOf('</script>', index);
|
|
535
|
+
let endhead = html.indexOf('>', index);
|
|
536
|
+
let template = html.substring(html.indexOf('>', endhead) + 1, endindex);
|
|
537
|
+
html = html.replace(html.substring(begindex, endindex + 9), '~WIDGET#' + response.tangular.length + '~');
|
|
404
538
|
response.tangular.push({ type: 'breadcrumb', template: Tangular.compile(template) });
|
|
405
|
-
index =
|
|
539
|
+
index = begindex;
|
|
406
540
|
}
|
|
407
541
|
|
|
408
542
|
response.html = tidy(trash(layout(html, '~WIDGETLAYOUT~')));
|
|
409
543
|
response.multiple = expressions_multiple(response.html);
|
|
410
544
|
|
|
411
|
-
for (
|
|
545
|
+
for (let item of response.multiple)
|
|
412
546
|
response.html = response.html.replace(item.html, item.replace);
|
|
413
547
|
|
|
414
548
|
response.expressions = expressions(response.html);
|
|
415
549
|
response.widgets.reverse();
|
|
416
550
|
|
|
417
|
-
|
|
418
|
-
|
|
551
|
+
let builder = [];
|
|
552
|
+
let text = [];
|
|
419
553
|
|
|
420
554
|
while (true) {
|
|
421
555
|
|
|
@@ -423,8 +557,8 @@ exports.compile = function(html, widgets, used) {
|
|
|
423
557
|
|
|
424
558
|
if (beg !== -1) {
|
|
425
559
|
end = response.html.indexOf('~', beg + 6) + 1;
|
|
426
|
-
|
|
427
|
-
|
|
560
|
+
let h = response.html.substring(0, beg);
|
|
561
|
+
let windex = response.html.substring(beg + 7, end - 1);
|
|
428
562
|
if (windex[0] === '#') {
|
|
429
563
|
response.html = response.html.substring(end);
|
|
430
564
|
builder.push('text[{0}]+tangular[{1}]'.format(text.push(h) - 1, windex.substring(1)));
|