diff --git a/README.md b/README.md index e075d8212..6b4e1e956 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,14 @@ documented codebase makes it easier for developers to improve the code and contr Etherpad Lite is optimized to be easy embeddable. It provides a [HTTP API](https://github.com/Pita/etherpad-lite/wiki/HTTP-API) that allows your web application to manage pads, users and groups. -You can use this [PHP Client](https://github.com/TomNomNom/etherpad-lite-client) to work with the API -(If you don't want to use PHP, feel free to create a client for your favourite web development language). +There are several clients in for this API: + +* [PHP](https://github.com/TomNomNom/etherpad-lite-client), thx to [TomNomNom](https://github.com/TomNomNom) +* [.Net](https://github.com/ja-jo/EtherpadLiteDotNet), thx to [ja-jo](https://github.com/ja-jo) +* [Node.js](https://github.com/tomassedovic/etherpad-lite-client-js), thx to [tomassedovic](https://github.com/tomassedovic) +* [Ruby](https://github.com/jhollinger/ruby-etherpad-lite), thx to [jhollinger](https://github.com/jhollinger) +* [Python](https://github.com/devjones/PyEtherpadLite), thx to [devjones](https://github.com/devjones) + There is also a [jQuery plugin](https://github.com/johnyma22/etherpad-lite-jquery-plugin) that helps you to embed Pads into your website **Online demo**
@@ -51,12 +57,14 @@ Here is the **[FAQ](https://github.com/Pita/etherpad-lite/wiki/FAQ)** **As root:**
    -
  1. Install the dependencies. We need the gzip, git, curl, libssl develop libraries and python
    apt-get install gzip git-core curl python libssl-dev

  2. +
  3. Install the dependencies. We need gzip, git, curl, libssl develop libraries, python and gcc.
    For Debian/Ubuntu apt-get install gzip git-core curl python libssl-dev build-essential
    + For Fedora/CentOS yum install gzip git-core curl python openssl-dev && yum groupinstall "Development Tools" +

  4. Install node.js
      -
    1. Download the latest 0.4.x node.js release from http://nodejs.org/#download
    2. -
    3. Extract it with tar xf node-v0.4*
    4. -
    5. Move into the node folder cd node-v0.4* and build node with ./configure && make && make install
    6. +
    7. Download the latest 0.6.x node.js release from http://nodejs.org/#download
    8. +
    9. Extract it with tar xf node-v0.6*
    10. +
    11. Move into the node folder cd node-v0.6* and build node with ./configure && make && make install
  5. Install npm curl http://npmjs.org/install.sh | sh
  6. @@ -74,6 +82,8 @@ Here is the **[FAQ](https://github.com/Pita/etherpad-lite/wiki/FAQ)** ## Next Steps You can modify the settings in the file `settings.json` +You should use a dedicated database such as "mysql" if you are planning on using etherpad-lite in a production environment, the "dirty" database driver is only for testing and/or development purposes. + You can update to the latest version with `git pull origin`. The next start with bin/run.sh will update the dependencies Look at this wiki pages: diff --git a/bin/buildForWindows.sh b/bin/buildForWindows.sh index 1c693fa55..8e6ce4f6e 100755 --- a/bin/buildForWindows.sh +++ b/bin/buildForWindows.sh @@ -1,6 +1,6 @@ #!/bin/sh -NODE_VERSION="0.5.4" +NODE_VERSION="0.6.1" #Move to the folder where ep-lite is installed cd `dirname $0` @@ -48,16 +48,6 @@ cp -rL node_modules node_modules_resolved rm -rf node_modules mv node_modules_resolved node_modules -echo "remove sqlite, cause we can't use it with windows..." -rm -rf node_modules/ueberDB/node_modules/sqlite3 - -echo "replace log4js with a patched log4js, this log4js runs on windows too..." -rm -rf node_modules/log4js/* -wget https://github.com/Pita/log4js-node/zipball/master -O log4js.zip -unzip log4js.zip -mv Pita-log4js-node*/* node_modules/log4js -rm -rf log4js.zip Pita-log4js-node* - echo "download windows node..." cd bin wget "http://nodejs.org/dist/v$NODE_VERSION/node.exe" -O node.exe diff --git a/bin/installDeps.sh b/bin/installDeps.sh index cb3676063..59e474563 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 @@ -54,9 +47,9 @@ npm install || { echo "Ensure jQuery is downloaded and up to date..." DOWNLOAD_JQUERY="true" -NEEDED_VERSION="1.6.2" +NEEDED_VERSION="1.7" if [ -f "static/js/jquery.min.js" ]; then - VERSION=$(cat static/js/jquery.min.js | head -n 2 | tail -n 1 | grep -o "v[0-9]*\.[0-9]*\.[0-9]*"); + VERSION=$(cat static/js/jquery.min.js | head -n 1 | grep -o "v[0-9].[0-9]"); if [ ${VERSION#v} = $NEEDED_VERSION ]; then DOWNLOAD_JQUERY="false" 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/db/PadManager.js b/node/db/PadManager.js index 8af299ccc..4e16c7c45 100644 --- a/node/db/PadManager.js +++ b/node/db/PadManager.js @@ -21,10 +21,20 @@ require("../db/Pad"); var db = require("./DB").db; -/** - * A Array with all known Pads +/** + * An Object containing all known Pads. Provides "get" and "set" functions, + * which should be used instead of indexing with brackets. These prepend a + * colon to the key, to avoid conflicting with built-in Object methods or with + * these functions themselves. + * + * If this is needed in other places, it would be wise to make this a prototype + * that's defined somewhere more sensible. */ -globalPads = []; +globalPads = { + get: function (name) { return this[':'+name]; }, + set: function (name, value) { this[':'+name] = value; }, + remove: function (name) { delete this[':'+name]; } +}; /** * Returns a Pad Object with the callback @@ -65,7 +75,7 @@ exports.getPad = function(id, text, callback) } } - var pad = globalPads[id]; + var pad = globalPads.get(id); //return pad if its already loaded if(pad != null) @@ -86,7 +96,7 @@ exports.getPad = function(id, text, callback) } else { - globalPads[id] = pad; + globalPads.set(id, pad); callback(null, pad); } }); @@ -110,6 +120,6 @@ exports.isValidPadId = function(padId) //removes a pad from the array exports.unloadPad = function(padId) { - if(globalPads[padId]) - delete globalPads[padId]; + if(globalPads.get(padId)) + globalPads.remove(padId); } 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/handler/ExportHandler.js b/node/handler/ExportHandler.js index a87219bb7..8cc74747d 100644 --- a/node/handler/ExportHandler.js +++ b/node/handler/ExportHandler.js @@ -81,10 +81,9 @@ exports.doExport = function(req, res, padId, type) res.send(html); callback("stop"); } - //write the html export to a file - else + else //write the html export to a file { - randNum = Math.floor(Math.random()*new Date().getTime()); + randNum = Math.floor(Math.random()*0xFFFFFFFF); srcFile = tempDirectory + "/eplite_export_" + randNum + ".html"; fs.writeFile(srcFile, html, callback); } @@ -114,10 +113,13 @@ exports.doExport = function(req, res, padId, type) function(callback) { //100ms delay to accomidate for slow windows fs - setTimeout(function() - { - fs.unlink(destFile, callback); - }, 100); + if(os.type().indexOf("Windows") > -1) + { + setTimeout(function() + { + fs.unlink(destFile, callback); + }, 100); + } } ], callback); } diff --git a/node/handler/ImportHandler.js b/node/handler/ImportHandler.js index 8936e488a..a1ddf9924 100644 --- a/node/handler/ImportHandler.js +++ b/node/handler/ImportHandler.js @@ -61,10 +61,19 @@ exports.doImport = function(req, res, padId) form.parse(req, function(err, fields, files) { - //save the path of the uploaded file - srcFile = files.file.path; - - callback(err); + //the upload failed, stop at this point + if(err || files.file === undefined) + { + console.warn("Uploading Error: " + err.stack); + callback("uploadFailed"); + } + //everything ok, continue + else + { + //save the path of the uploaded file + srcFile = files.file.path; + callback(); + } }); }, @@ -157,6 +166,13 @@ exports.doImport = function(req, res, padId) } ], function(err) { + //the upload failed, there is nothing we can do, send a 500 + if(err == "uploadFailed") + { + res.send(500); + return; + } + if(err) throw err; //close the connection diff --git a/node/handler/PadMessageHandler.js b/node/handler/PadMessageHandler.js index f89f4934c..5c855651c 100644 --- a/node/handler/PadMessageHandler.js +++ b/node/handler/PadMessageHandler.js @@ -136,7 +136,7 @@ exports.handleDisconnect = function(client) { if(pad2sessions[sessionPad][i] == client.id) { - delete pad2sessions[sessionPad][i]; + pad2sessions[sessionPad].splice(i, 1); break; } } @@ -190,10 +190,10 @@ exports.handleMessage = function(client, message) { handleSuggestUserName(client, message); } - //if the message type is unkown, throw an exception + //if the message type is unknown, throw an exception else { - messageLogger.warn("Droped message, unkown Message Type " + message.type); + messageLogger.warn("Dropped message, unknown Message Type " + message.type); } } @@ -272,12 +272,12 @@ function handleSuggestUserName(client, message) //check if all ok if(message.data.payload.newName == null) { - messageLogger.warn("Droped message, suggestUserName Message has no newName!"); + messageLogger.warn("Dropped message, suggestUserName Message has no newName!"); return; } if(message.data.payload.unnamedId == null) { - messageLogger.warn("Droped message, suggestUserName Message has no unnamedId!"); + messageLogger.warn("Dropped message, suggestUserName Message has no unnamedId!"); return; } @@ -304,7 +304,7 @@ function handleUserInfoUpdate(client, message) //check if all ok if(message.data.userInfo.colorId == null) { - messageLogger.warn("Droped message, USERINFO_UPDATE Message has no colorId!"); + messageLogger.warn("Dropped message, USERINFO_UPDATE Message has no colorId!"); return; } @@ -348,17 +348,17 @@ function handleUserChanges(client, message) //check if all ok if(message.data.baseRev == null) { - messageLogger.warn("Droped message, USER_CHANGES Message has no baseRev!"); + messageLogger.warn("Dropped message, USER_CHANGES Message has no baseRev!"); return; } if(message.data.apool == null) { - messageLogger.warn("Droped message, USER_CHANGES Message has no apool!"); + messageLogger.warn("Dropped message, USER_CHANGES Message has no apool!"); return; } if(message.data.changeset == null) { - messageLogger.warn("Droped message, USER_CHANGES Message has no changeset!"); + messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!"); return; } @@ -600,22 +600,22 @@ function handleClientReady(client, message) //check if all ok if(!message.token) { - messageLogger.warn("Droped message, CLIENT_READY Message has no token!"); + messageLogger.warn("Dropped message, CLIENT_READY Message has no token!"); return; } if(!message.padId) { - messageLogger.warn("Droped message, CLIENT_READY Message has no padId!"); + messageLogger.warn("Dropped message, CLIENT_READY Message has no padId!"); return; } if(!message.protocolVersion) { - messageLogger.warn("Droped message, CLIENT_READY Message has no protocolVersion!"); + messageLogger.warn("Dropped message, CLIENT_READY Message has no protocolVersion!"); return; } if(message.protocolVersion != 2) { - messageLogger.warn("Droped message, CLIENT_READY Message has a unkown protocolVersion '" + message.protocolVersion + "'!"); + messageLogger.warn("Dropped message, CLIENT_READY Message has a unknown protocolVersion '" + message.protocolVersion + "'!"); return; } diff --git a/node/handler/SocketIORouter.js b/node/handler/SocketIORouter.js index 2d8f4f44d..00e3e4f3f 100644 --- a/node/handler/SocketIORouter.js +++ b/node/handler/SocketIORouter.js @@ -128,7 +128,7 @@ exports.setSocketIO = function(_socket) //drop message else { - messageLogger.warn("Droped message cause of bad permissions:" + stringifyWithoutPassword(message)); + messageLogger.warn("Dropped message cause of bad permissions:" + stringifyWithoutPassword(message)); } } }); diff --git a/node/handler/TimesliderMessageHandler.js b/node/handler/TimesliderMessageHandler.js index a06ab54c8..86864977f 100644 --- a/node/handler/TimesliderMessageHandler.js +++ b/node/handler/TimesliderMessageHandler.js @@ -77,7 +77,7 @@ exports.handleMessage = function(client, message) //if the message type is unkown, throw an exception else { - messageLogger.warn("Droped message, unkown Message Type: '" + message.type + "'"); + messageLogger.warn("Dropped message, unknown Message Type: '" + message.type + "'"); } } @@ -85,7 +85,7 @@ function handleClientReady(client, message) { if(message.padId == null) { - messageLogger.warn("Droped message, changeset request has no padId!"); + messageLogger.warn("Dropped message, changeset request has no padId!"); return; } @@ -106,27 +106,27 @@ function handleChangesetRequest(client, message) //check if all ok if(message.data == null) { - messageLogger.warn("Droped message, changeset request has no data!"); + messageLogger.warn("Dropped message, changeset request has no data!"); return; } if(message.padId == null) { - messageLogger.warn("Droped message, changeset request has no padId!"); + messageLogger.warn("Dropped message, changeset request has no padId!"); return; } if(message.data.granularity == null) { - messageLogger.warn("Droped message, changeset request has no granularity!"); + messageLogger.warn("Dropped message, changeset request has no granularity!"); return; } if(message.data.start == null) { - messageLogger.warn("Droped message, changeset request has no start!"); + messageLogger.warn("Dropped message, changeset request has no start!"); return; } if(message.data.requestID == null) { - messageLogger.warn("Droped message, changeset request has no requestID!"); + messageLogger.warn("Dropped message, changeset request has no requestID!"); return; } diff --git a/node/server.js b/node/server.js index 2bebe6a24..1e0b6283c 100644 --- a/node/server.js +++ b/node/server.js @@ -91,7 +91,10 @@ async.waterfall([ var httpLogger = log4js.getLogger("http"); app.configure(function() { - app.use(log4js.connectLogger(httpLogger, { level: log4js.levels.INFO, format: ':status, :method :url'})); + // If the log level specified in the config file is WARN or ERROR the application server never starts listening to requests as reported in issue #158. + // Not installing the log4js connect logger when the log level has a higher severity than INFO since it would not log at that level anyway. + if (!(settings.loglevel === "WARN" || settings.loglevel == "ERROR")) + app.use(log4js.connectLogger(httpLogger, { level: log4js.levels.INFO, format: ':status, :method :url'})); app.use(express.cookieParser()); }); @@ -287,14 +290,13 @@ async.waterfall([ }); var apiLogger = log4js.getLogger("API"); - - //This is a api call, collect all post informations and pass it to the apiHandler - app.get('/api/1/:func', function(req, res) - { + + //This is for making an api call, collecting all post information and passing it to the apiHandler + var apiCaller = function(req, res, fields) { res.header("Server", serverName); res.header("Content-Type", "application/json; charset=utf-8"); - apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(req.query)); + apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(fields)); //wrap the send function so we can log the response res._send = res.send; @@ -311,7 +313,22 @@ async.waterfall([ } //call the api handler - apiHandler.handle(req.params.func, req.query, req, res); + apiHandler.handle(req.params.func, fields, req, res); + } + + //This is a api GET call, collect all post informations and pass it to the apiHandler + app.get('/api/1/:func', function(req, res) + { + apiCaller(req, res, req.query) + }); + + //This is a api POST call, collect all post informations and pass it to the apiHandler + app.post('/api/1/:func', function(req, res) + { + new formidable.IncomingForm().parse(req, function(err, fields, files) + { + apiCaller(req, res, fields) + }); }); //The Etherpad client side sends information about how a disconnect happen @@ -419,25 +436,25 @@ async.waterfall([ //this is only a workaround to ensure it works with all browers behind a proxy //we should remove this when the new socket.io version is more stable - io.set('transports', ['xhr-polling']); + //io.set('transports', ['xhr-polling']); var socketIOLogger = log4js.getLogger("socket.io"); io.set('logger', { debug: function (str) { - socketIOLogger.debug(str); + socketIOLogger.debug.apply(socketIOLogger, arguments); }, info: function (str) { - socketIOLogger.info(str); + socketIOLogger.info.apply(socketIOLogger, arguments); }, warn: function (str) { - socketIOLogger.warn(str); + socketIOLogger.warn.apply(socketIOLogger, arguments); }, error: function (str) { - socketIOLogger.error(str); + socketIOLogger.error.apply(socketIOLogger, arguments); }, }); diff --git a/node/utils/ExportHtml.js b/node/utils/ExportHtml.js index dce156ec8..782bb7016 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(); @@ -119,8 +121,10 @@ function getHTMLFromAtext(pad, atext) var taker = Changeset.stringIterator(text); var assem = Changeset.stringAssembler(); + var openTags = []; function emitOpenTag(i) { + openTags.unshift(i); assem.append('<'); assem.append(tags[i]); assem.append('>'); @@ -128,10 +132,27 @@ function getHTMLFromAtext(pad, atext) function emitCloseTag(i) { + openTags.shift(); assem.append(''); } + + function orderdCloseTags(tags2close) + { + for(var i=0;i= 0; i--) { if (propVals[i] === LEAVE) { - emitCloseTag(i); + //emitCloseTag(i); + tags2close.push(i); propVals[i] = false; } else if (propVals[i] === STAY) { - emitCloseTag(i); + //emitCloseTag(i); + tags2close.push(i); } } + + orderdCloseTags(tags2close); + for (var i = 0; i < propVals.length; i++) { if (propVals[i] === ENTER || propVals[i] === STAY) @@ -231,18 +259,27 @@ function getHTMLFromAtext(pad, atext) { chars--; // exclude newline at end of line, if present } + var s = taker.take(chars); - + + //removes the characters with the code 12. Don't know where they come + //from but they break the abiword parser and are completly useless + s = s.replace(String.fromCharCode(12), ""); + assem.append(_escapeHTML(s)); } // end iteration over spans in line + + var tags2close = []; for (var i = propVals.length - 1; i >= 0; i--) { if (propVals[i]) { - emitCloseTag(i); + tags2close.push(i); propVals[i] = false; } } + + orderdCloseTags(tags2close); } // end processNextChars if (urls) { diff --git a/package.json b/package.json index b90f789a7..f1c30caa7 100644 --- a/package.json +++ b/package.json @@ -3,23 +3,23 @@ "description" : "A Etherpad based on node.js", "homepage" : "https://github.com/Pita/etherpad-lite", "keywords" : ["etherpad", "realtime", "collaborative", "editor"], - "author" : "Peter 'Pita' Martischka ", + "author" : "Peter 'Pita' Martischka - Primary Technology Ltd", "contributors": [ { "name": "John McLear", "name": "Hans Pinckaers", "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" } diff --git a/settings.json.template b/settings.json.template index a7afaecc9..199ac6d0b 100644 --- a/settings.json.template +++ b/settings.json.template @@ -8,7 +8,8 @@ "ip": "0.0.0.0", "port" : 9001, - //The Type of the database. You can choose between sqlite and mysql + //The Type of the database. You can choose between dirty, sqlite and mysql + //You should use mysql or sqlite for anything else than testing or development "dbType" : "dirty", //the database specific settings "dbSettings" : { diff --git a/static/css/pad.css b/static/css/pad.css index 45385a5b7..3d170c3dd 100644 --- a/static/css/pad.css +++ b/static/css/pad.css @@ -93,7 +93,7 @@ a img } input[type="file"] { - color: #fff; + color: #000; } #editbar ul li.separator diff --git a/static/index.html b/static/index.html index e995cdb2f..2bed58f98 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 diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 1575fc9ad..f45c61b23 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -3097,7 +3097,11 @@ function OUTER(gscope) // Such a div is what IE 6 creates naturally when you make a blank line // in a document of divs. However, when copy-and-pasted the div will // contain a space, so we note its emptiness with a property. - lineElem.innerHTML = ""; + if(browser.version < 9) { + lineElem.innerHTML = ""; + } else { + lineElem.innerHTML = "
    "; + } // a primitive-valued property survives copy-and-paste setAssoc(lineElem, "shouldBeEmpty", true); // an object property doesn't @@ -3576,9 +3580,15 @@ function OUTER(gscope) function doTabKey(shiftDown) { - if (!doIndentOutdent(shiftDown)) + if (shiftDown === true){ + doDeleteKey(); + } + else { - performDocumentReplaceSelection(THE_TAB); + if (!doIndentOutdent(shiftDown)) + { + performDocumentReplaceSelection(THE_TAB); + } } } diff --git a/static/js/domline.js b/static/js/domline.js index 119b83783..7732805fd 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -152,6 +152,10 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) { if (href) { + if(!~href.indexOf("http")) // if the url doesn't include http or https etc prefix it. + { + href = "http://"+href; + } extraOpenTags = extraOpenTags + ''; extraCloseTags = '' + extraCloseTags; } diff --git a/static/js/pad2.js b/static/js/pad2.js index b79ff8b97..d6429eea9 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -18,6 +18,7 @@ var socket; var LineNumbersDisabled = false; +var noColors = false; var useMonospaceFontGlobal = false; var globalUserName = false; @@ -78,11 +79,21 @@ function randomString() function getParams() { - var showControls = getUrlVars()["showControls"]; - var showChat = getUrlVars()["showChat"]; - var userName = getUrlVars()["userName"]; - var showLineNumbers = getUrlVars()["showLineNumbers"]; - var useMonospaceFont = getUrlVars()["useMonospaceFont"]; + var params = getUrlVars() + var showControls = params["showControls"]; + var showChat = params["showChat"]; + var userName = params["userName"]; + var showLineNumbers = params["showLineNumbers"]; + var useMonospaceFont = params["useMonospaceFont"]; + var IsnoColors = params["noColors"]; + + if(IsnoColors) + { + if(IsnoColors == "true") + { + noColors = true; + } + } if(showControls) { if(showControls == "false") @@ -120,7 +131,7 @@ function getParams() if(userName) { // If the username is set as a parameter we should set a global value that we can call once we have initiated the pad. - globalUserName = userName; + globalUserName = unescape(userName); } } @@ -236,6 +247,13 @@ function handshake() { pad.changeViewOption('showLineNumbers', false); } + + // If the noColors value is set to true then we need to hide the backround colors on the ace spans + if (noColors == true) + { + pad.changeViewOption('noColors', true); + } + // If the Monospacefont value is set to true then change it to monospace. if (useMonospaceFontGlobal == true) { @@ -245,6 +263,7 @@ function handshake() if (globalUserName !== false) { pad.notifyChangeName(globalUserName); // Notifies the server + pad.myUserInfo.name = globalUserName; $('#myusernameedit').attr({"value":globalUserName}); // Updates the current users UI } } diff --git a/static/js/pad_editor.js b/static/js/pad_editor.js index 93ef36295..e98252cff 100644 --- a/static/js/pad_editor.js +++ b/static/js/pad_editor.js @@ -61,6 +61,8 @@ var padeditor = (function() { pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace'); }); + + noColors = !noColors; // Inversed so we can pass it to showauthorcolors }, setViewOptions: function(newOptions) { @@ -84,6 +86,9 @@ var padeditor = (function() v = getOption('useMonospaceFont', false); self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif")); $("#viewfontmenu").val(v ? "monospace" : "normal"); + + self.ace.setProperty("showsauthorcolors", noColors); + }, initViewZoom: function() {