feature(server) combine: add minify

This commit is contained in:
coderaiser 2013-11-25 14:53:16 +00:00
parent d9957c52d7
commit 2864512018

View file

@ -170,7 +170,7 @@
lRet = Util.exec(Route, lData);
if (!lRet)
lRet = combine(lPath, pRes);
lRet = combine(lData);
if (!lRet) {
lName = lData.name;
@ -204,19 +204,37 @@
}
}
function combine(path, res) {
var names,
function combine(params) {
var names, i, n, name, minName,
config = main.config,
dir = DIR,
COMBINE = '/combine',
p = params,
path = params.name,
COMBINE = '/combine/',
isCombine = Util.isContainStrAtBegin(path, COMBINE);
if (isCombine) {
path = Util.removeStrOneTime(path, COMBINE);
names = path.split(':');
console.log(names, DIR);
files.readPipe(names, dir, res, function(error) {
Util.log(error);
main.sendError(res);
n = names.length;
if (config.minify)
for (i = 0; i < n; i++) {
name = Path.join(DIR, names[i]);
minName = Minify.getName(name);
if (name !== minName) {
names[i] = minName;
dir = '';
}
}
console.log(names);
files.readPipe(names, dir, p.response, function(error) {
if (error) {
Util.log(error);
main.sendError(params, error);
}
});
}