mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
refactored out readonly pad render combinators
This commit is contained in:
parent
b0a58b0b3e
commit
c5c548db11
1 changed files with 27 additions and 21 deletions
|
@ -243,6 +243,32 @@ function translateRoCombinator(managers, req, ERR){
|
||||||
managers.ro.getPadID(req.params.id, padBack);
|
managers.ro.getPadID(req.params.id, padBack);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function roAsyncOutCombinator(ERR, callback){
|
||||||
|
return function(err, data){
|
||||||
|
if(ERR(err, callback)) return;
|
||||||
|
callback(err, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function roAccessbackCombinator(exporthtml, padId, callback){
|
||||||
|
return function(){
|
||||||
|
exporthtml.getPadHTMLDocument(padId, null, false, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function roRenderCombinator(padAccessp, req, res, exporthtml, ERR){
|
||||||
|
return function(padId, callback){
|
||||||
|
if(null == padId)
|
||||||
|
return callback("notfound");
|
||||||
|
padAccessp(
|
||||||
|
req, res,
|
||||||
|
roAccessbackCombinator(
|
||||||
|
exporthtml, padId,
|
||||||
|
roAsyncOutCombinator(
|
||||||
|
ERR, callback
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
//initalize the database
|
//initalize the database
|
||||||
setupDb,
|
setupDb,
|
||||||
|
@ -348,27 +374,7 @@ async.waterfall([
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
translateRoCombinater({ro: readOnlyManager}, req, ERR),
|
translateRoCombinater({ro: readOnlyManager}, req, ERR),
|
||||||
//render the html document
|
roRenderCombinator(hasPadAccess, req, res, exporthtml, ERR),
|
||||||
function(padId, callback)
|
|
||||||
{
|
|
||||||
//return if the there is no padId
|
|
||||||
if(padId == null)
|
|
||||||
{
|
|
||||||
callback("notfound");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasPadAccess(req, res, function()
|
|
||||||
{
|
|
||||||
//render the html document
|
|
||||||
exporthtml.getPadHTMLDocument(padId, null, false, function(err, _html)
|
|
||||||
{
|
|
||||||
if(ERR(err, callback)) return;
|
|
||||||
//html = _html;
|
|
||||||
callback(null, _html);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function(html, callback)
|
function(html, callback)
|
||||||
{
|
{
|
||||||
res.send(html);
|
res.send(html);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue