(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, Util = main.util, update = main.update, Server = main.require(LIBDIR + 'server'), Minify = Server.Minify, srv = Server.CloudServer, Config = main.config; /* reinit main dir os if we on * Win32 should be backslashes */ DIR = main.DIR; readConfig(); Server.start(Config, { appcache : appCacheProcessing, index : indexProcessing, 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(!srv.Config.appcache) lData = Util.removeStr(lData, ' manifest="/cloudcmd.appcache"'); if(!srv.Config.show_keys_panel){ var lKeysPanel = '
auth'); pParams.name = main.HTMLDIR + lName + '.html'; main.sendFile(pParams); lRet = true; }else if( Util.strCmp(lName, '/auth/github') ){ Util.log('* Routing' + '-> github'); pParams.name = main.HTMLDIR + lName + '.html'; main.sendFile(pParams); lRet = true; }else if( Util.isContainStr(lName, [CloudFunc.Fs, CloudFunc.NoJS] ) || Util.strCmp(lName, '/') || Util.strCmp(lName, 'json') ) { main.commander({ request : pParams.request, response : pParams.response, indexProcessing : indexProcessing }); lRet = true; } 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); } })();