Skip to content

Commit e12dcf3

Browse files
committed
added: dependencies
1 parent e872c5b commit e12dcf3

10 files changed

Lines changed: 293 additions & 24 deletions

File tree

changes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ BETA ======= 1.8.1
4040
- added: String.base64ToBuffer();
4141
- added: terminal -> `tpm unpack [package_name] [optional: target_directory]`
4242
- added: versions is applied to raw HTML
43-
- added: sync2(), e.g. sync2(fn), diff with v1: sync(fn)()
43+
- added: sync2(), e.g. sync2(fn), diff with v1: sync(fn)() and v2: sync2(fn)
44+
- added: "dependencies" file for installing dependencies (modules, packages, etc.)
4445

4546
- updated: (IMPORTANT) routing: `json` flag is not required for receiving incomming data as JSON
4647
- updated: `F.mail(address, subject, view, [model], [callback], [language])` added language

index.js

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function Framework() {
198198

199199
this.id = null;
200200
this.version = 1810;
201-
this.version_header = '1.8.1-46';
201+
this.version_header = '1.8.1-47';
202202

203203
var version = process.version.toString().replace('v', '').replace(/\./g, '');
204204
if (version[1] === '0')
@@ -1734,6 +1734,10 @@ Framework.prototype.$load = function(types) {
17341734
}
17351735

17361736
self._routesSort();
1737+
1738+
if (!types || types.indexOf('dependencies') !== -1)
1739+
self._configure_dependencies();
1740+
17371741
return self;
17381742
};
17391743

@@ -6260,6 +6264,106 @@ Framework.prototype.translator = function(language, text) {
62606264
return framework_internal.parseLocalization(text, language);
62616265
};
62626266

