mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
genereteHeaders refactored
This commit is contained in:
parent
0c856ba7f7
commit
893f3cd1a3
2 changed files with 28 additions and 29 deletions
|
|
@ -272,7 +272,7 @@ CloudFunc._getDirPath = function(url)
|
|||
* @pName - получает имя файла
|
||||
* @pExt - расширение
|
||||
*/
|
||||
CloudFunc.checkExtension=function(pName,pExt)
|
||||
CloudFunc.checkExtension = function(pName, pExt)
|
||||
{
|
||||
/* если длина имени больше
|
||||
* длинны расширения -
|
||||
|
|
@ -296,6 +296,12 @@ CloudFunc.checkExtension=function(pName,pExt)
|
|||
return false;
|
||||
};
|
||||
|
||||
CloudFunc.getExtension = function(pName){
|
||||
var lDot = pName.lastIndexOf('.');
|
||||
|
||||
return pName.substr(lDot);
|
||||
};
|
||||
|
||||
/*
|
||||
* Функция формирует заголовки столбиков
|
||||
* @pFileTableTitles - массив названий столбиков
|
||||
|
|
@ -484,8 +490,9 @@ CloudFunc.buildFromJSON = function(pJSON, pKeyBinded)
|
|||
*/
|
||||
try{
|
||||
if(exports){
|
||||
/* экспортируемые функции */
|
||||
/* экспортируемые функции */
|
||||
exports.checkExtension = CloudFunc.checkExtension;
|
||||
exports.getExtension = CloudFunc.getExtension;
|
||||
exports.buildFromJSON = CloudFunc.buildFromJSON;
|
||||
exports.setTitle = CloudFunc.setTitle;
|
||||
exports.getUserUIDsAndNames = CloudFunc.getUserUIDsAndNames;
|
||||
|
|
|
|||
46
server.js
46
server.js
|
|
@ -78,7 +78,17 @@ var CloudServer = {
|
|||
/* КОНСТАНТЫ */
|
||||
INDEX : 'index.html',
|
||||
LIBDIR : './lib',
|
||||
LIBDIRSERVER : './lib/server'
|
||||
LIBDIRSERVER : './lib/server',
|
||||
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'
|
||||
}
|
||||
};
|
||||
|
||||
var DirPath = '/';
|
||||
|
|
@ -191,33 +201,15 @@ CloudServer.generateHeaders = function(pName, pGzip){
|
|||
/* если расширение у файла css -
|
||||
* загружаем стили
|
||||
*/
|
||||
if(CloudFunc.checkExtension(pName,'css'))
|
||||
lType = 'text/css';
|
||||
/* загружаем js */
|
||||
else if(CloudFunc.checkExtension(pName,'js'))
|
||||
lType = 'text/javascript';
|
||||
/* загружаем картинки*/
|
||||
else if(CloudFunc.checkExtension(pName,'png'))
|
||||
lType = 'image/png';
|
||||
/* загружаем json*/
|
||||
else if(CloudFunc.checkExtension(pName,'json'))
|
||||
lType = 'application/json';
|
||||
else if(CloudFunc.checkExtension(pName,'html'))
|
||||
lType = 'text/html';
|
||||
else if(CloudFunc.checkExtension(pName,'woff'))
|
||||
lType = 'font/woff';
|
||||
else if(CloudFunc.checkExtension(pName,'appcache')){
|
||||
lType = 'text/cache-manifest';
|
||||
|
||||
var lExt = CloudFunc.getExtension(pName);
|
||||
console.log(lExt);
|
||||
lType = CloudServer.Extensions[lExt] || 'text/plain';
|
||||
console.log(lType);
|
||||
|
||||
if(lExt === '.appcache')
|
||||
lCacheControl = 1;
|
||||
}
|
||||
else if(CloudFunc.checkExtension(pName,'mp3'))
|
||||
lType = 'audio/mpeg';
|
||||
|
||||
/* если это неизвестный тип файла -
|
||||
* высылаем его просто как текст
|
||||
*/
|
||||
else lType='text/plain';
|
||||
|
||||
|
||||
var lQuery = CloudServer.Queries[pName];
|
||||
if(lQuery){
|
||||
if(lQuery === 'download')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue