total5 0.0.13-8 → 0.0.13-9

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/changelog.txt CHANGED
@@ -23,6 +23,7 @@
23
23
  - fixed removing of multiple spaces in the `String.toName()` method
24
24
  - fixed a problem with case-sensitive characters in the route parameters
25
25
  - fixed markdown parser
26
+ - added missing ViewEngine `@{meta(...)}` method
26
27
 
27
28
  ========================
28
29
  0.0.12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.13-8",
3
+ "version": "0.0.13-9",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/viewengine.js CHANGED
@@ -116,7 +116,7 @@ exports.compile = function(name, content, debug = true) {
116
116
 
117
117
  while (command) {
118
118
 
119
- if (!isCookie && command.command.indexOf('cookie') !== -1)
119
+ if (!isCookie && command.command.includes('cookie'))
120
120
  isCookie = true;
121
121
 
122
122
  if (old) {
@@ -186,7 +186,7 @@ exports.compile = function(name, content, debug = true) {
186
186
 
187
187
  counter++;
188
188
 
189
- if (cmd.indexOf('foreach var ') !== -1)
189
+ if (cmd.includes('foreach var '))
190
190
  cmd = cmd.replace(' var ', SPACE);
191
191
 
192
192
  newCommand = (cmd.substring(8, cmd.indexOf(SPACE, 8)) || '').trim();
@@ -378,7 +378,7 @@ function prepare(command, dcommand, functions) {
378
378
  return 'self.hostname';
379
379
 
380
380
  case 'href':
381
- return command.indexOf('(') === -1 ? 'self.href()' : 'self.' + command;
381
+ return command.includes('(') ? ('self.' + command) : 'self.href()';
382
382
 
383
383
  case 'url':
384
384
  return 'self.' + command;
@@ -387,7 +387,10 @@ function prepare(command, dcommand, functions) {
387
387
  case 'description':
388
388
  case 'keywords':
389
389
  case 'author':
390
- return command.indexOf('(') === -1 ? '((repository[\'' + command + '\'] || \'\') + \'\').safehtml()' : 'self.' + command;
390
+ return command.includes('(') ? ('self.' + command) : '((repository[\'' + command + '\'] || \'\') + \'\').safehtml()';
391
+
392
+ case 'meta':
393
+ return command.includes('(') ? ('self.' + command) : ('self.' + command + '()');
391
394
 
392
395
  case 'title2':
393
396
  return 'self.' + command;
@@ -399,10 +402,10 @@ function prepare(command, dcommand, functions) {
399
402
  return '(repository[\'' + command.substring(1) + '\'] || \'\')';
400
403
 
401
404
  case 'place':
402
- return command.indexOf('(') === -1 ? '(repository[\'' + command + '\'] || \'\')' : 'self.' + command;
405
+ return command.includes('(') ? ('self.' + command) : ('(repository[\'' + command + '\'] || \'\')');
403
406
 
404
407
  case 'import':
405
- return 'self.' + command + (command.indexOf('(') === -1 ? '()' : '');
408
+ return 'self.' + command + (command.includes('(') ? '' : '()');
406
409
 
407
410
  case 'index':
408
411
  return '(' + command + ')';
@@ -424,7 +427,7 @@ function prepare(command, dcommand, functions) {
424
427
  return '(new Date()' + command.substring(3) + ')';
425
428
 
426
429
  default:
427
- return F.def.helpers[name] ? ('F.def.helpers.' + insertcall(command)) : ('self.safehtml(' + (functions.indexOf(name) === -1 ? command[0] === '!' ? command.substring(1) + ')' : command + ', 1)' : command + ')'));
430
+ return F.def.helpers[name] ? ('F.def.helpers.' + insertcall(command)) : ('self.safehtml(' + (!functions.includes(name) ? command[0] === '!' ? command.substring(1) + ')' : command + ', 1)' : command + ')'));
428
431
  }
429
432
  }
430
433
 
@@ -668,6 +671,28 @@ View.prototype.keywords = function(value) {
668
671
  return '';
669
672
  };
670
673
 
674
+ View.prototype.meta = function() {
675
+
676
+ let self = this;
677
+
678
+ if (!arguments.length)
679
+ return makehtmlmeta(self);
680
+
681
+ if (arguments[0])
682
+ self.repository.title = arguments[0].encode();
683
+
684
+ if (arguments[1])
685
+ self.repository.description = arguments[1].encode();
686
+
687
+ if (arguments[2] && arguments[2].length)
688
+ self.repository.keywords = (arguments[2] instanceof Array ? arguments[2].join(', ') : arguments[2]).encode();
689
+
690
+ if (arguments[3])
691
+ self.repository.image = arguments[3];
692
+
693
+ return '';
694
+ };
695
+
671
696
  // @{href({ key1: 1, key2: 2 })}
672
697
  // @{href('key', 'value')}
673
698
  // @{href({ key1: 1, key2: 2 })}
@@ -784,12 +809,13 @@ function makehtmlmeta(self) {
784
809
  builder += '<meta name="description" content="' + repo.description.safehtml() + '" />';
785
810
 
786
811
  if (repo.keywords)
787
- builder += '<meta name="description" content="' + repo.keywords.safehtml() + '" />';
812
+ builder += '<meta name="keywords" content="' + repo.keywords.safehtml() + '" />';
788
813
 
789
814
  if (repo.image) {
790
815
  let tmp = repo.image.substring(0, 6);
791
- let src = tmp === 'http:/' || tmp === 'https:' || tmp.substring(0, 2) === '//' ? repo.image : ((self?.controller.host || '') + repo.image);
792
- builder += '<meta property="og:image" content="' + src + '" /><meta name="twitter:image" content="' + src + '" />';
816
+ let src = tmp === 'http:/' || tmp === 'https:' || tmp.substring(0, 2) === '//' ? repo.image : self.controller ? self.controller.hostname(repo.image[0] === '/' ? repo.image : ('/' + repo.image)) : '';
817
+ if (src)
818
+ builder += '<meta property="og:image" content="' + src + '" /><meta name="twitter:image" content="' + src + '" />';
793
819
  }
794
820
 
795
821
  return builder;
@@ -827,7 +853,7 @@ View.prototype.import = function() {
827
853
  continue;
828
854
  }
829
855
 
830
- if (m.indexOf('+') === -1) {
856
+ if (!m.includes('+')) {
831
857
  let absolute = m[0] === '/';
832
858
  let key = absolute ? m : ('/' + m);
833
859
  if (REG_CHECKCSS.test(m)) {
@@ -923,4 +949,4 @@ View.prototype.render = function(name, model, ispartial = false) {
923
949
  return content;
924
950
  };
925
951
 
926
- exports.View = View;
952
+ exports.View = View;