etherpad-lite/src/node/hooks/express/preview.js
Johan Friis fd3472589b Add preview as HTML functionality
Add a toolbar button that opens a new window and shows the content
of the pad as text/html. Used the 'eye' icon from the Iconic set at
http://somerandomdude.com/work/iconic/
2012-09-11 17:37:40 +02:00

19 lines
590 B
JavaScript

var hasPadAccess = require("../../padaccess");
var previewHandler = require('../../handler/PreviewHandler');
exports.expressCreateServer = function (hook_name, args, cb) {
args.app.get('/p/:pad/:rev?/preview/:type', function(req, res, next) {
var types = ['html'];
//send a 404 if we don't support this filetype
if (types.indexOf(req.params.type) == -1) {
next();
return;
}
res.header("Access-Control-Allow-Origin", "*");
hasPadAccess(req, res, function() {
previewHandler.doPreview(req, res, req.params.pad, req.params.type);
});
});
}