chore(server, minify, ischanged) add " "

This commit is contained in:
coderaiser 2013-08-09 12:55:55 +00:00
parent de42e83fbf
commit 8a02b1cd69
3 changed files with 19 additions and 20 deletions

View file

@ -1,4 +1,4 @@
(function(){
(function() {
'use strict';
if(!global.cloudcmd)
@ -30,7 +30,7 @@
Server, Rest, Route, Minimize;
/* базовая инициализация */
function init(pAppCachProcessing){
function init(pAppCachProcessing) {
var lConfig = main.config,
lMinifyAllowed = lConfig.minification;
@ -74,12 +74,12 @@
lConfig.ip ||
(main.WIN32 ? '127.0.0.1' : '0.0.0.0'),
lSSL = pProcessing.ssl,
lSSL = pProcessing.ssl,
lSSLPort = lConfig.sslPort,
lHTTP = 'http://',
lHTTPS = 'https://',
lSockets = function(pServer){
lSockets = function(pServer) {
var lListen;
if(lConfig.socket && Socket)
lListen = Socket.listen(pServer);
@ -87,7 +87,7 @@
Util.log('* Sockets ' + (lListen ? 'running' : 'disabled'));
},
lHTTPServer = function(){
lHTTPServer = function() {
Server = http.createServer( controller );
Server.on('error', function (pError) {
Util.log(pError);
@ -97,15 +97,15 @@
lSockets(Server);
},
lServerLog = function(pHTTP, pPort){
lServerLog = function(pHTTP, pPort) {
Util.log('* Server running at ' + pHTTP + lIP + ':' + pPort);
};
/* server mode or testing mode */
if (lConfig.server) {
if(lSSL){
if(lSSL) {
Util.log('* Redirection http -> https is setted up');
lServerLog(lHTTP, lPort);
var lRedirectServer = http.createServer( function(pReq, pRes){
var lRedirectServer = http.createServer( function(pReq, pRes) {
var lHost = pReq.headers.host;
main.redirect({
@ -143,8 +143,7 @@
* @param req - запрос клиента (Request)
* @param res - ответ сервера (Response)
*/
function controller(pReq, pRes)
{
function controller(pReq, pRes) {
/* Читаем содержимое папки, переданное в url */
var lRet, lName, lMin, lExt, lResult,
lConfig = main.config,
@ -169,7 +168,7 @@
if( !lRet && Route)
lRet = Util.exec(Route, lData);
if(!lRet){
if(!lRet) {
/* добавляем текующий каталог к пути */
lName = lData.name;
Util.log('reading ' + lName);
@ -189,7 +188,7 @@
lExt === '.html' && lMin.html;
Util.ifExec(!lResult,
function(pParams){
function(pParams) {
var lSendName = pParams && pParams.name || lName;
main.sendFile({
@ -199,7 +198,7 @@
request : pReq,
response : pRes
});
}, function(pCallBack){
}, function(pCallBack) {
Minify.optimize(lName, {
callback : pCallBack,
returnName : true

View file

@ -30,7 +30,7 @@
fs.stat(pFileName, function(pError, pStat){
var lTimeChanged, lFileTime;
if (!pError){
if (!pError) {
lFileTime = pStat.mtime.getTime();
if(lReadedTime !== lFileTime)

View file

@ -1,6 +1,6 @@
/* Обьект для сжатия скриптов и стилей */
(function(){
(function() {
'use strict';
if(!global.cloudcmd)
@ -46,7 +46,7 @@
* img отвечает за перевод картинок в base64
* и сохранение их в css-файл
*/
setAllowed :function(pAllowed){
setAllowed :function(pAllowed) {
this.allowed = pAllowed && Minify ? pAllowed : {
js : false,
css : false,
@ -54,9 +54,9 @@
};
},
optimize: function(pName, pParams){
optimize: function(pName, pParams) {
var lRet;
if(Minify){
if (Minify) {
pParams.name = Minify.getName(pName);
lRet = this.allowed.css || this.allowed.js || this.allowed.html;
@ -67,14 +67,14 @@
if(pParams && pParams.force)
Minify.optimize(pName, pParams);
else if(lRet)
IsChanged.isFileChanged(pName, function(pChanged){
IsChanged.isFileChanged(pName, function(pChanged) {
if(pChanged)
Minify.optimize(pName, pParams);
else
Util.exec(pParams.callback, pParams);
});
}
else{
else {
this.allowed = {
js : false,
css : false,