pad.libre-service.eu-etherpad/src/node/hooks/express/padreadonly.js

27 lines
764 B
JavaScript
Raw Normal View History

var readOnlyManager = require("../../db/ReadOnlyManager");
var hasPadAccess = require("../../padaccess");
var exporthtml = require("../../utils/ExportHtml");
2012-02-25 00:15:57 +01:00
2012-02-25 16:53:15 +01:00
exports.expressCreateServer = function (hook_name, args, cb) {
// serve read only pad
args.app.get('/ro/:id', async function(req, res) {
2012-02-25 00:15:57 +01:00
// translate the read only pad to a padId
let padId = await readOnlyManager.getPadId(req.params.id);
if (padId == null) {
res.status(404).send('404 - Not Found');
return;
}
2012-02-25 00:15:57 +01:00
// we need that to tell hasPadAcess about the pad
req.params.pad = padId;
2012-02-25 00:15:57 +01:00
if (await hasPadAccess(req, res)) {
// render the html document
let html = await exporthtml.getPadHTMLDocument(padId, null);
res.send(html);
}
2012-02-25 00:15:57 +01:00
});
}