my version plus recent

This commit is contained in:
Wikinaut 2011-11-13 22:36:01 +01:00
commit e1052a6a5d
7 changed files with 102 additions and 19 deletions

View file

@ -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

View file

@ -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 <strong>Text</strong>"}}
{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 */
/*****************/

View file

@ -50,6 +50,7 @@ var functions = {
"listSessionsOfAuthor" : ["authorID"],
"getText" : ["padID", "rev"],
"setText" : ["padID", "text"],
"getHTML" : ["padID", "rev"],
"getRevisionsCount" : ["padID"],
"deletePad" : ["padID"],
"getReadOnlyID" : ["padID"],

View file

@ -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));
}
}

View file

@ -85,6 +85,8 @@ function getPadHTML(pad, revNum, callback)
});
}
exports.getPadHTML = getPadHTML;
function getHTMLFromAtext(pad, atext)
{
var apool = pad.apool();

View file

@ -10,16 +10,16 @@
"name": "Robin Buse"}
],
"dependencies" : {
"socket.io" : "0.7.9",
"ueberDB" : "0.1.2",
"async" : "0.1.9",
"joose" : "3.18.0",
"express" : "2.4.5",
"socket.io" : "0.8.7",
"ueberDB" : "0.1.3",
"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"
}

View file

@ -89,7 +89,7 @@
<link href="static/custom/index.css" rel="stylesheet">
<script src="static/custom/index.js"></script>
<script>
function go2Name()
function go2Name()
{
var padname = document.getElementById("padname").value;
padname.length > 0 ? window.location = /** "p/" + **/ padname : alert("Please enter a name")
@ -116,11 +116,13 @@
//start the costum js
if(typeof costumStart == "function") costumStart();
</script>
<body onload= "document.mainform.padname.focus();" >
<div id="container">
<div id="button" onclick="go2Random()" title="open a new pad with a generated random name like 'B3GYd74mn2yBH6'">create new random pad</div><br><div id="label">open an existing pad or create a new pad with the name</div>
<form action="#" onsubmit="go2Name();return false;">
<input type="text" id="padname" autofocus>
<form action="#" name="mainform" onsubmit="go2Name();return false;">
<input type="text" name="padname" id="padname" autofocus>
<input type="submit" value="OK">
</form>
</div>
</body>
</html>