2012-02-24 20:45:02 +01:00
|
|
|
var path = require('path');
|
2012-02-25 17:23:44 +01:00
|
|
|
var minify = require('../../utils/Minify');
|
2012-02-25 19:43:00 +01:00
|
|
|
var plugins = require("../../pluginfw/plugins");
|
2012-02-24 20:45:02 +01:00
|
|
|
|
2012-02-25 16:53:15 +01:00
|
|
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
2012-02-24 20:45:02 +01:00
|
|
|
//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();
|
|
|
|
});
|
2012-02-25 19:43:00 +01:00
|
|
|
|
|
|
|
args.app.get('/static/plugins/*', function(req, res) {
|
|
|
|
var url = req.url.replace(/\.\./g, '').split("?")[0];
|
|
|
|
url = url.split("/");
|
|
|
|
url.splice(0, 3);
|
|
|
|
var plugin_name = url.splice(0, 1)[0];
|
|
|
|
url = url.join("/");
|
|
|
|
|
|
|
|
var filePath = path.normalize(path.join(plugins.plugins[plugin_name].package.path, "static", url));
|
|
|
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
|
|
|
});
|
|
|
|
|
|
|
|
args.app.get('/static/*', function(req, res) {
|
2012-02-25 17:23:44 +01:00
|
|
|
var filePath = path.normalize(__dirname + "/../../.." +
|
2012-02-24 20:45:02 +01:00
|
|
|
req.url.replace(/\.\./g, '').split("?")[0]);
|
|
|
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
|
|
|
});
|
|
|
|
}
|