From 41c5b1d8366275a39098b8acb8e391dc5a3d3fda Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 6 Feb 2013 08:02:16 -0500 Subject: [PATCH] minor changes --- cloudcmd.js | 445 +++++++++++++++++++++++++------------------------- shell/kill.js | 36 ++-- 2 files changed, 241 insertions(+), 240 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index d4012c5d..df0fdd1b 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -1,223 +1,224 @@ -(function(){ - 'use strict'; - - var DIR = __dirname + '/', - main = require(DIR + 'lib/server/main'), - - LIBDIR = main.LIBDIR, - SRVDIR = main.SRVDIR, - CLIENTDIR = LIBDIR + 'client', - - path = main.path, - fs = main.fs, - CloudFunc = main.cloudfunc, - AppCache = main.appcache, - Util = main.util, - update = main.update, - - server = main.librequire('server'), - Minify = main.minify, - Config = main.config, - - REQUEST = 'request', - RESPONSE = 'response', - INDEX = DIR + 'html' + main.SLASH + 'index.html'; - - /* reinit main dir os if we on - * Win32 should be backslashes */ - DIR = main.DIR; - - readConfig(); - server.start(Config, { - appcache : appCacheProcessing, - minimize : minimize, - rest : rest, - route : route - }); - - if(update) - update.get(); - - /** - * additional processing of index file - */ - function indexProcessing(pData){ - var lReplace_s, - lData = pData.data, - lAdditional = pData.additional; - - /* - * если выбрана опция минимизировать скрипты - * меняем в index.html обычные css на - * минифицированый - */ - if(Minify.allowed.css){ - var lPath = '/' + Minify.MinFolder.replace(DIR, ''); - lReplace_s = ''; - lData = Util.removeStr(lData, lReplace_s) - .replace('/css/style.css', lPath + 'all.min.css'); - } - - /* меняем title */ - lReplace_s = '
'; - lData = lData.replace(lReplace_s, lReplace_s + lAdditional) - .replace('Cloud Commander', - '' + CloudFunc.getTitle() + ''); - - if(!Config.appcache) - lData = Util.removeStr(lData, ' manifest="/cloudcmd.appcache"'); - - if(!Config.show_keys_panel){ - var lKeysPanel = '
auth'); - - pParams.name = main.HTMLDIR + lName + '.html'; - lRet = main.sendFile(pParams); - }else if( Util.strCmp(lName, '/auth/github') ){ - Util.log('* Routing' + - '-> github'); - - pParams.name = main.HTMLDIR + lName + '.html'; - lRet = main.sendFile(pParams); - }else if( Util.isContainStr(lName, CloudFunc.FS) || - Util.isContainStr(lName, CloudFunc.NO_JS ) || - Util.strCmp(lName, '/') || - Util.strCmp(lName, 'json') ){ - - lRet = main.commander.sendContent({ - request : pParams[REQUEST], - response : pParams[RESPONSE], - processing : indexProcessing, - index : Minify.allowed.html ? Minify.getName(INDEX) : INDEX - }); - } - - return lRet; - } - - - /* function sets stdout to file log.txt */ - function writeLogsToFile(){ - var stdo = fs.createWriteStream('./log.txt'); - - process.stdout.write = (function(write) { - return function(string, encoding, fd) { - stdo.write(string); - }; - })(process.stdout.write); - } +(function(){ + 'use strict'; + + var DIR = __dirname + '/', + main = require(DIR + 'lib/server/main'), + + LIBDIR = main.LIBDIR, + SRVDIR = main.SRVDIR, + CLIENTDIR = LIBDIR + 'client', + HTMLDIR = main.HTMLDIR, + + path = main.path, + fs = main.fs, + CloudFunc = main.cloudfunc, + AppCache = main.appcache, + Util = main.util, + update = main.update, + + server = main.librequire('server'), + Minify = main.minify, + Config = main.config, + + REQUEST = 'request', + RESPONSE = 'response', + INDEX = HTMLDIR + 'index.html'; + + /* reinit main dir os if we on + * Win32 should be backslashes */ + DIR = main.DIR; + + readConfig(); + server.start(Config, { + appcache : appCacheProcessing, + minimize : minimize, + rest : rest, + route : route + }); + + if(update) + update.get(); + + /** + * additional processing of index file + */ + function indexProcessing(pData){ + var lReplace_s, + lData = pData.data, + lAdditional = pData.additional; + + /* + * если выбрана опция минимизировать скрипты + * меняем в index.html обычные css на + * минифицированый + */ + if(Minify.allowed.css){ + var lPath = '/' + Minify.MinFolder.replace(DIR, ''); + lReplace_s = ''; + lData = Util.removeStr(lData, lReplace_s) + .replace('/css/style.css', lPath + 'all.min.css'); + } + + /* меняем title */ + lReplace_s = '
'; + lData = lData.replace(lReplace_s, lReplace_s + lAdditional) + .replace('Cloud Commander', + '' + CloudFunc.getTitle() + ''); + + if(!Config.appcache) + lData = Util.removeStr(lData, ' manifest="/cloudcmd.appcache"'); + + if(!Config.show_keys_panel){ + var lKeysPanel = '
auth'); + + pParams.name = main.HTMLDIR + lName + '.html'; + lRet = main.sendFile(pParams); + }else if( Util.strCmp(lName, '/auth/github') ){ + Util.log('* Routing' + + '-> github'); + + pParams.name = main.HTMLDIR + lName + '.html'; + lRet = main.sendFile(pParams); + }else if( Util.isContainStr(lName, CloudFunc.FS) || + Util.isContainStr(lName, CloudFunc.NO_JS ) || + Util.strCmp(lName, '/') || + Util.strCmp(lName, 'json') ){ + + lRet = main.commander.sendContent({ + request : pParams[REQUEST], + response : pParams[RESPONSE], + processing : indexProcessing, + index : Minify.allowed.html ? Minify.getName(INDEX) : INDEX + }); + } + + return lRet; + } + + + /* function sets stdout to file log.txt */ + function writeLogsToFile(){ + var stdo = fs.createWriteStream('./log.txt'); + + process.stdout.write = (function(write) { + return function(string, encoding, fd) { + stdo.write(string); + }; + })(process.stdout.write); + } })(); \ No newline at end of file diff --git a/shell/kill.js b/shell/kill.js index 30a659dc..8d85033c 100644 --- a/shell/kill.js +++ b/shell/kill.js @@ -1,18 +1,18 @@ - -/* c9.io kill active node process */ - -(function(){ - 'use strict'; - - var exec = require('child_process').exec, - lCmd = 'kill -9' + ' ' + /* kill finded process */ - '`ps ax' + '|' + /* show all process */ - 'grep node-openshift' + '|' + /* find node-openshift */ - 'grep -v grep' + '|' + /* exlude grep command */ - 'awk "{print $1}"`'; /* show first collumn */ - - exec(lCmd, function(error, stdout, stderr){ - console.log(error || stdout || stderr); - }); - -})(); +#!/usr/bin/env node +/* c9.io kill active node process */ + +(function(){ + 'use strict'; + + var exec = require('child_process').exec, + lCmd = 'kill -9' + ' ' + /* kill finded process */ + '`ps ax' + '|' + /* show all process */ + 'grep node-openshift' + '|' + /* find node-openshift */ + 'grep -v grep' + '|' + /* exlude grep command */ + 'awk "{print $1}"`'; /* show first collumn */ + + exec(lCmd, function(error, stdout, stderr){ + console.log(error || stdout || stderr); + }); + +})();