6267+
Framework.prototype._configure_dependencies = function(content) {
6268+
6269+
if (content === undefined) {
6270+
var filename = framework_utils.combine('/', 'dependencies');
6271+
if (fs.existsSync(filename))
6272+
content = fs.readFileSync(filename).toString(ENCODING);
6273+
else
6274+
content = '';
6275+
}
6276+
6277+
var self = this;
6278+
6279+
if (!content)
6280+
return self;
6281+
6282+
var arr = content.split('\n');
6283+
6284+
for (var i = 0, length = arr.length; i < length; i++) {
6285+
6286+
var str = arr[i];
6287+
6288+
if (str === '' || str[0] === '#' || str.substring(0, 3) === '// ')
6289+
continue;
6290+
6291+
var index = str.indexOf(' :');
6292+
if (index === -1) {
6293+
index = str.indexOf('\t:');
6294+
if (index === -1)
6295+
continue;
6296+
}
6297+
6298+
var key = str.substring(0, index).trim();
6299+
var url = str.substring(index + 2).trim();
6300+
var options = {};
6301+
6302+
index = url.indexOf('-->');
6303+
6304+
if (index !== -1) {
6305+
var opt = url.substring(index + 3).trim();
6306+
if (opt.isJSON())
6307+
options = JSON.parse(opt);
6308+
url = url.substring(0, index).trim();
6309+
}
6310+
6311+
switch (key) {
6312+
case 'package':
6313+
case 'packages':
6314+
case 'pkg':
6315+
self.install('package', url, options);
6316+
break;
6317+
case 'module':
6318+
case 'modules':
6319+
self.install('module', url, options);
6320+
break;
6321+
case 'model':
6322+
case 'models':
6323+
self.install('model', url, options);
6324+
break;
6325+
case 'source':
6326+
case 'sources':
6327+
self.install('source', url, options);
6328+
break;
6329+
case 'controller':
6330+
case 'controllers':
6331+
self.install('controller', url, options);
6332+
break;
6333+
case 'controller':
6334+
case 'controllers':
6335+
self.install('controller', url, options);
6336+
break;
6337+
case 'view':
6338+
case 'views':
6339+
self.install('view', url, options);
6340+
break;
6341+
case 'version':
6342+
case 'versions':
6343+
self.install('version', url, options);
6344+
break;
6345+
case 'config':
6346+
case 'configuration':
6347+
self.install('config', url, options);
6348+
break;
6349+
case 'isomorphic':
6350+
case 'isomorphics':
6351+
self.install('isomorphic', url, options);
6352+
break;
6353+
case 'definition':
6354+
case 'definitions':
6355+
self.install('definition', url, options);
6356+
break;
6357+
case 'middleware':
6358+
case 'middlewares':
6359+
self.install('middleware', url, options);
6360+
break;
6361+
}
6362+
}
6363+
6364+
return self;
6365+
};
6366+
62636367
/**
62646368
* Versions configuration
62656369
* @private
@@ -6271,14 +6375,11 @@ Framework.prototype._configure_versions = function(content) {
62716375
var self = this;
62726376

62736377
if (content === undefined) {
6274-
62756378
var filename = framework_utils.combine('/', 'versions');
6276-
62776379
if (fs.existsSync(filename))
62786380
content = fs.readFileSync(filename).toString(ENCODING);
62796381
else
62806382
content = '';
6281-
62826383
self.versions = null;
62836384
}
62846385

minify/merged/total.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

minify/total.js/bin/total

Lines changed: 0 additions & 1 deletion
Large diffs are not rendered by default.

minify/total.js/index.js

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function Framework() {
219219

220220
this.id = null;
221221
this.version = 1810;
222-
this.version_header = '1.8.1-46';
222+
this.version_header = '1.8.1-47';
223223

224224
var version = process.version.toString().replace('v', '').replace(/\./g, '');
225225
if (version[1] === '0')
@@ -1755,6 +1755,10 @@ Framework.prototype.$load = function(types) {
17551755
}
17561756

17571757
self._routesSort();
1758+
1759+
if (!types || types.indexOf('dependencies') !== -1)
1760+
self._configure_dependencies();
1761+
17581762
return self;
17591763
};
17601764

@@ -6281,6 +6285,106 @@ Framework.prototype.translator = function(language, text) {
62816285
return framework_internal.parseLocalization(text, language);
62826286
};
62836287

6288+
Framework.prototype._configure_dependencies = function(content) {
6289+
6290+
if (content === undefined) {
6291+
var filename = framework_utils.combine('/', 'dependencies');
6292+
if (fs.existsSync(filename))
6293+
content = fs.readFileSync(filename).toString(ENCODING);
6294+
else
6295+
content = '';
6296+
}
6297+
6298+
var self = this;
6299+
6300+
if (!content)
6301+
return self;
6302+
6303+
var arr = content.split('\n');
6304+
6305+
for (var i = 0, length = arr.length; i < length; i++) {
6306+
6307+
var str = arr[i];
6308+
6309+
if (str === '' || str[0] === '#' || str.substring(0, 3) === '// ')
6310+
continue;
6311+
6312+
var index = str.indexOf(' :');
6313+
if (index === -1) {
6314+
index = str.indexOf('\t:');
6315+
if (index === -1)
6316+
continue;
6317+
}
6318+
6319+
var key = str.substring(0, index).trim();
6320+
var url = str.substring(index + 2).trim();
6321+
var options = {};
6322+
6323+
index = url.indexOf('-->');
6324+
6325+
if (index !== -1) {
6326+
var opt = url.substring(index + 3).trim();
6327+
if (opt.isJSON())
6328+
options = JSON.parse(opt);
6329+
url = url.substring(0, index).trim();
6330+
}
6331+
6332+
switch (key) {
6333+
case 'package':
6334+
case 'packages':
6335+
case 'pkg':
6336+
self.install('package', url, options);
6337+
break;
6338+
case 'module':
6339+
case 'modules':
6340+
self.install('module', url, options);
6341+
break;
6342+
case 'model':
6343+
case 'models':
6344+
self.install('model', url, options);
6345+
break;
6346+
case 'source':
6347+
case 'sources':
6348+
self.install('source', url, options);
6349+
break;
6350+
case 'controller':
6351+
case 'controllers':
6352+
self.install('controller', url, options);
6353+
break;
6354+
case 'controller':
6355+
case 'controllers':
6356+
self.install('controller', url, options);
6357+
break;
6358+
case 'view':
6359+
case 'views':
6360+
self.install('view', url, options);
6361+
break;
6362+
case 'version':
6363+
case 'versions':
6364+
self.install('version', url, options);
6365+
break;
6366+
case 'config':
6367+
case 'configuration':
6368+
self.install('config', url, options);
6369+
break;
6370+
case 'isomorphic':
6371+
case 'isomorphics':
6372+
self.install('isomorphic', url, options);
6373+
break;
6374+
case 'definition':
6375+
case 'definitions':
6376+
self.install('definition', url, options);
6377+
break;
6378+
case 'middleware':
6379+
case 'middlewares':
6380+
self.install('middleware', url, options);
6381+
break;
6382+
}
6383+
}
6384+
6385+
return self;
6386+
};
6387+
62846388
/**
62856389
* Versions configuration
62866390
* @private
@@ -6292,14 +6396,11 @@ Framework.prototype._configure_versions = function(content) {
62926396
var self = this;
62936397

62946398
if (content === undefined) {
6295-
62966399
var filename = framework_utils.combine('/', 'versions');
6297-
62986400
if (fs.existsSync(filename))
62996401
content = fs.readFileSync(filename).toString(ENCODING);
63006402
else
63016403
content = '';
6302-
63036404
self.versions = null;
63046405
}
63056406

minify/total.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@
6565
"scripts": {
6666
"test": "echo \"Error: no test specified\" && exit 1"
6767
},
68-
"version": "1.8.1-46"
68+
"version": "1.8.1-47"
6969
}

minify/total.js/utils.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3151,6 +3151,72 @@ Number.prototype.format = function(decimals, separator, separatorDecimal) {
31513151
return minus + output + (dec.length > 0 ? separatorDecimal + dec : '');
31523152
};
31533153

3154+
Number.prototype.add = function(value, decimals) {
3155+
3156+
if (value === undefined || value === null)
3157+
return this;
3158+
3159+
if (typeof(value) === NUMBER)
3160+
return this + value;
3161+
3162+
var first = value.charCodeAt(0);
3163+
var is = false;
3164+
3165+
if (first < 48 || first > 57) {
3166+
is = true;
3167+
value = value.substring(1);
3168+
}
3169+
3170+
var length = value.length;
3171+
var isPercentage = false;
3172+
var num;
3173+
3174+
if (value[length - 1] === '%') {
3175+
value = value.substring(0, length - 1);
3176+
isPercentage = true;
3177+
3178+
if (is) {
3179+
var tmp = ((value.parseFloat() / 100) + 1);
3180+
if (first === 43 || first === 42)
3181+
num = this * tmp;
3182+
else
3183+
num = this / tmp;
3184+
return decimals !== undefined ? num.floor(decimals) : num;
3185+
} else {
3186+
num = (this / 100) * value.parseFloat();
3187+
return decimals !== undefined ? num.floor(decimals) : num;
3188+
}
3189+
3190+
} else
3191+
num = value.parseFloat();
3192+
3193+
switch (first) {
3194+
case 42:
3195+
num = this * num;
3196+
break;
3197+
case 43:
3198+
num = this + num;
3199+
break;
3200+
case 45:
3201+
num = this - num;
3202+
break;
3203+
case 47:
3204+
num = this / num;
3205+
break;
3206+
case 47:
3207+
num = this / num;
3208+
break;
3209+
default:
3210+
num = this;
3211+
break;
3212+
}
3213+
3214+
if (decimals !== undefined)
3215+
return num.floor(decimals);
3216+
3217+
return num;
3218+
};
3219+
31543220
/*
31553221
Format number :: 10000 = 10 000
31563222
@format {Number or String} :: number is decimal and string is specified format, example: ## ###.##
@@ -4686,4 +4752,4 @@ exports.minifyHTML = function(value) {
46864752

46874753
global.async = exports.async;
46884754
global.sync = global.SYNCHRONIZE = exports.sync;
4689-
global.sync2 = exports.sync2;
4755+
global.sync2 = exports.sync2;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@
6565
"scripts": {
6666
"test": "echo \"Error: no test specified\" && exit 1"
6767
},
68-
"version": "1.8.1-46"
68+
"version": "1.8.1-47"
6969
}

test/dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module : https://www.totaljs.com/framework/include.js --> {"test":true}

0 commit comments

Comments
 (0)