From e4481ea22b911d9818750e74ad30c7983d1a34dc Mon Sep 17 00:00:00 2001 From: Lorenzo Gil Date: Mon, 31 Oct 2011 11:18:44 +0100 Subject: [PATCH 1/7] Allow to get the HTML of the pad with the API --- node/db/API.js | 85 ++++++++++++++++++++++++++++++++++++++ node/handler/APIHandler.js | 1 + node/utils/ExportHtml.js | 2 + 3 files changed, 88 insertions(+) diff --git a/node/db/API.js b/node/db/API.js index 9912b098d..2069ce688 100644 --- a/node/db/API.js +++ b/node/db/API.js @@ -25,6 +25,7 @@ var groupManager = require("./GroupManager"); var authorManager = require("./AuthorManager"); var sessionManager = require("./SessionManager"); var async = require("async"); +var exportHtml = require("../utils/ExportHtml"); /**********************/ /**GROUP FUNCTIONS*****/ @@ -169,6 +170,90 @@ exports.setText = function(padID, text, callback) }); } +/** +getHTML(padID, [rev]) returns the html of a pad + +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) +{ + if(typeof rev == "function") + { + callback = rev; + rev = undefined; + } + + if (rev !== undefined && typeof rev != "number") + { + if (!isNaN(parseInt(rev))) + { + rev = parseInt(rev); + } + else + { + callback({stop: "rev is not a number"}); + return; + } + } + + if(rev !== undefined && rev < 0) + { + callback({stop: "rev is a negative number"}); + return; + } + + if(rev !== undefined && !is_int(rev)) + { + callback({stop: "rev is a float value"}); + return; + } + + getPadSafe(padID, true, function(err, pad) + { + if(err) + { + callback(err); + return; + } + + //the client asked for a special revision + if(rev !== undefined) + { + //check if this is a valid revision + if(rev > pad.getHeadRevisionNumber()) + { + callback({stop: "rev is higher than the head revision of the pad"}); + return; + } + + //get the html of this revision + exportHtml.getPadHTML(pad, rev, function(err, html) + { + if(!err) + { + data = {html: html}; + } + callback(err, data); + }); + } + //the client wants the latest text, lets return it to him + else + { + exportHtml.getPadHTML(pad, undefined, function (err, html) + { + if(!err) + { + data = {html: html}; + } + callback(err, data); + }); + } + }); +} + /*****************/ /**PAD FUNCTIONS */ /*****************/ diff --git a/node/handler/APIHandler.js b/node/handler/APIHandler.js index 34d63f18d..57eeeb734 100644 --- a/node/handler/APIHandler.js +++ b/node/handler/APIHandler.js @@ -50,6 +50,7 @@ var functions = { "listSessionsOfAuthor" : ["authorID"], "getText" : ["padID", "rev"], "setText" : ["padID", "text"], + "getHTML" : ["padID", "rev"], "getRevisionsCount" : ["padID"], "deletePad" : ["padID"], "getReadOnlyID" : ["padID"], diff --git a/node/utils/ExportHtml.js b/node/utils/ExportHtml.js index dce156ec8..354757e1e 100644 --- a/node/utils/ExportHtml.js +++ b/node/utils/ExportHtml.js @@ -85,6 +85,8 @@ function getPadHTML(pad, revNum, callback) }); } +exports.getPadHTML = getPadHTML; + function getHTMLFromAtext(pad, atext) { var apool = pad.apool(); From eecb45cbfd230062d11aeb95a68f62889c39bf88 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 12 Nov 2011 18:30:38 +0000 Subject: [PATCH 2/7] Focus on input box onLoad --- static/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index e995cdb2f..86b33acc0 100644 --- a/static/index.html +++ b/static/index.html @@ -86,12 +86,13 @@ input[type="submit"]::-moz-focus-inner { border: 0 } @-moz-document url-prefix() { input[type="submit"] { padding: 7px } } +
New Pad

or create/open a Pad with the name
-
- + +
@@ -123,4 +124,5 @@ //start the costum js if(typeof costumStart == "function") costumStart(); + \ No newline at end of file From 08e0c91204b2d199d6244e794b3778ced2f54492 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 12 Nov 2011 16:46:10 -0800 Subject: [PATCH 3/7] removed the node v0.4 check, it works now with node v0.6 --- bin/installDeps.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bin/installDeps.sh b/bin/installDeps.sh index cb3676063..3fd6da747 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -20,13 +20,6 @@ hash node > /dev/null 2>&1 || { exit 1 } -#check node version -NODE_VERSION=$(node --version) -if [ ! $(echo $NODE_VERSION | cut -d "." -f 1-2) = "v0.4" ]; then - echo "You're running a wrong version of node, you're using $NODE_VERSION, we need v0.4.x" >&2 - exit 1 -fi - #Is npm installed? hash npm > /dev/null 2>&1 || { echo "Please install npm ( http://npmjs.org )" >&2 From 08fbc3c3bc324765a1e32dc10227057759450b7c Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 12 Nov 2011 16:46:26 -0800 Subject: [PATCH 4/7] Updated all dependencies --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 322fb9139..7be586830 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,16 @@ "name": "Robin Buse"} ], "dependencies" : { - "socket.io" : "0.7.9", + "socket.io" : "0.8.7", "ueberDB" : "0.1.2", - "async" : "0.1.9", - "joose" : "3.18.0", - "express" : "2.4.5", + "async" : "0.1.15", + "joose" : "3.50.0", + "express" : "2.5.0", "clean-css" : "0.2.4", - "uglify-js" : "1.0.7", + "uglify-js" : "1.1.1", "gzip" : "0.1.0", - "formidable" : "1.0.2", - "log4js" : "0.3.8" + "formidable" : "1.0.7", + "log4js" : "0.3.9" }, "version" : "1.0.0" } From 820326dc2bb70c298325fd03145bbd6a5f691f79 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 12 Nov 2011 16:47:01 -0800 Subject: [PATCH 5/7] Output more informations on message dropped --- node/handler/PadMessageHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/handler/PadMessageHandler.js b/node/handler/PadMessageHandler.js index 0fdece233..af4aa6426 100644 --- a/node/handler/PadMessageHandler.js +++ b/node/handler/PadMessageHandler.js @@ -193,7 +193,7 @@ exports.handleMessage = function(client, message) //if the message type is unkown, throw an exception else { - messageLogger.warn("Dropped message, unkown Message Type " + message.type); + messageLogger.warn("Dropped message, unkown Message Type " + message.type + ": " + JSON.stringify(message)); } } From 5f12744446792045446d652e2fd4b38faac8db25 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 12 Nov 2011 17:32:30 -0800 Subject: [PATCH 6/7] update ueberDB --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7be586830..f1c30caa7 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "dependencies" : { "socket.io" : "0.8.7", - "ueberDB" : "0.1.2", + "ueberDB" : "0.1.3", "async" : "0.1.15", "joose" : "3.50.0", "express" : "2.5.0", From dac828e8f6213c19247a698bf092c97a82a94d2e Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 13 Nov 2011 14:32:21 +0000 Subject: [PATCH 7/7] Update static/index.html --- static/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index 86b33acc0..2bed58f98 100644 --- a/static/index.html +++ b/static/index.html @@ -91,7 +91,7 @@
New Pad

or create/open a Pad with the name
-
+