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/
This commit is contained in:
Johan Friis 2012-09-11 17:37:40 +02:00
parent b2c06e78d0
commit fd3472589b
7 changed files with 103 additions and 1 deletions

View file

@ -0,0 +1,19 @@
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);
});
});
}