moved appcahe processing to cloudcmd.js

This commit is contained in:
coderaiser 2012-11-01 05:55:01 -04:00
parent 42e91991c8
commit eb720db4cf
2 changed files with 25 additions and 21 deletions

View file

@ -11,7 +11,8 @@ var DIR = process.cwd() + '/',
CloudFunc = srvfunc.require(LIBDIR +'cloudfunc'),
update = srvfunc.require(SRVDIR + 'update'),
Config = readConfig();
srv = Server.CloudServer,
Config = readConfig();
Server.start(Config, indexProcessing);
@ -25,7 +26,7 @@ function indexProcessing(pIndex, pList){
* меняем в index.html обычные css на
* минифицированый
*/
if(Server.CloudServer.Minify._allowed.css){
if(srv.Minify._allowed.css){
var lReplace_s = '<link rel=stylesheet href=';
if(lWin32)
lReplace_s = lReplace_s + '/css/reset.css>';
@ -33,7 +34,7 @@ function indexProcessing(pIndex, pList){
lReplace_s = lReplace_s + '"/css/reset.css">';
pIndex = pIndex.replace(lReplace_s, '');
pIndex = pIndex.replace('/css/style.css', Server.CloudServer.Minify.MinFolder + 'all.min.css');
pIndex = pIndex.replace('/css/style.css', srv.Minify.MinFolder + 'all.min.css');
}
pIndex = pIndex.replace('<div id=fm class=no-js>',
@ -43,7 +44,7 @@ function indexProcessing(pIndex, pList){
pIndex = pIndex.replace('<title>Cloud Commander</title>',
'<title>' + CloudFunc.setTitle() + '</title>');
if(!Server.CloudServer.Config.appcache){
if(!srv.Config.appcache){
if(lWin32)
pIndex = pIndex.replace(' manifest=/cloudcmd.appcache', '');
else
@ -54,6 +55,20 @@ function indexProcessing(pIndex, pList){
}
function appCacheProcessing(){
var lAppCache = srv.AppCache;
/* создаём файл app cache */
if(srv.Config.appcache && lAppCache && srv.Config.server){
var lFiles = [{'//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff' : './font/DroidSansMono.woff'},
{'//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js' : './lib/client/jquery.js'}];
if(srv.Minify._allowed.css)
lFiles.push('./min/all.min.css');
lAppCache.addFiles(lFiles);
lAppCache.createManifest();
}
}
function readConfig(){

View file

@ -127,7 +127,7 @@ else
console.log('could not found one of Cloud Commander SS files');
/* базовая инициализация */
CloudServer.init = (function(){
CloudServer.init = (function(pAppCachProcessing){
/* Переменная в которой храниться кэш*/
this.Cache.setAllowed(CloudServer.Config.cache.allowed);
/* Change default parameters of
@ -138,18 +138,7 @@ CloudServer.init = (function(){
this.Minify._allowed = this.Minify.doit();
var lAppCache = CloudServer.AppCache;
/* создаём файл app cache */
if(this.Config.appcache && lAppCache && this.Config.server){
var lFiles = [{'//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff' : './font/DroidSansMono.woff'},
{'//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js' : './lib/client/jquery.js'}];
if(this.Minify._allowed.css)
lFiles.push('./min/all.min.css');
lAppCache.addFiles(lFiles);
lAppCache.createManifest();
}
Util.exec( pAppCachProcessing );
});
@ -157,7 +146,7 @@ CloudServer.init = (function(){
* Функция создаёт сервер
* @param pConfig
*/
CloudServer.start = function (pConfig, pIndexProcessing) {
CloudServer.start = function (pConfig, pIndexProcessing, pAppCachProcessing) {
if(pConfig)
this.Config = pConfig;
else
@ -167,7 +156,7 @@ CloudServer.start = function (pConfig, pIndexProcessing) {
CloudServer.indexProcessing = pIndexProcessing;
this.init();
this.init(pAppCachProcessing);
this.Port = process.env.PORT || /* c9 */
process.env.app_port || /* nodester */
@ -814,7 +803,7 @@ CloudServer.sendResponse = function(pHead, pData, pName){
}
};
exports.start = function(pConfig, pIndexProcessing){
CloudServer.start(pConfig, pIndexProcessing);
exports.start = function(pConfig, pIndexProcessing, pAppCachProcessing){
CloudServer.start(pConfig, pIndexProcessing, pAppCachProcessing);
};
exports.CloudServer = CloudServer;