mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
factored out pad import
This commit is contained in:
parent
b38d88e454
commit
e703fd1ba0
1 changed files with 26 additions and 22 deletions
|
@ -306,9 +306,9 @@ function sendStaticIfPad(goToPad, padManager, path, filename){
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler){
|
function getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler, serverName){
|
||||||
return function(req, res, next){
|
return function getExportPad(req, res, next){
|
||||||
goToPad(req, res, function() {
|
goToPad(req, res, function padback() {
|
||||||
var types = ["pdf", "doc", "txt", "html", "odt", "dokuwiki"];
|
var types = ["pdf", "doc", "txt", "html", "odt", "dokuwiki"];
|
||||||
//send a 404 if we don't support this filetype
|
//send a 404 if we don't support this filetype
|
||||||
if(types.indexOf(req.params.type) == -1)
|
if(types.indexOf(req.params.type) == -1)
|
||||||
|
@ -335,6 +335,27 @@ function getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler){
|
||||||
|
return function postImportPad(req, res, next){
|
||||||
|
goToPad(req, res, function padback() {
|
||||||
|
//if abiword is disabled, skip handling this request
|
||||||
|
if(settings.abiword == null)
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.header("Server", serverName);
|
||||||
|
|
||||||
|
hasPadAccess(req, res, function()
|
||||||
|
{
|
||||||
|
importHandler.doImport(req, res, req.params.pad);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
//initalize the database
|
//initalize the database
|
||||||
setupDb,
|
setupDb,
|
||||||
|
@ -447,27 +468,10 @@ async.waterfall([
|
||||||
|
|
||||||
//serve timeslider.html under /p/$padname/timeslider
|
//serve timeslider.html under /p/$padname/timeslider
|
||||||
//the above comment is wrong
|
//the above comment is wrong
|
||||||
app.get('/p/:pad/:rev?/export/:type', getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler));
|
app.get('/p/:pad/:rev?/export/:type', getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler, serverName));
|
||||||
|
|
||||||
//handle import requests
|
//handle import requests
|
||||||
app.post('/p/:pad/import', function(req, res, next)
|
app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler));
|
||||||
{
|
|
||||||
goToPad(req, res, function() {
|
|
||||||
//if abiword is disabled, skip handling this request
|
|
||||||
if(settings.abiword == null)
|
|
||||||
{
|
|
||||||
next();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
res.header("Server", serverName);
|
|
||||||
|
|
||||||
hasPadAccess(req, res, function()
|
|
||||||
{
|
|
||||||
importHandler.doImport(req, res, req.params.pad);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
var apiLogger = log4js.getLogger("API");
|
var apiLogger = log4js.getLogger("API");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue