mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Moved static files serving to its own file
This commit is contained in:
parent
1f2b52ba5a
commit
21300bd6c7
4 changed files with 26 additions and 20 deletions
|
@ -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);
|
||||
|
||||
|
|
17
node/static.js
Normal file
17
node/static.js
Normal file
|
@ -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 });
|
||||
});
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
exports.expressServer = function (hook_name, args, cb) {
|
||||
args.app.get('/testxx', function(req, res) {
|
||||
res.send("<em>Testing testing</em>");
|
||||
});
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"parts": [{
|
||||
"name": "__builtin__",
|
||||
"name": "static",
|
||||
"hooks": {
|
||||
"expressServer": "../test:expressServer"
|
||||
"expressServer": "../static:expressServer"
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue