From 4ae88b2ee756c7dec48f338eef58e0ae9da5c61e Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 1 Dec 2015 17:38:52 +0000 Subject: [PATCH 1/2] Hook for export ocnvert control --- src/node/handler/ExportHandler.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js index 0a808977..8e7c070b 100644 --- a/src/node/handler/ExportHandler.js +++ b/src/node/handler/ExportHandler.js @@ -105,7 +105,7 @@ exports.doExport = function(req, res, padId, type) //if this is a html export, we can send this from here directly if(type == "html") { - // do any final changes the plugin might want to make cake + // do any final changes the plugin might want to make hooks.aCallFirst("exportHTMLSend", html, function(err, newHTML){ if(newHTML.length) html = newHTML; res.send(html); @@ -133,7 +133,19 @@ exports.doExport = function(req, res, padId, type) function(callback) { destFile = tempDirectory + "/etherpad_export_" + randNum + "." + type; - convertor.convertFile(srcFile, destFile, type, callback); + + var handledByPlugin = false; + // Allow plugins to overwrite the convert in export process + hooks.aCallAll("exportConvert", {srcFile: srcFile, destFile: destFile}, function(err, result){ + if(!err && result.length > 0){ + // console.log("export handled by plugin", destFile); + handledByPlugin = true; + callback(); + }else{ + convertor.convertFile(srcFile, destFile, type, callback); + } + }); + }, //send the file function(callback) From 1a8462fb4fc337e2f49737b40415a771f2c7ba30 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 1 Dec 2015 17:40:16 +0000 Subject: [PATCH 2/2] remove unused variable --- src/node/handler/ExportHandler.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js index 8e7c070b..5e7d6de4 100644 --- a/src/node/handler/ExportHandler.js +++ b/src/node/handler/ExportHandler.js @@ -134,7 +134,6 @@ exports.doExport = function(req, res, padId, type) { destFile = tempDirectory + "/etherpad_export_" + randNum + "." + type; - var handledByPlugin = false; // Allow plugins to overwrite the convert in export process hooks.aCallAll("exportConvert", {srcFile: srcFile, destFile: destFile}, function(err, result){ if(!err && result.length > 0){