2012-02-25 17:23:44 +01:00
|
|
|
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) {
|
2019-02-08 23:20:57 +01:00
|
|
|
// serve read only pad
|
2019-01-23 17:29:36 +01:00
|
|
|
args.app.get('/ro/:id', async function(req, res) {
|
2012-02-25 00:15:57 +01:00
|
|
|
|
2019-01-23 17:29:36 +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
|
|
|
|
2019-01-23 17:29:36 +01:00
|
|
|
// we need that to tell hasPadAcess about the pad
|
|
|
|
req.params.pad = padId;
|
2012-02-25 00:15:57 +01:00
|
|
|
|
2019-01-23 17:29:36 +01:00
|
|
|
if (await hasPadAccess(req, res)) {
|
2019-02-08 23:20:57 +01:00
|
|
|
// render the html document
|
2019-01-23 17:29:36 +01:00
|
|
|
html = await exporthtml.getPadHTMLDocument(padId, null);
|
|
|
|
res.send(html);
|
|
|
|
}
|
2012-02-25 00:15:57 +01:00
|
|
|
});
|
|
|
|
|
2013-12-05 08:41:29 +01:00
|
|
|
}
|