From f0bde9bf18b6ded6fb40b3ea5187b49ee3829c02 Mon Sep 17 00:00:00 2001 From: "nelson.silva" Date: Sat, 16 Feb 2013 11:51:10 +0000 Subject: [PATCH 1/3] Added versioning to API functions --- src/node/db/API.js | 19 ++++++++++++++----- src/node/handler/APIHandler.js | 21 ++++++++++++++++++++- src/package.json | 3 ++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index 7a9ce41fa..a9e367f71 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -192,7 +192,7 @@ Example returns: {code: 0, message:"ok", data: {text:"Welcome Text"}} {code: 1, message:"padID does not exist", data: null} */ -exports.getHTML = function(padID, rev, callback) +function getHTML(padID, rev, wrapBody, callback) { if(typeof rev == "function") { @@ -243,8 +243,10 @@ exports.getHTML = function(padID, rev, callback) exportHtml.getPadHTML(pad, rev, function(err, html) { if(ERR(err, callback)) return; - html = "" +html; // adds HTML head - html += ""; + if(wrapBody) { + html = "" +html; // adds HTML head + html += ""; + } data = {html: html}; callback(null, data); }); @@ -255,8 +257,10 @@ exports.getHTML = function(padID, rev, callback) exportHtml.getPadHTML(pad, undefined, function (err, html) { if(ERR(err, callback)) return; - html = "" +html; // adds HTML head - html += ""; + if(wrapBody){ + html = "" +html; // adds HTML head + html += ""; + } data = {html: html}; callback(null, data); }); @@ -264,6 +268,11 @@ exports.getHTML = function(padID, rev, callback) }); } +exports.getHTML = { + "<1.2.7": function(padID, rev, callback){ return getHTML(padID, rev, false, callback); }, + ">=1.2.7": function(padID, rev, callback){ return getHTML(padID, rev, true, callback); } // wrap the body +}; + exports.setHTML = function(padID, html, callback) { //get the pad diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 9f86277a0..7c2d2f737 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -21,6 +21,7 @@ var ERR = require("async-stacktrace"); var fs = require("fs"); +var semver = require("semver"); var api = require("../db/API"); var padManager = require("../db/PadManager"); var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; @@ -326,6 +327,24 @@ function callAPI(apiVersion, functionName, fields, req, res) } }); + var fn = api[functionName]; + + // If this is not a funcion it's a version=>function obj where version uses semver + if(typeof fn != "function") { + + // Get a proper version x.y.z + var v = apiVersion.split("."); + var apiVersion = [v[0]||'0', v[1]||'0', v[2]||'0'].join("."); + + // lookup the first version that satisfies the required version + for(var fnVersion in fn) { + if (semver.satisfies(apiVersion, fnVersion)) { + fn = fn[fnVersion]; + break; + } + } + } + //call the api function - api[functionName](functionParams[0],functionParams[1],functionParams[2],functionParams[3],functionParams[4]); + fn(functionParams[0],functionParams[1],functionParams[2],functionParams[3],functionParams[4]); } diff --git a/src/package.json b/src/package.json index 03df87f9b..64641031b 100644 --- a/src/package.json +++ b/src/package.json @@ -36,7 +36,8 @@ "tinycon" : "0.0.1", "underscore" : "1.3.1", "unorm" : "1.0.0", - "languages4translatewiki" : "0.1.3" + "languages4translatewiki" : "0.1.3", + "semver" : "1.1.3" }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": { From 29b4a045e1cf46026ba96913b766f89b185c6344 Mon Sep 17 00:00:00 2001 From: "nelson.silva" Date: Sat, 16 Feb 2013 12:36:36 +0000 Subject: [PATCH 2/3] Moved semver logic to API. --- src/node/db/API.js | 117 ++++++++++++++++++++++----------- src/node/handler/APIHandler.js | 22 +------ 2 files changed, 79 insertions(+), 60 deletions(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index a9e367f71..b47b061fd 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -19,6 +19,7 @@ */ var ERR = require("async-stacktrace"); +var semver = require("semver"); var customError = require("../utils/customError"); var padManager = require("./PadManager"); var padMessageHandler = require("../handler/PadMessageHandler"); @@ -32,43 +33,49 @@ var importHtml = require("../utils/ImportHtml"); var cleanText = require("./Pad").cleanText; var PadDiff = require("../utils/padDiff"); +var API = {}; + +API["*"] = {}; +API[">=1.2.7"] = {}; + + /**********************/ /**GROUP FUNCTIONS*****/ /**********************/ -exports.listAllGroups = groupManager.listAllGroups; -exports.createGroup = groupManager.createGroup; -exports.createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor; -exports.deleteGroup = groupManager.deleteGroup; -exports.listPads = groupManager.listPads; -exports.createGroupPad = groupManager.createGroupPad; +API["*"].listAllGroups = groupManager.listAllGroups; +API["*"].createGroup = groupManager.createGroup; +API["*"].createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor; +API["*"].deleteGroup = groupManager.deleteGroup; +API["*"].listPads = groupManager.listPads; +API["*"].createGroupPad = groupManager.createGroupPad; /**********************/ /**PADLIST FUNCTION****/ /**********************/ -exports.listAllPads = padManager.listAllPads; +API["*"].listAllPads = padManager.listAllPads; /**********************/ /**AUTHOR FUNCTIONS****/ /**********************/ -exports.createAuthor = authorManager.createAuthor; -exports.createAuthorIfNotExistsFor = authorManager.createAuthorIfNotExistsFor; -exports.getAuthorName = authorManager.getAuthorName; -exports.listPadsOfAuthor = authorManager.listPadsOfAuthor; -exports.padUsers = padMessageHandler.padUsers; -exports.padUsersCount = padMessageHandler.padUsersCount; +API["*"].createAuthor = authorManager.createAuthor; +API["*"].createAuthorIfNotExistsFor = authorManager.createAuthorIfNotExistsFor; +API["*"].getAuthorName = authorManager.getAuthorName; +API["*"].listPadsOfAuthor = authorManager.listPadsOfAuthor; +API["*"].padUsers = padMessageHandler.padUsers; +API["*"].padUsersCount = padMessageHandler.padUsersCount; /**********************/ /**SESSION FUNCTIONS***/ /**********************/ -exports.createSession = sessionManager.createSession; -exports.deleteSession = sessionManager.deleteSession; -exports.getSessionInfo = sessionManager.getSessionInfo; -exports.listSessionsOfGroup = sessionManager.listSessionsOfGroup; -exports.listSessionsOfAuthor = sessionManager.listSessionsOfAuthor; +API["*"].createSession = sessionManager.createSession; +API["*"].deleteSession = sessionManager.deleteSession; +API["*"].getSessionInfo = sessionManager.getSessionInfo; +API["*"].listSessionsOfGroup = sessionManager.listSessionsOfGroup; +API["*"].listSessionsOfAuthor = sessionManager.listSessionsOfAuthor; /************************/ /**PAD CONTENT FUNCTIONS*/ @@ -82,7 +89,7 @@ Example returns: {code: 0, message:"ok", data: {text:"Welcome Text"}} {code: 1, message:"padID does not exist", data: null} */ -exports.getText = function(padID, rev, callback) +API["*"].getText = function(padID, rev, callback) { //check if rev is set if(typeof rev == "function") @@ -162,7 +169,7 @@ Example returns: {code: 1, message:"padID does not exist", data: null} {code: 1, message:"text too long", data: null} */ -exports.setText = function(padID, text, callback) +API["*"].setText = function(padID, text, callback) { //text is required if(typeof text != "string") @@ -268,12 +275,12 @@ function getHTML(padID, rev, wrapBody, callback) }); } -exports.getHTML = { - "<1.2.7": function(padID, rev, callback){ return getHTML(padID, rev, false, callback); }, - ">=1.2.7": function(padID, rev, callback){ return getHTML(padID, rev, true, callback); } // wrap the body -}; +API["*"].getHTML = function(padID, rev, callback){ return getHTML(padID, rev, false, callback); }; -exports.setHTML = function(padID, html, callback) +// this overrides the getHTML function for api version >= 1.2.7 +API[">=1.2.7"].getHTML = function(padID, rev, callback){ return getHTML(padID, rev, true, callback); }; + +API["*"].setHTML = function(padID, html, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -305,7 +312,7 @@ Example returns: {code: 1, message:"padID does not exist", data: null} */ -exports.getChatHistory = function(padID, start, end, callback) +API["*"].getChatHistory = function(padID, start, end, callback) { if(start && end) { @@ -372,7 +379,7 @@ Example returns: {code: 0, message:"ok", data: {revisions: 56}} {code: 1, message:"padID does not exist", data: null} */ -exports.getRevisionsCount = function(padID, callback) +API["*"].getRevisionsCount = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -391,7 +398,7 @@ Example returns: {code: 0, message:"ok", data: {lastEdited: 1340815946602}} {code: 1, message:"padID does not exist", data: null} */ -exports.getLastEdited = function(padID, callback) +API["*"].getLastEdited = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -412,7 +419,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"pad does already exist", data: null} */ -exports.createPad = function(padID, text, callback) +API["*"].createPad = function(padID, text, callback) { //ensure there is no $ in the padID if(padID && padID.indexOf("$") != -1) @@ -437,7 +444,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -exports.deletePad = function(padID, callback) +API["*"].deletePad = function(padID, callback) { getPadSafe(padID, true, function(err, pad) { @@ -455,7 +462,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -exports.getReadOnlyID = function(padID, callback) +API["*"].getReadOnlyID = function(padID, callback) { //we don't need the pad object, but this function does all the security stuff for us getPadSafe(padID, true, function(err) @@ -479,7 +486,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -exports.setPublicStatus = function(padID, publicStatus, callback) +API["*"].setPublicStatus = function(padID, publicStatus, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -512,7 +519,7 @@ Example returns: {code: 0, message:"ok", data: {publicStatus: true}} {code: 1, message:"padID does not exist", data: null} */ -exports.getPublicStatus = function(padID, callback) +API["*"].getPublicStatus = function(padID, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -538,7 +545,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -exports.setPassword = function(padID, password, callback) +API["*"].setPassword = function(padID, password, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -567,7 +574,7 @@ Example returns: {code: 0, message:"ok", data: {passwordProtection: true}} {code: 1, message:"padID does not exist", data: null} */ -exports.isPasswordProtected = function(padID, callback) +API["*"].isPasswordProtected = function(padID, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -593,7 +600,7 @@ Example returns: {code: 0, message:"ok", data: {authorIDs : ["a.s8oes9dhwrvt0zif", "a.akf8finncvomlqva"]} {code: 1, message:"padID does not exist", data: null} */ -exports.listAuthorsOfPad = function(padID, callback) +API["*"].listAuthorsOfPad = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -627,7 +634,7 @@ Example returns: {code: 1, message:"padID does not exist"} */ -exports.sendClientsMessage = function (padID, msg, callback) { +API["*"].sendClientsMessage = function (padID, msg, callback) { getPadSafe(padID, true, function (err, pad) { if (ERR(err, callback)) { return; @@ -645,7 +652,7 @@ Example returns: {"code":0,"message":"ok","data":null} {"code":4,"message":"no or wrong API Key","data":null} */ -exports.checkToken = function(callback) +API["*"].checkToken = function(callback) { callback(); } @@ -658,7 +665,7 @@ Example returns: {code: 0, message:"ok", data: {chatHead: 42}} {code: 1, message:"padID does not exist", data: null} */ -exports.getChatHead = function(padID, callback) +API["*"].getChatHead = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -676,7 +683,7 @@ Example returns: {"code":0,"message":"ok","data":{"html":"Welcome to Etherpad Lite!

This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!

Get involved with Etherpad at http://etherpad.org
aw

","authors":["a.HKIv23mEbachFYfH",""]}} {"code":4,"message":"no or wrong API Key","data":null} */ -exports.createDiffHTML = function(padID, startRev, endRev, callback){ +API["*"].createDiffHTML = function(padID, startRev, endRev, callback){ //check if rev is a number if(startRev !== undefined && typeof startRev != "number") { @@ -803,3 +810,33 @@ function getPadSafe(padID, shouldExist, text, callback) } }); } + +// cache the API functions for each version +var _CACHE = {}; + +module.exports = function(apiVersion) { + + // Get a proper version x.y.z + var v = apiVersion.split("."); + var apiVersion = [v[0]||'0', v[1]||'0', v[2]||'0'].join("."); + + if (! _CACHE[apiVersion]) { + + _CACHE[apiVersion] = {}; + + // got through each of the semver rules + for(var version in API) { + + // if the rule satisfies the required version + if (semver.satisfies(apiVersion, version)) { + // Add these functions + for (var fn in API[version]) { + _CACHE[apiVersion][fn] = API[version][fn]; + } + } + } + + } + + return _CACHE[apiVersion]; +}; \ No newline at end of file diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 7c2d2f737..76e504178 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -21,8 +21,6 @@ var ERR = require("async-stacktrace"); var fs = require("fs"); -var semver = require("semver"); -var api = require("../db/API"); var padManager = require("../db/PadManager"); var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; @@ -327,24 +325,8 @@ function callAPI(apiVersion, functionName, fields, req, res) } }); - var fn = api[functionName]; + var api = require("../db/API")(apiVersion); - // If this is not a funcion it's a version=>function obj where version uses semver - if(typeof fn != "function") { - - // Get a proper version x.y.z - var v = apiVersion.split("."); - var apiVersion = [v[0]||'0', v[1]||'0', v[2]||'0'].join("."); - - // lookup the first version that satisfies the required version - for(var fnVersion in fn) { - if (semver.satisfies(apiVersion, fnVersion)) { - fn = fn[fnVersion]; - break; - } - } - } - //call the api function - fn(functionParams[0],functionParams[1],functionParams[2],functionParams[3],functionParams[4]); + api[functionName](functionParams[0],functionParams[1],functionParams[2],functionParams[3],functionParams[4]); } From 6086d6a8ac1f9076701e72a763bd7ac88b5180c8 Mon Sep 17 00:00:00 2001 From: Nelson Silva Date: Mon, 18 Feb 2013 10:10:58 +0000 Subject: [PATCH 3/3] Address @marcelklehr comments and 'dry' things --- src/node/db/API.js | 85 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index b47b061fd..37dbabe0f 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -33,49 +33,52 @@ var importHtml = require("../utils/ImportHtml"); var cleanText = require("./Pad").cleanText; var PadDiff = require("../utils/padDiff"); -var API = {}; - -API["*"] = {}; -API[">=1.2.7"] = {}; +var API = { + ">=1": {}, + ">=1.1": {}, + ">=1.2": {}, + ">=1.2.1": {}, + ">=1.2.7": {} +}; /**********************/ /**GROUP FUNCTIONS*****/ /**********************/ -API["*"].listAllGroups = groupManager.listAllGroups; -API["*"].createGroup = groupManager.createGroup; -API["*"].createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor; -API["*"].deleteGroup = groupManager.deleteGroup; -API["*"].listPads = groupManager.listPads; -API["*"].createGroupPad = groupManager.createGroupPad; +API[">=1.1"].listAllGroups = groupManager.listAllGroups; +API[">=1"].createGroup = groupManager.createGroup; +API[">=1"].createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor; +API[">=1"].deleteGroup = groupManager.deleteGroup; +API[">=1"].listPads = groupManager.listPads; +API[">=1"].createGroupPad = groupManager.createGroupPad; /**********************/ /**PADLIST FUNCTION****/ /**********************/ -API["*"].listAllPads = padManager.listAllPads; +API[">=1.2.1"].listAllPads = padManager.listAllPads; /**********************/ /**AUTHOR FUNCTIONS****/ /**********************/ -API["*"].createAuthor = authorManager.createAuthor; -API["*"].createAuthorIfNotExistsFor = authorManager.createAuthorIfNotExistsFor; -API["*"].getAuthorName = authorManager.getAuthorName; -API["*"].listPadsOfAuthor = authorManager.listPadsOfAuthor; -API["*"].padUsers = padMessageHandler.padUsers; -API["*"].padUsersCount = padMessageHandler.padUsersCount; +API[">=1"].createAuthor = authorManager.createAuthor; +API[">=1"].createAuthorIfNotExistsFor = authorManager.createAuthorIfNotExistsFor; +API[">=1.1"].getAuthorName = authorManager.getAuthorName; +API[">=1"].listPadsOfAuthor = authorManager.listPadsOfAuthor; +API[">=1.1"].padUsers = padMessageHandler.padUsers; +API[">=1"].padUsersCount = padMessageHandler.padUsersCount; /**********************/ /**SESSION FUNCTIONS***/ /**********************/ -API["*"].createSession = sessionManager.createSession; -API["*"].deleteSession = sessionManager.deleteSession; -API["*"].getSessionInfo = sessionManager.getSessionInfo; -API["*"].listSessionsOfGroup = sessionManager.listSessionsOfGroup; -API["*"].listSessionsOfAuthor = sessionManager.listSessionsOfAuthor; +API[">=1"].createSession = sessionManager.createSession; +API[">=1"].deleteSession = sessionManager.deleteSession; +API[">=1"].getSessionInfo = sessionManager.getSessionInfo; +API[">=1"].listSessionsOfGroup = sessionManager.listSessionsOfGroup; +API[">=1"].listSessionsOfAuthor = sessionManager.listSessionsOfAuthor; /************************/ /**PAD CONTENT FUNCTIONS*/ @@ -89,7 +92,7 @@ Example returns: {code: 0, message:"ok", data: {text:"Welcome Text"}} {code: 1, message:"padID does not exist", data: null} */ -API["*"].getText = function(padID, rev, callback) +API[">=1"].getText = function(padID, rev, callback) { //check if rev is set if(typeof rev == "function") @@ -169,7 +172,7 @@ Example returns: {code: 1, message:"padID does not exist", data: null} {code: 1, message:"text too long", data: null} */ -API["*"].setText = function(padID, text, callback) +API[">=1"].setText = function(padID, text, callback) { //text is required if(typeof text != "string") @@ -275,12 +278,12 @@ function getHTML(padID, rev, wrapBody, callback) }); } -API["*"].getHTML = function(padID, rev, callback){ return getHTML(padID, rev, false, callback); }; +API[">=1"].getHTML = function(padID, rev, callback){ return getHTML(padID, rev, false, callback); }; // this overrides the getHTML function for api version >= 1.2.7 API[">=1.2.7"].getHTML = function(padID, rev, callback){ return getHTML(padID, rev, true, callback); }; -API["*"].setHTML = function(padID, html, callback) +API[">=1"].setHTML = function(padID, html, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -312,7 +315,7 @@ Example returns: {code: 1, message:"padID does not exist", data: null} */ -API["*"].getChatHistory = function(padID, start, end, callback) +API[">=1.2.7"].getChatHistory = function(padID, start, end, callback) { if(start && end) { @@ -379,7 +382,7 @@ Example returns: {code: 0, message:"ok", data: {revisions: 56}} {code: 1, message:"padID does not exist", data: null} */ -API["*"].getRevisionsCount = function(padID, callback) +API[">=1"].getRevisionsCount = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -398,7 +401,7 @@ Example returns: {code: 0, message:"ok", data: {lastEdited: 1340815946602}} {code: 1, message:"padID does not exist", data: null} */ -API["*"].getLastEdited = function(padID, callback) +API[">=1"].getLastEdited = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -419,7 +422,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"pad does already exist", data: null} */ -API["*"].createPad = function(padID, text, callback) +API[">=1"].createPad = function(padID, text, callback) { //ensure there is no $ in the padID if(padID && padID.indexOf("$") != -1) @@ -444,7 +447,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -API["*"].deletePad = function(padID, callback) +API[">=1"].deletePad = function(padID, callback) { getPadSafe(padID, true, function(err, pad) { @@ -462,7 +465,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -API["*"].getReadOnlyID = function(padID, callback) +API[">=1"].getReadOnlyID = function(padID, callback) { //we don't need the pad object, but this function does all the security stuff for us getPadSafe(padID, true, function(err) @@ -486,7 +489,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -API["*"].setPublicStatus = function(padID, publicStatus, callback) +API[">=1"].setPublicStatus = function(padID, publicStatus, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -519,7 +522,7 @@ Example returns: {code: 0, message:"ok", data: {publicStatus: true}} {code: 1, message:"padID does not exist", data: null} */ -API["*"].getPublicStatus = function(padID, callback) +API[">=1"].getPublicStatus = function(padID, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -545,7 +548,7 @@ Example returns: {code: 0, message:"ok", data: null} {code: 1, message:"padID does not exist", data: null} */ -API["*"].setPassword = function(padID, password, callback) +API[">=1"].setPassword = function(padID, password, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -574,7 +577,7 @@ Example returns: {code: 0, message:"ok", data: {passwordProtection: true}} {code: 1, message:"padID does not exist", data: null} */ -API["*"].isPasswordProtected = function(padID, callback) +API[">=1"].isPasswordProtected = function(padID, callback) { //ensure this is a group pad if(padID && padID.indexOf("$") == -1) @@ -600,7 +603,7 @@ Example returns: {code: 0, message:"ok", data: {authorIDs : ["a.s8oes9dhwrvt0zif", "a.akf8finncvomlqva"]} {code: 1, message:"padID does not exist", data: null} */ -API["*"].listAuthorsOfPad = function(padID, callback) +API[">=1"].listAuthorsOfPad = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -634,7 +637,7 @@ Example returns: {code: 1, message:"padID does not exist"} */ -API["*"].sendClientsMessage = function (padID, msg, callback) { +API[">=1.1"].sendClientsMessage = function (padID, msg, callback) { getPadSafe(padID, true, function (err, pad) { if (ERR(err, callback)) { return; @@ -652,7 +655,7 @@ Example returns: {"code":0,"message":"ok","data":null} {"code":4,"message":"no or wrong API Key","data":null} */ -API["*"].checkToken = function(callback) +API[">=1.2"].checkToken = function(callback) { callback(); } @@ -665,7 +668,7 @@ Example returns: {code: 0, message:"ok", data: {chatHead: 42}} {code: 1, message:"padID does not exist", data: null} */ -API["*"].getChatHead = function(padID, callback) +API[">=1.2.7"].getChatHead = function(padID, callback) { //get the pad getPadSafe(padID, true, function(err, pad) @@ -683,7 +686,7 @@ Example returns: {"code":0,"message":"ok","data":{"html":"Welcome to Etherpad Lite!

This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!

Get involved with Etherpad at http://etherpad.org
aw

","authors":["a.HKIv23mEbachFYfH",""]}} {"code":4,"message":"no or wrong API Key","data":null} */ -API["*"].createDiffHTML = function(padID, startRev, endRev, callback){ +API[">=1.2.7"].createDiffHTML = function(padID, startRev, endRev, callback){ //check if rev is a number if(startRev !== undefined && typeof startRev != "number") {