From cb5a529fb477f74e4d4a45e9b0784b8272e44ea4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 16 Oct 2013 14:02:20 +0000 Subject: [PATCH] feature(config) minification -> minify: {} -> true --- HELP.md | 7 +---- cloudcmd.js | 61 +++++++++++++++++++++----------------------- json/config.json | 7 +---- lib/server.js | 6 ++--- lib/server/minify.js | 24 +++++------------ 5 files changed, 39 insertions(+), 66 deletions(-) diff --git a/HELP.md b/HELP.md index ce9c5ff1..106a377e 100644 --- a/HELP.md +++ b/HELP.md @@ -140,12 +140,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "appcache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ "localStorage" : true, /* cache directory data */ - "minification" : { /* minification of js,css,html and img */ - "js" : false, /* minify module needed */ - "css" : false, /* npm i minify */ - "html" : true, - "img" : false - }, + "minify" : true /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ "cache" : true, "logs" : false, /* logs or console ouput */ diff --git a/cloudcmd.js b/cloudcmd.js index 40da7413..5ea7050e 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -44,7 +44,7 @@ /** * additional processing of index file */ - function indexProcessing(pData){ + function indexProcessing(pData) { var lPath, lReplace, lKeysPanel, lData = pData.data, lAdditional = pData.additional; @@ -54,31 +54,31 @@ * меняем в index.html обычные css на * минифицированый */ - if (Minify.allowed.css){ + if (Minify.allowed) { lPath = '/' + Util.removeStr(Minify.MinFolder, DIR); lReplace = ''; lData = Util.removeStr(lData, lReplace) .replace('/css/style.css', lPath + 'all.min.css'); } + if (!Config.appcache) + lData = Util.removeStr(lData, [ + /* min */ + 'manifest=/cloudcmd.appcache', + /* normal */ + 'manifest="/cloudcmd.appcache"' + ]); + + if (!Config.show_keys_panel) { + lKeysPanel = '
' + ''; diff --git a/json/config.json b/json/config.json index 196aa398..2119fe5e 100644 --- a/json/config.json +++ b/json/config.json @@ -3,12 +3,7 @@ "appcache": false, "analytics": true, "localStorage": true, - "minification": { - "js": true, - "css": true, - "html": true, - "img": true - }, + "minify": true, "online": true, "cache": true, "logs": false, diff --git a/lib/server.js b/lib/server.js index 48cfdb0e..a9eaad10 100644 --- a/lib/server.js +++ b/lib/server.js @@ -32,7 +32,7 @@ /* базовая инициализация */ function init(pAppCachProcessing) { var lConfig = main.config, - lMinifyAllowed = lConfig.minification; + lMinifyAllowed = lConfig.minify; /* Change default parameters of * js/css/html minification @@ -179,9 +179,7 @@ lName = Path.join(DIR, lName); lMin = Minify.allowed, lExt = Util.getExtension(lName), - lResult = lExt === '.js' && lMin.js || - lExt === '.css' && lMin.css || - lExt === '.html' && lMin.html; + lResult = lMin && Util.strCmp(lExt, ['.js', '.css', '.html']); Util.ifExec(!lResult, function(pParams) { diff --git a/lib/server/minify.js b/lib/server/minify.js index 3279ef1e..9e971e6b 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -29,12 +29,7 @@ /* pathes to directories */ INDEX : HTMLDIR + 'index.html', /* приватный переключатель минимизации */ - allowed : { - css : true, - js : true, - html : true, - img : true - }, + allowed : true, /* функция разрешает или * запрещает минимизировать @@ -47,19 +42,16 @@ * и сохранение их в css-файл */ setAllowed :function(pAllowed) { - this.allowed = pAllowed && Minify ? pAllowed : { - js : false, - css : false, - html : false - }; + this.allowed = pAllowed && Minify; }, optimize: function(pName, pParams) { var lRet; + if (Minify) { pParams.name = Minify.getName(pName); - lRet = this.allowed.css || this.allowed.js || this.allowed.html; + lRet = this.allowed; if(!this.MinFolder) this.MinFolder = Minify.MinFolder; @@ -75,12 +67,8 @@ }); } else { - this.allowed = { - js : false, - css : false, - html : false - }; - + this.allowed = false; + Util.log(COULD_NOT_MINIFY); }