moved extensions from main.js to json/ext.json

This commit is contained in:
coderaiser 2013-01-31 04:19:16 -05:00
parent dc7b0673fd
commit 75dafc40ff
4 changed files with 181 additions and 19 deletions

View file

@ -293,7 +293,7 @@
CloudServer.NoJS = false;
else{
CloudServer.NoJS = true;
lPath = Util.removeStr(lPath, lNoJS_s);
lPath = Util.removeStr(lPath, lNoJS_s);
}
/* убираем индекс файловой системы */

View file

@ -16,20 +16,10 @@
fs,
path,
zlib,
ext,
OK = 200,
ERROR = 404,
Extensions = {
'.css' : 'text/css',
'.js' : 'text/javascript',
'.png' : 'image/png',
'.json' : 'application/json',
'.html' : 'text/html',
'.woff' : 'font/woff',
'.appcache' : 'text/cache-manifest',
'.mp3' : 'audio/mpeg'
};
FILE_NOT_FOUND = 404;
/* Native Modules*/
exports.crypto = require('crypto'),
@ -65,13 +55,14 @@
exports.fs.exists = exports.fs.exists || exports.path.exists;
/* Needed Modules */
exports.util = Util = require(LIBDIR + 'util'),
exports.util = Util = require(LIBDIR + 'util'),
exports.zlib = zlib = mrequire('zlib'),
exports.zlib = zlib = mrequire('zlib'),
/* Main Information */
exports.config = mrequire(JSONDIR + 'config');
exports.modules = mrequire(JSONDIR + 'modules');
exports.config = jsonrequire('config');
exports.modules = jsonrequire('modules');
exports.ext = ext = jsonrequire('ext');
exports.mainpackage = rootrequire('package');
@ -122,6 +113,8 @@
function srvrequire(pSrc){ return mrequire(SRVDIR + pSrc); }
function jsonrequire(pSrc){ return mrequire(JSONDIR + pSrc);}
/**
* function check is current platform is win32
*/
@ -146,7 +139,7 @@
if( Util.strCmp(lExt, '.appcache') )
lCacheControl = 1;
lType = Extensions[lExt] || 'text/plain';
lType = ext[lExt] || 'text/plain';
if( !Util.isContainStr(lType, 'img') )
lContentEncoding = '; charset=UTF-8';
@ -202,7 +195,7 @@
});
lReadStream.on('error', function(pError){
lRes.writeHead(ERROR, 'OK');
lRes.writeHead(FILE_NOT_FOUND, 'OK');
lRes.end(String(pError));
});