mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-04 22:27:10 -04:00
factored out static sendfile
This commit is contained in:
parent
e1159f0ee0
commit
7b96bb7f8e
1 changed files with 22 additions and 0 deletions
|
@ -226,6 +226,12 @@ function setupShutdown(db, app){
|
|||
|
||||
return process.on('uncaughtException', gracefulShutdown);
|
||||
}
|
||||
function sendStatic(path, res, filename, callback){
|
||||
if("function" != typeof callback) callback = function(){};
|
||||
res.header("Server", serverName);
|
||||
var filePath = path.normalize(__dirname + "/../static/" + filename);
|
||||
return res.sendfile(filePath, { maxAge: exports.maxAge }, callback);
|
||||
}
|
||||
async.waterfall([
|
||||
//initalize the database
|
||||
setupDb,
|
||||
|
@ -406,9 +412,12 @@ async.waterfall([
|
|||
app.get('/p/:pad', function(req, res, next)
|
||||
{
|
||||
goToPad(req, res, function() {
|
||||
return sendStatic(path, res, "pad.html");
|
||||
/*
|
||||
res.header("Server", serverName);
|
||||
var filePath = path.normalize(__dirname + "/../static/pad.html");
|
||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -416,9 +425,12 @@ async.waterfall([
|
|||
app.get('/p/:pad/timeslider', function(req, res, next)
|
||||
{
|
||||
goToPad(req, res, function() {
|
||||
return sendStatic(path, res "timeslider.html");
|
||||
/*
|
||||
res.header("Server", serverName);
|
||||
var filePath = path.normalize(__dirname + "/../static/timeslider.html");
|
||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -538,26 +550,36 @@ async.waterfall([
|
|||
//serve index.html under /
|
||||
app.get('/', function(req, res)
|
||||
{
|
||||
return sendStatic(path, res, "index.html");
|
||||
/*
|
||||
res.header("Server", serverName);
|
||||
var filePath = path.normalize(__dirname + "/../static/index.html");
|
||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||
*/
|
||||
});
|
||||
|
||||
//serve robots.txt
|
||||
app.get('/robots.txt', function(req, res)
|
||||
{
|
||||
return sendStatic(path, res, "robots.txt");
|
||||
/*
|
||||
res.header("Server", serverName);
|
||||
var filePath = path.normalize(__dirname + "/../static/robots.txt");
|
||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||
*/
|
||||
});
|
||||
|
||||
//serve favicon.ico
|
||||
app.get('/favicon.ico', function(req, res)
|
||||
{
|
||||
return sendStatic(path, res, "custom/favicon.ico",
|
||||
function(err){
|
||||
/*
|
||||
res.header("Server", serverName);
|
||||
var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico");
|
||||
res.sendfile(filePath, { maxAge: exports.maxAge }, function(err)
|
||||
{
|
||||
*/
|
||||
//there is no custom favicon, send the default favicon
|
||||
if(err)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue