From 26ee40697b0e00eabff1b3a4ef921cae627e3e33 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 11 May 2016 20:22:24 +0300 Subject: [PATCH] fix(route) prefix without "/" at beginning in rendered view --- lib/cloudcmd.js | 16 +++++++--------- lib/server/route.js | 20 +++++++------------- package.json | 2 ++ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lib/cloudcmd.js b/lib/cloudcmd.js index 830a8cf4..206b0492 100644 --- a/lib/cloudcmd.js +++ b/lib/cloudcmd.js @@ -14,6 +14,7 @@ validate = require(DIR_SERVER + 'validate'), prefixer = require(DIR_SERVER + 'prefixer'), + apart = require('apart'), join = require('join-io'), ponse = require('ponse'), mollify = require('mollify'), @@ -141,11 +142,11 @@ return config(name); }, - isMinify = isOption.bind(null, 'minify'), - isOnline = isOption.bind(null, 'online'), - isCache = isOption.bind(null, 'cache'), - isDiff = isOption.bind(null, 'diff'), - isZip = isOption.bind(null, 'zip'), + isMinify = apart(isOption, 'minify'), + isOnline = apart(isOption, 'online'), + isCache = apart(isOption, 'cache'), + isDiff = apart(isOption, 'diff'), + isZip = apart(isOption, 'zip'), ponseStatic = ponse.static(DIR_ROOT, { cache: isCache @@ -206,10 +207,7 @@ }), rest, - - route({ - prefix: prefix - }), + route, join({ dir : DIR_ROOT, diff --git a/lib/server/route.js b/lib/server/route.js index fda52ded..b697ba59 100644 --- a/lib/server/route.js +++ b/lib/server/route.js @@ -19,9 +19,13 @@ minify = require('minify'), format = require('format-io'), + squad = require('squad'), + apart = require('apart'), config = require(DIR_SERVER + 'config'), root = require(DIR_SERVER + 'root'), + prefixer = require(DIR_SERVER + 'prefixer'), + prefix = squad(prefixer, apart(config, 'prefix')), CloudFunc = require(DIR_LIB + 'cloudfunc'), @@ -37,8 +41,6 @@ Template = {}, - Prefix, - FS = CloudFunc.FS, CSS_URL = require(DIR_JSON + 'css.json') @@ -47,15 +49,7 @@ }).join(':'); - module.exports = function(params) { - var p = params || {}; - - Prefix = p.prefix || ''; - - return middle; - }; - - function middle(req, res, next) { + module.exports = function (req, res, next) { readFiles(function() { route(req, res, next); }); @@ -95,7 +89,7 @@ data = rendy(data, { title : CloudFunc.getTitle(), fm : left + right, - prefix : Prefix, + prefix : prefix(), css : CSS_URL }); @@ -214,7 +208,7 @@ if (!error) { panel = CloudFunc.buildFromJSON({ data : json, - prefix : config('prefix'), + prefix : prefix(), template : Template }), diff --git a/package.json b/package.json index ccdcd4d7..6aa6cb02 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ }, "subdomain": "cloudcmd", "dependencies": { + "apart": "~1.0.1", "chalk": "~1.1.0", "checkup": "~1.3.0", "console-io": "~2.7.1", @@ -98,6 +99,7 @@ "restafary": "~1.6.0", "socket.io": "~1.4.3", "spero": "~1.3.0", + "squad": "~1.1.3", "try-catch": "~1.0.0", "tryrequire": "~1.1.5", "writejson": "~1.1.0"