total5 0.0.1-2 → 0.0.1-20

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 CHANGED
@@ -132,7 +132,7 @@ APICallProto.error = APICallProto.err = function(err, reverse) {
132
132
 
133
133
  APICallProto.callback = function($) {
134
134
  var t = this;
135
- t.$callback = typeof($) === 'function' ? $ : $.callback;
135
+ t.$callback = typeof($) === 'function' ? $ : $.callback();
136
136
  return t;
137
137
  };
138
138
 
package/builders.js CHANGED
@@ -5,6 +5,7 @@
5
5
  'use strict';
6
6
 
7
7
  const REG_ARGS = /\{{1,2}[a-z0-9_.-\s]+\}{1,2}/gi;
8
+ const SESSIONSEPARATOR = '\0';
8
9
 
9
10
  var transforms = { error: {}, restbuilder: {} };
10
11
  var restbuilderupgrades = [];
@@ -23,7 +24,11 @@ Options.prototype = {
23
24
  },
24
25
 
25
26
  get websocket() {
26
- return this.controller.parent;
27
+ return this.controller ? this.controller.parent : null;
28
+ },
29
+
30
+ get sessionid() {
31
+ return this.controller ? this.controller.sessionid : null;
27
32
  },
28
33
 
29
34
  get value() {
@@ -51,15 +56,15 @@ Options.prototype = {
51
56
  },
52
57
 
53
58
  get path() {
54
- return (this.controller ? this.controller.pathname : EMPTYARRAY);
59
+ return this.controller ? this.controller.pathname : EMPTYARRAY;
55
60
  },
56
61
 
57
62
  get split() {
58
- return (this.controller ? this.controller.split : EMPTYARRAY);
63
+ return this.controller ? this.controller.split : EMPTYARRAY;
59
64
  },
60
65
 
61
66
  get split2() {
62
- return (this.controller ? this.controller.split2 : EMPTYARRAY);
67
+ return this.controller ? this.controller.split2 : EMPTYARRAY;
63
68
  },
64
69
 
65
70
  get language() {
@@ -98,7 +103,7 @@ Options.prototype.action = function(schema, payload) {
98
103
  Options.prototype.publish = function(value) {
99
104
  var self = this;
100
105
  var name = self.id;
101
- if (F.TMS.cache.socket && F.TMS.cache.pcache[name] && F.TMS.cache.publishers[name]) {
106
+ if (F.TTMS.cache.socket && F.TTMS.cache.pcache[name]) {
102
107
 
103
108
  var tmp = {};
104
109
  if (tmp) {
@@ -109,7 +114,7 @@ Options.prototype.publish = function(value) {
109
114
  }
110
115
 
111
116
  F.stats.performance.publish++;
112
- F.TMS.cache.socket.send({ type: 'publish', id: name, data: tmp }, client => client.tmsready);
117
+ F.TTMS.cache.socket.send({ type: 'publish', id: name, data: tmp }, client => client.tmsready && client.$subscribers[name]);
113
118
  }
114
119
  return self;
115
120
  };
@@ -148,8 +153,14 @@ Options.prototype.cancel = function() {
148
153
  };
149
154
 
150
155
  Options.prototype.redirect = function(url) {
151
- this.redirect(url);
152
- this.cancel();
156
+ var self = this;
157
+ self.$callback = null;
158
+ if (self.controller) {
159
+ self.controller.redirect(url);
160
+ self.controller.destroyed = true;
161
+ }
162
+ self.cancel();
163
+ return self;
153
164
  };
154
165
 
155
166
  Options.prototype.audit = function(message, type) {
@@ -164,6 +175,16 @@ Options.prototype.success = function(value) {
164
175
  self.callback(DEF.onSuccess(value));
165
176
  };
166
177
 
178
+ Options.prototype.successful = function(callback) {
179
+ var self = this;
180
+ return function(err, a, b, c) {
181
+ if (err)
182
+ self.invalid(err);
183
+ else
184
+ callback.call(self, a, b, c);
185
+ };
186
+ };
187
+
167
188
  Options.prototype.callback = function(value) {
168
189
 
169
190
  var self = this;
@@ -183,7 +204,7 @@ Options.prototype.done = function(arg) {
183
204
  return function(err, response) {
184
205
  if (err) {
185
206
  err && self.error.push(err);
186
- self.callback();
207
+ self.callback(null);
187
208
  } else {
188
209
  if (self.TYPE === 'auth')
189
210
  self.callback(arg === true ? response : arg);
@@ -196,7 +217,7 @@ Options.prototype.done = function(arg) {
196
217
  Options.prototype.invalid = function(error, path, index) {
197
218
  var self = this;
198
219
  self.error.push(error, path, index);
199
- self.$callback(error);
220
+ self.$callback(true);
200
221
  };
201
222
 
202
223
  Options.prototype.cookie = function(name, value, expire, options) {
@@ -262,6 +283,11 @@ ErrorBuilder.prototype = {
262
283
  }
263
284
  };
264
285
 
286
+ ErrorBuilder.prototype.reject = function(language) {
287
+ var self = this;
288
+ return new Error(self.toString(language, ''));
289
+ };
290
+
265
291
  ErrorBuilder.prototype.push = function(err, path, index) {
266
292
  var self = this;
267
293
 
@@ -316,8 +342,10 @@ ErrorBuilder.prototype.output = function(language = 'default') {
316
342
 
317
343
  let err = m.error;
318
344
 
319
- if (err[0] == '@')
345
+ if (err == '@')
320
346
  err = F.resource(language, 'T' + (err === '@' ? m.name : err.substring(1)).hash(true).toString(36)) || 'The field "' + m.name + '" is invalid';
347
+ else if (err[0] === '@')
348
+ err = F.translate(language, err);
321
349
 
322
350
  if (self.replacer) {
323
351
  for (let key in self.replacer)
@@ -333,12 +361,12 @@ ErrorBuilder.prototype.output = function(language = 'default') {
333
361
  return output;
334
362
  };
335
363
 
336
- ErrorBuilder.prototype.toString = function(language = 'default') {
364
+ ErrorBuilder.prototype.toString = function(language = 'default', divider = '\n') {
337
365
  var self = this;
338
366
  var output = self.output(language);
339
367
  var str = '';
340
368
  for (let err of output)
341
- str += (str ? '\n' : '') + err.error;
369
+ str += (str ? divider : '') + err.error;
342
370
  return str;
343
371
  };
344
372
 
@@ -1121,7 +1149,7 @@ exports.newaction = function(name, obj) {
1121
1149
 
1122
1150
  if (obj.route) {
1123
1151
  if (obj.route.indexOf('-->') === -1)
1124
- obj.route = obj.route + ' ' + (obj.input ? '+' : '-') + obj.$url + ' * --> ' + name;
1152
+ obj.route = obj.route + ' ' + (obj.input ? '+' : '-') + obj.$url + ' --> ' + name;
1125
1153
  var flags = null;
1126
1154
  if (obj.encrypt)
1127
1155
  flags = '@encrypt';
@@ -1147,20 +1175,24 @@ exports.newaction = function(name, obj) {
1147
1175
  }
1148
1176
  }
1149
1177
 
1150
- F.TMS.newpublish(name, tmsschema);
1178
+ F.TTMS.newpublish(name, tmsschema);
1151
1179
  }
1152
1180
 
1153
1181
  F.makesourcemap && F.makesourcemap();
1154
1182
  return obj;
1155
1183
  };
1156
1184
 
1185
+ function ActionCallerExec(self) {
1186
+ self.exec();
1187
+ }
1188
+
1157
1189
  function ActionCaller() {
1158
1190
  var self = this;
1159
1191
  self.$ = new Options();
1160
1192
  self.error = new ErrorBuilder();
1161
1193
  self.options = {};
1162
1194
  self.actions = [];
1163
- setImmediate(self => self.exec(), self);
1195
+ setImmediate(ActionCallerExec, self);
1164
1196
  }
1165
1197
 
1166
1198
  ActionCaller.prototype.debug = function() {
@@ -1219,7 +1251,7 @@ ActionCaller.prototype.exec = function() {
1219
1251
  var type = meta.payload || (action.input ? '+' : '-');
1220
1252
  var $ = self.$;
1221
1253
 
1222
- $.id = id;
1254
+ $.id = action.id;
1223
1255
  $.error = self.error;
1224
1256
  $.controller = self.controller;
1225
1257
  $.fields = action.fields;
@@ -1272,7 +1304,8 @@ ActionCaller.prototype.exec = function() {
1272
1304
  return;
1273
1305
  }
1274
1306
  $.query = response.response;
1275
- }
1307
+ } else
1308
+ $.query = query;
1276
1309
 
1277
1310
  if (action.jsparams) {
1278
1311
  self.error.prefix = 'params.';
@@ -1283,16 +1316,18 @@ ActionCaller.prototype.exec = function() {
1283
1316
  return;
1284
1317
  }
1285
1318
  $.params = response.response;
1286
- }
1319
+ } else
1320
+ $.params = params;
1287
1321
 
1288
1322
  if (action.jsinput && type !== '-') {
1289
- response = action.jsinput.transform(payload, type === '%', self.error);
1323
+ response = action.jsinput.transform(payload, action.partial, self.error);
1290
1324
  if (response.error) {
1291
1325
  self.cancel();
1292
1326
  return;
1293
1327
  }
1294
1328
  $.payload = response.response;
1295
- }
1329
+ } else
1330
+ $.payload = payload;
1296
1331
 
1297
1332
  action.action($, $.payload);
1298
1333
  };
@@ -1363,7 +1398,7 @@ ActionCaller.prototype.promise = function($) {
1363
1398
  if ($ && $.invalid)
1364
1399
  $.invalid(err);
1365
1400
  else
1366
- reject(err);
1401
+ reject(err.reject());
1367
1402
  } else
1368
1403
  resolve(response);
1369
1404
  };
@@ -1421,15 +1456,281 @@ exports.action = function(name, payload, controller) {
1421
1456
  };
1422
1457
 
1423
1458
  exports.newschema = function(name, callback) {
1459
+
1460
+ if (name[0] === '@')
1461
+ name = name.substring(1);
1462
+
1463
+ if (typeof(callback) === 'string')
1464
+ return F.jsonschemas[name] = F.TUtils.jsonschema(callback, true);
1465
+
1424
1466
  var $ = {};
1425
1467
  $.name = name;
1426
1468
  $.actions = {};
1427
1469
  $.action = function(aname, meta) {
1428
1470
  return $.actions[aname] = F.newaction(name + '/' + aname, meta);
1429
1471
  };
1472
+
1430
1473
  callback($);
1431
1474
  };
1432
1475
 
1476
+ exports.builtinauth = function(opt) {
1477
+
1478
+ // opt.secret {String}
1479
+ // opt.ddos {Number}
1480
+ // opt.expire {String}
1481
+ // opt.cookie {String} A cookie name
1482
+ // opt.header {String} A header name
1483
+ // opt.options {Object} A cookie options
1484
+ // opt.strict {Boolean}
1485
+
1486
+ if (opt.strict == null)
1487
+ opt.strict = true;
1488
+
1489
+ // Delegates
1490
+ // opt.onddos = function($)
1491
+ // opt.onread = function({ sessionid: String, userid: String, ua: String }, callback(USER_DATA), $)
1492
+ // opt.onfree = function({ sessions: Array, users: Array })
1493
+ // opt.onlogout = function(sessionid, userid)
1494
+ // opt.onauthorize = function($) must return true for canceling of processing
1495
+
1496
+ opt.sessions = {};
1497
+ opt.blocked = {};
1498
+ opt.pending = {};
1499
+
1500
+ if (!opt.cleaner)
1501
+ opt.cleaner = 5;
1502
+
1503
+ if (!opt.secret)
1504
+ opt.secret = F.secret;
1505
+
1506
+ opt.logout = function($) {
1507
+
1508
+ var id = $;
1509
+
1510
+ if (typeof(id) === 'object')
1511
+ id = $.sessionid;
1512
+
1513
+ if (id) {
1514
+ for (var key in opt.sessions) {
1515
+ var session = opt.sessions[key];
1516
+ if (session.sessionid === id) {
1517
+ delete opt.sessions[key];
1518
+ opt.onlogout && opt.onlogout(session);
1519
+ opt.cookie && !$.controller.parent && $.controller.cookie && $.controller.cookie(opt.cookie, '', '-1 year', opt.options);
1520
+ return true;
1521
+ }
1522
+ }
1523
+ }
1524
+ };
1525
+
1526
+ opt.update = function(userid, fn) {
1527
+ var count = 0;
1528
+ for (var key in opt.sessions) {
1529
+ var session = opt.sessions[key];
1530
+ if (session.userid === userid) {
1531
+ count++;
1532
+ fn(session.data, session);
1533
+ }
1534
+ }
1535
+ return count;
1536
+ };
1537
+
1538
+ opt.refresh = function(userid, exceptsessionid) {
1539
+ var count = 0;
1540
+ for (var key in opt.sessions) {
1541
+ var session = opt.sessions[key];
1542
+ if (session.userid === userid && session.sessionid !== exceptsessionid) {
1543
+ count++;
1544
+ delete opt.sessions[key];
1545
+ }
1546
+ }
1547
+ return count;
1548
+ };
1549
+
1550
+ opt.sign = function(sessionid, userid) {
1551
+ return (sessionid + SESSIONSEPARATOR + userid + SESSIONSEPARATOR + Date.now().toString(36)).encrypt(opt.secret);
1552
+ };
1553
+
1554
+ opt.authcookie = function($, sessionid, userid, expiration, options) {
1555
+ if (!options)
1556
+ options = opt.options;
1557
+ var ctrl = $.controller ? $.controller : $;
1558
+ ctrl.cookie && !ctrl.parent && $.cookie(opt.cookie, opt.sign(sessionid, userid), expiration, options);
1559
+ };
1560
+
1561
+ if (!opt.expire)
1562
+ opt.expire = '5 minutes';
1563
+
1564
+ var callpending = function(pending, data) {
1565
+ for (var i = 0; i < pending.length; i++) {
1566
+ if (data)
1567
+ pending[i].success(data);
1568
+ else
1569
+ pending[i].invalid();
1570
+ }
1571
+ };
1572
+
1573
+ opt.auth = function($) {
1574
+
1575
+ if (opt.onauthorize && opt.onauthorize($))
1576
+ return;
1577
+
1578
+ var sessionid = opt.cookie ? $.cookie(opt.cookie) : null;
1579
+ if (!sessionid && opt.header)
1580
+ sessionid = $.controller.headers[opt.header];
1581
+
1582
+ var localize = opt.locale || opt.localize;
1583
+
1584
+ if (!sessionid) {
1585
+
1586
+ if (localize)
1587
+ $.controller.language = localize(null, $.controller);
1588
+
1589
+ $.invalid();
1590
+ return;
1591
+ }
1592
+
1593
+ var id = sessionid.decrypt(opt.secret);
1594
+ if (id) {
1595
+
1596
+ id = id.split(SESSIONSEPARATOR);
1597
+
1598
+ if (!id[0] || !id[1] || !id[2])
1599
+ id = null;
1600
+
1601
+ if (id) {
1602
+ var session = opt.sessions[id[0]];
1603
+ if (session && session.data) {
1604
+ if (!opt.strict || session.ua === $.controller.ua) {
1605
+ $.controller.session = session;
1606
+ $.controller.sessionid = session.sessionid;
1607
+ if (!opt.onsession || !opt.onsession(session, $)) {
1608
+ if (localize)
1609
+ $.controller.language = localize(session.data, $.controller);
1610
+ $.success(session.data);
1611
+ }
1612
+ } else {
1613
+
1614
+ if (localize)
1615
+ $.controller.language = localize(null, $.controller);
1616
+
1617
+ $.invalid();
1618
+ sessionid = null;
1619
+ }
1620
+ return;
1621
+ }
1622
+ }
1623
+ }
1624
+
1625
+ if (opt.ddos && opt.blocked[$.controller.ip] > opt.ddos) {
1626
+ opt.onddos && opt.onddos($);
1627
+ $.invalid();
1628
+ return;
1629
+ }
1630
+
1631
+ if (!id) {
1632
+
1633
+ if (opt.ddos) {
1634
+ if (opt.blocked[$.controller.ip])
1635
+ opt.blocked[$.controller.ip]++;
1636
+ else
1637
+ opt.blocked[$.controller.ip] = 1;
1638
+ }
1639
+
1640
+ opt.cookie && $.controller && !$.controller.parent && $.controller.cookie && $.controller.cookie(opt.cookie, '', '-1 year', opt.options);
1641
+ $.invalid();
1642
+ return;
1643
+ }
1644
+
1645
+ var meta = { ip: $.controller.ip, ua: $.controller.ua, sessionid: id[0], userid: id[1] };
1646
+
1647
+ if (opt.pending[meta.sessionid]) {
1648
+ opt.pending[meta.sessionid].push($);
1649
+ return;
1650
+ }
1651
+
1652
+ opt.pending[meta.sessionid] = [];
1653
+ opt.onread(meta, function(err, data) {
1654
+
1655
+ var pending = opt.pending[meta.sessionid];
1656
+ delete opt.pending[meta.sessionid];
1657
+
1658
+ if (!err && data) {
1659
+
1660
+ $.controller.session = opt.sessions[meta.sessionid] = { sessionid: meta.sessionid, userid: meta.userid, data: data, ua: $.controller.ua, expire: NOW.add(opt.expire) };
1661
+ $.controller.sessionid = meta.sessionid;
1662
+
1663
+ if (localize)
1664
+ $.controller.language = localize(data, $.controller);
1665
+
1666
+ if (!opt.onsession || !opt.onsession($.controller.session, $, true))
1667
+ $.success(data);
1668
+
1669
+ if (pending.length)
1670
+ setImmediate(callpending, pending, data);
1671
+
1672
+ } else {
1673
+
1674
+ if (opt.ddos) {
1675
+ if (opt.blocked[$.controller.ip])
1676
+ opt.blocked[$.controller.ip]++;
1677
+ else
1678
+ opt.blocked[$.controller.ip] = 1;
1679
+ }
1680
+
1681
+ opt.cookie && !$.controller.parent && $.controller.cookie && $.controller.cookie(opt.cookie, '', '-1 year', opt.options);
1682
+ $.invalid();
1683
+
1684
+ if (pending.length)
1685
+ setImmediate(callpending, pending);
1686
+ }
1687
+
1688
+ }, $);
1689
+
1690
+ };
1691
+
1692
+ F.def.onAuthorize = opt.auth;
1693
+
1694
+ F.on('service', function(counter) {
1695
+
1696
+ if (counter % opt.cleaner)
1697
+ return;
1698
+
1699
+ var expired = [];
1700
+ var users_expired = {};
1701
+ var users_live = {};
1702
+
1703
+ for (var key in opt.sessions) {
1704
+ var session = opt.sessions[key];
1705
+ if (session.expire < NOW) {
1706
+ expired.push(key);
1707
+ delete opt.sessions[key];
1708
+ users_expired[session.userid] = 1;
1709
+ } else
1710
+ users_live[session.userid] = 1;
1711
+ }
1712
+
1713
+ if (expired.length) {
1714
+ for (var key in users_expired) {
1715
+ if (users_live[key])
1716
+ delete users_expired[key];
1717
+ }
1718
+ }
1719
+
1720
+ if (expired.length && opt.onfree) {
1721
+ var meta = {};
1722
+ meta.sessions = expired;
1723
+ meta.users = expired.length ? Object.keys(users_expired) : null;
1724
+ opt.onfree && opt.onfree(meta);
1725
+ }
1726
+
1727
+ opt.blocked = {};
1728
+
1729
+ });
1730
+
1731
+ return opt;
1732
+ };
1733
+
1433
1734
  exports.RESTBuilder = RESTBuilder;
1434
1735
  exports.ErrorBuilder = ErrorBuilder;
1435
1736
  exports.Options = Options;
package/bundles.js CHANGED
@@ -400,7 +400,7 @@ exports.extract = function(callback, skip) {
400
400
  try {
401
401
 
402
402
  if (F.Fs.readFileSync('bundles.debug')) {
403
- F.isbundle = true;
403
+ F.isBundle = true;
404
404
  F.dir(F.path.root('/.src/'));
405
405
  callback();
406
406
  return;
@@ -428,7 +428,7 @@ exports.extract = function(callback, skip) {
428
428
  });
429
429
  }, function() {
430
430
  extract(function() {
431
- F.isbundle = true;
431
+ F.isBundle = true;
432
432
  F.dir(F.path.root('/.src/'));
433
433
  callback();
434
434
  });
@@ -436,21 +436,11 @@ exports.extract = function(callback, skip) {
436
436
  };
437
437
 
438
438
  try {
439
-
440
439
  var files = F.Fs.readdirSync(bundles);
441
440
  if (files.length)
442
441
  extractbundles();
443
442
  else
444
443
  callback();
445
-
446
- /*
447
- if (F.$bundling) {
448
- makebundle();
449
- return;
450
- } else {
451
- F.isbundle = true;
452
- F.dir(F.path.root('/.src/'));
453
- }*/
454
444
  } catch(e) {
455
445
  callback();
456
446
  }
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.lastIndexOf('<', index);
30
- var tag = body.substring(b + 1, body.indexOf(' ', b));
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,25 @@ 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
+
79
+ return -1;
80
+
81
+ }
82
+
56
83
  function expressions(body) {
57
84
 
58
85
  var index = 0;
@@ -65,9 +92,17 @@ function expressions(body) {
65
92
  if (index === -1)
66
93
  break;
67
94
 
68
- var b = body.lastIndexOf('<', index);
69
- var tag = body.substring(b + 1, body.indexOf(' ', b));
95
+ var b = findstart(body, index);
96
+ if (b === -1)
97
+ break;
98
+
99
+ var end = body.indexOf(' ', b);
100
+ if (end === -1) {
101
+ index += 15;
102
+ continue;
103
+ }
70
104
 
105
+ var tag = body.substring(b + 1, end);
71
106
  var e = body.indexOf('</' + tag + '>', index);
72
107
  var size = e + 3 + tag.length;
73
108
  var obj = {};
@@ -90,12 +125,27 @@ function trash(body) {
90
125
 
91
126
  index = body.indexOf(t, index + t.length);
92
127
 
93
- if (index === -1) {
128
+ if (index === -1)
129
+ break;
130
+
131
+ var b = findstart(body, index);
132
+ if (b === -1)
94
133
  break;
134
+
135
+ var end = body.indexOf(' ', b);
136
+
137
+ if (end === -1) {
138
+ index += t.length + 1;
139
+ continue;
140
+ }
141
+
142
+ var tag = body.substring(b + 1, end);
143
+
144
+ if (tag.length > 10) {
145
+ index += tag.length;
146
+ continue;
95
147
  }
96
148
 
97
- var b = body.lastIndexOf('<', index);
98
- var tag = body.substring(b + 1, body.indexOf(' ', b));
99
149
  var e = body.indexOf('</' + tag + '>', index);
100
150
  var size = e + 3 + tag.length;
101
151
  body = body.replace(body.substring(b, size), '');
@@ -347,7 +397,7 @@ exports.compile = function(html, widgets, used) {
347
397
  opt.id = id;
348
398
  opt.indexer = indexer;
349
399
  opt.body = tidy(clean(body));
350
- opt.text = body.substring(body.lastIndexOf('~BEG~') + 5, body.lastIndexOf('~END~'));
400
+ opt.html = body.substring(body.lastIndexOf('~BEG~') + 5, body.lastIndexOf('~END~'));
351
401
  opt.config = config || EMPTYOBJECT;
352
402
  opt.render = widget.render;
353
403
  opt.beg = opt.body.substring(0, opt.body.indexOf('>') + 1);
@@ -577,7 +627,7 @@ CMSRender.prototype._render = function(meta, layout, callback) {
577
627
  }
578
628
 
579
629
  render(opt, function(response, replace, cache) {
580
- widgets[item.indexer] = replace === true ? response == null ? '' : (response + '').replace(/~(BEG|END)~/g, '') : (item.beg + (response || '') + item.end);
630
+ widgets[item.indexer] = replace === true ? (response == null || response == '' ? '' : (response + '').replace(/~(BEG|END)~/g, '')) : (item.beg + (response || '') + item.end);
581
631
  if (cache)
582
632
  self.cache[opt.cacheid] = widgets[item.indexer];
583
633
  next();