mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) add readIndex; when minify - index to
This commit is contained in:
parent
7385fd6242
commit
8a08fef833
1 changed files with 39 additions and 20 deletions
59
cloudcmd.js
59
cloudcmd.js
|
|
@ -239,9 +239,7 @@
|
|||
if (lRet) {
|
||||
p = pParams;
|
||||
main.commander.getDirContent(p.name, function(pError, pJSON) {
|
||||
var lQuery, isJSON, lPanel, lList,
|
||||
config = main.config,
|
||||
minify = config.minify;
|
||||
var lQuery, isJSON;
|
||||
|
||||
if (pError)
|
||||
main.sendError(pParams, pError);
|
||||
|
|
@ -249,31 +247,52 @@
|
|||
lQuery = main.getQuery(p.request);
|
||||
isJSON = Util.isContainStr(lQuery, 'json');
|
||||
|
||||
if (isJSON) {
|
||||
if (!isJSON)
|
||||
readIndex(pJSON, pParams);
|
||||
else {
|
||||
p.data = Util.stringifyJSON(pJSON);
|
||||
p.name +='.json';
|
||||
main.sendResponse(p, null, true);
|
||||
} else
|
||||
fs.readFile(INDEX_PATH, 'utf8', function(error, template) {
|
||||
if (error)
|
||||
main.sendError(p, error);
|
||||
else {
|
||||
p.name = INDEX_PATH,
|
||||
lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate),
|
||||
lList = '<div id=left class=panel>' + lPanel + '</div>' +
|
||||
'<div id=right class=panel>' + lPanel + '</div>';
|
||||
|
||||
main.sendResponse(p, indexProcessing({
|
||||
additional : lList,
|
||||
data : template,
|
||||
}), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function readIndex(pJSON, params) {
|
||||
var p = params;
|
||||
|
||||
Util.ifExec(!minify, function(params) {
|
||||
var name = params && params.name;
|
||||
|
||||
fs.readFile(name || INDEX_PATH, 'utf8', function(error, template) {
|
||||
var lPanel, lList,
|
||||
config = main.config,
|
||||
minify = config.minify;
|
||||
|
||||
if (error)
|
||||
main.sendError(p, error);
|
||||
else {
|
||||
p.name = INDEX_PATH,
|
||||
lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate),
|
||||
lList = '<div id=left class=panel>' + lPanel + '</div>' +
|
||||
'<div id=right class=panel>' + lPanel + '</div>';
|
||||
|
||||
main.sendResponse(p, indexProcessing({
|
||||
additional : lList,
|
||||
data : template,
|
||||
}), true);
|
||||
}
|
||||
});
|
||||
}, function(callback) {
|
||||
Minify.optimize(INDEX_PATH, {
|
||||
callback : callback,
|
||||
returnName : true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* function sets stdout to file log.txt */
|
||||
function writeLogsToFile() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue