From 21300bd6c7370525761b8067edae54c0c2ba5978 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Fri, 24 Feb 2012 20:45:02 +0100 Subject: [PATCH] Moved static files serving to its own file --- node/server.js | 20 +++++++------------- node/static.js | 17 +++++++++++++++++ node/test.js | 5 ----- pluginomatic.json | 4 ++-- 4 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 node/static.js delete mode 100644 node/test.js diff --git a/node/server.js b/node/server.js index 804a1ad87..de50ea241 100644 --- a/node/server.js +++ b/node/server.js @@ -72,6 +72,13 @@ log4js.setGlobalLogLevel(settings.loglevel); async.waterfall([ plugins.update, + function (callback) { + console.log(["plugins", plugins.plugins]); + console.log(["parts", plugins.parts]); + console.log(["hooks", plugins.hooks]); + callback(); + }, + //initalize the database function (callback) { @@ -147,19 +154,6 @@ async.waterfall([ gracefulShutdown(); }); - //serve static files - app.get('/static/js/require-kernel.js', function (req, res, next) { - res.header("Content-Type","application/javascript; charset: utf-8"); - res.write(minify.requireDefinition()); - res.end(); - }); - app.get('/static/*', function(req, res) - { - var filePath = path.normalize(__dirname + "/.." + - req.url.replace(/\.\./g, '').split("?")[0]); - res.sendfile(filePath, { maxAge: exports.maxAge }); - }); - //serve minified files app.get('/minified/:filename', minify.minifyJS); diff --git a/node/static.js b/node/static.js new file mode 100644 index 000000000..71f40b45d --- /dev/null +++ b/node/static.js @@ -0,0 +1,17 @@ +var path = require('path'); +var minify = require('./utils/Minify'); + +exports.expressServer = function (hook_name, args, cb) { + //serve static files + args.app.get('/static/js/require-kernel.js', function (req, res, next) { + res.header("Content-Type","application/javascript; charset: utf-8"); + res.write(minify.requireDefinition()); + res.end(); + }); + args.app.get('/static/*', function(req, res) + { + var filePath = path.normalize(__dirname + "/.." + + req.url.replace(/\.\./g, '').split("?")[0]); + res.sendfile(filePath, { maxAge: exports.maxAge }); + }); +} diff --git a/node/test.js b/node/test.js deleted file mode 100644 index 5db54720d..000000000 --- a/node/test.js +++ /dev/null @@ -1,5 +0,0 @@ -exports.expressServer = function (hook_name, args, cb) { - args.app.get('/testxx', function(req, res) { - res.send("Testing testing"); - }); -} diff --git a/pluginomatic.json b/pluginomatic.json index ca9ee4163..e78f11492 100644 --- a/pluginomatic.json +++ b/pluginomatic.json @@ -1,8 +1,8 @@ { "parts": [{ - "name": "__builtin__", + "name": "static", "hooks": { - "expressServer": "../test:expressServer" + "expressServer": "../static:expressServer" } }] }