From c66577f79fec3ef6942bf7e0668d6e9415979e2d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Oct 2013 09:27:03 +0000 Subject: [PATCH 001/152] docs(help) install: add "\n" --- HELP.md | 1 + 1 file changed, 1 insertion(+) diff --git a/HELP.md b/HELP.md index 4a0a55a1..a74296a2 100644 --- a/HELP.md +++ b/HELP.md @@ -36,6 +36,7 @@ Install Installing **Cloud Commander** is very simple. All you need is + - install [node.js](http://nodejs.org/ "node.js") - [download](https://github.com/coderaiser/cloudcmd/archive/master.zip) and unpack or just clone repository from github: From 5a9c75975e73eb4051ba71ae38136dea9b9ac586 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Oct 2013 15:37:22 +0000 Subject: [PATCH 002/152] feature(util) log: add if lArg[0] --- lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 9ed142a2..d56a8180 100644 --- a/lib/util.js +++ b/lib/util.js @@ -395,7 +395,7 @@ Util = exports || {}; lShift = Util.bind([].shift, lArg), lJoin = Util.bind([].join, lArg); - if (lConsole && lArg.length) { + if (lConsole && lArg.length && lArg[0]) { lUnShift(lDate); lConsole.log.apply(lConsole, lArg); lShift(); From fed2eccdfbcfe97e976c1292bf9230e637f884b8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Oct 2013 15:49:36 +0000 Subject: [PATCH 003/152] feature(cloudcmd) change logs: rm pathname, request, name; add method, data --- cloudcmd.js | 2 +- lib/server.js | 7 +------ lib/server/main.js | 9 +++++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 3007fec2..4a72b2bf 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -325,7 +325,7 @@ main.sendResponse(p, indexProcessing({ additional : lList, data : pData.toString(), - })); + }), true); } else main.sendError(pParams, pError); diff --git a/lib/server.js b/lib/server.js index a9eaad10..205059a2 100644 --- a/lib/server.js +++ b/lib/server.js @@ -150,9 +150,7 @@ /* added supporting of Russian language in directory names */ lPath = Querystring.unescape(lPath); - Util.log('pathname: ' + lPath); - - Util.log("request for " + lPath + " received..."); + Util.log(pReq.method + ': ' + lPath); var lData = { name : lPath, @@ -168,14 +166,11 @@ if(!lRet) { lName = lData.name; - Util.log('reading ' + lName); /* watching is file changed */ if(lConfig.appcache) AppCache.watch(lName); - Util.log(Path.basename(lName)); - lName = Path.join(DIR, lName); lMin = Minify.allowed, lExt = Util.getExtension(lName), diff --git a/lib/server/main.js b/lib/server/main.js index 49c5d2bf..a983c73b 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -258,7 +258,7 @@ * @param Data - данные * @param pName - имя отсылаемого файла */ - function sendResponse(pParams, pData){ + function sendResponse(pParams, pData, pNotLog) { var lRet = checkParams(pParams); if(lRet){ @@ -273,7 +273,10 @@ gzip : lGzip, query : lQuery }); - + + if (!pNotLog) + Util.log(pData || p.data); + /* если браузер поддерживает gzip-сжатие - сжимаем данные*/ Util.ifExec(!lGzip, function(pParams) { @@ -286,8 +289,6 @@ p.response.writeHead(p.status || OK, lHead); p.response.end(p.data); - - Util.log( p.name + ' sended'); }, function(pCallBack) { From 94de61a218ea3de63739fc26ff8dd87bded31f9a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Oct 2013 16:08:37 +0000 Subject: [PATCH 004/152] feature(cloudcmd) sendResponse: p -> p, null, true --- cloudcmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudcmd.js b/cloudcmd.js index 4a72b2bf..5a3de550 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -312,7 +312,7 @@ if ( Util.isContainStr(lQuery, 'json') ){ p.data = Util.stringifyJSON(pJSON); p.name +='.json'; - main.sendResponse(p); + main.sendResponse(p, null, true); } else{ /* get back html*/ p.name = Minify.allowed ? Minify.getName(INDEX) : INDEX; From fdc5f0c932f3b80a86af6e7fafe4ea5adbbb6a1b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Oct 2013 16:08:57 +0000 Subject: [PATCH 005/152] feature(server) add query --- lib/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index 205059a2..34889c39 100644 --- a/lib/server.js +++ b/lib/server.js @@ -146,11 +146,12 @@ var lRet, lName, lMin, lExt, lResult, lConfig = main.config, lParsedUrl = URL.parse(pReq.url), + lQuery = lParsedUrl.search || '', lPath = lParsedUrl.pathname; /* added supporting of Russian language in directory names */ lPath = Querystring.unescape(lPath); - Util.log(pReq.method + ': ' + lPath); + Util.log(pReq.method + ': ' + lPath + lQuery); var lData = { name : lPath, From b08fd9b4b1ffeef7979645ed3a2d706a01558d8a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Oct 2013 16:09:11 +0000 Subject: [PATCH 006/152] chore(main) sendResponse --- lib/server/main.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index a983c73b..1ace21f8 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -262,9 +262,8 @@ var lRet = checkParams(pParams); if(lRet){ - var p = pParams; - - var lQuery = getQuery(p.request), + var p = pParams, + lQuery = getQuery(p.request), /* download, json */ lGzip = isGZIP(p.request), lHead = generateHeaders({ From e44486c092a360db7dd73d6e7ce96084f04a9e27 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 07:12:05 +0000 Subject: [PATCH 007/152] refactor(cloudcmd) init: Config always is --- cloudcmd.js | 119 +++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 63 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 5a3de550..14ccfe84 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -162,71 +162,64 @@ } Util.log('server dir: ' + lServerDir); - Util.log('reading configuration file config.json...'); - if (Config) { - Util.log('config.json readed'); - - /* if command line parameter testing resolved - * setting config to testing, so server - * not created, just init and - * all logs writed to screen */ - lArg = process.argv; - lArg = lArg[lArg.length - 1]; - - if ( lArg === 'test' || lArg === 'test\r') { - Util.log(process.argv); - Config.server = false; - } - - if (Config.logs) { - Util.log('log param setted up in config.json\n' + - 'from now all logs will be writed to log.txt'); - writeLogsToFile(); - } - - if (Config.server) - Util.tryCatchLog(function(){ - fs.watch(CONFIG_PATH, function(){ - /* every catch up - calling twice */ - setTimeout(function() { - readConfig(); - }, 1000); - }); - }); - - lParams = { - appcache : appCacheProcessing, - minimize : minimize, - rest : rest, - route : route - }, - - lFiles = [FILE_TMPL, PATH_TMPL]; - - if (Config.ssl) - lFiles.push(CA, KEY, CERT); - - main.readFiles(lFiles, function(pErrors, pFiles){ - if (pErrors) - Util.log(pErrors); - else { - FileTemplate = pFiles[FILE_TMPL].toString(); - PathTemplate = pFiles[PATH_TMPL].toString(); - - if (Config.ssl) - lParams.ssl = { - ca : pFiles[CA], - key : pFiles[KEY], - cert : pFiles[CERT] - }; - - server.start(lParams); - } - }); + /* if command line parameter testing resolved + * setting config to testing, so server + * not created, just init and + * all logs writed to screen */ + lArg = process.argv; + lArg = lArg[lArg.length - 1]; + + if ( lArg === 'test' || lArg === 'test\r') { + Util.log(process.argv); + Config.server = false; } - else - Util.log('read error: config.json'); + + if (Config.logs) { + Util.log('log param setted up in config.json\n' + + 'from now all logs will be writed to log.txt'); + writeLogsToFile(); + } + + if (Config.server) + Util.tryCatchLog(function(){ + fs.watch(CONFIG_PATH, function(){ + /* every catch up - calling twice */ + setTimeout(function() { + readConfig(); + }, 1000); + }); + }); + + lParams = { + appcache : appCacheProcessing, + minimize : minimize, + rest : rest, + route : route + }, + + lFiles = [FILE_TMPL, PATH_TMPL]; + + if (Config.ssl) + lFiles.push(CA, KEY, CERT); + + main.readFiles(lFiles, function(pErrors, pFiles){ + if (pErrors) + Util.log(pErrors); + else { + FileTemplate = pFiles[FILE_TMPL].toString(); + PathTemplate = pFiles[PATH_TMPL].toString(); + + if (Config.ssl) + lParams.ssl = { + ca : pFiles[CA], + key : pFiles[KEY], + cert : pFiles[CERT] + }; + + server.start(lParams); + } + }); } function readConfig(pCallBack){ From 2c8edb698c8e557e5c9e944816df86d4b70dde0e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 07:30:32 +0000 Subject: [PATCH 008/152] refactor(cloudcmd) readConfig: add formatMsg --- cloudcmd.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 14ccfe84..86051331 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -224,8 +224,9 @@ function readConfig(pCallBack){ fs.readFile(CONFIG_PATH, function(pError, pData){ + var msg, status; if (!pError){ - Util.log('config: readed'); + status = 'ok'; var lStr = pData.toString(), lReadedConf = Util.parseJSON(lStr); @@ -241,7 +242,10 @@ }); } else - Util.log(pError); + status = 'error'; + + msg = CloudFunc.formatMsg('read', 'config', status); + Util.log(msg); Util.exec(pCallBack); }); From a57058dbda82adad8e9a8d5c8df804563260743f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 08:08:56 +0000 Subject: [PATCH 009/152] feature(main) readFiles: add formatMsg --- lib/server/main.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 1ace21f8..b30921cc 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -11,7 +11,7 @@ SLASH, ISWIN32, ext, - path, fs, zlib, url, pipe, + path, fs, zlib, url, pipe, CloudFunc, OK, FILE_NOT_FOUND, MOVED_PERMANENTLY, REQUEST, RESPONSE, @@ -105,7 +105,7 @@ exports.socket = srvrequire('socket'), exports.auth = srvrequire('auth').auth, exports.appcache = srvrequire('appcache'), - exports.cloudfunc = librequire('cloudfunc'), + exports.cloudfunc = CloudFunc = librequire('cloudfunc'), exports.dir = srvrequire('dir'), exports.rest = srvrequire('rest').api, exports.update = srvrequire('update'), @@ -370,7 +370,8 @@ lErrors, lReadedFiles = {}, lDoneFunc = function (pParams){ - var lRet = Util.checkObj(pParams, ['error', 'data', 'params']); + var msg, status, + lRet = Util.checkObj(pParams, ['error', 'data', 'params']); if(lRet){ lDone.pop(); @@ -378,15 +379,21 @@ lName = p.params; if(p.error){ + status = 'error'; if(!lErrors) lErrors = {}; lErrors[lName] = p.error; } else{ - Util.log(lName + ' readed'); + status = 'ok'; lReadedFiles[lName] = p.data; } + lName = path.basename(lName); + msg = CloudFunc.formatMsg('read', lName, status); + + Util.log(msg); + if( !lDone.length ) Util.exec(pCallBack, lErrors, lReadedFiles); } From d849ecd168b6b5ad338930cf7c0cf904cb7cb0f1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 08:12:20 +0000 Subject: [PATCH 010/152] feature(socket) rm flashsocket --- lib/server/socket.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 04dd4412..fbc8f027 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -63,7 +63,6 @@ lListen.set('transports', [ 'websocket', - 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling' From 9fc5e881865d93dfb24e6fb243aeed0ac43f7232 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 08:57:57 +0000 Subject: [PATCH 011/152] feature(cloudfunc) formatMsg: add empty name condition --- lib/cloudfunc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 207c89fb..f9d24a12 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -43,7 +43,8 @@ var Util, exports, CloudFunc = {}; CloudFunc.formatMsg = function(pMsg, pName, pStatus) { var status = pStatus || 'ok', - msg = pMsg + ': ' + status + '("' + pName + '")'; + name = !pName ? '': '("' + pName + '")', + msg = pMsg + ': ' + status + name; return msg; }; From 117ad39043a2af3f641b6d204dcdaa4054668f1b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 08:58:15 +0000 Subject: [PATCH 012/152] feature(server) change socket msg --- lib/server.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/server.js b/lib/server.js index 34889c39..4de38e78 100644 --- a/lib/server.js +++ b/lib/server.js @@ -20,6 +20,7 @@ Querystring = main.querystring, Minify = main.minify, + CloudFunc = main.cloudfunc, AppCache = main.appcache, Socket = main.socket, @@ -80,11 +81,15 @@ lHTTPS = 'https://', lSockets = function(pServer) { - var lListen; - if(lConfig.socket && Socket) + var lListen, msg, status; + + if (lConfig.socket && Socket) lListen = Socket.listen(pServer); - Util.log('* Sockets ' + (lListen ? 'running' : 'disabled')); + status = lListen ? 'on' : 'off'; + msg = CloudFunc.formatMsg('sockets', '', status); + + Util.log(msg); }, lHTTPServer = function() { From 261f6a4435c92fe167df3dbf493da49f0a1961bb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 13:12:09 +0300 Subject: [PATCH 013/152] feature(package) rm "node": "0.6.17" --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index cbdedebf..d325d417 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "test": "sh ./test/test.sh", "start": "cloudcmd.js" }, - "node": "0.6.17", "subdomain": "cloudcmd", "dependencies": { "dropbox": "0.10.1", From f6d3929dc42cb81dc53bb453985b60878374065d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 13:13:03 +0300 Subject: [PATCH 014/152] chore(package) github.com/coderaiser/cloudcmd -> cloudcmd.io --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d325d417..7c65d42f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.5.0", "author": "coderaiser (https://github.com/coderaiser)", "description": "Cloud Commander - file manager with console and editor", - "homepage": "https://github.com/coderaiser/cloudcmd", + "homepage": "http://cloudcmd.io", "repository": { "type": "git", "url": "git://github.com/coderaiser/cloudcmd.git" From dad01ae9d5a661a57e951dc6b6285d7109ce1a76 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 10:21:14 +0000 Subject: [PATCH 015/152] featuer(procfile) heroku: add --- Procfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..e24c4096 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node cloudcmd.js \ No newline at end of file From e74c64d0bdd7e7ce6dcea414fe80b5c780a13946 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 10:35:37 +0000 Subject: [PATCH 016/152] docs(help) Demo -> Live, add jitsu --- HELP.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index a74296a2..dd497ee8 100644 --- a/HELP.md +++ b/HELP.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] [Demo][DemoURL] +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -13,7 +13,8 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [NPM_INFO_URL]: https://npmjs.org/package/cloudcmd "npm" [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" -[DemoURL]: http://io.cloudcmd.io "Demo" +[IOURL]: http://io.cloudcmd.io "IO" +[jitSuURL]: http://cloudcmd.jit.su "JitSu" **Cloud Commander** - cloud file manager with console and editor. From 8e38017ae5827674f3f84dfa64e57dbb2e773981 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 10:36:50 +0000 Subject: [PATCH 017/152] docs(readme) Demo -> Live, add jitsu --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e115f3e6..53b4da86 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] [Demo][DemoURL] +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -13,7 +13,8 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [NPM_INFO_URL]: https://npmjs.org/package/cloudcmd "npm" [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" -[DemoURL]: http://io.cloudcmd.io "Demo" +[IOURL]: http://io.cloudcmd.io "IO" +[jitSuURL]: http://cloudcmd.jit.su "JitSu" **Cloud Commander** - cloud file manager with console and editor. From 280e32a5bab4fb7cafafba117a67c56934367f66 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:34:55 +0000 Subject: [PATCH 018/152] chore(server) add " " --- lib/server.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/server.js b/lib/server.js index 4de38e78..f2e2c17f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,7 +1,7 @@ (function() { 'use strict'; - if(!global.cloudcmd) + if (!global.cloudcmd) return console.log( '# server.js' + '\n' + '# -----------' + '\n' + @@ -44,7 +44,7 @@ Util.exec(Minimize, lMinifyAllowed); /* создаём файл app cache */ - if( lConfig.appcache && AppCache && lConfig.server ) + if (lConfig.appcache && AppCache && lConfig.server ) Util.exec( pAppCachProcessing ); } @@ -57,7 +57,7 @@ function start(pProcessing) { var lConfig = main.config; - if(!pProcessing) + if (!pProcessing) pProcessing = {}; Rest = pProcessing.rest; @@ -70,7 +70,7 @@ process.env.app_port || /* nodester */ process.env.VCAP_APP_PORT || /* cloudfoundry */ lConfig.port, - + lIP = process.env.IP || /* c9 */ lConfig.ip || (main.WIN32 ? '127.0.0.1' : '0.0.0.0'), @@ -132,10 +132,9 @@ Server.listen(lSSLPort, lIP); lServerLog(lHTTPS, lSSLPort); - } - else + } else lHTTPServer(); - }else + } else Util.log('Cloud Commander testing mode'); } @@ -164,17 +163,17 @@ response : pRes }; - if( lConfig.rest ) + if (lConfig.rest ) lRet = Util.exec(Rest, lData); - if( !lRet && Route) + if (!lRet && Route) lRet = Util.exec(Route, lData); - if(!lRet) { + if (!lRet) { lName = lData.name; /* watching is file changed */ - if(lConfig.appcache) + if (lConfig.appcache) AppCache.watch(lName); lName = Path.join(DIR, lName); From 4b5df3f8009867a1326498f5fb220a60ee684c13 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:37:05 +0000 Subject: [PATCH 019/152] chore(server) rm " " --- cloudcmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudcmd.js b/cloudcmd.js index 86051331..2e3ea81d 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -161,7 +161,7 @@ process.chdir(lServerDir); } - Util.log('server dir: ' + lServerDir); + Util.log('server dir: ' + lServerDir); /* if command line parameter testing resolved * setting config to testing, so server From a937a4aa6037d298bc5e39cb829a52329d50af30 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:43:41 +0000 Subject: [PATCH 020/152] docs(help, readme) add heroku --- HELP.md | 3 ++- README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index dd497ee8..f099c5b4 100644 --- a/HELP.md +++ b/HELP.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL], [Heroku][HerokuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -15,6 +15,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" [jitSuURL]: http://cloudcmd.jit.su "JitSu" +[HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index 53b4da86..e3de6f3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL], [Heroku][HerokuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -15,6 +15,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" [jitSuURL]: http://cloudcmd.jit.su "JitSu" +[HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. From d7240a52ccae077d976063f7e8da67ac1f9fa2ee Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:47:19 +0000 Subject: [PATCH 021/152] docs(help, readme) jitSuURL -> JitSuURL --- HELP.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index f099c5b4..fba25070 100644 --- a/HELP.md +++ b/HELP.md @@ -14,7 +14,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" -[jitSuURL]: http://cloudcmd.jit.su "JitSu" +[JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index e3de6f3b..df9bab81 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" -[jitSuURL]: http://cloudcmd.jit.su "JitSu" +[JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. From deb50dbe8c6a3aaf8449f3c35e4bb427ed4c0895 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 10:35:37 +0000 Subject: [PATCH 022/152] docs(help) Demo -> Live, add jitsu --- HELP.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index a74296a2..dd497ee8 100644 --- a/HELP.md +++ b/HELP.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] [Demo][DemoURL] +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -13,7 +13,8 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [NPM_INFO_URL]: https://npmjs.org/package/cloudcmd "npm" [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" -[DemoURL]: http://io.cloudcmd.io "Demo" +[IOURL]: http://io.cloudcmd.io "IO" +[jitSuURL]: http://cloudcmd.jit.su "JitSu" **Cloud Commander** - cloud file manager with console and editor. From b960545ea2c22a6ecce1d4b622a80397ed24b8cc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 10:36:50 +0000 Subject: [PATCH 023/152] docs(readme) Demo -> Live, add jitsu --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e115f3e6..53b4da86 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] [Demo][DemoURL] +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -13,7 +13,8 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [NPM_INFO_URL]: https://npmjs.org/package/cloudcmd "npm" [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" -[DemoURL]: http://io.cloudcmd.io "Demo" +[IOURL]: http://io.cloudcmd.io "IO" +[jitSuURL]: http://cloudcmd.jit.su "JitSu" **Cloud Commander** - cloud file manager with console and editor. From b4330b7f470816215791626df8d46be693e3feb3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:34:55 +0000 Subject: [PATCH 024/152] chore(server) add " " --- lib/server.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/server.js b/lib/server.js index 4de38e78..f2e2c17f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,7 +1,7 @@ (function() { 'use strict'; - if(!global.cloudcmd) + if (!global.cloudcmd) return console.log( '# server.js' + '\n' + '# -----------' + '\n' + @@ -44,7 +44,7 @@ Util.exec(Minimize, lMinifyAllowed); /* создаём файл app cache */ - if( lConfig.appcache && AppCache && lConfig.server ) + if (lConfig.appcache && AppCache && lConfig.server ) Util.exec( pAppCachProcessing ); } @@ -57,7 +57,7 @@ function start(pProcessing) { var lConfig = main.config; - if(!pProcessing) + if (!pProcessing) pProcessing = {}; Rest = pProcessing.rest; @@ -70,7 +70,7 @@ process.env.app_port || /* nodester */ process.env.VCAP_APP_PORT || /* cloudfoundry */ lConfig.port, - + lIP = process.env.IP || /* c9 */ lConfig.ip || (main.WIN32 ? '127.0.0.1' : '0.0.0.0'), @@ -132,10 +132,9 @@ Server.listen(lSSLPort, lIP); lServerLog(lHTTPS, lSSLPort); - } - else + } else lHTTPServer(); - }else + } else Util.log('Cloud Commander testing mode'); } @@ -164,17 +163,17 @@ response : pRes }; - if( lConfig.rest ) + if (lConfig.rest ) lRet = Util.exec(Rest, lData); - if( !lRet && Route) + if (!lRet && Route) lRet = Util.exec(Route, lData); - if(!lRet) { + if (!lRet) { lName = lData.name; /* watching is file changed */ - if(lConfig.appcache) + if (lConfig.appcache) AppCache.watch(lName); lName = Path.join(DIR, lName); From 823bfecec7ff6dc7b2d66180d2fe4364823e0e46 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:37:05 +0000 Subject: [PATCH 025/152] chore(server) rm " " --- cloudcmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudcmd.js b/cloudcmd.js index 86051331..2e3ea81d 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -161,7 +161,7 @@ process.chdir(lServerDir); } - Util.log('server dir: ' + lServerDir); + Util.log('server dir: ' + lServerDir); /* if command line parameter testing resolved * setting config to testing, so server From d5190e5338d9ff2b12c9b548db4cac77d82f2844 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:43:41 +0000 Subject: [PATCH 026/152] docs(help, readme) add heroku --- HELP.md | 3 ++- README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index dd497ee8..f099c5b4 100644 --- a/HELP.md +++ b/HELP.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL], [Heroku][HerokuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -15,6 +15,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" [jitSuURL]: http://cloudcmd.jit.su "JitSu" +[HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index 53b4da86..e3de6f3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL]) +###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL], [Heroku][HerokuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -15,6 +15,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" [jitSuURL]: http://cloudcmd.jit.su "JitSu" +[HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. From f1c8e129ace92d1e42b968891c5db0132426c2c8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 11:47:19 +0000 Subject: [PATCH 027/152] docs(help, readme) jitSuURL -> JitSuURL --- HELP.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index f099c5b4..fba25070 100644 --- a/HELP.md +++ b/HELP.md @@ -14,7 +14,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" -[jitSuURL]: http://cloudcmd.jit.su "JitSu" +[JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index e3de6f3b..df9bab81 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [MainURL]: http://cloudcmd.io "Main" [BlogURL]: http://blog.cloudcmd.io "Blog" [IOURL]: http://io.cloudcmd.io "IO" -[jitSuURL]: http://cloudcmd.jit.su "JitSu" +[JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" **Cloud Commander** - cloud file manager with console and editor. From f78c40d0d1c2f5b267da8bbfda7a7c3ac32b8284 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 18 Oct 2013 14:45:14 +0000 Subject: [PATCH 028/152] chore(cloudfunc) add " " --- lib/cloudfunc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index f9d24a12..5a9cab15 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -21,7 +21,7 @@ var Util, exports, CloudFunc = {}; Util = global.cloudcmd.main.util; CloudFunc = exports; } - + /* Путь с которым мы сейчас работаем */ CloudFunc.Path = ''; From 9d93812f308e0f12ba66936b8a18794fa253349c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 10:08:51 +0300 Subject: [PATCH 029/152] docs(help) "like that" -> "this way:" --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index fba25070..ba077b93 100644 --- a/HELP.md +++ b/HELP.md @@ -203,7 +203,7 @@ in your list they could differ). ``` ###nginx -Get [nginx](http://nginx.org/ "nginx"). On linux it could be done like that +Get [nginx](http://nginx.org/ "nginx"). On linux it could be done this way: ```sh sudo apt-get install nginx #for ubuntu and debian From 762606a2697be40f3a977c3e86d492e03f50551e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 10:21:12 +0000 Subject: [PATCH 030/152] feature(dom) addOneTime -> addOnce --- lib/client.js | 2 +- lib/client/dom.js | 2 +- lib/client/listeners.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/client.js b/lib/client.js index 76c94959..412fa576 100644 --- a/lib/client.js +++ b/lib/client.js @@ -505,5 +505,5 @@ var Util, DOM, CloudFunc, CloudCmd; return Util.stringifyJSON(lFileTable); } - DOM.Events.addOneTime('load', CloudCmd.init); + DOM.Events.addOnce('load', CloudCmd.init); })(Util, DOM); diff --git a/lib/client/dom.js b/lib/client/dom.js index eed2f535..42c3f88b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -343,7 +343,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - this.addOneTime = function(pType, pListener, pElement, pUseCapture) { + this.addOnce = function(pType, pListener, pElement, pUseCapture) { var lRet = this, lOneTime = function (pEvent) { lRet.remove(pType, lOneTime, pElement, pUseCapture); diff --git a/lib/client/listeners.js b/lib/client/listeners.js index a509ec0e..c624a10d 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -16,7 +16,7 @@ var Util, DOM, CloudCmd; online = config.online; if (analytics && online) { - Events.addOneTime('mousemove', function(){ + Events.addOnce('mousemove', function(){ var FIVE_SECONDS = 5000, lUrl = CloudCmd.LIBDIRCLIENT + 'analytics.js'; @@ -60,7 +60,7 @@ var Util, DOM, CloudCmd; lKeysPanel[lButton] = lEl; if (i === 1 || i === 3 || i === 4 || i === 9) - Events.addOneTime('click', lFuncs[i], lEl); + Events.addOnce('click', lFuncs[i], lEl); else Events.addClick(lFuncs[i], lEl); } @@ -68,7 +68,7 @@ var Util, DOM, CloudCmd; lButton = '~', lEl = DOM.getById('~'); lKeysPanel[lButton] = lEl; - Events.addOneTime('click', CloudCmd.Console, lEl); + Events.addOnce('click', CloudCmd.Console, lEl); return lKeysPanel; }; @@ -301,7 +301,7 @@ var Util, DOM, CloudCmd; }); if (navigator.onLine) - Events.addOneTime('offline', cssSet); + Events.addOnce('offline', cssSet); else cssSet(); } From 996877f1c248b81fb0a34023a18939177d17e558 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 10:24:23 +0000 Subject: [PATCH 031/152] feature(help) add margin: 25px --- lib/client/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/help.js b/lib/client/help.js index e6a54f28..7d26166e 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -34,7 +34,7 @@ var CloudCmd, Util, DOM; success:function(pResult){ var lDiv = DOM.anyload({ name : 'div', - style : 'white-space: normal;', + style : 'white-space: normal; margin: 25px', inner : pResult.toString() }); From bed4543a6ff18e037e51a062911fe84e963477d3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 10:44:10 +0000 Subject: [PATCH 032/152] feature(cloudcmd) retExec -> retFunc --- lib/client.js | 2 +- lib/client/dom.js | 2 +- lib/client/listeners.js | 2 +- lib/client/menu.js | 10 +++++----- lib/client/socket.js | 2 +- lib/server/dir.js | 2 +- lib/server/rest.js | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/client.js b/lib/client.js index 412fa576..b5dbbd28 100644 --- a/lib/client.js +++ b/lib/client.js @@ -143,7 +143,7 @@ var Util, DOM, CloudFunc, CloudCmd; lCallBack = function(){ Util.loadOnLoad([ - Util.retExec(CloudCmd.route, location.hash), + Util.retFunc(CloudCmd.route, location.hash), baseInit, initModules, ]); diff --git a/lib/client/dom.js b/lib/client/dom.js index 42c3f88b..450e8314 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -114,7 +114,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lText) { Util.log(lText); - setTimeout(Util.retExec(alert, lText), 100); + setTimeout(Util.retFunc(alert, lText), 100); } return lErrorImage; diff --git a/lib/client/listeners.js b/lib/client/listeners.js index c624a10d..1e62bb42 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -291,7 +291,7 @@ var Util, DOM, CloudCmd; } function online() { - var cssSet = Util.retExec(DOM.cssSet, { + var cssSet = Util.retFunc(DOM.cssSet, { id :'local-droids-font', element : document.head, inner : '@font-face {font-family: "Droid Sans Mono";' + diff --git a/lib/client/menu.js b/lib/client/menu.js index d35f51bb..3f1d8bfd 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -174,12 +174,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; function getConfig (){ var lRet, lMenuItems = { - 'View' : Util.retExec(show, 'View'), - 'Edit' : Util.retExec(show, 'Edit'), + 'View' : Util.retFunc(show, 'View'), + 'Edit' : Util.retFunc(show, 'Edit'), 'Rename' : function(){ - setTimeout( Util.retExec(DOM.renameCurrent), 100); + setTimeout( Util.retFunc(DOM.renameCurrent), 100); }, - 'Delete' : Util.retExec(DOM.promptDeleteSelected), + 'Delete' : Util.retFunc(DOM.promptDeleteSelected), '(Un)Select All': DOM.toggleAllSelectedFiles, 'Zip file' : DOM.zipFile }; @@ -187,7 +187,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; if (UploadToItemNames.length) lMenuItems['Upload to'] = getUploadToItems(UploadToItemNames); - lMenuItems.Download = Util.retExec(downloadFromMenu); + lMenuItems.Download = Util.retFunc(downloadFromMenu); lMenuItems.New = { 'File' : DOM.promptNewFile, diff --git a/lib/client/socket.js b/lib/client/socket.js index f3ac82fe..7ff57c0c 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -11,7 +11,7 @@ var CloudCmd, Util, DOM, io; 'npm i socket.io'; DOM.jsload('/socket.io/lib/socket.io.js', { - onerror : Util.retExec(Util.log, ERROR_MSG), + onerror : Util.retFunc(Util.log, ERROR_MSG), onload : connect }); diff --git a/lib/server/dir.js b/lib/server/dir.js index 817e7517..781bfe7b 100644 --- a/lib/server/dir.js +++ b/lib/server/dir.js @@ -80,7 +80,7 @@ for (var i = 0; i < n; i++) { lDirPath = path.join(lPath, pFiles[i]); - process.nextTick( Util.retExec(getDirInfo, lDirPath) ); + process.nextTick(Util.retFunc(getDirInfo, lDirPath)); } } diff --git a/lib/server/rest.js b/lib/server/rest.js index ea27d266..e35acb53 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -176,7 +176,7 @@ var lFiles = Util.parseJSON(pBody), n = lFiles.length, lDir = p.name, - log = Util.retExec(Util.log), + log = Util.log, lAssync = 0; function stat(pStat) { @@ -191,7 +191,7 @@ if (p.error){ main.sendError(pParams, p.error); - Util.log(p.error); + log(p.error); } else if (p.data.isDirectory()) From b9a3e4330af53078417d1a9bf61aac321c0d1e49 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 11:03:00 +0000 Subject: [PATCH 033/152] feature(util) checkObj: add trace --- lib/util.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/util.js b/lib/util.js index d56a8180..a07af434 100644 --- a/lib/util.js +++ b/lib/util.js @@ -119,6 +119,7 @@ Util = exports || {}; var lProp = pPropArr[i]; lRet = pObj.hasOwnProperty( lProp ); if (!lRet) { + console.trace(); Util.logError(lProp + ' not in Obj!'); Util.log(pObj); break; @@ -152,6 +153,7 @@ Util = exports || {}; lRet = pObj[lProp]; if (!lRet) { + console.trace(); Util.logError(lProp + ' not true!'); Util.log(pObj); break; From cda210b8d5a7df33bc918c8de19f48debbd137d9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 11:15:20 +0000 Subject: [PATCH 034/152] feature(main) mrequire: add formatMsg --- lib/server/main.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index b30921cc..442df33a 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -122,13 +122,15 @@ * @param {Strin} pSrc */ function mrequire(pSrc){ - var lModule, - lError = Util.tryCatch(function(){ - lModule = require(pSrc); - }); + var lModule, msg, + lError = Util.tryCatch(function() { + lModule = require(pSrc); + }); if(lError) - Util.log('Module ' + pSrc + ' not connected'); + msg = CloudFunc.formatMsg('require', pSrc, 'error'); + + Util.log(msg); return lModule; } From 825fac1f6e4fb9abf428823a3ca8a6ba6646d615 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 11:19:54 +0000 Subject: [PATCH 035/152] chore(cloudcmd) add " ": "){" -> ") {"; "if(" -> "if (" --- cloudcmd.js | 48 ++++++++++---------- lib/client.js | 106 ++++++++++++++++++++++----------------------- lib/server/main.js | 78 ++++++++++++++++----------------- lib/util.js | 2 +- 4 files changed, 117 insertions(+), 117 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 2e3ea81d..8e293918 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; var DIR = __dirname + '/', @@ -86,7 +86,7 @@ /** * init and process of appcache if it allowed in config */ - function appCacheProcessing(){ + function appCacheProcessing() { var lFONT_REMOTE = '//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff', lFONT_LOCAL = './font/DroidSansMono.woff', lJQUERY_REMOTE = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', @@ -107,7 +107,7 @@ * Функция минимизирует css/js/html * если установлены параметры минимизации */ - function minimize(pAllowed){ + function minimize(pAllowed) { var lOptimizeParams = [], lStyles = [{}, {}], lStyleCSS = DIR + 'css/style.css', @@ -139,11 +139,11 @@ * rest interface * @pParams pConnectionData {request, responce} */ - function rest(pConnectionData){ + function rest(pConnectionData) { return Util.exec(main.rest, pConnectionData); } - function init(){ + function init() { var lServerDir, lArg, lParams, lFiles; if (update) @@ -182,8 +182,8 @@ } if (Config.server) - Util.tryCatchLog(function(){ - fs.watch(CONFIG_PATH, function(){ + Util.tryCatchLog(function() { + fs.watch(CONFIG_PATH, function() { /* every catch up - calling twice */ setTimeout(function() { readConfig(); @@ -203,7 +203,7 @@ if (Config.ssl) lFiles.push(CA, KEY, CERT); - main.readFiles(lFiles, function(pErrors, pFiles){ + main.readFiles(lFiles, function(pErrors, pFiles) { if (pErrors) Util.log(pErrors); else { @@ -222,10 +222,10 @@ }); } - function readConfig(pCallBack){ - fs.readFile(CONFIG_PATH, function(pError, pData){ + function readConfig(pCallBack) { + fs.readFile(CONFIG_PATH, function(pError, pData) { var msg, status; - if (!pError){ + if (!pError) { status = 'ok'; var lStr = pData.toString(), @@ -234,7 +234,7 @@ if (!Config.minify) main.config = Config = lReadedConf; - Util.tryCatchLog(function(){ + Util.tryCatchLog(function() { Config.minify = lReadedConf.minify; Config.cache = lReadedConf.cache; @@ -254,13 +254,13 @@ /** * routing of server queries */ - function route(pParams){ + function route(pParams) { var lRet = main.checkParams(pParams); - if (lRet){ + if (lRet) { var p = pParams; - if ( Util.strCmp(p.name, ['/auth', '/auth/github']) ){ + if ( Util.strCmp(p.name, ['/auth', '/auth/github']) ) { Util.log('* Routing' + '-> ' + p.name); @@ -277,14 +277,14 @@ return lRet; } - function sendCommanderContent(pParams){ + function sendCommanderContent(pParams) { var p, lRet = main.checkParams(pParams); - if (lRet){ + if (lRet) { p = pParams; p.name = Util.removeStrOneTime(p.name, CloudFunc.FS) || main.SLASH; - fs.stat(p.name, function(pError, pStat){ + fs.stat(p.name, function(pError, pStat) { if (!pError) if ( pStat.isDirectory() ) processCommanderContent(pParams); @@ -298,22 +298,22 @@ return lRet; } - function processCommanderContent(pParams){ + function processCommanderContent(pParams) { var lRet = main.checkParams(pParams); - if (lRet){ + if (lRet) { var p = pParams; - main.commander.getDirContent(p.name, function(pError, pJSON){ - if (!pError){ + main.commander.getDirContent(p.name, function(pError, pJSON) { + if (!pError) { var lQuery = main.getQuery(p.request); - if ( Util.isContainStr(lQuery, 'json') ){ + if ( Util.isContainStr(lQuery, 'json') ) { p.data = Util.stringifyJSON(pJSON); p.name +='.json'; main.sendResponse(p, null, true); } else{ /* get back html*/ p.name = Minify.allowed ? Minify.getName(INDEX) : INDEX; - fs.readFile(p.name, function(pError, pData){ + fs.readFile(p.name, function(pError, pData) { if (!pError) { var lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), lList = '
    ' + lPanel + '
' + diff --git a/lib/client.js b/lib/client.js index b5dbbd28..d9118657 100644 --- a/lib/client.js +++ b/lib/client.js @@ -4,7 +4,7 @@ */ var Util, DOM, CloudFunc, CloudCmd; -(function(Util, DOM){ +(function(Util, DOM) { 'use strict'; var Key, Config, Modules, FileTemplate, PathTemplate, Listeners, @@ -19,7 +19,7 @@ var Util, DOM, CloudFunc, CloudCmd; MIN_ONE_PANEL_WIDTH : 1155, OLD_BROWSER : false, - HOST : (function(){ + HOST : (function() { var lLocation = document.location; return lLocation.protocol + '//' + lLocation.host; })() @@ -32,8 +32,8 @@ var Util, DOM, CloudFunc, CloudCmd; * @param pLink - ссылка * @param pNeedRefresh - необходимость обязательной загрузки данных с сервера */ - CloudCmd.loadDir = function(pLink, pNeedRefresh){ - return function(pEvent){ + CloudCmd.loadDir = function(pLink, pNeedRefresh) { + return function(pEvent) { /* показываем гиф загрузки возле пути папки сверху * ctrl+r нажата? */ @@ -43,7 +43,7 @@ var Util, DOM, CloudFunc, CloudCmd; lLink += '?json'; - if(lLink || lCurrentLink.target !== '_blank'){ + if (lLink || lCurrentLink.target !== '_blank') { DOM.Images.showLoad(pNeedRefresh ? {top:true} : null); /* загружаем содержимое каталога */ @@ -61,13 +61,13 @@ var Util, DOM, CloudFunc, CloudCmd; * в верх по файловой структуре * @param pDirName - имя каталога с которого мы пришли */ - function currentToParent(pDirName){ + function currentToParent(pDirName) { var lRootDir; /* убираем слэш с имени каталога */ pDirName = Util.removeStr(pDirName, '/'); lRootDir = DOM.getCurrentFileByName(pDirName); - if (lRootDir){ + if (lRootDir) { DOM.setCurrentFile(lRootDir); DOM.scrollIntoViewIfNeeded(lRootDir, true); } @@ -77,36 +77,36 @@ var Util, DOM, CloudFunc, CloudCmd; * function load modules * @pParams = {name, path, func, dobefore, arg} */ - function loadModule(pParams){ - if(pParams){ + function loadModule(pParams) { + if (pParams) { var lName = pParams.name, lPath = pParams.path, lFunc = pParams.func, lDoBefore = pParams.dobefore; - if( Util.isString(pParams) ) + if ( Util.isString(pParams) ) lPath = pParams; - if(lPath && !lName){ + if (lPath && !lName) { lName = Util.getStrBigFirst(lPath); lName = Util.removeStr(lName, '.js'); var lSlash = lName.indexOf('/'); - if(lSlash > 0){ + if (lSlash > 0) { var lAfterSlash = lName.substr(lSlash); lName = Util.removeStr(lName, lAfterSlash); } } - if( !Util.isContainStr(lPath, '.js') ) + if ( !Util.isContainStr(lPath, '.js') ) lPath += '.js'; - if(!CloudCmd[lName]) - CloudCmd[lName] = function(pArg){ + if (!CloudCmd[lName]) + CloudCmd[lName] = function(pArg) { Util.exec(lDoBefore); return DOM.jsload(CloudCmd.LIBDIRCLIENT + lPath, lFunc || - function(){ + function() { Util.exec(CloudCmd[lName].init, pArg); }); }; @@ -117,7 +117,7 @@ var Util, DOM, CloudFunc, CloudCmd; * выполняет весь функционал по * инициализации */ - CloudCmd.init = function(){ + CloudCmd.init = function() { var lCallBack, lFunc, lHeight; /* устанавливаем размер высоты таблицы файлов * исходя из размеров разрешения экрана @@ -141,14 +141,14 @@ var Util, DOM, CloudFunc, CloudCmd; '}' }); - lCallBack = function(){ + lCallBack = function() { Util.loadOnLoad([ Util.retFunc(CloudCmd.route, location.hash), baseInit, initModules, ]); }, - lFunc = function(pCallBack){ + lFunc = function(pCallBack) { CloudCmd.OLD_BROWSER = true; var lSrc = CloudCmd.LIBDIRCLIENT + 'polyfill.js'; @@ -160,7 +160,7 @@ var Util, DOM, CloudFunc, CloudCmd; Util.ifExec(document.body.scrollIntoViewIfNeeded, lCallBack, lFunc); }; - CloudCmd.route = function(pPath){ + CloudCmd.route = function(pPath) { var lQuery, lModule, lFile, lCurrent, lMsg; if (pPath.length > 0) { @@ -181,11 +181,11 @@ var Util, DOM, CloudFunc, CloudCmd; } }; - function initModules(pCallBack){ + function initModules(pCallBack) { loadModule({ /* привязываем клавиши к функциям */ path : 'key.js', - func : function(){ + func : function() { Key = CloudCmd.Key; Key.bind(); } @@ -214,14 +214,14 @@ var Util, DOM, CloudFunc, CloudCmd; for (i = 0, n = pModules.length; i < n ; i++) { var lModule = pModules[i]; - if( Util.isString(lModule) ) + if ( Util.isString(lModule) ) lLoad(null, lModule, lDoBefore[lModule]); } var lStorageObj = Util.findObjByNameInArr( pModules, lStorage ), lMod = Util.getNamesFromObjArray( lStorageObj ); - for (i = 0, n = lMod.length; i < n; i++){ + for (i = 0, n = lMod.length; i < n; i++) { var lName = lMod[i], lPath = lStorage + '/_' + lName.toLowerCase(); @@ -270,7 +270,7 @@ var Util, DOM, CloudFunc, CloudCmd; /* выделяем строку с первым файлом */ var lFmHeader = DOM.getByClass('fm-header'); - if(lFmHeader && lFmHeader[0]){ + if (lFmHeader && lFmHeader[0]) { var lCurrent = lFmHeader[0].nextSibling; DOM.setCurrentFile(lCurrent); } @@ -282,14 +282,14 @@ var Util, DOM, CloudFunc, CloudCmd; CloudCmd.Key(); } - function getSystemFile(pGlobal, pURL){ + function getSystemFile(pGlobal, pURL) { - function lGetSysFile(pCallBack){ - Util.ifExec(pGlobal, pCallBack, function(pCallBack){ - if(!pGlobal) + function lGetSysFile(pCallBack) { + Util.ifExec(pGlobal, pCallBack, function(pCallBack) { + if (!pGlobal) DOM.ajax({ url : pURL, - success : function(pLocal){ + success : function(pLocal) { pGlobal = pLocal; Util.exec(pCallBack, pLocal); } @@ -307,20 +307,20 @@ var Util, DOM, CloudFunc, CloudCmd; CloudCmd.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); CloudCmd.getPathTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'path.html'); - CloudCmd.execFromModule = function(pModuleName, pFuncName, pParams){ + CloudCmd.execFromModule = function(pModuleName, pFuncName, pParams) { var lObject = CloudCmd[pModuleName]; Util.ifExec(Util.isObject(lObject), - function(){ + function() { var lObj = CloudCmd[pModuleName]; Util.exec( lObj[pFuncName], pParams); }, - function(pCallBack){ + function(pCallBack) { Util.exec(lObject, pCallBack); }); }; - CloudCmd.refresh = function(pCurrent){ + CloudCmd.refresh = function(pCurrent) { var lNEEDREFRESH = true, lPanel = pCurrent && pCurrent.parentElement, lPath = DOM.getCurrentDirPath(lPanel), @@ -338,8 +338,8 @@ var Util, DOM, CloudFunc, CloudCmd; * @param pOptions * { refresh, nohistory } - необходимость обновить данные о каталоге */ - CloudCmd.ajaxLoad = function(pPath, pOptions){ - if(!pOptions) + CloudCmd.ajaxLoad = function(pPath, pOptions) { + if (!pOptions) pOptions = {}; /* Отображаем красивые пути */ @@ -350,12 +350,12 @@ var Util, DOM, CloudFunc, CloudCmd; lOldURL = window.location.pathname; - if(lCleanPath === lSLASH) + if (lCleanPath === lSLASH) lNOJSPath = lSLASH; Util.log ('reading dir: "' + lCleanPath + '";'); - if(!pOptions.nohistory) + if (!pOptions.nohistory) DOM.setHistory(lNOJSPath, null, lNOJSPath); DOM.setTitle( CloudFunc.getTitle(lCleanPath) ); @@ -369,10 +369,10 @@ var Util, DOM, CloudFunc, CloudCmd; * перезагружаемся */ var lRet = pOptions.refresh; - if(!lRet){ + if (!lRet) { var lJSON = Cache.get(lCleanPath); - if (lJSON){ + if (lJSON) { lJSON = Util.parseJSON(lJSON); createFileTable(lPanel, lJSON); } @@ -380,17 +380,17 @@ var Util, DOM, CloudFunc, CloudCmd; lRet = true; } - if(lRet) + if (lRet) DOM.getCurrentFileContent({ url : lFSPath, dataType: 'json', - error : function(){ + error : function() { DOM.setHistory(lOldURL, null, lOldURL); }, - success : function(pData){ + success : function(pData) { createFileTable(lPanel, pData); /* переводим таблицу файлов в строку, для * @@ -400,7 +400,7 @@ var Util, DOM, CloudFunc, CloudCmd; /* если размер данных не очень бошьой * * сохраняем их в кэше */ - if(lJSON_s.length < 50000 ) + if (lJSON_s.length < 50000 ) Cache.set(lCleanPath, lJSON_s); } }); @@ -411,7 +411,7 @@ var Util, DOM, CloudFunc, CloudCmd; * @param pEleme - родительский элемент * @param pJSON - данные о файлах */ - function createFileTable(pElem, pJSON){ + function createFileTable(pElem, pJSON) { var lElem = DOM.getById(pElem), /* getting current element if was refresh */ lPath = DOM.getByClass('path', lElem), @@ -438,28 +438,28 @@ var Util, DOM, CloudFunc, CloudCmd; /* если нажали на ссылку на верхний каталог*/ var lFound; /* searching current file */ - if(lWasRefresh_b){ + if (lWasRefresh_b) { var n = lElem.childNodes.length; - for(i = 2; i < n ; i++){ + for(i = 2; i < n ; i++) { var lVarCurrent = lElem.childNodes[i], lVarName = DOM.getCurrentName(lVarCurrent); lFound = lVarName === lName; - if(lFound){ + if (lFound) { lCurrent = lElem.childNodes[i]; break; } } } - if(!lFound) /* .. */ + if (!lFound) /* .. */ lCurrent = lElem.childNodes[2]; DOM.setCurrentFile(lCurrent); Listeners.changeLinks(pElem); - if(lName === '..' && lDir !== '/') + if (lName === '..' && lDir !== '/') currentToParent(lDir); }); } @@ -468,7 +468,7 @@ var Util, DOM, CloudFunc, CloudCmd; * Функция генерирует JSON из html-таблицы файлов и * используеться при первом заходе в корень */ - function getJSONfromFileTable(){ + function getJSONfromFileTable() { var lLeft = DOM.getById('left'), lPath = DOM.getByClass('path')[0].textContent, @@ -487,7 +487,7 @@ var Util, DOM, CloudFunc, CloudCmd; */ /* пропускам Path и Header*/ - for(i = 2, n = lLI.length; i < n; i++){ + for(i = 2, n = lLI.length; i < n; i++) { var lCurrent = lLI[i], lName = DOM.getCurrentName(lCurrent), lSize = DOM.getCurrentSize(lCurrent), @@ -495,7 +495,7 @@ var Util, DOM, CloudFunc, CloudCmd; lMode = DOM.getCurrentMode(lCurrent); lMode = CloudFunc.getNumericPermissions(lMode); - if(lName !== '..') + if (lName !== '..') lFileTable[ j++ ] = { name: lName, size: lSize, diff --git a/lib/server/main.js b/lib/server/main.js index 442df33a..4308fda6 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; /* Global var accessible from any loaded module */ @@ -121,13 +121,13 @@ * function do safe require of needed module * @param {Strin} pSrc */ - function mrequire(pSrc){ + function mrequire(pSrc) { var lModule, msg, lError = Util.tryCatch(function() { lModule = require(pSrc); }); - if(lError) + if (lError) msg = CloudFunc.formatMsg('require', pSrc, 'error'); Util.log(msg); @@ -135,37 +135,37 @@ return lModule; } - function quietrequire(pSrc){ + function quietrequire(pSrc) { var lModule; - Util.tryCatch(function(){ + Util.tryCatch(function() { lModule = require(pSrc); }); return lModule; } - function rootrequire(pSrc){ return mrequire(DIR + pSrc); } + function rootrequire(pSrc) { return mrequire(DIR + pSrc); } - function librequire(pSrc){ return mrequire(LIBDIR + pSrc); } + function librequire(pSrc) { return mrequire(LIBDIR + pSrc); } - function srvrequire(pSrc){ return mrequire(SRVDIR + pSrc); } + function srvrequire(pSrc) { return mrequire(SRVDIR + pSrc); } - function jsonrequire(pSrc){ return mrequire(JSONDIR + pSrc);} + function jsonrequire(pSrc) { return mrequire(JSONDIR + pSrc);} /** * function check is current platform is win32 */ - function isWin32(){ return process.platform === 'win32'; } + function isWin32() { return process.platform === 'win32'; } /** * get volumes if win32 or get nothing if nix */ - function getVolumes(){ + function getVolumes() { var lRet = ISWIN32 ? [] : '/'; - if(ISWIN32) - srvrequire('win').getVolumes(function(pVolumes){ + if (ISWIN32) + srvrequire('win').getVolumes(function(pVolumes) { console.log(pVolumes); exports.VOLUMES = pVolumes; }); @@ -183,20 +183,20 @@ * query * https://developers.google.com/speed/docs/best-practices/caching?hl=ru#LeverageProxyCaching */ - function generateHeaders(pParams){ + function generateHeaders(pParams) { var lRet = Util.checkObjTrue(pParams, ['name']); - if(lRet){ + if (lRet) { var p = pParams, lExt = Util.getExtension(p.name), lType = ext[lExt] || 'text/plain', lContentEncoding = ''; /* if type of file any, but img - then we shoud specify charset */ - if( !Util.isContainStr(lType, 'img') ) + if ( !Util.isContainStr(lType, 'img') ) lContentEncoding = '; charset=UTF-8'; - if( Util.isContainStr(p.query, 'download') ) + if ( Util.isContainStr(p.query, 'download') ) lType = 'application/octet-stream'; lRet = { @@ -206,10 +206,10 @@ 'Vary' : 'Accept-Encoding' }; - if( !Util.strCmp(lExt, '.appcache') && p.cache) + if (!Util.strCmp(lExt, '.appcache') && p.cache) lRet['cache-control'] = 'max-age=' + 31337 * 21; - if(p.gzip) + if (p.gzip) lRet['content-encoding'] = 'gzip'; } @@ -223,7 +223,7 @@ * @param pName - имя файла * @param pGzip - данные сжаты gzip'ом */ - function sendFile(pParams){ + function sendFile(pParams) { var lRet = checkParams(pParams); if (lRet) { var p = pParams, @@ -263,7 +263,7 @@ function sendResponse(pParams, pData, pNotLog) { var lRet = checkParams(pParams); - if(lRet){ + if (lRet) { var p = pParams, lQuery = getQuery(p.request), /* download, json */ @@ -283,7 +283,7 @@ function(pParams) { var lRet = Util.checkObj(pParams, ['data']); - if(lRet) { + if (lRet) { p.status = pParams.status || p.status; p.data = pParams.data; } @@ -304,11 +304,11 @@ /** * redirect to another URL */ - function redirect(pParams){ + function redirect(pParams) { var lRet = Util.checkObjTrue(pParams, [RESPONSE]); - if(lRet){ + if (lRet) { var p = pParams; p.response.writeHead(MOVED_PERMANENTLY, {'Location': p.url}); @@ -339,18 +339,18 @@ * @param pHeader - заголовок файла * @pName */ - function gzipData(pParams){ + function gzipData(pParams) { var lRet = checkCallBackParams(pParams), p = pParams; - if(lRet) + if (lRet) lRet = Util.checkObj(pParams.params, ['callback']); - if(lRet){ + if (lRet) { var lCallBack = p.params.callback, lParams = {}; - if(!p.error) + if (!p.error) lParams.data = p.data; else{ lParams.status = FILE_NOT_FOUND; @@ -362,27 +362,27 @@ } - function checkCallBackParams(pParams){ + function checkCallBackParams(pParams) { return Util.checkObj(pParams, ['error', 'data', 'params']); } - function readFiles(pFiles, pCallBack){ + function readFiles(pFiles, pCallBack) { var lDone = [], lFiles, lErrors, lReadedFiles = {}, - lDoneFunc = function (pParams){ + lDoneFunc = function (pParams) { var msg, status, lRet = Util.checkObj(pParams, ['error', 'data', 'params']); - if(lRet){ + if (lRet) { lDone.pop(); var p = pParams, lName = p.params; - if(p.error){ + if (p.error) { status = 'error'; - if(!lErrors) lErrors = {}; + if (!lErrors) lErrors = {}; lErrors[lName] = p.error; } @@ -396,12 +396,12 @@ Util.log(msg); - if( !lDone.length ) + if ( !lDone.length ) Util.exec(pCallBack, lErrors, lReadedFiles); } }; - if( Util.isArray(pFiles) ) + if ( Util.isArray(pFiles) ) lFiles = pFiles; else lFiles = [pFiles]; @@ -414,7 +414,7 @@ } } - function checkParams(pParams, pAdditional){ + function checkParams(pParams, pAdditional) { var lRet = Util.checkObjTrue( pParams, ['name', REQUEST, RESPONSE] ); if (lRet && pAdditional) @@ -423,7 +423,7 @@ return lRet; } - function getQuery(pReq){ + function getQuery(pReq) { var lQuery, lParsedUrl; if (pReq) { @@ -434,7 +434,7 @@ return lQuery; } - function isGZIP(pReq){ + function isGZIP(pReq) { var lEnc, lGZIP; if (pReq) { lEnc = pReq.headers['accept-encoding'] || ''; diff --git a/lib/util.js b/lib/util.js index a07af434..c360c2ba 100644 --- a/lib/util.js +++ b/lib/util.js @@ -30,7 +30,7 @@ Util = exports || {}; } function callCheckFunc(pNum, pFunc) { - Util.exec(pFunc, function(pData){ + Util.exec(pFunc, function(pData) { checkFunc(pNum, pData); }); } From d653744000214e8e772b53036176bfae0bf24216 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 12:32:17 +0000 Subject: [PATCH 036/152] feature(server) controller log: rm ":" --- lib/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index f2e2c17f..779075de 100644 --- a/lib/server.js +++ b/lib/server.js @@ -155,7 +155,7 @@ /* added supporting of Russian language in directory names */ lPath = Querystring.unescape(lPath); - Util.log(pReq.method + ': ' + lPath + lQuery); + Util.log(pReq.method + ' ' + lPath + lQuery); var lData = { name : lPath, From f52f122a6b20c195ae5a459707c230534e5e21d3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 12:50:53 +0000 Subject: [PATCH 037/152] feature(help) show: add cssSet, list-style-type --- lib/client/help.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/client/help.js b/lib/client/help.js index 7d26166e..8db66811 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -23,6 +23,18 @@ var CloudCmd, Util, DOM; this.show = function(){ Images.showLoad({top:true}); + DOM.cssSet({ + id : 'help-css', + inner : '#help {' + + 'white-space' + ': normal;' + + 'margin' + ': 25px;' + + '}' + + + '#help li {' + + 'list-style-type' + ': disc;' + + '}' + }); + DOM.ajax({ url: '/HELP.md', success: function (pData){ @@ -34,7 +46,7 @@ var CloudCmd, Util, DOM; success:function(pResult){ var lDiv = DOM.anyload({ name : 'div', - style : 'white-space: normal; margin: 25px', + id : 'help', inner : pResult.toString() }); From 6b2fd62cb1d45a920f9b69c638a302e8720258c5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 13:42:39 +0000 Subject: [PATCH 038/152] feature(dom) add Dialog --- lib/client/dom.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 450e8314..8a8193b6 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1,4 +1,4 @@ -var CloudCmd, Util, DOM, CloudFunc; +var CloudCmd, Util, DOM, CloudFunc, Dialog; (function(Util) { 'use strict'; @@ -6,6 +6,11 @@ var CloudCmd, Util, DOM, CloudFunc; var DOMFunc = function() {}, DOMProto, + DialogProto = function() { + this.alert = alert.bind(window); + this.prompt = prompt.bind(window); + }, + ImagesProto = function() { var LImagesProto = function() { function getImage(pName) { @@ -114,7 +119,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lText) { Util.log(lText); - setTimeout(Util.retFunc(alert, lText), 100); + setTimeout(Util.retFunc(Dialog.alert, lText), 100); } return lErrorImage; @@ -1098,7 +1103,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lName === '..') lName = ''; - lName = prompt(lMsg, lName); + lName = Dialog.prompt(lMsg, lName); if (lName) RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh); @@ -1175,7 +1180,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lName !== '..') lRet = confirm(lMsg); else - alert('No files selected!'); + Dialog.alert('No files selected!'); if (lRet) { var lUrl; @@ -1813,7 +1818,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lCurrent = pCurrentFile || Cmd.getCurrentFile(), lFrom = Cmd.getCurrentName(lCurrent), - lTo = prompt('Rename', lFrom) || lFrom, + lTo = Dialog.prompt('Rename', lFrom) || lFrom, lDirPath = Cmd.getCurrentDirPath(); if ( !Util.strCmp(lFrom, lTo) ) { @@ -1842,7 +1847,7 @@ var CloudCmd, Util, DOM, CloudFunc; lFromPath = Cmd.getCurrentPath(), lToPath = Cmd.getNotCurrentDirPath() + lName; - lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); + lToPath = Dialog.prompt('Rename/Move file "' + lName + '"', lToPath); if ( lToPath && !Util.strCmp(lFromPath, lToPath) ) { var lFiles = { @@ -1875,7 +1880,7 @@ var CloudCmd, Util, DOM, CloudFunc; lName = Cmd.getCurrentName(lCurrent), lFromPath = Cmd.getCurrentPath(), lToPath = Cmd.getNotCurrentDirPath() + lName; - lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); + lToPath = Dialog.prompt( 'Copy file "' + lName + '" to', lToPath ); if ( lToPath && !Util.strCmp(lFromPath, lToPath) ) { var lFiles = { @@ -1945,6 +1950,8 @@ var CloudCmd, Util, DOM, CloudFunc; DOMProto = DOMFunc.prototype = new CmdProto(); + Dialog = new DialogProto(); + Util.extend(DOMProto, [ DOMTree, Loader, { From 7d78246a7f7a09b510fc277672a0f75b573cca3a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 13:58:40 +0000 Subject: [PATCH 039/152] feature(dom) Dialog: add confirm --- lib/client/dom.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 8a8193b6..a837e40b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -7,8 +7,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOMProto, DialogProto = function() { - this.alert = alert.bind(window); - this.prompt = prompt.bind(window); + this.alert = alert.bind(window); + this.prompt = prompt.bind(window); + this.confirm = confirm.bind(window); }, ImagesProto = function() { @@ -1178,7 +1179,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } if (lName !== '..') - lRet = confirm(lMsg); + lRet = Dialog.confirm(lMsg); else Dialog.alert('No files selected!'); From 11647dc8ef3ed1c1a24f0053093452949e212593 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 12:58:26 +0300 Subject: [PATCH 040/152] feature(package) dropbox: 0.10.1 -> 0.10.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c65d42f..0dd0f7b0 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "subdomain": "cloudcmd", "dependencies": { - "dropbox": "0.10.1", + "dropbox": "0.10.2", "minify": "0.2.2", "socket.io": "0.9.16" }, From 0485f88b2d05b29d4ef3af1d4ec0723de9b57448 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 13:03:19 +0300 Subject: [PATCH 041/152] feature(package) add MIT --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0dd0f7b0..a0b90b36 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "socket.io": "0.9.16" }, "devDependencies": {}, + "license" : "MIT", "engines": { "node": ">=0.4.x" }, From cff91ed11c27cbebe3d135b8d12873587db32411 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 13:04:14 +0300 Subject: [PATCH 042/152] chore(package) rm " " --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0b90b36..0c0366ad 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "socket.io": "0.9.16" }, "devDependencies": {}, - "license" : "MIT", + "license": "MIT", "engines": { "node": ">=0.4.x" }, From da43ce1eccfff6bf30fc847d0540c830bd10e403 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 10:34:30 +0000 Subject: [PATCH 043/152] feature(client) getSystemFile: rm !pGlobal --- lib/client.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/client.js b/lib/client.js index d9118657..bfc4ec53 100644 --- a/lib/client.js +++ b/lib/client.js @@ -286,14 +286,13 @@ var Util, DOM, CloudFunc, CloudCmd; function lGetSysFile(pCallBack) { Util.ifExec(pGlobal, pCallBack, function(pCallBack) { - if (!pGlobal) - DOM.ajax({ - url : pURL, - success : function(pLocal) { - pGlobal = pLocal; - Util.exec(pCallBack, pLocal); - } - }); + DOM.ajax({ + url : pURL, + success : function(pLocal) { + pGlobal = pLocal; + Util.exec(pCallBack, pLocal); + } + }); }); } From 402696deecc9fb28cce1937aa2c377851489d90b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 11:01:28 +0000 Subject: [PATCH 044/152] feature(asyncCall) add any count of params --- lib/util.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/util.js b/lib/util.js index c360c2ba..e988253c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -12,26 +12,36 @@ Util = exports || {}; Util.asyncCall = function(pFuncs, pOnLoad, pContext) { var i, element, name, func, - n = pFuncs.length, + funcsCount = pFuncs.length, count = 0, data = []; - for (i = 0; i < n; i++) { + for (i = 0; i < funcsCount; i++) { func = pFuncs[i]; callCheckFunc(i, func); } function checkFunc(pNum, pData) { - ++count; - data[pNum] = pData; + var i, m = pData.length, + params = []; - if (count === n) + ++count; + + if (m >= 2) { + for (i = 0; i < m; i++) + params[i] = pData[i]; + + data[pNum] = params; + } else + data[pNum] = pData[0]; + + if (count === funcsCount) pOnLoad.apply(pContext, data); } function callCheckFunc(pNum, pFunc) { - Util.exec(pFunc, function(pData) { - checkFunc(pNum, pData); + Util.exec(pFunc, function() { + checkFunc(pNum, arguments); }); } }, From 8036e3be659fc6e791cbf61ec5683b912b7f65eb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 11:26:55 +0000 Subject: [PATCH 045/152] chore(commander) add " " --- lib/server/commander.js | 47 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index ea8de4ab..75782274 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -1,7 +1,7 @@ -(function(){ +(function() { 'use strict'; - if(!global.cloudcmd) + if (!global.cloudcmd) return console.log( '# commander.js' + '\n' + '# -----------' + '\n' + @@ -14,9 +14,10 @@ fs = main.fs, Util = main.util; - exports.getDirContent = function(pPath, pCallBack){ + exports.getDirContent = function(pPath, pCallBack) { var lRet = Util.isString(pPath); - if( lRet ) + + if (lRet) fs.readdir(pPath, Util.call(readDir, { callback: pCallBack, path : pPath @@ -33,16 +34,17 @@ * @param pError * @param pFiles */ - function readDir(pParams){ + function readDir(pParams) { var lRet = checkParams(pParams); lRet = lRet && Util.checkObj(pParams.params, ['path']); - if(lRet){ + + if (lRet) { var p = pParams, c = pParams.params, lFiles = p.data, lDirPath = getDirPath(c.path); - if(!p.error && lFiles){ + if (!p.error && lFiles) { lFiles.data = lFiles.sort(); /* Получаем информацию о файлах */ @@ -59,8 +61,8 @@ fillJSON(lFilesData); }; - if(n){ - for(var i = 0; i < n; i++){ + if (n) + for (var i = 0; i < n; i++) { var lName = lDirPath + lFiles[i], lParams = { callback : lFill, @@ -69,13 +71,11 @@ stats : lStats, }; - fs.stat( lName, Util.call(getFilesStat, lParams) ); + fs.stat(lName, Util.call(getFilesStat, lParams)); } - } else fillJSON(lFilesData); - } - else + } else Util.exec(c.callback, p.error.toString()); } } @@ -84,12 +84,12 @@ * async getting file states * and putting it to lStats object */ - function getFilesStat(pParams){ + function getFilesStat(pParams) { var lRet = checkParams(pParams); lRet = lRet && Util.checkObjTrue(pParams.params, ['callback', 'stats', 'name', 'count']); - if(lRet){ + if (lRet) { var p = pParams, c = p.params; @@ -99,7 +99,7 @@ 'isDirectory' : Util.retFalse }; - if(c.count === Object.keys(c.stats).length) + if (c.count === Object.keys(c.stats).length) Util.exec(c.callback); } } @@ -112,11 +112,10 @@ * * @param pFiles - array of files of current directory */ - function fillJSON(pParams){ + function fillJSON(pParams) { var lRet = Util.checkObjTrue(pParams, ['files', 'stats', 'path']); - if(lRet) - { + if (lRet) { var p = pParams, i, n = p.files.length || 0, @@ -131,12 +130,12 @@ }; var lName, lStats, lMode, lIsDir; - for( i = 0; i < n; i++ ){ + for (i = 0; i < n; i++ ) { /* Переводим права доступа в 8-ричную систему */ lName = p.files[i], lStats = p.stats[lName]; - if(lStats){ + if (lStats) { lMode = (lStats.mode - 0).toString(8), lIsDir = lStats.isDirectory(); } @@ -158,14 +157,14 @@ } } - function checkParams(pParams){ + function checkParams(pParams) { return Util.checkObj(pParams, ['error', 'data', 'params']); } - function getDirPath(pPath){ + function getDirPath(pPath) { var lRet = pPath; - if(lRet !== '/') + if (lRet !== '/') lRet += '/'; return lRet; From 64ac96651b0f831f46e04d19c53cc7c58a3c85d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 11:27:51 +0000 Subject: [PATCH 046/152] refactor(commander) function -> retFunc --- lib/server/commander.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 75782274..c2a50924 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -57,9 +57,7 @@ path : c.path }, - lFill = function(){ - fillJSON(lFilesData); - }; + lFill = Util.retFunc(fillJSON, lFilesData); if (n) for (var i = 0; i < n; i++) { From 6995cf8ad6c36323c5aa03e7f44725ad5f2568dd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 11:54:11 +0000 Subject: [PATCH 047/152] feature(edit) show: rm className --- lib/client/edit.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 6d99bd91..790ca5e3 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -49,7 +49,6 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; if (!Element) { Element = DOM.anyload({ name : 'div', - className : 'edit', style : 'width : 100%;' + 'height : 100%;' + From c1e771b61882357aff58291cf4e9bfe4617dd539 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 11:55:45 +0000 Subject: [PATCH 048/152] feature(edit) showMessage: ".msg" -> "#view .msg" --- lib/client/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 790ca5e3..0bc1bf46 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -160,7 +160,7 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; if (!Msg) { DOM.cssSet({ id : 'msg-css', - inner : '.msg {' + + inner : '#view .msg {' + 'z-index' + ': 1;' + 'background-color' + ': #7285B7;' + 'color' + ': #D1F1A9;' + From a00a8812591179043212e898cc0e7e8bf41df3d0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 22 Oct 2013 14:42:53 +0000 Subject: [PATCH 049/152] feature(socket) connect: rm reconnect, reconnect delay --- lib/client/socket.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/client/socket.js b/lib/client/socket.js index 7ff57c0c..d755e1bc 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -17,8 +17,6 @@ var CloudCmd, Util, DOM, io; function connect() { socket = io.connect(CloudCmd.HOST, { - 'reconnect' : true, - 'reconnection delay' : 500, 'max reconnection attempts' : Math.pow(2, 32), 'reconnect_failed' : function() { Util.log('Could not reconnect. Reload page.'); From c566639c320b1ba28785275e6954e2c9d22601ac Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 23 Oct 2013 08:35:31 +0000 Subject: [PATCH 050/152] feature(main) mrequire: error -> no --- lib/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index 4308fda6..816e7e6a 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -128,7 +128,7 @@ }); if (lError) - msg = CloudFunc.formatMsg('require', pSrc, 'error'); + msg = CloudFunc.formatMsg('require', pSrc, 'no'); Util.log(msg); From bb7156df5eeeb078dbc67aa10007eaffc86bcf81 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 23 Oct 2013 11:39:48 +0000 Subject: [PATCH 051/152] chore(socket) add " " --- lib/server/socket.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index fbc8f027..3b464717 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -1,6 +1,6 @@ /* module make possible connectoin thru socket.io on a server */ -(function(){ +(function() { 'use strict'; var main = global.cloudcmd.main, @@ -39,10 +39,10 @@ * function listen on servers port * @pServer {Object} started server object */ - exports.listen = function(pServer){ + exports.listen = function(pServer) { var lRet, lListen, lConnNum, lMsg, lConn_func; - if(io){ + if (io) { lListen = io.listen(pServer), lConnNum = 0; @@ -68,7 +68,7 @@ 'jsonp-polling' ]); - lRet = lListen.sockets.on('connection', function (socket){ + lRet = lListen.sockets.on('connection', function (socket) { ++lConnNum; if(!OnMessageFuncs[lConnNum]) { @@ -92,7 +92,7 @@ return lRet; }; - function disconnect(pParams){ + function disconnect(pParams) { var lConnNum, lRet = Util.checkObj(pParams, ['params']); if(lRet) { @@ -111,17 +111,17 @@ * * @param pConnNum, pSocket */ - function onMessage(pConnNum, pSocket){ + function onMessage(pConnNum, pSocket) { return function(pCommand) { var lMsg, lJSON, lWinCommand, lExec_func, lDir, lHome, lError, lRet; Util.log('#' + pConnNum + ': ' + pCommand); - if( Util.isContainStrAtBegin(pCommand, CLOUDCMD) ) { + if (Util.isContainStrAtBegin(pCommand, CLOUDCMD)) { pCommand = Util.removeStr(pCommand, CLOUDCMD); - if( Util.isContainStrAtBegin(pCommand, ' ') ){ + if( Util.isContainStrAtBegin(pCommand, ' ') ) { pCommand = Util.removeStr(pCommand, ' '); if( Util.isContainStrAtBegin(pCommand, 'update') && update ) @@ -153,7 +153,7 @@ if ( Util.isContainStr(lDir, '~') ) lDir = Util.replaceStr(lDir, '~', lHome); - lError = Util.tryCatchLog(function(){ + lError = Util.tryCatchLog(function() { process.chdir(lDir); }); @@ -175,7 +175,7 @@ * change code page to unicode becouse * windows use unicode on non English versions */ - if(WIN32){ + if(WIN32) { lWinCommand = pCommand.toUpperCase(); if( Win32Commands.indexOf(lWinCommand) >= 0 ) @@ -197,7 +197,7 @@ * function send result of command to client * @param pSocket */ - function getExec(pSocket, pConnNum){ + function getExec(pSocket, pConnNum) { return function(pError, pStdout, pStderr) { var lErrorStr, lExecStr, lExec, lError = pStderr || pError; @@ -223,7 +223,7 @@ }; } - function log(pConnNum, pStr, pType){ + function log(pConnNum, pStr, pType) { var lRet, lType = ' '; if (pStr) { From 7b92cb55aaab6a74ce31d9940ab58d335fe5cc13 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 23 Oct 2013 12:01:17 +0000 Subject: [PATCH 052/152] feature(server) add express --- lib/server.js | 11 +++++++++-- package.json | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/server.js b/lib/server.js index 779075de..da8dc359 100644 --- a/lib/server.js +++ b/lib/server.js @@ -27,8 +27,9 @@ http = main.http, https = main.https, Util = main.util, + express = main.require('express'), - Server, Rest, Route, Minimize; + app, Server, Rest, Route, Minimize; /* базовая инициализация */ function init(pAppCachProcessing) { @@ -93,7 +94,13 @@ }, lHTTPServer = function() { - Server = http.createServer( controller ); + if (express) { + app = express(), + app.all('*', controller); + Server = http.createServer(app); + } else + Server = http.createServer(controller); + Server.on('error', Util.log); Server.listen(lPort, lIP); lServerLog(lHTTP, lPort); diff --git a/package.json b/package.json index 0c0366ad..9f26831a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "dependencies": { "dropbox": "0.10.2", "minify": "0.2.2", - "socket.io": "0.9.16" + "socket.io": "0.9.16", + "express": "3.4.2" }, "devDependencies": {}, "license": "MIT", From b88b10d0595dd804f8bf068d61257928903fc8ec Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 23 Oct 2013 12:06:03 +0000 Subject: [PATCH 053/152] feature(server) add express logger (if exist) --- lib/server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/server.js b/lib/server.js index da8dc359..ef2e0a2f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -96,7 +96,9 @@ lHTTPServer = function() { if (express) { app = express(), - app.all('*', controller); + app.use(express.logger('dev')) + .all('*', controller); + Server = http.createServer(app); } else Server = http.createServer(controller); @@ -162,7 +164,9 @@ /* added supporting of Russian language in directory names */ lPath = Querystring.unescape(lPath); - Util.log(pReq.method + ' ' + lPath + lQuery); + + if (!express) + Util.log(pReq.method + ' ' + lPath + lQuery); var lData = { name : lPath, From 9563cf3b832b406a59e3714018549b3361be96d4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 23 Oct 2013 12:09:02 +0000 Subject: [PATCH 054/152] feature(rest) rm log error (would log later anyway) --- lib/server/rest.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index e35acb53..3fee8f42 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -151,10 +151,8 @@ callback : function(pError) { var lName; - if (pError) { - Util.log(pError); + if (pError) main.sendError(pParams, pError); - } else { lName = path.basename(p.name); sendMsg(pParams, 'save', lName); From 071e62d0997fc627bd46e95f2b5830a92219050b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:14:37 +0300 Subject: [PATCH 055/152] feature(package) express: 3.4.2 -> 3.4.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f26831a..81095ab8 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dropbox": "0.10.2", "minify": "0.2.2", "socket.io": "0.9.16", - "express": "3.4.2" + "express": "3.4.x" }, "devDependencies": {}, "license": "MIT", From e2bce6c48adde9327eac08984bca017c3e80fc3b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 07:24:33 +0000 Subject: [PATCH 056/152] feature(console) rm addNewLine --- lib/client/console.js | 15 ++------------- lib/client/socket.js | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index 7a801325..01b6592c 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -108,25 +108,14 @@ var CloudCmd, Util, DOM, $; this.log = function(pText){ if (jqconsole) - jqconsole.Write( addNewLine(pText), 'log-msg'); + jqconsole.Write(pText, 'log-msg'); }; this.error = function(pText){ if (jqconsole) - jqconsole.Write( addNewLine(pText), 'error-msg'); + jqconsole.Write(pText, 'error-msg'); }; - function addNewLine(pText){ - var lNewLine = '', - n = pText && pText.length; - - if(n && pText[n-1] !== '\n') - lNewLine = '\n'; - - return pText + lNewLine; - } - - function load(pCallBack){ Util.time(Name + ' load'); diff --git a/lib/client/socket.js b/lib/client/socket.js index d755e1bc..8a2a6511 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -26,7 +26,7 @@ var CloudCmd, Util, DOM, io; CloudCmd.Socket = socket; socket.on('connect', function () { - outToTerminal({stdout: 'socket connected'}); + outToTerminal({stdout: 'socket connected\n'}); }); socket.on('message', function (msg) { @@ -37,7 +37,7 @@ var CloudCmd, Util, DOM, io; }); socket.on('disconnect', function () { - outToTerminal({stderr: 'socket disconected'}); + outToTerminal({stderr: 'socket disconected\n'}); }); } From 05456bfe7472a81ff65cada00ff06fca469e2651 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:46:05 +0300 Subject: [PATCH 057/152] feature(socket) connected -> connected\n --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 3b464717..8a47cd36 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -72,7 +72,7 @@ ++lConnNum; if(!OnMessageFuncs[lConnNum]) { - lMsg = log(lConnNum, 'connected'); + lMsg = log(lConnNum, 'connected\n'); socket.send('{"stdout":"' + lMsg + '"}'); OnMessageFuncs[lConnNum] = onMessage(lConnNum, socket); From 638ac9f00395d5dce5a1cede710ef2c2bb8e9dd1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:58:06 +0300 Subject: [PATCH 058/152] feature(socket) listen: add stringifyJSON --- lib/server/socket.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 8a47cd36..80f67424 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -69,11 +69,17 @@ ]); lRet = lListen.sockets.on('connection', function (socket) { + var lJSON; ++lConnNum; if(!OnMessageFuncs[lConnNum]) { - lMsg = log(lConnNum, 'connected\n'); - socket.send('{"stdout":"' + lMsg + '"}'); + lMsg = log(lConnNum, 'connected\n'); + lJSON = { + stdout : lMsg + }; + lMsg = Util.stringifyJSON(lJSON); + + socket.send(lMsg); OnMessageFuncs[lConnNum] = onMessage(lConnNum, socket); lConn_func = OnMessageFuncs[lConnNum]; From a0a064e985391fb13999de0731504fd1c710fd2c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 08:08:13 +0000 Subject: [PATCH 059/152] feature(console) add Buffer --- lib/client/console.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index 01b6592c..19b8ed7d 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -2,6 +2,11 @@ var CloudCmd, Util, DOM, $; (function(CloudCmd, Util, DOM){ 'use strict'; + var Buffer = { + log : '', + error : '' + }; + CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM); function ConsoleProto(CloudCmd, Util, DOM){ @@ -106,16 +111,26 @@ var CloudCmd, Util, DOM, $; CloudCmd.View.hide(); }; - this.log = function(pText){ - if (jqconsole) - jqconsole.Write(pText, 'log-msg'); + this.log = function(pText) { + log(pText, 'log'); }; - this.error = function(pText){ - if (jqconsole) - jqconsole.Write(pText, 'error-msg'); + this.error = function(pText) { + log(pText, 'error'); }; + function log(msg, status) { + var ret; + + Buffer[status] += msg; + ret = Util.isContainStr(Buffer[status], '\n'); + + if (jqconsole && ret) { + jqconsole.Write(Buffer[status], status + '-msg'); + Buffer[status] = ''; + } + } + function load(pCallBack){ Util.time(Name + ' load'); From 7bda84f98f4ab051b271f1b4656150e641fdbabc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 08:28:55 +0000 Subject: [PATCH 060/152] feature(socket) add spawn --- lib/server/socket.js | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 80f67424..472427c8 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -120,7 +120,7 @@ function onMessage(pConnNum, pSocket) { return function(pCommand) { var lMsg, lJSON, lWinCommand, lExec_func, lDir, - lHome, lError, lRet; + lHome, lError, lRet, lExecSymbols; Util.log('#' + pConnNum + ': ' + pCommand); @@ -193,7 +193,12 @@ lExec_func = ClientFuncs[pConnNum]; - exec(pCommand, lExec_func); + lExecSymbols = ['{', '}', '|', '\'', '"']; + + if (Util.isContainStr(pCommand, lExecSymbols)) + exec(pCommand, lExec_func); + else + getSpawn(pSocket, pConnNum, pCommand); } }; } @@ -220,7 +225,7 @@ stderr : lError }; - lExecStr = JSON.stringify(lExec); + lExecStr = JSON.stringify(lExec); log(pConnNum, pError, 'error'); log(pConnNum, pStderr, 'stderror'); @@ -229,6 +234,40 @@ }; } + function getSpawn(pSocket, pConnNum, pCommand) { + var send, cmd, spawn, + args = pCommand.split(' '); + + pCommand = args.shift(); + + spawn = main.child_process.spawn; + cmd = spawn(pCommand, args); + send = function(data, isError) { + var lExecStr, + lExec = {}, + msg = data.toString(); + + if (isError) + lExec.stderr = msg; + else + lExec.stdout = msg; + + lExecStr = JSON.stringify(lExec); + pSocket.send(lExecStr); + Util.log(msg); + }; + + cmd.stdout.on('data', send); + + cmd.stderr.on('data', function(data) { + send(data, true); + }); + + cmd.on('error', function(data) { + send(data, true); + }); + } + function log(pConnNum, pStr, pType) { var lRet, lType = ' '; From 01034d206affa83df87ed8a89f369f36e1c5e989 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 08:35:53 +0000 Subject: [PATCH 061/152] feature(socket) getSpawn error: add retFalse --- lib/server/socket.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 472427c8..49057598 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -263,9 +263,7 @@ send(data, true); }); - cmd.on('error', function(data) { - send(data, true); - }); + cmd.on('error', Util.retFalse); } function log(pConnNum, pStr, pType) { From 79a272a078c863f535174e529993ff2bf0b469f8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 08:40:29 +0000 Subject: [PATCH 062/152] feature(socket) lExecSymbols: add "&" --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 49057598..2fda5dba 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -193,7 +193,7 @@ lExec_func = ClientFuncs[pConnNum]; - lExecSymbols = ['{', '}', '|', '\'', '"']; + lExecSymbols = ['&', '{', '}', '|', '\'', '"']; if (Util.isContainStr(pCommand, lExecSymbols)) exec(pCommand, lExec_func); From c43a1833338a6afdeeab0a23454d884ce78839bb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 09:09:53 +0000 Subject: [PATCH 063/152] refactor(socket) rm stderr.code --- lib/client/socket.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/socket.js b/lib/client/socket.js index 8a2a6511..0ace2eb1 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -73,8 +73,8 @@ var CloudCmd, Util, DOM, io; if(lStdout) lResult = lConsole.log(lStdout); - if(lStderr && lStderr.code !== 1) - lResult = lConsole.error(lStderr.toString()); + if (lStderr) + lResult = lConsole.error(lStderr); } else /* if term not accesable save msg to buffer */ From 8f85326cf33e6a2edd648902775b36610a33e6b3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 09:10:56 +0000 Subject: [PATCH 064/152] refactor(socket) getExec --- lib/server/socket.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 2fda5dba..0c66a6ce 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -211,18 +211,15 @@ function getExec(pSocket, pConnNum) { return function(pError, pStdout, pStderr) { var lErrorStr, lExecStr, lExec, - lError = pStderr || pError; + lError = pError || pStderr; - if (lError) - if ( Util.isString(lError) ) - lErrorStr = lError; - else - lErrorStr = Util.stringifyJSON( lError ); + if (!Util.isString(lError)) + lErrorStr = lError.toString() + '\n'; lExec = { stdout : pStdout, - stderr : lError + stderr : lErrorStr || lError }; lExecStr = JSON.stringify(lExec); From 94b6492a662855aafa65a379aec0f531736709d5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:33:32 +0000 Subject: [PATCH 065/152] feature(express) add --- lib/server.js | 17 +++++++---------- lib/server/express.js | 23 +++++++++++++++++++++++ lib/server/main.js | 1 + 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 lib/server/express.js diff --git a/lib/server.js b/lib/server.js index ef2e0a2f..3f6dcee4 100644 --- a/lib/server.js +++ b/lib/server.js @@ -27,9 +27,10 @@ http = main.http, https = main.https, Util = main.util, - express = main.require('express'), + express = main.express, + expressApp = express.getApp(controller), - app, Server, Rest, Route, Minimize; + Server, Rest, Route, Minimize; /* базовая инициализация */ function init(pAppCachProcessing) { @@ -94,13 +95,9 @@ }, lHTTPServer = function() { - if (express) { - app = express(), - app.use(express.logger('dev')) - .all('*', controller); - - Server = http.createServer(app); - } else + if (expressApp) + Server = http.createServer(expressApp); + else Server = http.createServer(controller); Server.on('error', Util.log); @@ -165,7 +162,7 @@ /* added supporting of Russian language in directory names */ lPath = Querystring.unescape(lPath); - if (!express) + if (!expressApp) Util.log(pReq.method + ' ' + lPath + lQuery); var lData = { diff --git a/lib/server/express.js b/lib/server/express.js new file mode 100644 index 00000000..c52cb822 --- /dev/null +++ b/lib/server/express.js @@ -0,0 +1,23 @@ +(function() { + 'use strict'; + + if (!global.cloudcmd) + return console.log( + '# express.js' + '\n' + + '# -----------' + '\n' + + '# Module is part of Cloud Commander,' + '\n' + + '# easy to use web server.' + '\n' + + '# http://cloudcmd.io' + '\n'); + + var main = global.cloudcmd.main, + express = main.require('express'), + app = express && express(); + + exports.getApp = function(controller) { + if (app) + app.use(express.logger('dev')) + .all('*', controller); + + return app; + }; +})(); diff --git a/lib/server/main.js b/lib/server/main.js index 816e7e6a..6350b1f7 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -103,6 +103,7 @@ /* Additional Modules */ exports.pipe = pipe = srvrequire('pipe'), exports.socket = srvrequire('socket'), + exports.express = srvrequire('express'), exports.auth = srvrequire('auth').auth, exports.appcache = srvrequire('appcache'), exports.cloudfunc = CloudFunc = librequire('cloudfunc'), From 04af8f7f3c068daae2e78fffe304ebb7520a83e3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:34:21 +0000 Subject: [PATCH 066/152] feature(socket) getSpawn: rm log --- lib/server/socket.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 0c66a6ce..68f39689 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -251,7 +251,6 @@ lExecStr = JSON.stringify(lExec); pSocket.send(lExecStr); - Util.log(msg); }; cmd.stdout.on('data', send); From 1ff073d78ba7e3b39418932faa1529fc51a48e7d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:45:05 +0000 Subject: [PATCH 067/152] refactor(main) mv CloudFunc to up --- lib/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index 6350b1f7..2f1acc60 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -101,12 +101,12 @@ exports.VOLUMES = getVolumes(), /* Additional Modules */ + exports.cloudfunc = CloudFunc = librequire('cloudfunc'), exports.pipe = pipe = srvrequire('pipe'), exports.socket = srvrequire('socket'), exports.express = srvrequire('express'), exports.auth = srvrequire('auth').auth, exports.appcache = srvrequire('appcache'), - exports.cloudfunc = CloudFunc = librequire('cloudfunc'), exports.dir = srvrequire('dir'), exports.rest = srvrequire('rest').api, exports.update = srvrequire('update'), From e25d526ac4cf429102906f0161ffae3759e96cfb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 10:51:43 +0000 Subject: [PATCH 068/152] feature(util) add addNewLine --- lib/server/socket.js | 4 +++- lib/util.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 68f39689..07e3b99b 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -215,7 +215,9 @@ if (!Util.isString(lError)) - lErrorStr = lError.toString() + '\n'; + lErrorStr = lError.toString(); + + lErrorStr = Util.addNewLine(lErrorStr); lExec = { stdout : pStdout, diff --git a/lib/util.js b/lib/util.js index e988253c..2f649037 100644 --- a/lib/util.js +++ b/lib/util.js @@ -46,6 +46,20 @@ Util = exports || {}; } }, + /** + * ad new line (if it's not) + * @param {string} pText + */ + Util.addNewLine = function(pText){ + var lNewLine = '', + n = pText && pText.length; + + if(n && pText[n-1] !== '\n') + lNewLine = '\n'; + + return pText + lNewLine; + }; + /** setting function context * @param {function} pFunction * @param {object} pContext From 00b30d4f1931941060a96840612685c973bb50e0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 13:02:38 +0000 Subject: [PATCH 069/152] refactor(server) start --- lib/server.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/server.js b/lib/server.js index 3f6dcee4..75e55857 100644 --- a/lib/server.js +++ b/lib/server.js @@ -95,11 +95,7 @@ }, lHTTPServer = function() { - if (expressApp) - Server = http.createServer(expressApp); - else - Server = http.createServer(controller); - + Server = http.createServer(expressApp || controller); Server.on('error', Util.log); Server.listen(lPort, lIP); lServerLog(lHTTP, lPort); From e9727e21b70b093a304788e8dc5053bbcb6c0293 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 13:04:34 +0000 Subject: [PATCH 070/152] chore(socket) add " " --- lib/client/socket.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/client/socket.js b/lib/client/socket.js index 0ace2eb1..61e116ec 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -1,6 +1,6 @@ /* module make possible connectoin thrue socket.io on a client */ var CloudCmd, Util, DOM, io; -(function(CloudCmd, Util, DOM){ +(function(CloudCmd, Util, DOM) { 'use strict'; var Messages = [], @@ -41,24 +41,24 @@ var CloudCmd, Util, DOM, io; }); } - function outToTerminal(pMsg){ + function outToTerminal(pMsg) { var i, n, lResult, lStdout, lStderr, lConsole = CloudCmd.Console; DOM.Images.hideLoad(); - if( Util.isObject(lConsole) ){ - if(Messages.length){ + if (Util.isObject(lConsole)) { + if (Messages.length) { /* show oll msg from buffer */ - for(i = 0, n = Messages.length; i < n; i++){ + for (i = 0, n = Messages.length; i < n; i++) { lStdout = Messages[i].stdout; lStderr = Messages[i].stderr; - if(lStdout) + if (lStdout) lConsole.log(lStdout); - if(lStderr){ + if (lStderr) { /* if it's object - convert is to string' */ - if( Util.isObject(lStderr) ) + if (Util.isObject(lStderr)) lStderr = Util.stringifyJSON(lStderr); lConsole.error(lStderr); @@ -70,7 +70,7 @@ var CloudCmd, Util, DOM, io; lStdout = pMsg.stdout; lStderr = pMsg.stderr; - if(lStdout) + if (lStdout) lResult = lConsole.log(lStdout); if (lStderr) From b708b7b68785e9fb1a0815579e652f45c82ffce1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 13:07:37 +0000 Subject: [PATCH 071/152] refactor(socket) log: add msg condition --- lib/client/console.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index 19b8ed7d..e30b7fe4 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -122,12 +122,14 @@ var CloudCmd, Util, DOM, $; function log(msg, status) { var ret; - Buffer[status] += msg; - ret = Util.isContainStr(Buffer[status], '\n'); - - if (jqconsole && ret) { - jqconsole.Write(Buffer[status], status + '-msg'); - Buffer[status] = ''; + if (msg) { + Buffer[status] += msg; + ret = Util.isContainStr(Buffer[status], '\n'); + + if (jqconsole && ret) { + jqconsole.Write(Buffer[status], status + '-msg'); + Buffer[status] = ''; + } } } From d602d4878f72257ef3c9a8662fbf618218ca0718 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 13:09:16 +0000 Subject: [PATCH 072/152] chore(dom) Images: rm " " --- lib/client/dom.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index a837e40b..d1faedf9 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -101,14 +101,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } /* если файла не существует*/ - if ( Util.isContainStr(lText, 'Error: ENOENT, ') ) + if (Util.isContainStr(lText, 'Error: ENOENT, ')) lText = lText.replace('Error: ENOENT, n','N'); /* если не хватает прав для чтения файла*/ - else if ( Util.isContainStr(lText, 'Error: EACCES,') ) + else if (Util.isContainStr(lText, 'Error: EACCES,')) lText = lText.replace('Error: EACCES, p','P'); - DOM.show(lErrorImage); lErrorImage.title = lText; From 519d359b05331e5049b1be98cbb294c239deb77a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Oct 2013 13:11:21 +0000 Subject: [PATCH 073/152] feature(socket) getExec: add lError condition --- lib/server/socket.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 07e3b99b..e05bfc66 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -214,10 +214,12 @@ lError = pError || pStderr; - if (!Util.isString(lError)) - lErrorStr = lError.toString(); - - lErrorStr = Util.addNewLine(lErrorStr); + if (lError) { + if (!Util.isString(lError)) + lErrorStr = lError.toString(); + + lErrorStr = Util.addNewLine(lErrorStr); + } lExec = { stdout : pStdout, From cd3b2d2732b399356971a11d3e9e189a86e9b03d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 07:36:10 +0000 Subject: [PATCH 074/152] chore(main) add " " --- lib/server/main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 2f1acc60..ff7857a2 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -235,14 +235,15 @@ cache : p.cache, gzip : lGzip, query : getQuery(p.request) - }) ); + })); pipe.create({ - from: p.name, - write: p.response, - zip : lGzip && !p.gziped, - callback: function(pError) { - var lError = pError && pError.toString(); + from: p.name, + write: p.response, + zip : lGzip && !p.gziped, + callback: function(pError) { + var lError = pError && pError.toString(); + if (pError) { p.response.writeHead(FILE_NOT_FOUND, 'OK'); p.response.end(lError); From d4264d101935019feaad0a0741f2a916b6872d91 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 07:40:27 +0000 Subject: [PATCH 075/152] chore(main) rm " " --- lib/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index ff7857a2..775ae484 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -229,7 +229,7 @@ if (lRet) { var p = pParams, lGzip = isGZIP(p.request) && p.gzip; - + p.response.writeHead(OK, generateHeaders({ name : p.name, cache : p.cache, From cbf080e19f72cb23b34b4cb073aaa9a18625dfa5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 08:03:51 +0000 Subject: [PATCH 076/152] fix(main) header was sended twice --- lib/server/main.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 775ae484..dc0b05b0 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -225,17 +225,23 @@ * @param pGzip - данные сжаты gzip'ом */ function sendFile(pParams) { - var lRet = checkParams(pParams); + var name, header, lRet = checkParams(pParams); + if (lRet) { var p = pParams, lGzip = isGZIP(p.request) && p.gzip; - p.response.writeHead(OK, generateHeaders({ + p.response.statusCode = OK; + + header = generateHeaders({ name : p.name, cache : p.cache, gzip : lGzip, query : getQuery(p.request) - })); + }); + + for (name in header) + p.response.setHeader(name, header[name]); pipe.create({ from: p.name, @@ -245,7 +251,7 @@ var lError = pError && pError.toString(); if (pError) { - p.response.writeHead(FILE_NOT_FOUND, 'OK'); + p.response.statusCode = FILE_NOT_FOUND; p.response.end(lError); } } From e707ed98536f92e39e1d772a8a9991305a486af7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 10:57:16 +0000 Subject: [PATCH 077/152] fix(main) if file not exist - send error; sendFile: add stat, add setHeader --- lib/server/main.js | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index dc0b05b0..e2c33ef6 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -225,35 +225,35 @@ * @param pGzip - данные сжаты gzip'ом */ function sendFile(pParams) { - var name, header, lRet = checkParams(pParams); + var header, lRet = checkParams(pParams); if (lRet) { var p = pParams, lGzip = isGZIP(p.request) && p.gzip; - p.response.statusCode = OK; - - header = generateHeaders({ - name : p.name, - cache : p.cache, - gzip : lGzip, - query : getQuery(p.request) - }); - - for (name in header) - p.response.setHeader(name, header[name]); - - pipe.create({ - from: p.name, - write: p.response, - zip : lGzip && !p.gziped, - callback: function(pError) { - var lError = pError && pError.toString(); + fs.stat(p.name, function(error, stat) { + if (error) + sendError(pParams, error); + else { + p.response.statusCode = OK; - if (pError) { - p.response.statusCode = FILE_NOT_FOUND; - p.response.end(lError); - } + header = generateHeaders({ + name : p.name, + cache : p.cache, + gzip : lGzip, + query : getQuery(p.request) + }); + + setHeader(header, p.response); + + pipe.create({ + from : p.name, + write : p.response, + zip : lGzip && !p.gziped, + callback: function(error) { + sendError(pParams, error); + } + }); } }); } @@ -296,7 +296,8 @@ p.data = pParams.data; } - p.response.writeHead(p.status || OK, lHead); + setHeader(lHead, p.response); + p.response.statusCode = p.status || OK; p.response.end(p.data); }, @@ -452,4 +453,12 @@ return lGZIP; } + function setHeader(header, response) { + var name; + + if (Util.isObject(header)) + for (name in header) + response.setHeader(name, header[name]); + } + })(); From c4b7b5e3eedf22589f7526a98325f5bc49773583 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 11:25:05 +0000 Subject: [PATCH 078/152] refactor(rest) onFS --- lib/server/rest.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 3fee8f42..da09c3cc 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -106,32 +106,32 @@ case 'GET': if (Util.strCmp(lQuery, 'size')) dir.getSize(p.name, function(pErr, pSize) { - if (!pErr){ + if (pErr) + main.sendError(p, pErr); + else { lSize = CloudFunc.getShortSize(pSize); Util.log(lSize); main.sendResponse(p, lSize); } - else - main.sendError(p, pErr); + }); else fs.stat(p.name, function(pError, pStat) { - if (!pError) - if (pStat.isDirectory()) + if (pError) + main.sendError(p, pError); + else + if (!pStat.isDirectory()) + main.sendFile(p); + else main.commander.getDirContent(p.name, function(pError, pData) { - if (!pError){ + if (pError) + main.sendError(p, pError); + else { p.name += '.json'; p.data = Util.stringifyJSON(pData); main.sendResponse(p); } - else - main.sendError(p, pError); }); - else - main.sendFile(p); - else - main.sendError(p, pError); - }); break; From 11c1cbda161586ff93161292e6d44ca92f5fc268 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 13:53:59 +0000 Subject: [PATCH 079/152] fix(main) sendFile callback: add error condition --- lib/server/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index e2c33ef6..4a53cb58 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -235,8 +235,6 @@ if (error) sendError(pParams, error); else { - p.response.statusCode = OK; - header = generateHeaders({ name : p.name, cache : p.cache, @@ -244,14 +242,15 @@ query : getQuery(p.request) }); - setHeader(header, p.response); + p.response.writeHead(OK, header); pipe.create({ from : p.name, write : p.response, zip : lGzip && !p.gziped, callback: function(error) { - sendError(pParams, error); + if (error) + sendError(pParams, error); } }); } @@ -283,6 +282,8 @@ query : lQuery }); + setHeader(lHead, p.response); + if (!pNotLog) Util.log(pData || p.data); @@ -296,7 +297,6 @@ p.data = pParams.data; } - setHeader(lHead, p.response); p.response.statusCode = p.status || OK; p.response.end(p.data); }, From 90926725e70a713811b70fbb8b17671fd0d22c97 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 14:20:07 +0000 Subject: [PATCH 080/152] feature(rest) rm log lSize --- lib/server/rest.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index da09c3cc..eb0105bf 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -110,7 +110,6 @@ main.sendError(p, pErr); else { lSize = CloudFunc.getShortSize(pSize); - Util.log(lSize); main.sendResponse(p, lSize); } From 91210a8b1fa0d26c00ae62432eb9438947b68123 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 14:20:28 +0000 Subject: [PATCH 081/152] feature(rest) rm " " --- lib/server/rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index eb0105bf..de24eb86 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -112,7 +112,7 @@ lSize = CloudFunc.getShortSize(pSize); main.sendResponse(p, lSize); } - + }); else fs.stat(p.name, function(pError, pStat) { From 8a86bf287578c0abdc90ab9250a7f0169a079445 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 14:22:13 +0000 Subject: [PATCH 082/152] chore(main) rm " " --- lib/server/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 4a53cb58..70273708 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -194,10 +194,10 @@ lContentEncoding = ''; /* if type of file any, but img - then we shoud specify charset */ - if ( !Util.isContainStr(lType, 'img') ) + if (!Util.isContainStr(lType, 'img')) lContentEncoding = '; charset=UTF-8'; - if ( Util.isContainStr(p.query, 'download') ) + if (Util.isContainStr(p.query, 'download')) lType = 'application/octet-stream'; lRet = { From 4dd931756fc8777697cc2cb2c80f27037b1295fc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Oct 2013 14:41:13 +0000 Subject: [PATCH 083/152] refactor(main) writeHead -> setHeader --- lib/server/main.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 70273708..df3f02ac 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -242,7 +242,9 @@ query : getQuery(p.request) }); - p.response.writeHead(OK, header); + //p.response.writeHead(OK, header); + setHeader(header, p.response); + p.response.statusCode = p.status || OK; pipe.create({ from : p.name, @@ -314,13 +316,18 @@ * redirect to another URL */ function redirect(pParams) { - var lRet = Util.checkObjTrue(pParams, - [RESPONSE]); + var p, header, + lRet = Util.checkObjTrue(pParams, [RESPONSE]); if (lRet) { - var p = pParams; + p = pParams; - p.response.writeHead(MOVED_PERMANENTLY, {'Location': p.url}); + header = { + 'Location': p.url + }, + + setHeader(header, p.response); + p.response.statusCode = MOVED_PERMANENTLY; p.response.end(); } } From 0a9e26a27ec66e5d3bfba21af5e39678d911f88b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 28 Oct 2013 10:02:27 +0000 Subject: [PATCH 084/152] chore(dir) processDir: rm log --- lib/server/dir.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/server/dir.js b/lib/server/dir.js index 781bfe7b..46db3d8b 100644 --- a/lib/server/dir.js +++ b/lib/server/dir.js @@ -29,8 +29,7 @@ lTotal += lSize; } - processDir(pDir, calcSize, function(){ - Util.log(pDir + ' -> ' + lTotal); + processDir(pDir, calcSize, function() { Util.exec(pCallBack, null, lTotal); }); }; From 0cc56f8b7830da37282f01a127c33a6219c49736 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 28 Oct 2013 15:30:03 +0000 Subject: [PATCH 085/152] chore(cloudcmd) RESTfull -> RESTful --- ChangeLog | 2 +- ChangeLog.rus.md | 2 +- lib/client/dom.js | 20 ++++++++++---------- lib/client/edit.js | 2 +- lib/client/key.js | 2 +- lib/client/listeners.js | 2 +- lib/client/menu.js | 2 +- lib/server/rest.js | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 888f6c01..2f90a374 100644 --- a/ChangeLog +++ b/ChangeLog @@ -578,7 +578,7 @@ generation of json of directory listing. * Added ability to rename files. -* Added RESTfull object to DOM for easy work with +* Added RESTful object to DOM for easy work with CloudCmd REST API. * Added help screen (on F1 after viewer loads). diff --git a/ChangeLog.rus.md b/ChangeLog.rus.md index 0952eb49..0f826bba 100644 --- a/ChangeLog.rus.md +++ b/ChangeLog.rus.md @@ -225,4 +225,4 @@ - Изминен принцип работы функции clickProcessing в меню, теперь он гораздо проще. - Произведен тотальный рефакторинг в файле commander.js, теперь там только генерация. структуры каталогов в формате json. -- добавлен обьект RESTfull в DOM модуль для упрощения работы с CloudCmd REST API. +- добавлен обьект RESTful в DOM модуль для упрощения работы с CloudCmd REST API. diff --git a/lib/client/dom.js b/lib/client/dom.js index d1faedf9..a2bc85a2 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -126,7 +126,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; }, - RESTfullProto = function() { + RESTfulProto = function() { this.delete = function(pUrl, pData, pCallBack, pQuery) { sendRequest({ method : 'DELETE', @@ -1106,7 +1106,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName = Dialog.prompt(lMsg, lName); if (lName) - RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh); + RESTful.save(lDir + lName + lType, null, CloudCmd.refresh); }; /** @@ -1122,7 +1122,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; if (lName && lName !== '..') - RESTfull.zip(lFiles, CloudCmd.refresh); + RESTful.zip(lFiles, CloudCmd.refresh); }; @@ -1193,7 +1193,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } if (lCurrent || lSelected) - RESTfull.delete(lUrl, lSelected, function() { + RESTful.delete(lUrl, lSelected, function() { if (n > 1) DOM.deleteSelected(lFiles); else @@ -1322,7 +1322,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; /* если это папка - возвращаем слово dir вместо размера*/ if (lName !== '..') - RESTfull.read(lLink, function(pSize) { + RESTful.read(lLink, function(pSize) { DOM.setCurrentSize(pSize, lCurrent); Util.exec(pCallBack, lCurrent); }, '?size'); @@ -1827,7 +1827,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; to : lDirPath + lTo }; - RESTfull.mv(lFiles, function() { + RESTful.mv(lFiles, function() { DOM.setCurrentName(lTo, lCurrent); }); } @@ -1855,7 +1855,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; to : lToPath }; - RESTfull.mv(lFiles, function() { + RESTful.mv(lFiles, function() { DOM.deleteCurrent(lCurrent); var lPanel = DOM.getPanel(true), @@ -1888,7 +1888,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; to : lToPath }; - RESTfull.cp(lFiles, function() { + RESTful.cp(lFiles, function() { var lPanel = DOM.getPanel(true), lDotDot = DOM.getById( '..(' + lPanel.id + ')'); @@ -1945,7 +1945,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Events = Util.extendProto(EventsProto), Loader = Util.extendProto(LoaderProto), Images = Util.extendProto(ImagesProto), - RESTfull = Util.extendProto(RESTfullProto), + RESTful = Util.extendProto(RESTfulProto), Cache = Util.extendProto(CacheProto); DOMProto = DOMFunc.prototype = new CmdProto(); @@ -1956,7 +1956,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOMTree, Loader, { Events : Events, - RESTfull: RESTfull, + RESTful: RESTful, Images : Images, Cache : Cache } diff --git a/lib/client/edit.js b/lib/client/edit.js index 0bc1bf46..3d90ceb9 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -121,7 +121,7 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; var lPath = DOM.getCurrentPath(), lValue = Ace.getValue(); - DOM.RESTfull.save(lPath, lValue, Edit.showMessage); + DOM.RESTful.save(lPath, lValue, Edit.showMessage); } }); } diff --git a/lib/client/key.js b/lib/client/key.js index ef6ef032..b476a26a 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -112,7 +112,7 @@ var CloudCmd, Util, DOM; if ( DOM.isCurrentIsDir(lCurrent) ) lUrl += '?dir'; - DOM.RESTfull.delete(lUrl, function() { + DOM.RESTful.delete(lUrl, function() { DOM.deleteCurrent(lCurrent); }); } diff --git a/lib/client/listeners.js b/lib/client/listeners.js index 1e62bb42..3cce9608 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -232,7 +232,7 @@ var Util, DOM, CloudCmd; var path = dir + file.name, data = event.target.result; - DOM.RESTfull.save(path, data, CloudCmd.refresh); + DOM.RESTful.save(path, data, CloudCmd.refresh); }; }; diff --git a/lib/client/menu.js b/lib/client/menu.js index 3f1d8bfd..392d61bb 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -197,7 +197,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; CloudCmd.execFromModule('FilePicker', 'saveFile', function(pName, pData){ var lPath = DOM.getCurrentDirPath() + pName; - DOM.RESTfull.save(lPath, pData, CloudCmd.refresh); + DOM.RESTful.save(lPath, pData, CloudCmd.refresh); }); } }; diff --git a/lib/server/rest.js b/lib/server/rest.js index de24eb86..6f13c3d1 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -1,4 +1,4 @@ -/* RESTfull module */ +/* RESTful module */ (function() { 'use strict'; From c2a28bc6fdab5fe16e8e7c939c4fe6730bd33be2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 28 Oct 2013 15:48:09 +0000 Subject: [PATCH 086/152] feature(rest) rm proxy --- lib/server/rest.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 6f13c3d1..60932722 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -244,10 +244,6 @@ }; send(p); break; - - case 'proxy': - - break; case 'zip': main.sendFile(pParams); From 7ab3e5549eefb3f31890662dbe8a1ac85152fb8b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 28 Oct 2013 15:54:39 +0000 Subject: [PATCH 087/152] chore(rest) rm " " --- lib/server/rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 60932722..823352dc 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -39,7 +39,7 @@ lRet = Util.isContainStr(p.name, lAPIURL); if (lRet) { p.name = Util.removeStrOneTime(p.name, lAPIURL); - sendData( pParams); + sendData(pParams); } } return lRet; From a6b7e3a9bd1714ee42dbc8f8deb9b0121aec41c8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 28 Oct 2013 15:57:58 +0000 Subject: [PATCH 088/152] fix(rest) crash on /api/v1 --- lib/server/rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 823352dc..62b62da3 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -38,7 +38,7 @@ lRet = Util.isContainStr(p.name, lAPIURL); if (lRet) { - p.name = Util.removeStrOneTime(p.name, lAPIURL); + p.name = Util.removeStrOneTime(p.name, lAPIURL) || '/'; sendData(pParams); } } From 6a84d8330ce67d5cfcff63481c8cf4c4b4933e27 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Oct 2013 08:28:27 +0000 Subject: [PATCH 089/152] docs(help) add date of v0.1.0 --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index ba077b93..de21405e 100644 --- a/HELP.md +++ b/HELP.md @@ -340,7 +340,7 @@ Version history - *2012.07.19*, **[v0.1.3](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.1.3.zip)** - *2012.07.14*, **[v0.1.2](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.1.2.zip)** - *2012.07.11*, **[v0.1.1](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.1.1.zip)** -- *2012.00.00*, **[v0.1.0](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.1.0.zip)** +- *2012.07.09*, **[v0.1.0](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.1.0.zip)** License --------------- From 89357e7a47fbfc83155b5ebbdbe020d292ba899b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Oct 2013 12:47:36 +0000 Subject: [PATCH 090/152] feature(socket) reconnect_failed: mv from options to events --- lib/client/socket.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/client/socket.js b/lib/client/socket.js index 61e116ec..e59a8438 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -17,10 +17,7 @@ var CloudCmd, Util, DOM, io; function connect() { socket = io.connect(CloudCmd.HOST, { - 'max reconnection attempts' : Math.pow(2, 32), - 'reconnect_failed' : function() { - Util.log('Could not reconnect. Reload page.'); - } + 'max reconnection attempts' : Math.pow(2, 32) }); CloudCmd.Socket = socket; @@ -39,6 +36,10 @@ var CloudCmd, Util, DOM, io; socket.on('disconnect', function () { outToTerminal({stderr: 'socket disconected\n'}); }); + + socket.on('reconnect_failed', function () { + Util.log('Could not reconnect. Reload page.'); + }); } function outToTerminal(pMsg) { From 0c00458ac37f0e5049455c861c148fd43b5a77ac Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Oct 2013 12:52:56 +0000 Subject: [PATCH 091/152] feature(socket) connect: add reconnect limit: 5 seconds --- lib/client/socket.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/client/socket.js b/lib/client/socket.js index e59a8438..600c45a2 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -16,8 +16,11 @@ var CloudCmd, Util, DOM, io; }); function connect() { + var FIVE_SECONDS = 5000; + socket = io.connect(CloudCmd.HOST, { - 'max reconnection attempts' : Math.pow(2, 32) + 'max reconnection attempts' : Math.pow(2, 32), + 'reconnection limit' : FIVE_SECONDS }); CloudCmd.Socket = socket; From 5b7334f09d002ff3be9382ba082a09b03a613a86 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Oct 2013 15:26:25 +0000 Subject: [PATCH 092/152] feature(socket) add "#" --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index e05bfc66..3885e695 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -193,7 +193,7 @@ lExec_func = ClientFuncs[pConnNum]; - lExecSymbols = ['&', '{', '}', '|', '\'', '"']; + lExecSymbols = ['#', '&', '{', '}', '|', '\'', '"']; if (Util.isContainStr(pCommand, lExecSymbols)) exec(pCommand, lExec_func); From e41af3d5742c0b2a721c08e425d96dff1935f508 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 30 Oct 2013 08:49:01 +0000 Subject: [PATCH 093/152] feature(socket) exec symbols: add "*" --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 3885e695..75a5c360 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -193,7 +193,7 @@ lExec_func = ClientFuncs[pConnNum]; - lExecSymbols = ['#', '&', '{', '}', '|', '\'', '"']; + lExecSymbols = ['*','#', '&', '{', '}', '|', '\'', '"']; if (Util.isContainStr(pCommand, lExecSymbols)) exec(pCommand, lExec_func); From 2a8038762e6d733fd0a2eb96665bf98b81cc4a9f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 30 Oct 2013 14:42:32 +0000 Subject: [PATCH 094/152] feature(package) rm devDependencies --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 81095ab8..ced71ddf 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "socket.io": "0.9.16", "express": "3.4.x" }, - "devDependencies": {}, "license": "MIT", "engines": { "node": ">=0.4.x" From 17764b2c82c5a4d326b39b1e5ef78040cd5237bb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 30 Oct 2013 17:04:15 +0000 Subject: [PATCH 095/152] docs(readme, help) add status-ok --- HELP.md | 5 ++++- README.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index de21405e..f04d64ea 100644 --- a/HELP.md +++ b/HELP.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL], [Heroku][HerokuURL]) +###[Main][MainURL] [Blog][BlogURL] Live(![IO][IO_LIVE_IMG] [IO][IOURL], ![JitSu][JitSu_LIVE_IMG] [JitSu][JitSuURL], ![Heroku][Heroku_LIVE_IMG] [Heroku][HerokuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -16,6 +16,9 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [IOURL]: http://io.cloudcmd.io "IO" [JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" +[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/io.cloudcmd.io "IO" +[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/cloudcmd.jit.su "JitSu" +[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/cloudcmd.herokuapp.com "Heroku" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index df9bab81..9fb64a85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== -###[Main][MainURL] [Blog][BlogURL] Live([IO][IOURL], [JitSu][JitSuURL], [Heroku][HerokuURL]) +###[Main][MainURL] [Blog][BlogURL] Live(![IO][IO_LIVE_IMG] [IO][IOURL], ![JitSu][JitSu_LIVE_IMG] [JitSu][JitSuURL], ![Heroku][Heroku_LIVE_IMG] [Heroku][HerokuURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png @@ -16,6 +16,9 @@ Cloud Commander v0.5.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [IOURL]: http://io.cloudcmd.io "IO" [JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" +[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/io.cloudcmd.io "IO" +[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/cloudcmd.jit.su "JitSu" +[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/cloudcmd.herokuapp.com "Heroku" **Cloud Commander** - cloud file manager with console and editor. From 850703c75e0cb424d49cc2baa3396eccbfdaec48 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 1 Nov 2013 09:32:27 +0000 Subject: [PATCH 096/152] feature(socket) JSON.stringify -> Util.stringifyJSON --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 75a5c360..bf4e972d 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -226,7 +226,7 @@ stderr : lErrorStr || lError }; - lExecStr = JSON.stringify(lExec); + lExecStr = Util.stringifyJSON(lExec); log(pConnNum, pError, 'error'); log(pConnNum, pStderr, 'stderror'); From 8f168807d9b9e40da8ce8815abdad24186c59184 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 1 Nov 2013 09:39:27 +0000 Subject: [PATCH 097/152] fix(socket) error: undefined --- lib/server/socket.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index bf4e972d..095b7be2 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -211,11 +211,12 @@ function getExec(pSocket, pConnNum) { return function(pError, pStdout, pStderr) { var lErrorStr, lExecStr, lExec, - lError = pError || pStderr; - + lError = pStderr || pError; if (lError) { - if (!Util.isString(lError)) + if (Util.isString(lError)) + lErrorStr = lError; + else lErrorStr = lError.toString(); lErrorStr = Util.addNewLine(lErrorStr); From 3e96c1315731cbd9e1744ea3fa6a4a1e885d4fda Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 1 Nov 2013 14:20:47 +0200 Subject: [PATCH 098/152] docs(help) add "\n" --- HELP.md | 1 + 1 file changed, 1 insertion(+) diff --git a/HELP.md b/HELP.md index f04d64ea..e575273e 100644 --- a/HELP.md +++ b/HELP.md @@ -52,6 +52,7 @@ and unpack or just clone repository from github: node cloudcmd ``` or install in npm: + ``` npm i cloudcmd -g cloudcmd From 6b0b33cec34dfedce2e8763122735430fa0f851d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 10:47:05 +0000 Subject: [PATCH 099/152] feature(config) add --- css/config.css | 58 +++++++++++++++++++++++++++++++++ html/config.html | 21 ++++++++++++ html/index.html | 1 + json/modules.json | 1 + lib/client/config.js | 72 +++++++++++++++++++++++++++++++++++++++++ lib/client/key.js | 7 ++++ lib/client/listeners.js | 23 ++++++------- 7 files changed, 172 insertions(+), 11 deletions(-) create mode 100644 css/config.css create mode 100644 html/config.html create mode 100644 lib/client/config.js diff --git a/css/config.css b/css/config.css new file mode 100644 index 00000000..4d10e939 --- /dev/null +++ b/css/config.css @@ -0,0 +1,58 @@ +#config { + white-space: normal; +} + +.list li{ + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + user-select: none; +} + +#config .form-control{ + padding: 0 12px; + font-size: 16px; + line-height: 1.428571429; + color: #555555; + background-color: #ffffff; + border: 1px solid #cccccc; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; + transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; +} + +#config .form-control:focus { + border-color: #66afe9; + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 1px rgba(102, 175, 233, 0.6); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 1px rgba(102, 175, 233, 0.6); +} + +#config .form-control:-moz-placeholder { + color: #999999; +} + +#config .form-control::-moz-placeholder { + color: #999999; +} + +#config .form-control:-ms-input-placeholder { + color: #999999; +} + +#config .form-control::-webkit-input-placeholder { + color: #999999; +} + +#config .list { + text-align:left; + margin: 5%; +} + +#config #DivBorder{ + margin : 10% auto; + border :1px solid #ADCAFD; + width :300px; +} diff --git a/html/config.html b/html/config.html new file mode 100644 index 00000000..d8bae46f --- /dev/null +++ b/html/config.html @@ -0,0 +1,21 @@ +
+
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • + +
  • +
  • +
  • +
  • +
  • +
  • +
+ \ No newline at end of file diff --git a/html/index.html b/html/index.html index 2b8cb2d1..d37de6d1 100644 --- a/html/index.html +++ b/html/index.html @@ -26,6 +26,7 @@ + diff --git a/json/modules.json b/json/modules.json index 64732a08..957b6b7b 100644 --- a/json/modules.json +++ b/json/modules.json @@ -3,6 +3,7 @@ "menu", "view", "help", + "config", "console", { "name": "storage", "data": [{ diff --git a/lib/client/config.js b/lib/client/config.js new file mode 100644 index 00000000..6c32b8ee --- /dev/null +++ b/lib/client/config.js @@ -0,0 +1,72 @@ +var CloudCmd, Util, DOM; +(function(CloudCmd, Util, DOM){ + 'use strict'; + + CloudCmd.Config = new ConfigProto(CloudCmd, Util, DOM); + + function ConfigProto(CloudCmd, Util, DOM){ + var Key = CloudCmd.Key, + Images = DOM.Images, + Config = this; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + Config.show, + CloudCmd.View, + ]); + + DOM.Events.addKey(listener); + DOM.setButtonKey('f10', Config.show); + + delete Config.init; + }; + + this.show = function(){ + Images.showLoad({top:true}); + + DOM.ajax({ + url: '/css/config.css', + success: function (data){ + DOM.cssSet({ + id : 'config-css', + inner : data + }); + + Images.hideLoad(); + }, + + error:Images.showError + }); + + DOM.ajax({ + url: '/html/config.html', + success: function (data){ + var lDiv = DOM.anyload({ + name : 'div', + id : 'config', + inner : data.toString() + }); + + Images.hideLoad(); + CloudCmd.View.show(lDiv); + }, + + error:Images.showError + }); + }; + + + this.hide = CloudCmd.View.hide; + + function listener(pEvent){ + var f10 = Key.F10, + isBind = Key.isBind(), + key = pEvent.keyCode; + + /* если клавиши можно обрабатывать */ + if (isBind && key === f10) + Config.show(); + } + } + +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/key.js b/lib/client/key.js index b476a26a..b8d91b74 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -39,6 +39,7 @@ var CloudCmd, Util, DOM; F7 : 118, F8 : 119, F9 : 120, + F10 : 121, TRA : 192 /* Typewritten Reverse Apostrophe (`) */ }; @@ -163,6 +164,12 @@ var CloudCmd, Util, DOM; break; + case Key.F10: + Util.exec(CloudCmd.Config); + DOM.preventDefault(pEvent); + + break; + case Key.TRA: DOM.Images.showLoad({top: true}); Util.exec(CloudCmd.Console); diff --git a/lib/client/listeners.js b/lib/client/listeners.js index 3cce9608..72cb59db 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -43,23 +43,24 @@ var Util, DOM, CloudCmd; lFuncs =[ null, - CloudCmd.Help, /* f1 */ - DOM.renameCurrent, /* f2 */ - CloudCmd.View, /* f3 */ - CloudCmd.Edit, /* f4 */ - DOM.copyCurrent, /* f5 */ - DOM.moveCurrent, /* f6 */ - DOM.promptNewDir, /* f7 */ - DOM.promptDeleteSelected, /* f8 */ - CloudCmd.Menu, /* f9 */ + CloudCmd.Help, /* f1 */ + DOM.renameCurrent, /* f2 */ + CloudCmd.View, /* f3 */ + CloudCmd.Edit, /* f4 */ + DOM.copyCurrent, /* f5 */ + DOM.moveCurrent, /* f6 */ + DOM.promptNewDir, /* f7 */ + DOM.promptDeleteSelected, /* f8 */ + CloudCmd.Menu, /* f9 */ + CloudCmd.Config, /* f10 */ ]; - for (i = 1; i <= 9; i++) { + for (i = 1; i <= 10; i++) { lButton = 'f' + i, lEl = DOM.getById('f' + i); lKeysPanel[lButton] = lEl; - if (i === 1 || i === 3 || i === 4 || i === 9) + if (i === 1 || i === 3 || i === 4 || i === 9 || i === 10) Events.addOnce('click', lFuncs[i], lEl); else Events.addClick(lFuncs[i], lEl); From 4073b7ade5650063f6aaefc83aae8e09f20e3109 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 11:11:38 +0000 Subject: [PATCH 100/152] feature(util) copyObj: rm copy --- lib/util.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/util.js b/lib/util.js index 2f649037..5918902f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -197,15 +197,10 @@ Util = exports || {}; */ Util.copyObj = function(pFromObj, pToObj, pProps) { var lRet = pToObj || pProps || {}, - copy = function(name, obj) { - var value = obj[name]; - - if (value) - pToObj[name] = obj[name]; - }, + forIn = function(obj) { Util.forIn(obj, function(name) { - copy(name, obj); + pToObj[name] = obj[name]; }); }; From cea60d0c377ed7bba023a26b0a9584ad5f8d4152 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 11:12:08 +0000 Subject: [PATCH 101/152] feature(config) rm checked --- html/config.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/html/config.html b/html/config.html index d8bae46f..49315e75 100644 --- a/html/config.html +++ b/html/config.html @@ -1,21 +1,21 @@
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • -
  • +
  • -
  • -
  • +
  • +
- \ No newline at end of file + From ea46720de819379a461f4198d2761ecd050acb04 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 11:13:04 +0000 Subject: [PATCH 102/152] feature(config) add template-updating --- lib/client/config.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 6c32b8ee..e758c177 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -40,8 +40,17 @@ var CloudCmd, Util, DOM; DOM.ajax({ url: '/html/config.html', - success: function (data){ - var lDiv = DOM.anyload({ + success: function (data) { + CloudCmd.getConfig(function(config) { + var lDiv, obj = {}; + + Util.copyObj(config, obj); + + changeConfig(obj); + + data = Util.render(data, obj); + + lDiv = DOM.anyload({ name : 'div', id : 'config', inner : data.toString() @@ -49,13 +58,13 @@ var CloudCmd, Util, DOM; Images.hideLoad(); CloudCmd.View.show(lDiv); + }); }, error:Images.showError }); }; - this.hide = CloudCmd.View.hide; function listener(pEvent){ @@ -67,6 +76,23 @@ var CloudCmd, Util, DOM; if (isBind && key === f10) Config.show(); } + + function changeConfig(config) { + var name; + + for (name in config) + if (Util.isBoolean(config[name])) + config[name] = setState(config[name]); + } + + function setState(state) { + var ret = ""; + + if (state) + ret = " checked"; + + return ret; + } } -})(CloudCmd, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); From 1881c46fa2db7613e0f585e48aa0316fbed6b947 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 13:19:00 +0000 Subject: [PATCH 103/152] feature(config) add change --- lib/client/config.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index e758c177..88893cde 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -7,6 +7,9 @@ var CloudCmd, Util, DOM; function ConfigProto(CloudCmd, Util, DOM){ var Key = CloudCmd.Key, Images = DOM.Images, + Events = DOM.Events, + ESC = CloudCmd.Key.ESC, + INPUT = 'INPUT', Config = this; this.init = function(pCallBack){ @@ -42,7 +45,7 @@ var CloudCmd, Util, DOM; url: '/html/config.html', success: function (data) { CloudCmd.getConfig(function(config) { - var lDiv, obj = {}; + var i, n, div, li, param, obj = {}; Util.copyObj(config, obj); @@ -50,14 +53,23 @@ var CloudCmd, Util, DOM; data = Util.render(data, obj); - lDiv = DOM.anyload({ + div = DOM.anyload({ name : 'div', id : 'config', inner : data.toString() }); + li = DOM.getByTag(INPUT, div); + n = li.length; + + for (i = 0; i < n; i++) { + param = li[i]; + Events.add('change', change, param); + Events.addKey(key, param); + } + Images.hideLoad(); - CloudCmd.View.show(lDiv); + CloudCmd.View.show(div); }); }, @@ -65,7 +77,7 @@ var CloudCmd, Util, DOM; }); }; - this.hide = CloudCmd.View.hide; + this.hide = CloudCmd.View.hide function listener(pEvent){ var f10 = Key.F10, @@ -93,6 +105,17 @@ var CloudCmd, Util, DOM; return ret; } + + function change(event) { + Util.log(event); + } + + function key(event) { + var keyCode = event.keyCode; + + if (keyCode === ESC) + Config.hide(); + } } })(CloudCmd, Util, DOM); From 4f8f122caae0ab9a4baa67d3f3febb8183c6a4db Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 13:20:15 +0000 Subject: [PATCH 104/152] chore(config, help) add " " --- lib/client/config.js | 8 +++++--- lib/client/help.js | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 88893cde..87394826 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -12,7 +12,7 @@ var CloudCmd, Util, DOM; INPUT = 'INPUT', Config = this; - this.init = function(pCallBack){ + this.init = function(pCallBack){ Util.loadOnLoad([ Config.show, CloudCmd.View, @@ -24,7 +24,7 @@ var CloudCmd, Util, DOM; delete Config.init; }; - this.show = function(){ + this.show = function(){ Images.showLoad({top:true}); DOM.ajax({ @@ -77,7 +77,9 @@ var CloudCmd, Util, DOM; }); }; - this.hide = CloudCmd.View.hide + this.hide = function() { + CloudCmd.View.hide(); + }; function listener(pEvent){ var f10 = Key.F10, diff --git a/lib/client/help.js b/lib/client/help.js index 8db66811..b8ba278d 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -9,7 +9,7 @@ var CloudCmd, Util, DOM; Images = DOM.Images, Help = this; - this.init = function(pCallBack){ + this.init = function(pCallBack){ Util.loadOnLoad([ Help.show, CloudCmd.View, @@ -63,9 +63,11 @@ var CloudCmd, Util, DOM; }; - this.hide = CloudCmd.View.hide; + this.hide = function() { + CloudCmd.View.hide(); + }; - function listener(pEvent){ + function listener(pEvent) { var lF1 = Key.F1, lIsBind = Key.isBind(), lKey = pEvent.keyCode; From ba147191b9fc6b0c15e4a02f40af91d4ca340c9f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 13:23:49 +0000 Subject: [PATCH 105/152] chore(rest) add " " --- lib/server/rest.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/server/rest.js b/lib/server/rest.js index 62b62da3..fba4fca6 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -275,6 +275,7 @@ */ function onPUT(pParams) { var lRet = main.checkParams(pParams, ['body']); + if (lRet) { var p = pParams, lCmd = p.command, From edc8b36d4270fac73a1471800250458f8cd7f3c3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 4 Nov 2013 14:57:01 +0000 Subject: [PATCH 106/152] feature(rest) add config --- lib/client/config.js | 15 ++++++++++++++- lib/client/dom.js | 9 +++++++++ lib/server/rest.js | 21 ++++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 87394826..bd9fffd3 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -109,7 +109,20 @@ var CloudCmd, Util, DOM; } function change(event) { - Util.log(event); + var data, + obj = {}, + el = event.target, + name = el.id, + type = el.type; + + if (el.type === 'checkbox') + data = el.checked; + else + data = el.value; + + obj[name] = data; + + DOM.RESTful.config(obj); } function key(event) { diff --git a/lib/client/dom.js b/lib/client/dom.js index a2bc85a2..f8993021 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -181,6 +181,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; callback : pCallBack }); }; + + this.config = function(pData, pCallBack) { + sendRequest({ + method : 'PUT', + url : '/config', + data : pData, + callback : pCallBack + }); + }; function sendRequest(pParams) { var lRet = Util.checkObjTrue(pParams, ['method']); diff --git a/lib/server/rest.js b/lib/server/rest.js index fba4fca6..86ac0c57 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -20,6 +20,7 @@ pipe = main.pipe, CloudFunc = main.cloudfunc, dir = main.dir, + JSONDIR = main.JSONDIR, OK = 200, Header = main.generateHeaders({ name:'api.json' @@ -274,7 +275,8 @@ * @param pParams {command, method, body, requrest, response} */ function onPUT(pParams) { - var lRet = main.checkParams(pParams, ['body']); + var name, data, json, config, + lRet = main.checkParams(pParams, ['body']); if (lRet) { var p = pParams, @@ -350,6 +352,23 @@ main.sendError(pParams, p.data); break; + case 'config': + config = main.config; + + for (name in lFiles) + config[name] = lFiles[name]; + + json = Util.stringifyJSON(config) + '\n'; + + fs.writeFile(JSONDIR + 'config.json', json, function(error) { + if (error) + sendError(pParams, error); + else + sendMsg(pParams, 'config', name); + }); + + break; + default: send(pParams); break; From 1f3b88c79f5f1a2117e6052165a7648c6583650f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 08:40:47 +0000 Subject: [PATCH 107/152] feature(cloudcmd) rm all.min.css --- cloudcmd.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 8e293918..be2a8324 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -49,18 +49,6 @@ lData = pData.data, lAdditional = pData.additional; - /* - * если выбрана опция минимизировать скрипты - * меняем в index.html обычные css на - * минифицированый - */ - if (Minify.allowed) { - lPath = '/' + Util.removeStr(Minify.MinFolder, DIR); - lReplace = ''; - lData = Util.removeStr(lData, lReplace) - .replace('/css/style.css', lPath + 'all.min.css'); - } - if (!Config.appcache) lData = Util.removeStr(lData, [ /* min */ @@ -96,9 +84,6 @@ lFiles[0][lFONT_REMOTE] = lFONT_LOCAL; lFiles[1][lJQUERY_REMOTE] = lJQUERY_LOCAL; - if (Config.minify) - lFiles.push('node_modules/minify/min/all.min.css'); - AppCache.addFiles(lFiles); AppCache.createManifest(); } From 760d274d5d34b659b21561591bd2026957a438d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 08:44:09 +0000 Subject: [PATCH 108/152] feature(cloudocmd) rm minimize --- cloudcmd.js | 33 --------------------------------- lib/server.js | 6 +----- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index be2a8324..a168278f 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -88,38 +88,6 @@ AppCache.createManifest(); } - /** - * Функция минимизирует css/js/html - * если установлены параметры минимизации - */ - function minimize(pAllowed) { - var lOptimizeParams = [], - lStyles = [{}, {}], - lStyleCSS = DIR + 'css/style.css', - lResetCSS = DIR + 'css/reset.css', - - lCSSOptions = { - img : true, - merge : true - }; - - if (pAllowed) { - lOptimizeParams.push(LIBDIR + 'client.js'); - lOptimizeParams.push(INDEX); - - lStyles[0][lStyleCSS] = lCSSOptions; - lStyles[1][lResetCSS] = lCSSOptions; - - lOptimizeParams.push(lStyles[0]); - lOptimizeParams.push(lStyles[1]); - } - - if (lOptimizeParams.length) - Minify.optimize(lOptimizeParams, { - force: true - }); - } - /** * rest interface * @pParams pConnectionData {request, responce} @@ -178,7 +146,6 @@ lParams = { appcache : appCacheProcessing, - minimize : minimize, rest : rest, route : route }, diff --git a/lib/server.js b/lib/server.js index 75e55857..5b211a11 100644 --- a/lib/server.js +++ b/lib/server.js @@ -30,7 +30,7 @@ express = main.express, expressApp = express.getApp(controller), - Server, Rest, Route, Minimize; + Server, Rest, Route; /* базовая инициализация */ function init(pAppCachProcessing) { @@ -42,9 +42,6 @@ */ Minify.setAllowed(lMinifyAllowed); - /* Если нужно минимизируем скрипты */ - Util.exec(Minimize, lMinifyAllowed); - /* создаём файл app cache */ if (lConfig.appcache && AppCache && lConfig.server ) Util.exec( pAppCachProcessing ); @@ -64,7 +61,6 @@ Rest = pProcessing.rest; Route = pProcessing.route; - Minimize = pProcessing.minimize; init(pProcessing.appcache); From 1ff198b90c1b159ca2aaae0635c2baaa3b6060d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 08:51:32 +0000 Subject: [PATCH 109/152] feature(minify) rm force flag --- lib/server/minify.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/server/minify.js b/lib/server/minify.js index 9e971e6b..06783094 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -56,9 +56,7 @@ if(!this.MinFolder) this.MinFolder = Minify.MinFolder; - if(pParams && pParams.force) - Minify.optimize(pName, pParams); - else if(lRet) + if (lRet) IsChanged.isFileChanged(pName, function(pChanged) { if(pChanged) Minify.optimize(pName, pParams); From 25e8e1a1d6f9405235e520f625923a990cbd79a0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 08:52:01 +0000 Subject: [PATCH 110/152] chore(minify) add " " --- lib/server/minify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/minify.js b/lib/server/minify.js index 06783094..fd2e77b6 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -53,7 +53,7 @@ lRet = this.allowed; - if(!this.MinFolder) + if (!this.MinFolder) this.MinFolder = Minify.MinFolder; if (lRet) From 473eca965fd98926a3822bec9fc61b6042fe2206 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 08:59:45 +0000 Subject: [PATCH 111/152] chore(view) add " " --- lib/client/view.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/client/view.js b/lib/client/view.js index d550280d..08654bee 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -42,7 +42,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; padding : 0 }; - this.init = function(pCallBack){ + this.init = function(pCallBack) { var lFunc, lIsFunc, lIsCallBack; Loading = true; @@ -71,7 +71,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; /** * function shows FancyBox */ - this.show = function(pData, pCallBack){ + this.show = function(pData, pCallBack) { var lPath, lElement, lAfterFunc, lFunc; @@ -103,7 +103,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; } }; - this.hide = function(){ + this.hide = function() { $.fancybox.close(); }; @@ -112,7 +112,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; * @pParent - this * @pCallBack - executes, when everything loaded */ - function load(pCallBack){ + function load(pCallBack) { Util.time(Name + ' load'); var lDir = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/', lFiles = [ lDir + 'jquery.fancybox.css', @@ -147,12 +147,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; } - function view(){ + function view() { Images.showLoad(); View.show(); } - function listener(pEvent){ + function listener(pEvent) { var lF3 = Key.F3, lIsBind = Key.isBind(), lKey = pEvent.keyCode; From b6b46091f21467cafeea0900129d83e65a9de1f4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 09:10:44 +0000 Subject: [PATCH 112/152] feature(config) rm border --- css/config.css | 1 - 1 file changed, 1 deletion(-) diff --git a/css/config.css b/css/config.css index 4d10e939..b7e7315f 100644 --- a/css/config.css +++ b/css/config.css @@ -53,6 +53,5 @@ #config #DivBorder{ margin : 10% auto; - border :1px solid #ADCAFD; width :300px; } From 55d2fa0d372f608132fa30d6656eb5f44d02bd3a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 09:11:02 +0000 Subject: [PATCH 113/152] feature(config) add autosize --- lib/client/config.js | 5 ++++- lib/client/view.js | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index bd9fffd3..994ecd5d 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -69,7 +69,10 @@ var CloudCmd, Util, DOM; } Images.hideLoad(); - CloudCmd.View.show(div); + + CloudCmd.View.show(div, null, { + autoSize: true + }); }); }, diff --git a/lib/client/view.js b/lib/client/view.js index 08654bee..2f4a702d 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -71,9 +71,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; /** * function shows FancyBox */ - this.show = function(pData, pCallBack) { - var lPath, lElement, - lAfterFunc, lFunc; + this.show = function(pData, pCallBack, pConfig) { + var lPath, lElement, lAfterFunc, lFunc, name, + config = {}; if (!Loading) { Element = $('
'); @@ -87,7 +87,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; Config.afterShow = lFunc; - $.fancybox(lElement, Config); + Util.copyObj(Config, config); + + for (name in pConfig) + config[name] = pConfig[name]; + + $.fancybox(lElement, config); } else { lPath = CloudFunc.FS + DOM.getCurrentPath(); From bd6f94663cafa8a2f04463749027a887ad55edba Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 09:19:11 +0000 Subject: [PATCH 114/152] feature(config) rm api_url, server, ip, rest from gui --- html/config.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/html/config.html b/html/config.html index 49315e75..f9a5b4b7 100644 --- a/html/config.html +++ b/html/config.html @@ -1,6 +1,5 @@
    -
  • @@ -9,13 +8,9 @@
  • -
  • -
  • -
  • -
From d94a454cfe447642a0df018143a85f4bc7fe8bc6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 09:28:38 +0000 Subject: [PATCH 115/152] feature(config) port, ssl port: add title --- html/config.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/config.html b/html/config.html index f9a5b4b7..bbca6cd8 100644 --- a/html/config.html +++ b/html/config.html @@ -9,8 +9,8 @@
  • -
  • -
  • +
  • +
  • From a8eccebecacb44e09b13bc3f39ba9e82448c7577 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 10:25:34 +0000 Subject: [PATCH 116/152] feature(cloudcmd) rm config watch --- cloudcmd.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index a168278f..c74e8726 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -134,16 +134,6 @@ writeLogsToFile(); } - if (Config.server) - Util.tryCatchLog(function() { - fs.watch(CONFIG_PATH, function() { - /* every catch up - calling twice */ - setTimeout(function() { - readConfig(); - }, 1000); - }); - }); - lParams = { appcache : appCacheProcessing, rest : rest, From addeefdbb279992fd1791db7b8086d64d72c0b26 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 10:30:16 +0000 Subject: [PATCH 117/152] refactor(server) config --- lib/server.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/server.js b/lib/server.js index 5b211a11..8fb941c6 100644 --- a/lib/server.js +++ b/lib/server.js @@ -34,16 +34,15 @@ /* базовая инициализация */ function init(pAppCachProcessing) { - var lConfig = main.config, - lMinifyAllowed = lConfig.minify; - - /* Change default parameters of + var config = main.config; + /* + * Change default parameters of * js/css/html minification */ - Minify.setAllowed(lMinifyAllowed); + Minify.setAllowed(config.minify); /* создаём файл app cache */ - if (lConfig.appcache && AppCache && lConfig.server ) + if (config.appcache && AppCache && config.server ) Util.exec( pAppCachProcessing ); } @@ -177,7 +176,7 @@ AppCache.watch(lName); lName = Path.join(DIR, lName); - lMin = Minify.allowed, + lMin = lConfig.minify, lExt = Util.getExtension(lName), lResult = lMin && Util.strCmp(lExt, ['.js', '.css', '.html']); From 95d0ede4461309eb9457093d334553aef4755520 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 10:35:25 +0000 Subject: [PATCH 118/152] chore(console) add " " --- lib/client/console.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index e30b7fe4..294d3992 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -1,5 +1,5 @@ var CloudCmd, Util, DOM, $; -(function(CloudCmd, Util, DOM){ +(function(CloudCmd, Util, DOM) { 'use strict'; var Buffer = { @@ -9,7 +9,7 @@ var CloudCmd, Util, DOM, $; CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM); - function ConsoleProto(CloudCmd, Util, DOM){ + function ConsoleProto(CloudCmd, Util, DOM) { var Name = 'Console', Loading, jqconsole, @@ -77,10 +77,10 @@ var CloudCmd, Util, DOM, $; handler(); } - CloudCmd.View.show(Element, function(){ + CloudCmd.View.show(Element, function() { var l$Console = jqconsole.$console, l$Input = jqconsole.$input_source, - lFocus = function(){ + lFocus = function() { var x = window.scrollX, y = window.scrollY; @@ -107,7 +107,7 @@ var CloudCmd, Util, DOM, $; } }; - this.hide = function(){ + this.hide = function() { CloudCmd.View.hide(); }; @@ -133,7 +133,7 @@ var CloudCmd, Util, DOM, $; } } - function load(pCallBack){ + function load(pCallBack) { Util.time(Name + ' load'); var lDir = CloudCmd.LIBDIRCLIENT + 'console/', @@ -143,7 +143,7 @@ var CloudCmd, Util, DOM, $; lDir + 'ansi.css' ]; - DOM.anyLoadInParallel(lFiles, function(){ + DOM.anyLoadInParallel(lFiles, function() { Util.timeEnd(Name + ' load'); Loading = false; @@ -151,15 +151,15 @@ var CloudCmd, Util, DOM, $; }); } - function listener(pEvent){ + function listener(pEvent) { var lTRA = Key.TRA, lESC = Key.ESC, lIsBind = Key.isBind(), lKey = pEvent.keyCode; - switch(lKey){ + switch(lKey) { case lTRA: - if (lIsBind){ + if (lIsBind) { Console.show(); DOM.preventDefault(pEvent); } From 2d3d755fac76ea10a516082824867163c4811d71 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 10:46:56 +0000 Subject: [PATCH 119/152] refactor(config) add getTemplate, fillTemplate --- lib/client/config.js | 103 ++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 994ecd5d..cf98dc33 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -10,6 +10,7 @@ var CloudCmd, Util, DOM; Events = DOM.Events, ESC = CloudCmd.Key.ESC, INPUT = 'INPUT', + TEMPLATE, Config = this; this.init = function(pCallBack){ @@ -24,62 +25,62 @@ var CloudCmd, Util, DOM; delete Config.init; }; - this.show = function(){ + this.show = function() { Images.showLoad({top:true}); - DOM.ajax({ - url: '/css/config.css', - success: function (data){ - DOM.cssSet({ - id : 'config-css', - inner : data - }); - - Images.hideLoad(); - }, - - error:Images.showError - }); - - DOM.ajax({ - url: '/html/config.html', - success: function (data) { - CloudCmd.getConfig(function(config) { - var i, n, div, li, param, obj = {}; - - Util.copyObj(config, obj); - - changeConfig(obj); - - data = Util.render(data, obj); - - div = DOM.anyload({ - name : 'div', - id : 'config', - inner : data.toString() - }); - - li = DOM.getByTag(INPUT, div); - n = li.length; - - for (i = 0; i < n; i++) { - param = li[i]; - Events.add('change', change, param); - Events.addKey(key, param); - } - - Images.hideLoad(); - - CloudCmd.View.show(div, null, { - autoSize: true - }); - }); - }, - - error:Images.showError + DOM.cssLoad({ + src : '/css/config.css', + func: getTemplate }); }; + function getTemplate() { + Util.ifExec(TEMPLATE, fillTemplate, function (callback) { + DOM.ajax({ + url : '/html/config.html', + success : function(data) { + TEMPLATE = data; + callback(); + }, + error : Images.showError + }); + + }); + } + + function fillTemplate() { + CloudCmd.getConfig(function(config) { + var i, n, div, data, li, param, obj = {}; + + Util.copyObj(config, obj); + + changeConfig(obj); + + data = Util.render(TEMPLATE, obj); + + div = DOM.anyload({ + name : 'div', + id : 'config', + inner : data.toString() + }); + + li = DOM.getByTag(INPUT, div); + n = li.length; + + for (i = 0; i < n; i++) { + param = li[i]; + Events.add('change', change, param); + Events.addKey(key, param); + } + + Images.hideLoad(); + + CloudCmd.View.show(div, null, { + autoSize: true + }); + }); + } + this.hide = function() { CloudCmd.View.hide(); }; From 8537b0a33256ab792afef930f8d5a13e07195806 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 10:53:26 +0000 Subject: [PATCH 120/152] feature(reset) rm font-size, line-height --- css/reset.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/css/reset.css b/css/reset.css index 9a0cb0f5..0c70b773 100644 --- a/css/reset.css +++ b/css/reset.css @@ -10,7 +10,10 @@ html{ color: #222; } -body { margin: 0; font-size: 1em; line-height: 1.4; } + +body { + margin: 0; +} /* * Remove text-shadow in selection highlight: h5bp.com/i From 7ac3b1d5641d5ff5674f414cf7f8ac8a641a36ac Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 10:55:09 +0000 Subject: [PATCH 121/152] feature(config) add saving of config --- lib/client/config.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index cf98dc33..b532f62f 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -10,6 +10,7 @@ var CloudCmd, Util, DOM; Events = DOM.Events, ESC = CloudCmd.Key.ESC, INPUT = 'INPUT', + CONFIG, TEMPLATE, Config = this; @@ -49,10 +50,10 @@ var CloudCmd, Util, DOM; } function fillTemplate() { - CloudCmd.getConfig(function(config) { + Util.ifExec(CONFIG, function() { var i, n, div, data, li, param, obj = {}; - Util.copyObj(config, obj); + Util.copyObj(CONFIG, obj); changeConfig(obj); @@ -78,6 +79,11 @@ var CloudCmd, Util, DOM; CloudCmd.View.show(div, null, { autoSize: true }); + }, function(callback) { + CloudCmd.getConfig(function(config){ + CONFIG = config; + callback(); + }); }); } @@ -125,6 +131,7 @@ var CloudCmd, Util, DOM; data = el.value; obj[name] = data; + CONFIG[name] = data; DOM.RESTful.config(obj); } From 948dfcab59ba90608046ee15edb9b723085605bc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 11:04:24 +0000 Subject: [PATCH 122/152] feature(minify) rm setAllowed --- cloudcmd.js | 28 ++++++++++------------------ lib/server.js | 5 ----- lib/server/minify.js | 40 +++++++++------------------------------- 3 files changed, 19 insertions(+), 54 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index c74e8726..2bebe41e 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -166,25 +166,17 @@ function readConfig(pCallBack) { fs.readFile(CONFIG_PATH, function(pError, pData) { - var msg, status; - if (!pError) { - status = 'ok'; - - var lStr = pData.toString(), - lReadedConf = Util.parseJSON(lStr); - - if (!Config.minify) - main.config = Config = lReadedConf; - - Util.tryCatchLog(function() { - Config.minify = lReadedConf.minify; - Config.cache = lReadedConf.cache; - - Minify.setAllowed(Config.minify); - }); - } - else + var msg, status, str, readed; + + if (pError) status = 'error'; + else { + status = 'ok'; + str = pData.toString(), + readed = Util.parseJSON(str); + + main.config = Config = readed; + } msg = CloudFunc.formatMsg('read', 'config', status); Util.log(msg); diff --git a/lib/server.js b/lib/server.js index 8fb941c6..8a0e83ca 100644 --- a/lib/server.js +++ b/lib/server.js @@ -35,11 +35,6 @@ /* базовая инициализация */ function init(pAppCachProcessing) { var config = main.config; - /* - * Change default parameters of - * js/css/html minification - */ - Minify.setAllowed(config.minify); /* создаём файл app cache */ if (config.appcache && AppCache && config.server ) diff --git a/lib/server/minify.js b/lib/server/minify.js index fd2e77b6..90d54745 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -28,46 +28,24 @@ exports.Minify = { /* pathes to directories */ INDEX : HTMLDIR + 'index.html', - /* приватный переключатель минимизации */ - allowed : true, - - /* функция разрешает или - * запрещает минимизировать - * css/js/html - * @pAllowed: - структура, в которой - * передаються параметры - * минификации, вида - * {js:true,css:true,html:false; img:true} - * img отвечает за перевод картинок в base64 - * и сохранение их в css-файл - */ - setAllowed :function(pAllowed) { - this.allowed = pAllowed && Minify; - }, optimize: function(pName, pParams) { var lRet; - if (Minify) { + if (!Minify) + Util.log(COULD_NOT_MINIFY); + else { pParams.name = Minify.getName(pName); - lRet = this.allowed; - if (!this.MinFolder) this.MinFolder = Minify.MinFolder; - if (lRet) - IsChanged.isFileChanged(pName, function(pChanged) { - if(pChanged) - Minify.optimize(pName, pParams); - else - Util.exec(pParams.callback, pParams); - }); - } - else { - this.allowed = false; - - Util.log(COULD_NOT_MINIFY); + IsChanged.isFileChanged(pName, function(pChanged) { + if(pChanged) + Minify.optimize(pName, pParams); + else + Util.exec(pParams.callback, pParams); + }); } return lRet; From f504036ccadd51f5592927a21d36f8e75bf39386 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 12:01:24 +0000 Subject: [PATCH 123/152] chore(help) add " ", "\n" --- lib/client/help.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/client/help.js b/lib/client/help.js index b8ba278d..5229cd08 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -9,7 +9,7 @@ var CloudCmd, Util, DOM; Images = DOM.Images, Help = this; - this.init = function(pCallBack){ + this.init = function(pCallBack) { Util.loadOnLoad([ Help.show, CloudCmd.View, @@ -21,8 +21,9 @@ var CloudCmd, Util, DOM; delete Help.init; }; - this.show = function(){ + this.show = function() { Images.showLoad({top:true}); + DOM.cssSet({ id : 'help-css', inner : '#help {' + @@ -37,8 +38,9 @@ var CloudCmd, Util, DOM; DOM.ajax({ url: '/HELP.md', - success: function (pData){ + success: function (pData) { var lData = {text: pData}; + DOM.ajax({ method : 'post', url : 'https://api.github.com/markdown', @@ -62,7 +64,6 @@ var CloudCmd, Util, DOM; }); }; - this.hide = function() { CloudCmd.View.hide(); }; From a2747168c3950ef12cfc699909fb90a86a1aa7b9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 12:03:02 +0000 Subject: [PATCH 124/152] feature(dom) rest: add {top: true} --- lib/client/dom.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index f8993021..c22ee5e1 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -187,7 +187,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; method : 'PUT', url : '/config', data : pData, - callback : pCallBack + callback : pCallBack, + imgPosition : { top: true } }); }; From 83fc547c8d8e979ad26e551496fe1af505da42f7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 12:45:22 +0000 Subject: [PATCH 125/152] feature(style) .cmd-button width: 8% -> 9% --- css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/style.css b/css/style.css index 8f250198..4b585390 100644 --- a/css/style.css +++ b/css/style.css @@ -92,7 +92,7 @@ body { } .cmd-button { - width: 8%; + width: 9%; margin: 20px 2px 0 2px; overflow: hidden; color: rgb(49,123,249); From 7f78df069bfcc0328a12d4125c8c7cdfaeea033c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 12:45:46 +0000 Subject: [PATCH 126/152] feature(ind) f10: rm hidden --- html/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.html b/html/index.html index d37de6d1..c2596d49 100644 --- a/html/index.html +++ b/html/index.html @@ -26,7 +26,7 @@ - + From 2bee4d5f0ea0e783e376a81599217f3e1a7c24e5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 14:38:19 +0000 Subject: [PATCH 127/152] refactor(config) show: add asyncCall --- lib/client/config.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index b532f62f..176f3da2 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -27,21 +27,30 @@ var CloudCmd, Util, DOM; }; this.show = function() { + var funcs = [ + getTemplate, + cssLoad + ]; + Images.showLoad({top:true}); - - DOM.cssLoad({ - src : '/css/config.css', - func: getTemplate - }); + Util.asyncCall(funcs, fillTemplate); }; - function getTemplate() { - Util.ifExec(TEMPLATE, fillTemplate, function (callback) { + function cssLoad(callback) { + DOM.cssLoad({ + src : '/css/config.css', + func: Util.retExec(callback) + }); + } + + + function getTemplate(callback) { + Util.ifExec(TEMPLATE, callback, function (execCall) { DOM.ajax({ url : '/html/config.html', success : function(data) { TEMPLATE = data; - callback(); + execCall(); }, error : Images.showError }); From a886ed5c0ab14a53efcab07419a6b021cc30d308 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 14:48:29 +0000 Subject: [PATCH 128/152] chore(config) add " " --- lib/client/config.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 176f3da2..e3d98412 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -63,19 +63,16 @@ var CloudCmd, Util, DOM; var i, n, div, data, li, param, obj = {}; Util.copyObj(CONFIG, obj); - changeConfig(obj); - - data = Util.render(TEMPLATE, obj); - - div = DOM.anyload({ + data = Util.render(TEMPLATE, obj); + div = DOM.anyload({ name : 'div', id : 'config', inner : data.toString() }); - li = DOM.getByTag(INPUT, div); - n = li.length; + li = DOM.getByTag(INPUT, div); + n = li.length; for (i = 0; i < n; i++) { param = li[i]; @@ -84,7 +81,6 @@ var CloudCmd, Util, DOM; } Images.hideLoad(); - CloudCmd.View.show(div, null, { autoSize: true }); From 8843036584f6a41f932d8195e2965debe965f2f0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 5 Nov 2013 17:42:52 +0200 Subject: [PATCH 129/152] docs(help) add template, style --- HELP.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index e575273e..e18e6da8 100644 --- a/HELP.md +++ b/HELP.md @@ -352,5 +352,7 @@ MIT [license](LICENSE "license"). Special Thanks --------------- -- [Polietilena](http://polietilena.github.io/ "Polietilena") for [logo](img/logo/cloudcmd.png "logo") and [favicon](img/favicon/favicon.png "favicon"). -- [Elec-ua](https://github.com/elec-ua) for [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations. +- [Polietilena](http://polietilena.github.io/ "Polietilena") for [logo](img/logo/cloudcmd.png "logo") and [favicon](img/favicon/favicon.png "favicon"); +- [Elec-ua](https://github.com/elec-ua) + - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; + - config [template](html/config.html) and [style](css/config.css); From 498ed5134ad5cdcac1e07cfcd1f456baa13a85d1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 6 Nov 2013 09:45:42 +0000 Subject: [PATCH 130/152] fix(socket) if " " at begin execption occurs --- lib/server/socket.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 095b7be2..32fa379c 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -120,7 +120,7 @@ function onMessage(pConnNum, pSocket) { return function(pCommand) { var lMsg, lJSON, lWinCommand, lExec_func, lDir, - lHome, lError, lRet, lExecSymbols; + lHome, lError, lRet, lExecSymbols, isContain; Util.log('#' + pConnNum + ': ' + pCommand); @@ -191,11 +191,11 @@ if(!ClientFuncs[pConnNum]) ClientFuncs[pConnNum] = getExec(pSocket, pConnNum); - lExec_func = ClientFuncs[pConnNum]; + lExec_func = ClientFuncs[pConnNum]; + lExecSymbols = ['*','#', '&', '{', '}', '|', '\'', '"']; + isContain = Util.isContainStr(pCommand, lExecSymbols); - lExecSymbols = ['*','#', '&', '{', '}', '|', '\'', '"']; - - if (Util.isContainStr(pCommand, lExecSymbols)) + if (pCommand[0] === ' ' || isContain) exec(pCommand, lExec_func); else getSpawn(pSocket, pConnNum, pCommand); From 6dd45ff241d07b31ee2f47dfafe020414f6e6f04 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 6 Nov 2013 10:59:25 +0000 Subject: [PATCH 131/152] refactor(config) change order of #config #DivBorder --- css/config.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/config.css b/css/config.css index b7e7315f..3e9409ae 100644 --- a/css/config.css +++ b/css/config.css @@ -52,6 +52,6 @@ } #config #DivBorder{ + width : 300px; margin : 10% auto; - width :300px; } From d5909f5a37bf4777656f9d34f704a179a3e9dd07 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 6 Nov 2013 11:00:37 +0000 Subject: [PATCH 132/152] chore(config) #DivBorder -> .border --- css/config.css | 2 +- html/config.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/css/config.css b/css/config.css index 3e9409ae..867f06b2 100644 --- a/css/config.css +++ b/css/config.css @@ -51,7 +51,7 @@ margin: 5%; } -#config #DivBorder{ +#config .border{ width : 300px; margin : 10% auto; } diff --git a/html/config.html b/html/config.html index bbca6cd8..53e4397c 100644 --- a/html/config.html +++ b/html/config.html @@ -1,4 +1,4 @@ -
    +