diff --git a/src/node/utils/ExportEtherpad.js b/src/node/utils/ExportEtherpad.js index a68ab0b2a..84fe80333 100644 --- a/src/node/utils/ExportEtherpad.js +++ b/src/node/utils/ExportEtherpad.js @@ -18,8 +18,9 @@ var async = require("async"); var db = require("../db/DB").db; var ERR = require("async-stacktrace"); +const thenify = require("thenify").withCallback; -exports.getPadRaw = function(padId, callback){ +exports.getPadRaw = thenify(function(padId, callback){ async.waterfall([ function(cb){ db.get("pad:"+padId, cb); @@ -69,4 +70,4 @@ exports.getPadRaw = function(padId, callback){ ], function(err, data){ callback(null, data); }); -} +}); diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index f001fe452..fb15d867e 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -25,6 +25,7 @@ var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); var eejs = require('ep_etherpad-lite/node/eejs'); var _analyzeLine = require('./ExportHelper')._analyzeLine; var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace; +const thenify = require("thenify").withCallback; function getPadHTML(pad, revNum, callback) { @@ -67,7 +68,7 @@ function getPadHTML(pad, revNum, callback) }); } -exports.getPadHTML = getPadHTML; +exports.getPadHTML = thenify(getPadHTML); exports.getHTMLFromAtext = getHTMLFromAtext; function getHTMLFromAtext(pad, atext, authorColors) @@ -459,7 +460,7 @@ function getHTMLFromAtext(pad, atext, authorColors) return pieces.join(''); } -exports.getPadHTMLDocument = function (padId, revNum, callback) +exports.getPadHTMLDocument = thenify(function (padId, revNum, callback) { padManager.getPad(padId, function (err, pad) { @@ -484,7 +485,7 @@ exports.getPadHTMLDocument = function (padId, revNum, callback) }); }); }); -}; +}); // copied from ACE var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; diff --git a/src/node/utils/ImportEtherpad.js b/src/node/utils/ImportEtherpad.js index 1ff8b9b04..138c42936 100644 --- a/src/node/utils/ImportEtherpad.js +++ b/src/node/utils/ImportEtherpad.js @@ -17,8 +17,9 @@ var log4js = require('log4js'); var async = require("async"); var db = require("../db/DB").db; +const thenify = require("thenify").withCallback; -exports.setPadRaw = function(padId, records, callback) +exports.setPadRaw = thenify(function(padId, records, callback) { records = JSON.parse(records); @@ -70,4 +71,4 @@ exports.setPadRaw = function(padId, records, callback) function() { callback(null, true); }); -} +}); diff --git a/src/node/utils/TidyHtml.js b/src/node/utils/TidyHtml.js index 5d4e6ed75..0f7119894 100644 --- a/src/node/utils/TidyHtml.js +++ b/src/node/utils/TidyHtml.js @@ -5,8 +5,9 @@ var log4js = require('log4js'); var settings = require('./Settings'); var spawn = require('child_process').spawn; +const thenify = require("thenify").withCallback; -exports.tidy = function(srcFile, callback) { +exports.tidy = thenify(function(srcFile, callback) { var logger = log4js.getLogger('TidyHtml'); // Don't do anything if Tidy hasn't been enabled @@ -38,4 +39,4 @@ exports.tidy = function(srcFile, callback) { return callback('Tidy died with exit code ' + code); } }); -}; +}); diff --git a/src/node/utils/padDiff.js b/src/node/utils/padDiff.js index 33938b19c..a801fdc84 100644 --- a/src/node/utils/padDiff.js +++ b/src/node/utils/padDiff.js @@ -1,6 +1,7 @@ var Changeset = require("../../static/js/Changeset"); var async = require("async"); var exportHtml = require('./ExportHtml'); +const thenify = require("thenify").withCallback; function PadDiff (pad, fromRev, toRev) { // check parameters @@ -78,7 +79,7 @@ PadDiff.prototype._isClearAuthorship = function(changeset) { return true; }; -PadDiff.prototype._createClearAuthorship = function(rev, callback) { +PadDiff.prototype._createClearAuthorship = thenify(function(rev, callback) { var self = this; this._pad.getInternalRevisionAText(rev, function(err, atext) { if (err) { @@ -92,9 +93,9 @@ PadDiff.prototype._createClearAuthorship = function(rev, callback) { callback(null, changeset); }); -}; +}); -PadDiff.prototype._createClearStartAtext = function(rev, callback) { +PadDiff.prototype._createClearStartAtext = thenify(function(rev, callback) { var self = this; // get the atext of this revision @@ -119,9 +120,9 @@ PadDiff.prototype._createClearStartAtext = function(rev, callback) { callback(null, newAText); }); }); -}; +}); -PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) { +PadDiff.prototype._getChangesetsInBulk = thenify(function(startRev, count, callback) { var self = this; // find out which revisions we need @@ -150,7 +151,7 @@ PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) { function(err) { callback(err, changesets, authors); }); -}; +}); PadDiff.prototype._addAuthors = function(authors) { var self = this; @@ -163,7 +164,7 @@ PadDiff.prototype._addAuthors = function(authors) { }); }; -PadDiff.prototype._createDiffAtext = function(callback) { +PadDiff.prototype._createDiffAtext = thenify(function(callback) { var self = this; var bulkSize = 100; @@ -237,9 +238,9 @@ PadDiff.prototype._createDiffAtext = function(callback) { } ); }); -}; +}); -PadDiff.prototype.getHtml = function(callback) { +PadDiff.prototype.getHtml = thenify(function(callback) { // cache the html if (this._html != null) { return callback(null, this._html); @@ -283,9 +284,9 @@ PadDiff.prototype.getHtml = function(callback) { function(err) { callback(err, html); }); -}; +}); -PadDiff.prototype.getAuthors = function(callback) { +PadDiff.prototype.getAuthors = thenify(function(callback) { var self = this; // check if html was already produced, if not produce it, this generates the author array at the same time @@ -300,7 +301,7 @@ PadDiff.prototype.getAuthors = function(callback) { } else { callback(null, self._authors); } -}; +}); PadDiff.prototype._extendChangesetWithAuthor = function(changeset, author, apool) { // unpack