From 0b6709392b4a14fb5ba9cc92c7135d5f00a25230 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Wed, 7 Nov 2012 23:40:59 -0500 Subject: [PATCH] remove trailing whitespace --- CONTRIBUTING.md | 2 +- Makefile | 2 +- README.md | 18 +- bin/buildForWindows.sh | 14 +- bin/checkPad.js | 30 +- bin/convert.js | 146 ++++----- bin/convertSettings.json.template | 2 +- bin/debugRun.sh | 6 +- bin/extractPadData.js | 20 +- bin/installDeps.sh | 26 +- bin/loadTesting/README | 10 +- bin/safeRun.sh | 16 +- doc/api/changeset_library.md | 4 +- doc/api/hooks_client-side.md | 10 +- doc/api/http_api.md | 30 +- doc/database.md | 4 +- doc/easysync/easysync-full-description.tex | 8 +- doc/easysync/easysync-notes.tex | 4 +- doc/easysync/easysync-notes.txt | 2 +- settings.json.template | 26 +- src/ep.json | 2 +- src/node/db/API.js | 96 +++--- src/node/db/AuthorManager.js | 50 +-- src/node/db/DB.js | 8 +- src/node/db/GroupManager.js | 54 ++-- src/node/db/Pad.js | 18 +- src/node/db/PadManager.js | 22 +- src/node/db/ReadOnlyManager.js | 8 +- src/node/db/SecurityManager.js | 50 +-- src/node/db/SessionManager.js | 64 ++-- src/node/eejs/index.js | 2 +- src/node/handler/APIHandler.js | 18 +- src/node/handler/ExportHandler.js | 16 +- src/node/handler/ImportHandler.js | 42 +-- src/node/handler/PadMessageHandler.js | 228 ++++++------- src/node/handler/SocketIORouter.js | 28 +- src/node/hooks/express.js | 2 +- src/node/hooks/express/apicalls.js | 4 +- src/node/hooks/express/importexport.js | 2 +- src/node/hooks/express/padreadonly.js | 6 +- src/node/hooks/express/socketio.js | 6 +- src/node/hooks/express/specialpages.js | 2 +- src/node/hooks/express/static.js | 6 +- src/node/hooks/express/webaccess.js | 4 +- src/node/server.js | 10 +- src/node/utils/Abiword.js | 30 +- src/node/utils/ExportDokuWiki.js | 6 +- src/node/utils/ExportHtml.js | 54 ++-- src/node/utils/Minify.js | 8 +- src/node/utils/Settings.js | 4 +- src/node/utils/customError.js | 4 +- src/package.json | 4 +- src/static/css/admin.css | 260 +++++++-------- src/static/css/iframe_editor.css | 2 +- src/static/css/pad.css | 8 +- src/static/js/AttributeManager.js | 60 ++-- src/static/js/AttributePool.js | 2 +- src/static/js/Changeset.js | 82 ++--- src/static/js/ace.js | 24 +- src/static/js/ace2_common.js | 2 +- src/static/js/ace2_inner.js | 146 ++++----- src/static/js/admin/jquery.autosize.js | 358 ++++++++++----------- src/static/js/admin/minify.json.js | 10 +- src/static/js/admin/plugins.js | 4 +- src/static/js/admin/settings.js | 4 +- src/static/js/broadcast.js | 28 +- src/static/js/broadcast_revisions.js | 2 +- src/static/js/broadcast_slider.js | 28 +- src/static/js/changesettracker.js | 2 +- src/static/js/chat.js | 28 +- src/static/js/collab_client.js | 6 +- src/static/js/colorutils.js | 2 +- src/static/js/contentcollector.js | 18 +- src/static/js/cssmanager.js | 6 +- src/static/js/domline.js | 14 +- src/static/js/draggable.js | 2 +- src/static/js/farbtastic.js | 24 +- src/static/js/jquery.js | 82 ++--- src/static/js/linestylefilter.js | 14 +- src/static/js/pad.js | 40 +-- src/static/js/pad_connectionstatus.js | 12 +- src/static/js/pad_cookie.js | 2 +- src/static/js/pad_docbar.js | 2 +- src/static/js/pad_editbar.js | 14 +- src/static/js/pad_editor.js | 2 +- src/static/js/pad_impexp.js | 26 +- src/static/js/pad_modals.js | 4 +- src/static/js/pad_userlist.js | 10 +- src/static/js/pad_utils.js | 6 +- src/static/js/pluginfw/installer.js | 4 +- src/static/js/pluginfw/plugins.js | 4 +- src/static/js/skiplist.js | 4 +- src/static/js/timeslider.js | 6 +- src/static/js/undomodule.js | 2 +- src/static/js/virtual_lines.js | 2 +- src/static/tests.html | 12 +- src/templates/admin/index.html | 40 +-- src/templates/admin/plugins.html | 180 +++++------ src/templates/admin/settings.html | 68 ++-- src/templates/index.html | 32 +- src/templates/pad.html | 12 +- src/templates/timeslider.html | 14 +- src/web.config | 2 +- tools/doc/generate.js | 2 +- 104 files changed, 1479 insertions(+), 1479 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f42a82d9..7ba0e85b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ IRC channels: [#etherpad](irc://freenode/#etherpad) ([webchat](http://webchat.fr * easy to use for people * using less resources on server side * easy to embed for admins -* also runable as etherpad lite only +* also runable as etherpad lite only * keep it maintainable, we don't wanna end ob as the monster Etherpad was * extensible, as much functionality should be extendable with plugins so changes don't have to be done in core diff --git a/Makefile b/Makefile index 4e870a452..c6f3409f3 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ outdoc_files = $(addprefix out/,$(doc_sources:.md=.html)) docassets = $(addprefix out/,$(wildcard doc/assets/*)) -VERSION = $(shell node -e "console.log( require('./src/package.json').version )") +VERSION = $(shell node -e "console.log( require('./src/package.json').version )") docs: $(outdoc_files) $(docassets) diff --git a/README.md b/README.md index deb2ced23..5acfa0cc4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Making collaborative editing the standard on the web # About -Etherpad lite is a really-real time collaborative editor spawned from the Hell fire of Etherpad. -We're reusing the well tested Etherpad easysync library to make it really realtime. Etherpad Lite -is based on node.js ergo is much lighter and more stable than the original Etherpad. Our hope -is that this will encourage more users to use and install a realtime collaborative editor. A smaller, manageable and well +Etherpad lite is a really-real time collaborative editor spawned from the Hell fire of Etherpad. +We're reusing the well tested Etherpad easysync library to make it really realtime. Etherpad Lite +is based on node.js ergo is much lighter and more stable than the original Etherpad. Our hope +is that this will encourage more users to use and install a realtime collaborative editor. A smaller, manageable and well documented codebase makes it easier for developers to improve the code and contribute towards the project. **Etherpad vs Etherpad lite** @@ -24,10 +24,10 @@ documented codebase makes it easier for developers to improve the code and contr RAM Usage immediately after start257 MB (grows to ~1GB)16 MB (grows to ~30MB) - + -Etherpad Lite is designed to be easily embeddable and provides a [HTTP API](https://github.com/Pita/etherpad-lite/wiki/HTTP-API) +Etherpad Lite is designed to be easily embeddable and provides a [HTTP API](https://github.com/Pita/etherpad-lite/wiki/HTTP-API) that allows your web application to manage pads, users and groups. It is recommended to use the client implementations available for this API, listed on [this wiki page](https://github.com/Pita/etherpad-lite/wiki/HTTP-API-client-libraries). There is also a [jQuery plugin](https://github.com/johnyma22/etherpad-lite-jquery-plugin) that helps you to embed Pads into your website @@ -62,8 +62,8 @@ Update to the latest version with `git pull origin`, then run `bin\installOnWind [Next steps](#next-steps). ## Linux -You'll need gzip, git, curl, libssl develop libraries, python and gcc. -*For Debian/Ubuntu*: `apt-get install gzip git-core curl python libssl-dev pkg-config build-essential` +You'll need gzip, git, curl, libssl develop libraries, python and gcc. +*For Debian/Ubuntu*: `apt-get install gzip git-core curl python libssl-dev pkg-config build-essential` *For Fedora/CentOS*: `yum install gzip git-core curl python openssl-devel && yum groupinstall "Development Tools"` Additionally, you'll need [node.js](http://nodejs.org). @@ -73,7 +73,7 @@ Additionally, you'll need [node.js](http://nodejs.org). 1. Move to a folder where you want to install Etherpad Lite. Clone the git repository `git clone git://github.com/Pita/etherpad-lite.git` 2. Change into the new directory containing the cloned source code `cd etherpad-lite` -Now, run `bin\run.sh` and open in your browser. +Now, run `bin\run.sh` and open in your browser. Update to the latest version with `git pull origin`. The next start with bin/run.sh will update the dependencies. diff --git a/bin/buildForWindows.sh b/bin/buildForWindows.sh index 1d47bff1b..d70fe40de 100755 --- a/bin/buildForWindows.sh +++ b/bin/buildForWindows.sh @@ -11,26 +11,26 @@ if [ -d "../bin" ]; then fi #Is wget installed? -hash wget > /dev/null 2>&1 || { +hash wget > /dev/null 2>&1 || { echo "Please install wget" >&2 - exit 1 + exit 1 } #Is zip installed? -hash zip > /dev/null 2>&1 || { +hash zip > /dev/null 2>&1 || { echo "Please install zip" >&2 - exit 1 + exit 1 } #Is zip installed? -hash unzip > /dev/null 2>&1 || { +hash unzip > /dev/null 2>&1 || { echo "Please install unzip" >&2 - exit 1 + exit 1 } START_FOLDER=$(pwd); -echo "create a clean environment in /tmp/etherpad-lite-win..." +echo "create a clean environment in /tmp/etherpad-lite-win..." rm -rf /tmp/etherpad-lite-win cp -ar . /tmp/etherpad-lite-win cd /tmp/etherpad-lite-win diff --git a/bin/checkPad.js b/bin/checkPad.js index a46c18140..efc75deae 100644 --- a/bin/checkPad.js +++ b/bin/checkPad.js @@ -25,11 +25,11 @@ async.series([ { db.init(callback); }, - //get the pad + //get the pad function (callback) { padManager = require('../src/node/db/PadManager'); - + padManager.doesPadExists(padId, function(err, exists) { if(!exists) @@ -37,8 +37,8 @@ async.series([ console.error("Pad does not exist"); process.exit(1); } - - padManager.getPad(padId, function(err, _pad) + + padManager.getPad(padId, function(err, _pad) { pad = _pad; callback(err); @@ -46,7 +46,7 @@ async.series([ }); }, function (callback) - { + { //create an array with key kevisions //key revisions always save the full pad atext var head = pad.getHeadRevisionNumber(); @@ -55,7 +55,7 @@ async.series([ { keyRevisions.push(i); } - + //run trough all key revisions async.forEachSeries(keyRevisions, function(keyRev, callback) { @@ -65,10 +65,10 @@ async.series([ { revisionsNeeded.push(i); } - + //this array will hold all revision changesets var revisions = []; - + //run trough all needed revisions and get them from the database async.forEach(revisionsNeeded, function(revNum, callback) { @@ -84,14 +84,14 @@ async.series([ callback(err); return; } - + //check if the pad has a pool if(pad.pool === undefined ) { console.error("Attribute pool is missing"); process.exit(1); } - + //check if there is a atext in the keyRevisions if(revisions[keyRev] === undefined || revisions[keyRev].meta === undefined || revisions[keyRev].meta.atext === undefined) { @@ -99,10 +99,10 @@ async.series([ callback(); return; } - + var apool = pad.pool; var atext = revisions[keyRev].meta.atext; - + for(var i=keyRev+1;i<=keyRev+100 && i<=head; i++) { try @@ -118,7 +118,7 @@ async.series([ return; } } - + callback(); }); }, callback); @@ -126,8 +126,8 @@ async.series([ ], function (err) { if(err) throw err; - else - { + else + { console.log("finished"); process.exit(0); } diff --git a/bin/convert.js b/bin/convert.js index 4bbdd667c..ea8d6e612 100644 --- a/bin/convert.js +++ b/bin/convert.js @@ -27,21 +27,21 @@ log("open output file..."); var sqlOutput = fs.openSync(sqlOutputFile, "w"); var sql = "SET CHARACTER SET UTF8;\n" + "CREATE TABLE IF NOT EXISTS `store` ( \n" + - "`key` VARCHAR( 100 ) NOT NULL , \n" + - "`value` LONGTEXT NOT NULL , \n" + + "`key` VARCHAR( 100 ) NOT NULL , \n" + + "`value` LONGTEXT NOT NULL , \n" + "PRIMARY KEY ( `key` ) \n" + - ") ENGINE = INNODB;\n" + + ") ENGINE = INNODB;\n" + "START TRANSACTION;\n\n"; fs.writeSync(sqlOutput, sql); log("done"); //set setings for ep db var etherpadDB= new mysql.Client(); -etherpadDB.host = settings.etherpadDB.host; +etherpadDB.host = settings.etherpadDB.host; etherpadDB.port = settings.etherpadDB.port; -etherpadDB.database = settings.etherpadDB.database; -etherpadDB.user = settings.etherpadDB.user; -etherpadDB.password = settings.etherpadDB.password; +etherpadDB.database = settings.etherpadDB.database; +etherpadDB.user = settings.etherpadDB.user; +etherpadDB.password = settings.etherpadDB.password; //get the timestamp once var timestamp = new Date().getTime(); @@ -53,7 +53,7 @@ async.series([ function(callback) { log("get all padIds out of the database..."); - + etherpadDB.query("SELECT ID FROM PAD_META", [], function(err, _padIDs) { padIDs = _padIDs; @@ -63,9 +63,9 @@ async.series([ function(callback) { log("done"); - + //create a queue with a concurrency 100 - var queue = async.queue(function (padId, callback) + var queue = async.queue(function (padId, callback) { convertPad(padId, function(err) { @@ -73,10 +73,10 @@ async.series([ callback(err); }); }, 100); - + //set the step callback as the queue callback queue.drain = callback; - + //add the padids to the worker queue for(var i=0,length=padIDs.length;i /dev/null 2>&1 || { +hash node-inspector > /dev/null 2>&1 || { echo "You need to install node-inspector to run the tests!" >&2 echo "You can install it with npm" >&2 echo "Run: npm install -g node-inspector" >&2 - exit 1 + exit 1 } node-inspector & @@ -24,5 +24,5 @@ echo "If you are new to node-inspector, take a look at this video: http://youtu. node --debug node_modules/ep_etherpad-lite/node/server.js $* -#kill node-inspector before ending +#kill node-inspector before ending kill $! diff --git a/bin/extractPadData.js b/bin/extractPadData.js index 061a2e3f9..d7f2e7de7 100644 --- a/bin/extractPadData.js +++ b/bin/extractPadData.js @@ -16,7 +16,7 @@ log4js.setGlobalLogLevel("INFO"); var async = require("async"); var db = require('../node/db/DB'); var dirty = require("dirty")(padId + ".db"); -var padManager; +var padManager; var pad; var neededDBValues = ["pad:"+padId]; @@ -26,12 +26,12 @@ async.series([ { db.init(callback); }, - //get the pad + //get the pad function (callback) { padManager = require('../node/db/PadManager'); - - padManager.getPad(padId, function(err, _pad) + + padManager.getPad(padId, function(err, _pad) { pad = _pad; callback(err); @@ -45,21 +45,21 @@ async.series([ { neededDBValues.push("globalAuthor:" + authors[i]); } - + //add all revisions var revHead = pad.head; for(var i=0;i<=revHead;i++) { neededDBValues.push("pad:"+padId+":revs:" + i); } - + //get all chat values var chatHead = pad.chatHead; for(var i=0;i<=chatHead;i++) { neededDBValues.push("pad:"+padId+":chat:" + i); } - + //get and set all values async.forEach(neededDBValues, function(dbkey, callback) { @@ -67,7 +67,7 @@ async.series([ { if(err) { callback(err); return} dbvalue=JSON.parse(dbvalue); - + dirty.set(dbkey, dbvalue, callback); }); }, callback); @@ -75,8 +75,8 @@ async.series([ ], function (err) { if(err) throw err; - else - { + else + { console.log("finished"); process.exit(); } diff --git a/bin/installDeps.sh b/bin/installDeps.sh index 15731ae91..c0946b148 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -10,35 +10,35 @@ fi #Is gnu-grep (ggrep) installed on SunOS (Solaris) if [ $(uname) = "SunOS" ]; then - hash ggrep > /dev/null 2>&1 || { + hash ggrep > /dev/null 2>&1 || { echo "Please install ggrep (pkg install gnu-grep)" >&2 - exit 1 + exit 1 } fi #Is wget installed? -hash curl > /dev/null 2>&1 || { +hash curl > /dev/null 2>&1 || { echo "Please install curl" >&2 - exit 1 + exit 1 } #Is node installed? -hash node > /dev/null 2>&1 || { +hash node > /dev/null 2>&1 || { echo "Please install node.js ( http://nodejs.org )" >&2 - exit 1 + exit 1 } #Is npm installed? -hash npm > /dev/null 2>&1 || { +hash npm > /dev/null 2>&1 || { echo "Please install npm ( http://npmjs.org )" >&2 - exit 1 + exit 1 } #check npm version NPM_VERSION=$(npm --version) if [ ! $(echo $NPM_VERSION | cut -d "." -f 1) = "1" ]; then echo "You're running a wrong version of npm, you're using $NPM_VERSION, we need 1.x" >&2 - exit 1 + exit 1 fi #check node version @@ -46,7 +46,7 @@ NODE_VERSION=$(node --version) NODE_V_MINOR=$(echo $NODE_VERSION | cut -d "." -f 1-2) if [ ! $NODE_V_MINOR = "v0.8" ] && [ ! $NODE_V_MINOR = "v0.6" ]; then echo "You're running a wrong version of node, you're using $NODE_VERSION, we need v0.6.x or v0.8.x" >&2 - exit 1 + exit 1 fi #Get the name of the settings file @@ -70,9 +70,9 @@ echo "Ensure that all dependencies are up to date..." [ -e ep_etherpad-lite ] || ln -s ../src ep_etherpad-lite cd ep_etherpad-lite npm install -) || { +) || { rm -rf node_modules - exit 1 + exit 1 } echo "Ensure jQuery is downloaded and up to date..." @@ -105,7 +105,7 @@ do if [ ! -f "src/static/custom/$f.js" ]; then cp "src/static/custom/js.template" "src/static/custom/$f.js" || exit 1 fi - + if [ ! -f "src/static/custom/$f.css" ]; then cp "src/static/custom/css.template" "src/static/custom/$f.css" || exit 1 fi diff --git a/bin/loadTesting/README b/bin/loadTesting/README index 297756f9d..a97f95dfe 100644 --- a/bin/loadTesting/README +++ b/bin/loadTesting/README @@ -1,4 +1,4 @@ -This load tester is extremely useful for testing how many dormant clients can connect to etherpad lite. +This load tester is extremely useful for testing how many dormant clients can connect to etherpad lite. TODO: Emulate characters being typed into a pad @@ -14,7 +14,7 @@ Installed Xvfb and PhantomJS I installed Xvfb following (roughly) this guide: http://blog.martin-lyness.com/archives/installing-xvfb-on-ubuntu-9-10-karmic-koala #sudo apt-get install xvfb - #sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic + #sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic Launched two instances of Xvfb directly from the terminal: @@ -58,15 +58,15 @@ And finally a launcher script that uses screen to run 400 instances of PhantomJS ### BEGIN SHELL SCRIPT ### -#!/bin/bash +#!/bin/bash -# connect 200 instances to display :0 +# connect 200 instances to display :0 for i in {1..200} do DISPLAY=:0 screen -d -m phantomjs loader.js http://ec2-50-17-168-xx.compute-1.amazonaws.com:9001/p/pad2 && sleep 2 done -# connect 200 instances to display :1 +# connect 200 instances to display :1 for i in {1..200} do DISPLAY=:1 screen -d -m phantomjs loader.js http://ec2-50-17-168-xx.compute-1.amazonaws.com:9001/p/pad2 && sleep 2 diff --git a/bin/safeRun.sh b/bin/safeRun.sh index b060f5d19..164a34ef9 100755 --- a/bin/safeRun.sh +++ b/bin/safeRun.sh @@ -8,8 +8,8 @@ ERROR_HANDLING=0 # Your email address which should recieve the error messages EMAIL_ADDRESS="no-reply@example.com" -# Sets the minimun amount of time betweens the sending of error emails. -# This ensures you not get spamed while a endless reboot loop +# Sets the minimun amount of time betweens the sending of error emails. +# This ensures you not get spamed while a endless reboot loop # It's the time in seconds TIME_BETWEEN_EMAILS=600 # 10 minutes @@ -37,7 +37,7 @@ do if [ ! -f $1 ]; then touch $1 || ( echo "Logfile '$1' is not writeable" && exit 1 ) fi - + #check if the file is writeable if [ ! -w $1 ]; then echo "Logfile '$1' is not writeable" @@ -46,21 +46,21 @@ do #start the application bin/run.sh >>$1 2>>$1 - + #Send email if [ $ERROR_HANDLING = 1 ]; then TIME_NOW=$(date +%s) TIME_SINCE_LAST_SEND=$(($TIME_NOW - $LAST_EMAIL_SEND)) - + if [ $TIME_SINCE_LAST_SEND -gt $TIME_BETWEEN_EMAILS ]; then printf "Server was restared at: $(date)\nThe last 50 lines of the log before the error happens:\n $(tail -n 50 $1)" | mail -s "Pad Server was restarted" $EMAIL_ADDRESS - + LAST_EMAIL_SEND=$TIME_NOW fi fi - + echo "RESTART!" >>$1 - + #Sleep 10 seconds before restart sleep 10 done diff --git a/doc/api/changeset_library.md b/doc/api/changeset_library.md index 2dce55aa3..1c213ece8 100644 --- a/doc/api/changeset_library.md +++ b/doc/api/changeset_library.md @@ -70,11 +70,11 @@ This creates an empty apool. A apool saves which attributes were used during the ``` > apool.fromJsonable({"numToAttrib":{"0":["author","a.kVnWeomPADAT2pn9"],"1":["bold","true"],"2":["italic","true"]},"nextNum":3}); > console.log(apool) -{ numToAttrib: +{ numToAttrib: { '0': [ 'author', 'a.kVnWeomPADAT2pn9' ], '1': [ 'bold', 'true' ], '2': [ 'italic', 'true' ] }, - attribToNum: + attribToNum: { 'author,a.kVnWeomPADAT2pn9': 0, 'bold,true': 1, 'italic,true': 2 }, diff --git a/doc/api/hooks_client-side.md b/doc/api/hooks_client-side.md index 55d1da000..54794d739 100644 --- a/doc/api/hooks_client-side.md +++ b/doc/api/hooks_client-side.md @@ -175,7 +175,7 @@ This hook gets called every time the client receives a message of type `name`. T `collab_client.js` has a pretty extensive list of message types, if you want to take a look. -##aceStartLineAndCharForPoint-aceEndLineAndCharForPoint +##aceStartLineAndCharForPoint-aceEndLineAndCharForPoint Called from: src/static/js/ace2_inner.js Things in context: @@ -190,7 +190,7 @@ Things in context: This hook is provided to allow a plugin to turn DOM node selection into [line,char] selection. The return value should be an array of [line,char] -##aceKeyEvent +##aceKeyEvent Called from: src/static/js/ace2_inner.js Things in context: @@ -204,7 +204,7 @@ Things in context: This hook is provided to allow a plugin to handle key events. The return value should be true if you have handled the event. -##collectContentLineText +##collectContentLineText Called from: src/static/js/contentcollector.js Things in context: @@ -217,7 +217,7 @@ Things in context: This hook allows you to validate/manipulate the text before it's sent to the server side. The return value should be the validated/manipulated text. -##collectContentLineBreak +##collectContentLineBreak Called from: src/static/js/contentcollector.js Things in context: @@ -229,7 +229,7 @@ Things in context: This hook is provided to allow whether the br tag should induce a new magic domline or not. The return value should be either true(break the line) or false. -##disableAuthorColorsForThisLine +##disableAuthorColorsForThisLine Called from: src/static/js/linestylefilter.js Things in context: diff --git a/doc/api/http_api.md b/doc/api/http_api.md index 990d1b498..98139e96c 100644 --- a/doc/api/http_api.md +++ b/doc/api/http_api.md @@ -3,7 +3,7 @@ ## What can I do with this API? The API gives another web application control of the pads. The basic functions are -* create/delete pads +* create/delete pads * grant/forbid access to pads * get/set pad content @@ -15,30 +15,30 @@ Take a look at [HTTP API client libraries](https://github.com/Pita/etherpad-lite ### Example 1 -A portal (such as WordPress) wants to give a user access to a new pad. Let's assume the user have the internal id 7 and his name is michael. +A portal (such as WordPress) wants to give a user access to a new pad. Let's assume the user have the internal id 7 and his name is michael. -Portal maps the internal userid to an etherpad author. +Portal maps the internal userid to an etherpad author. > Request: `http://pad.domain/api/1/createAuthorIfNotExistsFor?apikey=secret&name=Michael&authorMapper=7` -> +> > Response: `{code: 0, message:"ok", data: {authorID: "a.s8oes9dhwrvt0zif"}}` Portal maps the internal userid to an etherpad group: > Request: `http://pad.domain/api/1/createGroupIfNotExistsFor?apikey=secret&groupMapper=7` -> +> > Response: `{code: 0, message:"ok", data: {groupID: "g.s8oes9dhwrvt0zif"}}` Portal creates a pad in the userGroup > Request: `http://pad.domain/api/1/createGroupPad?apikey=secret&groupID=g.s8oes9dhwrvt0zif&padName=samplePad&text=This is the first sentence in the pad` -> +> > Response: `{code: 0, message:"ok", data: null}` Portal starts the session for the user on the group: > Request: `http://pad.domain/api/1/createSession?apikey=secret&groupID=g.s8oes9dhwrvt0zif&authorID=a.s8oes9dhwrvt0zif&validUntil=1312201246` -> +> > Response: `{"data":{"sessionID": "s.s8oes9dhwrvt0zif"}}` Portal places the cookie "sessionID" with the given value on the client and creates an iframe including the pad. @@ -50,7 +50,7 @@ A portal (such as WordPress) wants to transform the contents of a pad that multi Portal retrieves the contents of the pad for entry into the db as a blog post: > Request: `http://pad.domain/api/1/getText?apikey=secret&padID=g.s8oes9dhwrvt0zif$123` -> +> > Response: `{code: 0, message:"ok", data: {text:"Welcome Text"}}` Portal submits content into new blog post @@ -98,7 +98,7 @@ Responses are valid JSON in the following format: ### Authentication -Authentication works via a token that is sent with each request as a post parameter. There is a single token per Etherpad-Lite deployment. This token will be random string, generated by Etherpad-Lite at the first start. It will be saved in APIKEY.txt in the root folder of Etherpad Lite. Only Etherpad Lite and the requesting application knows this key. Token management will not be exposed through this API. +Authentication works via a token that is sent with each request as a post parameter. There is a single token per Etherpad-Lite deployment. This token will be random string, generated by Etherpad-Lite at the first start. It will be saved in APIKEY.txt in the root folder of Etherpad Lite. Only Etherpad Lite and the requesting application knows this key. Token management will not be exposed through this API. ### Node Interoperability @@ -118,7 +118,7 @@ Pads can belong to a group. The padID of grouppads is starting with a groupID li #### createGroup() * API >= 1 - + creates a new group *Example returns:* @@ -127,7 +127,7 @@ creates a new group #### createGroupIfNotExistsFor(groupMapper) * API >= 1 -this functions helps you to map your application group ids to etherpad lite group ids +this functions helps you to map your application group ids to etherpad lite group ids *Example returns:* * `{code: 0, message:"ok", data: {groupID: g.s8oes9dhwrvt0zif}}` @@ -170,7 +170,7 @@ lists all existing groups * `{code: 0, message:"ok", data: {groupIDs: []}}` ### Author -These authors are bound to the attributes the users choose (color and name). +These authors are bound to the attributes the users choose (color and name). #### createAuthor([name]) * API >= 1 @@ -183,7 +183,7 @@ creates a new author #### createAuthorIfNotExistsFor(authorMapper [, name]) * API >= 1 -this functions helps you to map your application author ids to etherpad lite author ids +this functions helps you to map your application author ids to etherpad lite author ids *Example returns:* * `{code: 0, message:"ok", data: {authorID: "a.s8oes9dhwrvt0zif"}}` @@ -290,7 +290,7 @@ returns the text of a pad formatted as HTML * `{code: 1, message:"padID does not exist", data: null}` ### Pad -Group pads are normal pads, but with the name schema GROUPID$PADNAME. A security manager controls access of them and its forbidden for normal pads to include a $ in the name. +Group pads are normal pads, but with the name schema GROUPID$PADNAME. A security manager controls access of them and its forbidden for normal pads to include a $ in the name. #### createPad(padID [, text]) * API >= 1 @@ -398,7 +398,7 @@ returns the timestamp of the last revision of the pad *Example returns:* * `{code: 0, message:"ok", data: {lastEdited: 1340815946602}}` * `{code: 1, message:"padID does not exist", data: null}` - + #### sendClientsMessage(padID, msg) * API >= 1.1 diff --git a/doc/database.md b/doc/database.md index de3e9f547..66e2c228a 100644 --- a/doc/database.md +++ b/doc/database.md @@ -43,9 +43,9 @@ Information about an author * **colorID** - the colorID of this author as shown in the pad ### mapper2group:$MAPPER -Maps an external application identifier to an internal group +Maps an external application identifier to an internal group ### mapper2author:$MAPPER -Maps an external application identifier to an internal author +Maps an external application identifier to an internal author ### group:$GROUPID a group of pads diff --git a/doc/easysync/easysync-full-description.tex b/doc/easysync/easysync-full-description.tex index a831da647..19a5e657a 100644 --- a/doc/easysync/easysync-full-description.tex +++ b/doc/easysync/easysync-full-description.tex @@ -1,4 +1,4 @@ -\documentclass{article} +\documentclass{article} \usepackage{hyperref} \begin{document} @@ -258,7 +258,7 @@ in Section \ref{follows}. \paragraph{Proof that $\mathbf{AXY=V \Rightarrow A'X'Y'=VD}$.} Substituting $A'X'Y'=(AB)(f(B,X))(f(f(X,B),Y))$, we recall that merges are commutative. So for any two -changesets $P$ and $Q$, +changesets $P$ and $Q$, $$m(P,Q)=m(Q,P)=Qf(Q,P)=Pf(P,Q)$$ Applying this to the relation above, we see @@ -267,7 +267,7 @@ A'X'Y'&=& AB f(B,X) f(f(X,B),Y) \\ &=&AX f(X,B) f(f(X,B),Y) \\ &=&A X Y f(Y, f(X,B)) \\ &=&A X Y D \\ - &=&V D + &=&V D \end{eqnarray*} As claimed. @@ -348,7 +348,7 @@ the client's changeset $C$, it does five things: server's most recent revision number, which we call $r_H$ ($H$ for HEAD). $C'$ can be computed using follows (Section \ref{follows}). Remember that the server has a series of - changesets, + changesets, $$S_0\rightarrow S_1\rightarrow \ldots S_{r_c}\rightarrow S_{r_c+1} \rightarrow \ldots \rightarrow S_{r_H} $$ $C$ is relative to $S_{r_c}$, but we need to compute $C'$ relative to $S_{r_H}$. We can compute a new $C$ relative to $S_{r_c+1}$ by computing $f(S_{r_c+1},C)$. Similarly we can repeat for diff --git a/doc/easysync/easysync-notes.tex b/doc/easysync/easysync-notes.tex index b2c432073..534a69572 100644 --- a/doc/easysync/easysync-notes.tex +++ b/doc/easysync/easysync-notes.tex @@ -1,7 +1,7 @@ \documentclass[12pt]{article} \usepackage[T1]{fontenc} -\usepackage[USenglish]{babel} +\usepackage[USenglish]{babel} \begin{document} @@ -68,7 +68,7 @@ Here are descriptions of the operations, where capital letters are variables: \begin{description} -\item{{\bf :N}} \quad \\ +\item{{\bf :N}} \quad \\ Source text has length $N$ (must be first op) \item{{\bf >N}} \quad \\ Final text is $N$ (positive) characters longer than source diff --git a/doc/easysync/easysync-notes.txt b/doc/easysync/easysync-notes.txt index d3b3dc558..98094ac51 100644 --- a/doc/easysync/easysync-notes.txt +++ b/doc/easysync/easysync-notes.txt @@ -72,7 +72,7 @@ Here are descriptions of the operations, where capital letters are variables: "-N" : Skip over (delete) N characters from the source text, none of them newlines "=N" : Keep N characters from the source text, none of them newlines "|L+N" : Insert N characters from the source text, containing L newlines. The last - character inserted MUST be a newline, but not the (new) document's final newline. + character inserted MUST be a newline, but not the (new) document's final newline. "|L-N" : Delete N characters from the source text, containing L newlines. The last character inserted MUST be a newline, but not the (old) document's final newline. "|L=N" : Keep N characters from the source text, containing L newlines. The last character diff --git a/settings.json.template b/settings.json.template index 66192e4b9..554471ba6 100644 --- a/settings.json.template +++ b/settings.json.template @@ -10,11 +10,11 @@ // favicon default name // alternatively, set up a fully specified Url to your own favicon "favicon": "favicon.ico", - + //Ip and port which etherpad should bind at "ip": "0.0.0.0", "port" : 9001, - + //The Type of the database. You can choose between dirty, postgres, sqlite and mysql //You shouldn't use "dirty" for for anything else than testing or development "dbType" : "dirty", @@ -22,38 +22,38 @@ "dbSettings" : { "filename" : "var/dirty.db" }, - + /* An Example of MySQL Configuration "dbType" : "mysql", "dbSettings" : { - "user" : "root", - "host" : "localhost", - "password": "", + "user" : "root", + "host" : "localhost", + "password": "", "database": "store" }, */ - + //the default text of a pad "defaultPadText" : "Welcome to Etherpad Lite!\n\nThis 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!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n", - + /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */ "requireSession" : false, /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */ "editOnly" : false, - - /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, + + /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, but makes it impossible to debug the javascript/css */ "minify" : true, /* How long may clients use served javascript code (in seconds)? Without versioning this may cause problems during deployment. Set to 0 to disable caching */ "maxAge" : 21600, // 60 * 60 * 6 = 6 hours - + /* This is the path to the Abiword executable. Setting it to null, disables abiword. - Abiword is needed to enable the import/export of pads*/ + Abiword is needed to enable the import/export of pads*/ "abiword" : null, - + /* This setting is used if you require authentication of all users. Note: /admin always requires authentication. */ "requireAuthentication": false, diff --git a/src/ep.json b/src/ep.json index 26e4f603f..48d91162d 100644 --- a/src/ep.json +++ b/src/ep.json @@ -16,7 +16,7 @@ { "name": "admin", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/admin:expressCreateServer" } }, { "name": "adminplugins", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/adminplugins:expressCreateServer", - "socketio": "ep_etherpad-lite/node/hooks/express/adminplugins:socketio" } + "socketio": "ep_etherpad-lite/node/hooks/express/adminplugins:socketio" } }, { "name": "adminsettings", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/adminsettings:expressCreateServer", diff --git a/src/node/db/API.js b/src/node/db/API.js index 4979e8c65..bbf91d0df 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -68,7 +68,7 @@ exports.listSessionsOfAuthor = sessionManager.listSessionsOfAuthor; /************************/ /** -getText(padID, [rev]) returns the text of a pad +getText(padID, [rev]) returns the text of a pad Example returns: @@ -83,7 +83,7 @@ exports.getText = function(padID, rev, callback) callback = rev; rev = undefined; } - + //check if rev is a number if(rev !== undefined && typeof rev != "number") { @@ -98,26 +98,26 @@ exports.getText = function(padID, rev, callback) return; } } - + //ensure this is not a negativ number if(rev !== undefined && rev < 0) { callback(new customError("rev is a negativ number","apierror")); return; } - + //ensure this is not a float value if(rev !== undefined && !is_int(rev)) { callback(new customError("rev is a float value","apierror")); return; } - + //get the pad getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + //the client asked for a special revision if(rev !== undefined) { @@ -127,14 +127,14 @@ exports.getText = function(padID, rev, callback) callback(new customError("rev is higher than the head revision of the pad","apierror")); return; } - + //get the text of this revision pad.getInternalRevisionAText(rev, function(err, atext) { if(ERR(err, callback)) return; - + data = {text: atext.text}; - + callback(null, data); }) } @@ -147,7 +147,7 @@ exports.getText = function(padID, rev, callback) } /** -setText(padID, text) sets the text of a pad +setText(padID, text) sets the text of a pad Example returns: @@ -156,7 +156,7 @@ Example returns: {code: 1, message:"text too long", data: null} */ exports.setText = function(padID, text, callback) -{ +{ //text is required if(typeof text != "string") { @@ -168,17 +168,17 @@ exports.setText = function(padID, text, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + //set the text pad.setText(text); - + //update the clients on the pad padMessageHandler.updatePadClients(pad, callback); }); } /** -getHTML(padID, [rev]) returns the html of a pad +getHTML(padID, [rev]) returns the html of a pad Example returns: @@ -190,7 +190,7 @@ exports.getHTML = function(padID, rev, callback) if(typeof rev == "function") { callback = rev; - rev = undefined; + rev = undefined; } if (rev !== undefined && typeof rev != "number") @@ -221,7 +221,7 @@ exports.getHTML = function(padID, rev, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + //the client asked for a special revision if(rev !== undefined) { @@ -231,8 +231,8 @@ exports.getHTML = function(padID, rev, callback) callback(new customError("rev is higher than the head revision of the pad","apierror")); return; } - - //get the html of this revision + + //get the html of this revision exportHtml.getPadHTML(pad, rev, function(err, html) { if(ERR(err, callback)) return; @@ -246,9 +246,9 @@ exports.getHTML = function(padID, rev, callback) exportHtml.getPadHTML(pad, undefined, function (err, html) { if(ERR(err, callback)) return; - + data = {html: html}; - + callback(null, data); }); } @@ -276,7 +276,7 @@ exports.setHTML = function(padID, html, callback) /*****************/ /** -getRevisionsCount(padID) returns the number of revisions of this pad +getRevisionsCount(padID) returns the number of revisions of this pad Example returns: @@ -289,7 +289,7 @@ exports.getRevisionsCount = function(padID, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + callback(null, {revisions: pad.getHeadRevisionNumber()}); }); } @@ -316,7 +316,7 @@ exports.getLastEdited = function(padID, callback) } /** -createPad(padName [, text]) creates a new pad in this group +createPad(padName [, text]) creates a new pad in this group Example returns: @@ -324,14 +324,14 @@ Example returns: {code: 1, message:"pad does already exist", data: null} */ exports.createPad = function(padID, text, callback) -{ +{ //ensure there is no $ in the padID if(padID && padID.indexOf("$") != -1) { callback(new customError("createPad can't create group pads","apierror")); return; } - + //create pad getPadSafe(padID, false, text, function(err) { @@ -341,7 +341,7 @@ exports.createPad = function(padID, text, callback) } /** -deletePad(padID) deletes a pad +deletePad(padID) deletes a pad Example returns: @@ -353,13 +353,13 @@ exports.deletePad = function(padID, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + pad.remove(callback); }); } /** -getReadOnlyLink(padID) returns the read only link of a pad +getReadOnlyLink(padID) returns the read only link of a pad Example returns: @@ -372,7 +372,7 @@ exports.getReadOnlyID = function(padID, callback) getPadSafe(padID, true, function(err) { if(ERR(err, callback)) return; - + //get the readonlyId readOnlyManager.getReadOnlyId(padID, function(err, readOnlyId) { @@ -383,7 +383,7 @@ exports.getReadOnlyID = function(padID, callback) } /** -setPublicStatus(padID, publicStatus) sets a boolean for the public status of a pad +setPublicStatus(padID, publicStatus) sets a boolean for the public status of a pad Example returns: @@ -403,20 +403,20 @@ exports.setPublicStatus = function(padID, publicStatus, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + //convert string to boolean if(typeof publicStatus == "string") publicStatus = publicStatus == "true" ? true : false; - + //set the password pad.setPublicStatus(publicStatus); - + callback(); }); } /** -getPublicStatus(padID) return true of false +getPublicStatus(padID) return true of false Example returns: @@ -431,18 +431,18 @@ exports.getPublicStatus = function(padID, callback) callback(new customError("You can only get/set the publicStatus of pads that belong to a group","apierror")); return; } - + //get the pad getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + callback(null, {publicStatus: pad.getPublicStatus()}); }); } /** -setPassword(padID, password) returns ok or a error message +setPassword(padID, password) returns ok or a error message Example returns: @@ -457,21 +457,21 @@ exports.setPassword = function(padID, password, callback) callback(new customError("You can only get/set the password of pads that belong to a group","apierror")); return; } - + //get the pad getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + //set the password pad.setPassword(password == "" ? null : password); - + callback(); }); } /** -isPasswordProtected(padID) returns true or false +isPasswordProtected(padID) returns true or false Example returns: @@ -491,13 +491,13 @@ exports.isPasswordProtected = function(padID, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + callback(null, {isPasswordProtected: pad.isPasswordProtected()}); }); } /** -listAuthorsOfPad(padID) returns an array of authors who contributed to this pad +listAuthorsOfPad(padID) returns an array of authors who contributed to this pad Example returns: @@ -510,7 +510,7 @@ exports.listAuthorsOfPad = function(padID, callback) getPadSafe(padID, true, function(err, pad) { if(ERR(err, callback)) return; - + callback(null, {authorIDs: pad.getAllAuthors()}); }); } @@ -555,7 +555,7 @@ exports.sendClientsMessage = function (padID, msg, callback) { //checks if a number is an int function is_int(value) -{ +{ return (parseFloat(value) == parseInt(value)) && !isNaN(value) } @@ -574,19 +574,19 @@ function getPadSafe(padID, shouldExist, text, callback) callback(new customError("padID is not a string","apierror")); return; } - + //check if the padID maches the requirements if(!padManager.isValidPadId(padID)) { callback(new customError("padID did not match requirements","apierror")); return; } - + //check if the pad exists padManager.doesPadExists(padID, function(err, exists) { if(ERR(err, callback)) return; - + //does not exist, but should if(exists == false && shouldExist == true) { diff --git a/src/node/db/AuthorManager.js b/src/node/db/AuthorManager.js index 28b2dd91e..fae1d6a4a 100644 --- a/src/node/db/AuthorManager.js +++ b/src/node/db/AuthorManager.js @@ -38,9 +38,9 @@ exports.doesAuthorExists = function (authorID, callback) } /** - * Returns the AuthorID for a token. - * @param {String} token The token - * @param {Function} callback callback (err, author) + * Returns the AuthorID for a token. + * @param {String} token The token + * @param {Function} callback callback (err, author) */ exports.getAuthor4Token = function (token, callback) { @@ -53,21 +53,21 @@ exports.getAuthor4Token = function (token, callback) } /** - * Returns the AuthorID for a mapper. + * Returns the AuthorID for a mapper. * @param {String} token The mapper * @param {String} name The name of the author (optional) - * @param {Function} callback callback (err, author) + * @param {Function} callback callback (err, author) */ exports.createAuthorIfNotExistsFor = function (authorMapper, name, callback) { mapAuthorWithDBKey("mapper2author", authorMapper, function(err, author) { if(ERR(err, callback)) return; - + //set the name of this author if(name) exports.setAuthorName(author.authorID, name); - + //return the authorID callback(null, author); }); @@ -76,27 +76,27 @@ exports.createAuthorIfNotExistsFor = function (authorMapper, name, callback) /** * Returns the AuthorID for a mapper. We can map using a mapperkey, * so far this is token2author and mapper2author - * @param {String} mapperkey The database key name for this mapper + * @param {String} mapperkey The database key name for this mapper * @param {String} mapper The mapper - * @param {Function} callback callback (err, author) + * @param {Function} callback callback (err, author) */ function mapAuthorWithDBKey (mapperkey, mapper, callback) -{ +{ //try to map to an author db.get(mapperkey + ":" + mapper, function (err, author) { if(ERR(err, callback)) return; - + //there is no author with this mapper, so create one if(author == null) { exports.createAuthor(null, function(err, author) { if(ERR(err, callback)) return; - + //create the token2author relation db.set(mapperkey + ":" + mapper, author.authorID); - + //return the author callback(null, author); }); @@ -106,7 +106,7 @@ function mapAuthorWithDBKey (mapperkey, mapper, callback) { //update the timestamp of this author db.setSub("globalAuthor:" + author, ["timestamp"], new Date().getTime()); - + //return the author callback(null, {authorID: author}); } @@ -114,20 +114,20 @@ function mapAuthorWithDBKey (mapperkey, mapper, callback) } /** - * Internal function that creates the database entry for an author - * @param {String} name The name of the author + * Internal function that creates the database entry for an author + * @param {String} name The name of the author */ exports.createAuthor = function(name, callback) { //create the new author name var author = "a." + randomString(16); - + //create the globalAuthors db entry var authorObj = {"colorId" : Math.floor(Math.random()*32), "name": name, "timestamp": new Date().getTime()}; - + //set the global author db entry db.set("globalAuthor:" + author, authorObj); - + callback(null, {authorID: author}); } @@ -208,7 +208,7 @@ exports.listPadsOfAuthor = function (authorID, callback) } //everything is fine, return the pad IDs else - { + { var pads = []; if(author.padIDs != null) { @@ -234,16 +234,16 @@ exports.addPad = function (authorID, padID) { if(ERR(err)) return; if(author == null) return; - + //the entry doesn't exist so far, let's create it if(author.padIDs == null) { author.padIDs = {}; } - + //add the entry for this pad author.padIDs[padID] = 1;// anything, because value is not used - + //save the new element back db.set("globalAuthor:" + authorID, author); }); @@ -260,11 +260,11 @@ exports.removePad = function (authorID, padID) { if(ERR(err)) return; if(author == null) return; - + if(author.padIDs != null) { //remove pad from author - delete author.padIDs[padID]; + delete author.padIDs[padID]; db.set("globalAuthor:" + authorID, author); } }); diff --git a/src/node/db/DB.js b/src/node/db/DB.js index 7273c83e3..db041f8f2 100644 --- a/src/node/db/DB.js +++ b/src/node/db/DB.js @@ -1,5 +1,5 @@ /** - * The DB Module provides a database initalized with the settings + * The DB Module provides a database initalized with the settings * provided by the settings module */ @@ -33,14 +33,14 @@ exports.db = null; /** * Initalizes the database with the settings provided by the settings module - * @param {Function} callback + * @param {Function} callback */ exports.init = function(callback) { //initalize the database async db.init(function(err) { - //there was an error while initializing the database, output it and stop + //there was an error while initializing the database, output it and stop if(err) { console.error("ERROR: Problem while initalizing the database"); @@ -50,7 +50,7 @@ exports.init = function(callback) //everything ok else { - exports.db = db; + exports.db = db; callback(null); } }); diff --git a/src/node/db/GroupManager.js b/src/node/db/GroupManager.js index 81b0cb9ef..61e3f2bef 100644 --- a/src/node/db/GroupManager.js +++ b/src/node/db/GroupManager.js @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + var ERR = require("async-stacktrace"); var customError = require("../utils/customError"); @@ -30,13 +30,13 @@ var sessionManager = require("./SessionManager"); exports.listAllGroups = function(callback) { db.get("groups", function (err, groups) { if(ERR(err, callback)) return; - + // there are no groups if(groups == null) { callback(null, {groupIDs: []}); return; } - + var groupIDs = []; for ( var groupID in groups ) { groupIDs.push(groupID); @@ -44,20 +44,20 @@ exports.listAllGroups = function(callback) { callback(null, {groupIDs: groupIDs}); }); } - + exports.deleteGroup = function(groupID, callback) { var group; async.series([ - //ensure group exists + //ensure group exists function (callback) { //try to get the group entry db.get("group:" + groupID, function (err, _group) { if(ERR(err, callback)) return; - + //group does not exist if(_group == null) { @@ -80,14 +80,14 @@ exports.deleteGroup = function(groupID, callback) { padIDs.push(i); } - - //loop trough all pads and delete them + + //loop trough all pads and delete them async.forEach(padIDs, function(padID, callback) { padManager.getPad(padID, function(err, pad) { if(ERR(err, callback)) return; - + pad.remove(callback); }); }, callback); @@ -99,18 +99,18 @@ exports.deleteGroup = function(groupID, callback) db.get("group2sessions:" + groupID, function (err, group2sessions) { if(ERR(err, callback)) return; - + //skip if there is no group2sessions entry if(group2sessions == null) {callback(); return} - + //collect all sessions in an array, that allows us to use async.forEach var sessions = []; for(var i in group2sessions.sessionsIDs) { sessions.push(i); } - - //loop trough all sessions and delete them + + //loop trough all sessions and delete them async.forEach(sessions, function(session, callback) { sessionManager.deleteSession(session, callback); @@ -138,7 +138,7 @@ exports.deleteGroup = function(groupID, callback) } groups.splice(groups.indexOf(groupID), 1); - + // store empty groupe list if(groups.length == 0) { db.set("groups", {}); @@ -163,7 +163,7 @@ exports.deleteGroup = function(groupID, callback) callback(); }); } - + exports.doesGroupExist = function(groupID, callback) { //try to get the group entry @@ -178,17 +178,17 @@ exports.createGroup = function(callback) { //search for non existing groupID var groupID = "g." + randomString(16); - + //create the group db.set("group:" + groupID, {pads: {}}); - + //list the group exports.listAllGroups(function(err, groups) { if(ERR(err, callback)) return; groups = groups? groups.groupIDs : []; - + groups.push(groupID); - + // regenerate group list var newGroups = {}; async.forEach(groups, function(group, cb) { @@ -209,22 +209,22 @@ exports.createGroupIfNotExistsFor = function(groupMapper, callback) callback(new customError("groupMapper is no string","apierror")); return; } - + //try to get a group for this mapper db.get("mapper2group:"+groupMapper, function(err, groupID) { if(ERR(err, callback)) return; - + //there is no group for this mapper, let's create a group if(groupID == null) { exports.createGroup(function(err, responseObj) { if(ERR(err, callback)) return; - + //create the mapper entry for this group db.set("mapper2group:"+groupMapper, responseObj.groupID); - + callback(null, responseObj); }); } @@ -243,13 +243,13 @@ exports.createGroupPad = function(groupID, padName, text, callback) var padID = groupID + "$" + padName; async.series([ - //ensure group exists + //ensure group exists function (callback) { exports.doesGroupExist(groupID, function(err, exists) { if(ERR(err, callback)) return; - + //group does not exist if(exists == false) { @@ -268,7 +268,7 @@ exports.createGroupPad = function(groupID, padName, text, callback) padManager.doesPadExists(padID, function(err, exists) { if(ERR(err, callback)) return; - + //pad exists already if(exists == true) { @@ -308,7 +308,7 @@ exports.listPads = function(groupID, callback) exports.doesGroupExist(groupID, function(err, exists) { if(ERR(err, callback)) return; - + //group does not exist if(exists == false) { diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index dba791fd2..298ffb5b9 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -83,33 +83,33 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) { db.set("pad:"+this.id+":revs:"+newRev, newRevData); this.saveToDatabase(); - + // set the author to pad if(author) authorManager.addPad(author, this.id); - + if (this.head == 0) { hooks.callAll("padCreate", {'pad':this}); } else { hooks.callAll("padUpdate", {'pad':this}); - } + } }; //save all attributes to the database Pad.prototype.saveToDatabase = function saveToDatabase(){ var dbObject = {}; - + for(var attr in this){ if(typeof this[attr] === "function") continue; if(attributeBlackList.indexOf(attr) !== -1) continue; - + dbObject[attr] = this[attr]; - + if(jsonableList.indexOf(attr) !== -1){ dbObject[attr] = dbObject[attr].toJsonable(); } } - + db.set("pad:"+this.id, dbObject); } @@ -510,7 +510,7 @@ Pad.prototype.addSavedRevision = function addSavedRevision(revNum, savedById, la return; } } - + //build the saved revision object var savedRevision = {}; savedRevision.revNum = revNum; @@ -518,7 +518,7 @@ Pad.prototype.addSavedRevision = function addSavedRevision(revNum, savedById, la savedRevision.label = label || "Revision " + revNum; savedRevision.timestamp = new Date().getTime(); savedRevision.id = randomString(10); - + //save this new saved revision this.savedRevisions.push(savedRevision); this.saveToDatabase(); diff --git a/src/node/db/PadManager.js b/src/node/db/PadManager.js index 5f08b1b1b..00e5e5000 100644 --- a/src/node/db/PadManager.js +++ b/src/node/db/PadManager.js @@ -23,7 +23,7 @@ var customError = require("../utils/customError"); var Pad = require("../db/Pad").Pad; var db = require("./DB").db; -/** +/** * 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 @@ -50,24 +50,24 @@ var padIdTransforms = [ /** * Returns a Pad Object with the callback * @param id A String with the id of the pad - * @param {Function} callback + * @param {Function} callback */ exports.getPad = function(id, text, callback) -{ +{ //check if this is a valid padId if(!exports.isValidPadId(id)) { callback(new customError(id + " is not a valid padId","apierror")); return; } - + //make text an optional parameter if(typeof text == "function") { callback = text; text = null; } - + //check if this is a valid text if(text != null) { @@ -77,7 +77,7 @@ exports.getPad = function(id, text, callback) callback(new customError("text is not a string","apierror")); return; } - + //check if text is less than 100k chars if(text.length > 100000) { @@ -85,9 +85,9 @@ exports.getPad = function(id, text, callback) return; } } - + var pad = globalPads.get(id); - + //return pad if its already loaded if(pad != null) { @@ -97,12 +97,12 @@ exports.getPad = function(id, text, callback) else { pad = new Pad(id); - + //initalize the pad pad.init(text, function(err) { if(ERR(err, callback)) return; - + globalPads.set(id, pad); callback(null, pad); }); @@ -120,7 +120,7 @@ exports.doesPadExists = function(padId, callback) } else { - callback(null, false); + callback(null, false); } }); } diff --git a/src/node/db/ReadOnlyManager.js b/src/node/db/ReadOnlyManager.js index b135e6139..cc0625fb1 100644 --- a/src/node/db/ReadOnlyManager.js +++ b/src/node/db/ReadOnlyManager.js @@ -29,9 +29,9 @@ var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; * @param {String} padId the id of the pad */ exports.getReadOnlyId = function (padId, callback) -{ +{ var readOnlyId; - + async.waterfall([ //check if there is a pad2readonly entry function(callback) @@ -44,7 +44,7 @@ exports.getReadOnlyId = function (padId, callback) if(dbReadOnlyId == null) { readOnlyId = "r." + randomString(16); - + db.set("pad2readonly:" + padId, readOnlyId); db.set("readonly2pad:" + readOnlyId, padId); } @@ -53,7 +53,7 @@ exports.getReadOnlyId = function (padId, callback) { readOnlyId = dbReadOnlyId; } - + callback(); } ], function(err) diff --git a/src/node/db/SecurityManager.js b/src/node/db/SecurityManager.js index 59e27b550..5745afb08 100644 --- a/src/node/db/SecurityManager.js +++ b/src/node/db/SecurityManager.js @@ -33,11 +33,11 @@ var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; * @param padID the pad the user wants to access * @param sesssionID the session the user has (set via api) * @param token the token of the author (randomly generated at client side, used for public pads) - * @param password the password the user has given to access this pad, can be null + * @param password the password the user has given to access this pad, can be null * @param callback will be called with (err, {accessStatus: grant|deny|wrongPassword|needPassword, authorID: a.xxxxxx}) - */ + */ exports.checkAccess = function (padID, sessionCookie, token, password, callback) -{ +{ var statusObject; // a valid session is required (api-only mode) @@ -60,7 +60,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) authorManager.getAuthor4Token(token, function(err, author) { if(ERR(err, callback)) return; - + // assume user has access statusObject = {accessStatus: "grant", authorID: author}; // user can't create pads @@ -70,7 +70,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) padManager.doesPadExists(padID, function(err, exists) { if(ERR(err, callback)) return; - + // pad doesn't exist - user can't have access if(!exists) statusObject.accessStatus = "deny"; // grant or deny access, with author of token @@ -84,12 +84,12 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) callback(null, statusObject); } }) - + //don't continue return; } } - + var groupID = padID.split("$")[0]; var padExists = false; var validSession = false; @@ -100,7 +100,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) var passwordStatus = password == null ? "notGiven" : "wrong"; // notGiven, correct, wrong async.series([ - //get basic informations from the database + //get basic informations from the database function(callback) { async.parallel([ @@ -121,27 +121,27 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) callback(); return; } - + var sessionIDs = sessionCookie.split(','); async.forEach(sessionIDs, function(sessionID, callback) { sessionManager.getSessionInfo(sessionID, function(err, sessionInfo) { //skip session if it doesn't exist if(err && err.message == "sessionID does not exist") return; - + if(ERR(err, callback)) return; - + var now = Math.floor(new Date().getTime()/1000); - + //is it for this group? if(sessionInfo.groupID != groupID) return; - + //is validUntil still ok? if(sessionInfo.validUntil <= now) return; - + // There is a valid session validSession = true; sessionAuthor = sessionInfo.authorID; - + callback(); }); }, callback); @@ -163,28 +163,28 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) function(callback) { //skip this if the pad doesn't exists - if(padExists == false) + if(padExists == false) { callback(); return; } - + padManager.getPad(padID, function(err, pad) { if(ERR(err, callback)) return; - + //is it a public pad? isPublic = pad.getPublicStatus(); - + //is it password protected? isPasswordProtected = pad.isPasswordProtected(); - + //is password correct? if(isPasswordProtected && password && pad.isCorrectPassword(password)) { passwordStatus = "correct"; } - + callback(); }); }, @@ -221,7 +221,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) { throw new Error("Ops, something wrong happend"); } - } + } //- a valid session for this group avaible but pad doesn't exists else if(validSession && !padExists) { @@ -245,7 +245,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) //--> grant access, with author of token statusObject = {accessStatus: "grant", authorID: tokenAuthor}; } - //- its public and the pad is password protected but wrong password given + //- its public and the pad is password protected but wrong password given else if(isPublic && isPasswordProtected && passwordStatus == "wrong") { //--> deny access, ask for new password and tell them that the password is wrong @@ -267,14 +267,14 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback) { throw new Error("Ops, something wrong happend"); } - } + } // there is no valid session avaiable AND pad doesn't exists else { //--> deny access statusObject = {accessStatus: "deny"}; } - + callback(); } ], function(err) diff --git a/src/node/db/SessionManager.js b/src/node/db/SessionManager.js index 5ce4f7487..95e31ce4a 100644 --- a/src/node/db/SessionManager.js +++ b/src/node/db/SessionManager.js @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + var ERR = require("async-stacktrace"); var customError = require("../utils/customError"); @@ -26,7 +26,7 @@ var db = require("./DB").db; var async = require("async"); var groupMangager = require("./GroupManager"); var authorMangager = require("./AuthorManager"); - + exports.doesSessionExist = function(sessionID, callback) { //check if the database entry of this session exists @@ -36,7 +36,7 @@ exports.doesSessionExist = function(sessionID, callback) callback(null, session != null); }); } - + /** * Creates a new session between an author and a group */ @@ -51,7 +51,7 @@ exports.createSession = function(groupID, authorID, validUntil, callback) groupMangager.doesGroupExist(groupID, function(err, exists) { if(ERR(err, callback)) return; - + //group does not exist if(exists == false) { @@ -70,7 +70,7 @@ exports.createSession = function(groupID, authorID, validUntil, callback) authorMangager.doesAuthorExists(authorID, function(err, exists) { if(ERR(err, callback)) return; - + //author does not exist if(exists == false) { @@ -100,34 +100,34 @@ exports.createSession = function(groupID, authorID, validUntil, callback) return; } } - + //ensure this is not a negativ number if(validUntil < 0) { callback(new customError("validUntil is a negativ number","apierror")); return; } - + //ensure this is not a float value if(!is_int(validUntil)) { callback(new customError("validUntil is a float value","apierror")); return; } - + //check if validUntil is in the future if(Math.floor(new Date().getTime()/1000) > validUntil) { callback(new customError("validUntil is in the past","apierror")); return; } - + //generate sessionID sessionID = "s." + randomString(16); - + //set the session into the database db.set("session:" + sessionID, {"groupID": groupID, "authorID": authorID, "validUntil": validUntil}); - + callback(); }, //set the group2sessions entry @@ -137,19 +137,19 @@ exports.createSession = function(groupID, authorID, validUntil, callback) db.get("group2sessions:" + groupID, function(err, group2sessions) { if(ERR(err, callback)) return; - + //the entry doesn't exist so far, let's create it if(group2sessions == null || group2sessions.sessionIDs == null) { group2sessions = {sessionIDs : {}}; } - + //add the entry for this session group2sessions.sessionIDs[sessionID] = 1; - + //save the new element back db.set("group2sessions:" + groupID, group2sessions); - + callback(); }); }, @@ -160,26 +160,26 @@ exports.createSession = function(groupID, authorID, validUntil, callback) db.get("author2sessions:" + authorID, function(err, author2sessions) { if(ERR(err, callback)) return; - + //the entry doesn't exist so far, let's create it if(author2sessions == null || author2sessions.sessionIDs == null) { author2sessions = {sessionIDs : {}}; } - + //add the entry for this session author2sessions.sessionIDs[sessionID] = 1; - + //save the new element back db.set("author2sessions:" + authorID, author2sessions); - + callback(); }); } ], function(err) { if(ERR(err, callback)) return; - + //return error and sessionID callback(null, {sessionID: sessionID}); }) @@ -191,7 +191,7 @@ exports.getSessionInfo = function(sessionID, callback) db.get("session:" + sessionID, function (err, session) { if(ERR(err, callback)) return; - + //session does not exists if(session == null) { @@ -220,7 +220,7 @@ exports.deleteSession = function(sessionID, callback) db.get("session:" + sessionID, function (err, session) { if(ERR(err, callback)) return; - + //session does not exists if(session == null) { @@ -231,7 +231,7 @@ exports.deleteSession = function(sessionID, callback) { authorID = session.authorID; groupID = session.groupID; - + callback(); } }); @@ -261,15 +261,15 @@ exports.deleteSession = function(sessionID, callback) { //remove the session db.remove("session:" + sessionID); - + //remove session from group2sessions delete group2sessions.sessionIDs[sessionID]; db.set("group2sessions:" + groupID, group2sessions); - + //remove session from author2sessions delete author2sessions.sessionIDs[sessionID]; db.set("author2sessions:" + authorID, author2sessions); - + callback(); } ], function(err) @@ -284,7 +284,7 @@ exports.listSessionsOfGroup = function(groupID, callback) groupMangager.doesGroupExist(groupID, function(err, exists) { if(ERR(err, callback)) return; - + //group does not exist if(exists == false) { @@ -299,11 +299,11 @@ exports.listSessionsOfGroup = function(groupID, callback) } exports.listSessionsOfAuthor = function(authorID, callback) -{ +{ authorMangager.doesAuthorExists(authorID, function(err, exists) { if(ERR(err, callback)) return; - + //group does not exist if(exists == false) { @@ -334,14 +334,14 @@ function listSessionsWithDBKey (dbkey, callback) }); }, function(callback) - { + { //collect all sessionIDs in an arrary var sessionIDs = []; for (var i in sessions) { sessionIDs.push(i); } - + //foreach trough the sessions and get the sessioninfos async.forEach(sessionIDs, function(sessionID, callback) { @@ -362,6 +362,6 @@ function listSessionsWithDBKey (dbkey, callback) //checks if a number is an int function is_int(value) -{ +{ return (parseFloat(value) == parseInt(value)) && !isNaN(value) } diff --git a/src/node/eejs/index.js b/src/node/eejs/index.js index 7b43de634..db8eaeb21 100644 --- a/src/node/eejs/index.js +++ b/src/node/eejs/index.js @@ -120,7 +120,7 @@ exports.require = function (name, args, mod) { args.e = exports; args.require = require; var template = '<% e._init(buf); %>' + fs.readFileSync(ejspath).toString() + '<% e._exit(); %>'; - + exports.info.args.push(args); exports.info.file_stack.push({path: ejspath, inherit: []}); diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index f99762cea..2481122f1 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -31,7 +31,7 @@ try { apikey = fs.readFileSync("./APIKEY.txt","utf8"); } -catch(e) +catch(e) { apikey = randomString(32); fs.writeFileSync("./APIKEY.txt",apikey,"utf8"); @@ -124,7 +124,7 @@ exports.handle = function(apiVersion, functionName, fields, req, res) break; } } - + //say goodbye if this is an unkown API version if(!isKnownApiVersion) { @@ -132,7 +132,7 @@ exports.handle = function(apiVersion, functionName, fields, req, res) res.send({code: 3, message: "no such api version", data: null}); return; } - + //check if this is a valid function name var isKnownFunctionname = false; for(var knownFunctionname in version[apiVersion]) @@ -143,14 +143,14 @@ exports.handle = function(apiVersion, functionName, fields, req, res) break; } } - + //say goodbye if this is a unkown function if(!isKnownFunctionname) { res.send({code: 3, message: "no such function", data: null}); return; } - + //check the api key! if(fields["apikey"] != apikey.trim()) { @@ -190,16 +190,16 @@ function callAPI(apiVersion, functionName, fields, req, res) { functionParams.push(fields[ version[apiVersion][functionName][i] ]); } - + //add a callback function to handle the response functionParams.push(function(err, data) - { + { // no error happend, everything is fine if(err == null) { if(!data) data = null; - + res.send({code: 0, message: "ok", data: data}); } // parameters were wrong and the api stopped execution, pass the error @@ -214,7 +214,7 @@ function callAPI(apiVersion, functionName, fields, req, res) ERR(err); } }); - + //call the api function api[functionName](functionParams[0],functionParams[1],functionParams[2],functionParams[3],functionParams[4]); } diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js index 1b7fcc26d..4bfcffe5f 100644 --- a/src/node/handler/ExportHandler.js +++ b/src/node/handler/ExportHandler.js @@ -33,15 +33,15 @@ if(settings.abiword != null) var tempDirectory = "/tmp"; -//tempDirectory changes if the operating system is windows +//tempDirectory changes if the operating system is windows if(os.type().indexOf("Windows") > -1) { tempDirectory = process.env.TEMP; } - + /** * do a requested export - */ + */ exports.doExport = function(req, res, padId, type) { //tell the browser that this is a downloadable file @@ -100,7 +100,7 @@ exports.doExport = function(req, res, padId, type) if(ERR(err, callback)) return; html = _html; callback(); - }); + }); }, //decide what to do with the html export function(callback) @@ -109,13 +109,13 @@ exports.doExport = function(req, res, padId, type) if(type == "html") { res.send(html); - callback("stop"); + callback("stop"); } else //write the html export to a file { randNum = Math.floor(Math.random()*0xFFFFFFFF); srcFile = tempDirectory + "/eplite_export_" + randNum + ".html"; - fs.writeFile(srcFile, html, callback); + fs.writeFile(srcFile, html, callback); } }, //send the convert job to abiword @@ -123,7 +123,7 @@ exports.doExport = function(req, res, padId, type) { //ensure html can be collected by the garbage collector html = null; - + destFile = tempDirectory + "/eplite_export_" + randNum + "." + type; abiword.convertFile(srcFile, destFile, type, callback); }, @@ -145,7 +145,7 @@ exports.doExport = function(req, res, padId, type) //100ms delay to accomidate for slow windows fs if(os.type().indexOf("Windows") > -1) { - setTimeout(function() + setTimeout(function() { fs.unlink(destFile, callback); }, 100); diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index 788706ce7..19cedfe9c 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -38,20 +38,20 @@ if(os.type().indexOf("Windows") > -1) { tempDirectory = process.env.TEMP; } - + /** * do a requested import - */ + */ exports.doImport = function(req, res, padId) { //pipe to a file //convert file to text via abiword //set text in the pad - + var srcFile, destFile; var pad; var text; - + async.series([ //save the uploaded file to /tmp function(callback) @@ -59,9 +59,9 @@ exports.doImport = function(req, res, padId) var form = new formidable.IncomingForm(); form.keepExtensions = true; form.uploadDir = tempDirectory; - - form.parse(req, function(err, fields, files) - { + + form.parse(req, function(err, fields, files) + { //the upload failed, stop at this point if(err || files.file === undefined) { @@ -69,7 +69,7 @@ exports.doImport = function(req, res, padId) callback("uploadFailed"); } //everything ok, continue - else + else { //save the path of the uploaded file srcFile = files.file.path; @@ -77,14 +77,14 @@ exports.doImport = function(req, res, padId) } }); }, - + //ensure this is a file ending we know, else we change the file ending to .txt //this allows us to accept source code files like .c or .java function(callback) { var fileEnding = (srcFile.split(".")[1] || "").toLowerCase(); var knownFileEndings = ["txt", "doc", "docx", "pdf", "odt", "html", "htm"]; - + //find out if this is a known file ending var fileEndingKnown = false; for(var i in knownFileEndings) @@ -94,7 +94,7 @@ exports.doImport = function(req, res, padId) fileEndingKnown = true; } } - + //if the file ending is known, continue as normal if(fileEndingKnown) { @@ -105,11 +105,11 @@ exports.doImport = function(req, res, padId) { var oldSrcFile = srcFile; srcFile = srcFile.split(".")[0] + ".txt"; - + fs.rename(oldSrcFile, srcFile, callback); } }, - + //convert file to text function(callback) { @@ -125,7 +125,7 @@ exports.doImport = function(req, res, padId) } }); }, - + //get the pad object function(callback) { @@ -136,7 +136,7 @@ exports.doImport = function(req, res, padId) callback(); }); }, - + //read the text function(callback) { @@ -144,8 +144,8 @@ exports.doImport = function(req, res, padId) { if(ERR(err, callback)) return; text = _text; - - //node on windows has a delay on releasing of the file lock. + + //node on windows has a delay on releasing of the file lock. //We add a 100ms delay to work around this if(os.type().indexOf("Windows") > -1) { @@ -160,14 +160,14 @@ exports.doImport = function(req, res, padId) } }); }, - + //change text of the pad and broadcast the changeset function(callback) { pad.setText(text); padMessageHandler.updatePadClients(pad, callback); }, - + //clean up temporary files function(callback) { @@ -185,7 +185,7 @@ exports.doImport = function(req, res, padId) ], function(err) { var status = "ok"; - + //check for known errors and replace the status if(err == "uploadFailed" || err == "convertFailed") { @@ -194,7 +194,7 @@ exports.doImport = function(req, res, padId) } ERR(err); - + //close the connection res.send("", 200); }); diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index a30e4e818..809c465eb 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1,6 +1,6 @@ /** - * The MessageHandler handles all Messages that comes from Socket.IO and controls the sessions - */ + * The MessageHandler handles all Messages that comes from Socket.IO and controls the sessions + */ /* * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) @@ -71,7 +71,7 @@ exports.setSocketIO = function(socket_io) * @param client the new client */ exports.handleConnect = function(client) -{ +{ //Initalize sessioninfos for this new session sessioninfos[client.id]={}; } @@ -98,20 +98,20 @@ exports.kickSessionsFromPad = function(padID) * @param client the client that leaves */ exports.handleDisconnect = function(client) -{ +{ //save the padname of this session var sessionPad=sessioninfos[client.id].padId; - + //if this connection was already etablished with a handshake, send a disconnect message to the others if(sessioninfos[client.id] && sessioninfos[client.id].author) { var author = sessioninfos[client.id].author; - + //get the author color out of the db authorManager.getAuthorColorId(author, function(err, color) { ERR(err); - + //prepare the notification for the other users on the pad, that this user left var messageToTheOtherUsers = { "type": "COLLABROOM", @@ -125,7 +125,7 @@ exports.handleDisconnect = function(client) } } }; - + //Go trough all user that are still on the pad, and send them the USER_LEAVE message for(i in pad2sessions[sessionPad]) { @@ -133,23 +133,23 @@ exports.handleDisconnect = function(client) if(socket !== undefined){ socket.json.send(messageToTheOtherUsers); } - + } - }); + }); } - + //Go trough all sessions of this pad, search and destroy the entry of this client for(i in pad2sessions[sessionPad]) { if(pad2sessions[sessionPad][i] == client.id) { - pad2sessions[sessionPad].splice(i, 1); + pad2sessions[sessionPad].splice(i, 1); break; } } - + //Delete the sessioninfos entrys of this session - delete sessioninfos[client.id]; + delete sessioninfos[client.id]; } /** @@ -158,7 +158,7 @@ exports.handleDisconnect = function(client) * @param message the message from the client */ exports.handleMessage = function(client, message) -{ +{ if(message == null) { @@ -173,18 +173,18 @@ exports.handleMessage = function(client, message) var handleMessageHook = function(callback){ var dropMessage = false; - - // Call handleMessage hook. If a plugin returns null, the message will be dropped. Note that for all messages + + // Call handleMessage hook. If a plugin returns null, the message will be dropped. Note that for all messages // handleMessage will be called, even if the client is not authorized hooks.aCallAll("handleMessage", { client: client, message: message }, function ( err, messages ) { if(ERR(err, callback)) return; - + _.each(messages, function(newMessage){ if ( newMessage === null ) { dropMessage = true; } }); - + // If no plugins explicitly told us to drop the message, its ok to proceed if(!dropMessage){ callback() }; }); @@ -224,7 +224,7 @@ exports.handleMessage = function(client, message) //check permissions function(callback) { - + if(!message.padId){ // If the message has a padId we assume the client is already known to the server and needs no re-authorization callback(); @@ -265,11 +265,11 @@ exports.handleMessage = function(client, message) function handleSaveRevisionMessage(client, message){ var padId = sessioninfos[client.id].padId; var userId = sessioninfos[client.id].author; - + padManager.getPad(padId, function(err, pad) { if(ERR(err)) return; - + pad.addSavedRevision(pad.head, userId); }); } @@ -307,10 +307,10 @@ function handleChatMessage(client, message) var userId = sessioninfos[client.id].author; var text = message.data.text; var padId = sessioninfos[client.id].padId; - + var pad; var userName; - + async.series([ //get the pad function(callback) @@ -336,7 +336,7 @@ function handleChatMessage(client, message) { //save the chat message pad.appendChatMessage(text, userId, time); - + var msg = { type: "COLLABROOM", data: { @@ -347,13 +347,13 @@ function handleChatMessage(client, message) text: text } }; - + //broadcast the chat message to everyone on the pad for(var i in pad2sessions[padId]) { socketio.sockets.sockets[pad2sessions[padId][i]].json.send(msg); } - + callback(); } ], function(err) @@ -381,9 +381,9 @@ function handleSuggestUserName(client, message) messageLogger.warn("Dropped message, suggestUserName Message has no unnamedId!"); return; } - + var padId = sessioninfos[client.id].padId; - + //search the author and send him this message for(var i in pad2sessions[padId]) { @@ -408,14 +408,14 @@ function handleUserInfoUpdate(client, message) messageLogger.warn("Dropped message, USERINFO_UPDATE Message has no colorId!"); return; } - + //Find out the author name of this session var author = sessioninfos[client.id].author; - + //Tell the authorManager about the new attributes authorManager.setAuthorColorId(author, message.data.userInfo.colorId); authorManager.setAuthorName(author, message.data.userInfo.name); - + var padId = sessioninfos[client.id].padId; var infoMsg = { @@ -432,13 +432,13 @@ function handleUserInfoUpdate(client, message) } } }; - + //set a null name, when there is no name set. cause the client wants it null if(infoMsg.data.userInfo.name == null) { infoMsg.data.userInfo.name = null; } - + //Send the other clients on the pad the update message for(var i in pad2sessions[padId]) { @@ -481,7 +481,7 @@ function handleUserChanges(client, message) messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!"); return; } - + //get all Vars we need var baseRev = message.data.baseRev; var wireApool = (new AttributePool()).fromJsonable(message.data.apool); @@ -489,9 +489,9 @@ function handleUserChanges(client, message) // The client might disconnect between our callbacks. We should still // finish processing the changeset, so keep a reference to the session. var thisSession = sessioninfos[client.id]; - + var r, apool, pad; - + async.series([ //get the pad function(callback) @@ -507,7 +507,7 @@ function handleUserChanges(client, message) function(callback) { //ex. _checkChangesetAndPool - + try { // Verify that the changeset has valid syntax and is in canonical form @@ -528,12 +528,12 @@ function handleUserChanges(client, message) client.json.send({disconnect:"badChangeset"}); return; } - + //ex. adoptChangesetAttribs - + //Afaik, it copies the new attributes from the changeset, to the global Attribute Pool changeset = Changeset.moveOpsToNewPool(changeset, wireApool, pad.pool); - + //ex. applyUserChanges apool = pad.pool; r = baseRev; @@ -547,7 +547,7 @@ function handleUserChanges(client, message) function(callback) { r++; - + pad.getRevisionChangeset(r, function(err, c) { if(ERR(err, callback)) return; @@ -573,17 +573,17 @@ function handleUserChanges(client, message) function (callback) { var prevText = pad.text(); - - if (Changeset.oldLen(changeset) != prevText.length) + + if (Changeset.oldLen(changeset) != prevText.length) { console.warn("Can't apply USER_CHANGES "+changeset+" with oldLen " + Changeset.oldLen(changeset) + " to document of length " + prevText.length); client.json.send({disconnect:"badChangeset"}); callback(); return; } - + pad.appendRevision(changeset, thisSession.author); - + var correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool); if (correctionChangeset) { pad.appendRevision(correctionChangeset); @@ -594,7 +594,7 @@ function handleUserChanges(client, message) var nlChangeset = Changeset.makeSplice(pad.text(), pad.text().length-1, 0, "\n"); pad.appendRevision(nlChangeset); } - + exports.updatePadClients(pad, callback); } ], function(err) @@ -604,14 +604,14 @@ function handleUserChanges(client, message) } exports.updatePadClients = function(pad, callback) -{ +{ //skip this step if noone is on this pad if(!pad2sessions[pad.id]) { callback(); return; } - + //go trough all sessions on this pad async.forEach(pad2sessions[pad.id], function(session, callback) { @@ -621,10 +621,10 @@ exports.updatePadClients = function(pad, callback) async.whilst( function (){ return sessioninfos[session].rev < pad.getHeadRevisionNumber()}, function(callback) - { + { var author, revChangeset, currentTime; var r = sessioninfos[session].rev + 1; - + async.parallel([ function (callback) { @@ -677,8 +677,8 @@ exports.updatePadClients = function(pad, callback) author: author, currentTime: currentTime, timeDelta: currentTime - sessioninfos[session].time - }}; - + }}; + socketio.sockets.sockets[session].json.send(wireMsg); } @@ -687,13 +687,13 @@ exports.updatePadClients = function(pad, callback) sessioninfos[session].time = currentTime; sessioninfos[session].rev = r; } - + callback(null); }); }, callback ); - },callback); + },callback); } /** @@ -709,11 +709,11 @@ function _correctMarkersInPad(atext, apool) { var offset = 0; while (iter.hasNext()) { var op = iter.next(); - + var hasMarker = _.find(AttributeManager.lineAttributes, function(attribute){ return Changeset.opAttributeValue(op, attribute, apool); }) !== undefined; - + if (hasMarker) { for(var i=0;i 0 && text.charAt(offset-1) != '\n') { @@ -743,7 +743,7 @@ function _correctMarkersInPad(atext, apool) { } /** - * Handles a CLIENT_READY. A CLIENT_READY is the first message from the client to the server. The Client sends his token + * Handles a CLIENT_READY. A CLIENT_READY is the first message from the client to the server. The Client sends his token * and the pad it wants to enter. The Server answers with the inital values (clientVars) of the pad * @param client the client that send this message * @param message the message from the client @@ -802,7 +802,7 @@ function handleClientReady(client, message) securityManager.checkAccess (padIds.padId, message.sessionID, message.token, message.password, function(err, statusObject) { if(ERR(err, callback)) return; - + //access was granted if(statusObject.accessStatus == "grant") { @@ -815,7 +815,7 @@ function handleClientReady(client, message) client.json.send({accessStatus: statusObject.accessStatus}) } }); - }, + }, //get all authordata of this new user function(callback) { @@ -855,7 +855,7 @@ function handleClientReady(client, message) function(callback) { var authors = pad.getAllAuthors(); - + async.parallel([ //get timestamp of latest revission needed for timeslider function(callback) @@ -892,7 +892,7 @@ function handleClientReady(client, message) }); } ], callback); - + }, function(callback) { @@ -915,27 +915,27 @@ function handleClientReady(client, message) } } } - + //Save in sessioninfos that this session belonges to this pad sessioninfos[client.id].padId = padIds.padId; sessioninfos[client.id].readOnlyPadId = padIds.readOnlyPadId; sessioninfos[client.id].readonly = padIds.readonly; - + //check if there is already a pad2sessions entry, if not, create one if(!pad2sessions[padIds.padId]) { pad2sessions[padIds.padId] = []; } - + //Saves in pad2sessions that this session belongs to this pad pad2sessions[padIds.padId].push(client.id); - + //prepare all values for the wire var atext = Changeset.cloneAText(pad.atext); var attribsForWire = Changeset.prepareForWire(atext.attribs, pad.pool); var apool = attribsForWire.pool.toJsonable(); atext.attribs = attribsForWire.translated; - + // Warning: never ever send padIds.padId to the client. If the // client is read only you would open a security hole 1 swedish // mile wide... @@ -978,7 +978,7 @@ function handleClientReady(client, message) "fullWidth": false, "hideSidebar": false }, - "abiwordAvailable": settings.abiwordAvailable(), + "abiwordAvailable": settings.abiwordAvailable(), "plugins": { "plugins": plugins.plugins, "parts": plugins.parts, @@ -992,7 +992,7 @@ function handleClientReady(client, message) { clientVars.userName = authorName; } - + //If this is a reconnect, we don't have to send the client the ClientVars again if(message.reconnect == true) { @@ -1007,9 +1007,9 @@ function handleClientReady(client, message) //Save the current revision in sessioninfos, should be the same as in clientVars sessioninfos[client.id].rev = pad.getHeadRevisionNumber(); } - + sessioninfos[client.id].author = author; - + //prepare the notification for the other users on the pad, that this user joined var messageToTheOtherUsers = { "type": "COLLABROOM", @@ -1023,19 +1023,19 @@ function handleClientReady(client, message) } } }; - + //Add the authorname of this new User, if avaiable if(authorName != null) { messageToTheOtherUsers.data.userInfo.name = authorName; } - + //Run trough all sessions of this pad async.forEach(pad2sessions[padIds.padId], function(sessionID, callback) { var author, socket, sessionAuthorName, sessionAuthorColorId; - - //Since sessioninfos might change while being enumerated, check if the + + //Since sessioninfos might change while being enumerated, check if the //sessionID is still assigned to a valid session if(sessioninfos[sessionID] !== undefined && socketio.sockets.sockets[sessionID] !== undefined){ @@ -1070,7 +1070,7 @@ function handleClientReady(client, message) }) } ],callback); - }, + }, function (callback) { //Jump over, if this session is the connection session @@ -1078,7 +1078,7 @@ function handleClientReady(client, message) { //Send this Session the Notification about the new user socket.json.send(messageToTheOtherUsers); - + //Send the new User a Notification about this other user var messageToNotifyTheClientAboutTheOthers = { "type": "COLLABROOM", @@ -1096,7 +1096,7 @@ function handleClientReady(client, message) client.json.send(messageToNotifyTheClientAboutTheOthers); } } - ], callback); + ], callback); }, callback); } ],function(err) @@ -1106,7 +1106,7 @@ function handleClientReady(client, message) } /** - * Handles a request for a rough changeset, the timeslider client needs it + * Handles a request for a rough changeset, the timeslider client needs it */ function handleChangesetRequest(client, message) { @@ -1136,7 +1136,7 @@ function handleChangesetRequest(client, message) messageLogger.warn("Dropped message, changeset request has no requestID!"); return; } - + var granularity = message.data.granularity; var start = message.data.start; var end = start + (100 * granularity); @@ -1180,47 +1180,47 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback) var composedChangesets = {}; var revisionDate = []; var lines; - + async.series([ //get the pad from the database function(callback) { padManager.getPad(padId, function(err, _pad) - { + { if(ERR(err, callback)) return; pad = _pad; callback(); }); }, function(callback) - { + { //calculate the last full endnum var lastRev = pad.getHeadRevisionNumber(); if (endNum > lastRev+1) { endNum = lastRev+1; } endNum = Math.floor(endNum / granularity)*granularity; - + var compositesChangesetNeeded = []; var revTimesNeeded = []; - + //figure out which composite Changeset and revTimes we need, to load them in bulk var compositeStart = startNum; - while (compositeStart < endNum) + while (compositeStart < endNum) { var compositeEnd = compositeStart + granularity; - + //add the composite Changeset we needed compositesChangesetNeeded.push({start: compositeStart, end: compositeEnd}); - + //add the t1 time we need revTimesNeeded.push(compositeStart == 0 ? 0 : compositeStart - 1); //add the t2 time we need revTimesNeeded.push(compositeEnd - 1); - + compositeStart += granularity; } - + //get all needed db values parallel async.parallel([ function(callback) @@ -1257,58 +1257,58 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback) if(ERR(err, callback)) return; lines = _lines; callback(); - }); + }); } ], callback); }, //doesn't know what happens here excatly :/ function(callback) - { + { var compositeStart = startNum; - - while (compositeStart < endNum) + + while (compositeStart < endNum) { - if (compositeStart + granularity > endNum) + if (compositeStart + granularity > endNum) { break; } - + var compositeEnd = compositeStart + granularity; - + var forwards = composedChangesets[compositeStart + "/" + compositeEnd]; var backwards = Changeset.inverse(forwards, lines.textlines, lines.alines, pad.apool()); - + Changeset.mutateAttributionLines(forwards, lines.alines, pad.apool()); Changeset.mutateTextLines(forwards, lines.textlines); - + var forwards2 = Changeset.moveOpsToNewPool(forwards, pad.apool(), apool); var backwards2 = Changeset.moveOpsToNewPool(backwards, pad.apool(), apool); - + var t1, t2; - if (compositeStart == 0) + if (compositeStart == 0) { t1 = revisionDate[0]; } - else + else { t1 = revisionDate[compositeStart - 1]; } - + t2 = revisionDate[compositeEnd - 1]; - + timeDeltas.push(t2 - t1); forwardsChangesets.push(forwards2); backwardsChangesets.push(backwards2); - + compositeStart += granularity; } - + callback(); } ], function(err) { if(ERR(err, callback)) return; - + callback(null, {forwardsChangesets: forwardsChangesets, backwardsChangesets: backwardsChangesets, apool: apool.toJsonable(), @@ -1323,7 +1323,7 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback) * Tries to rebuild the getPadLines function of the original Etherpad * https://github.com/ether/pad/blob/master/etherpad/src/etherpad/control/pad/pad_changeset_control.js#L263 */ -function getPadLines(padId, revNum, callback) +function getPadLines(padId, revNum, callback) { var atext; var result = {}; @@ -1334,7 +1334,7 @@ function getPadLines(padId, revNum, callback) function(callback) { padManager.getPad(padId, function(err, _pad) - { + { if(ERR(err, callback)) return; pad = _pad; callback(); @@ -1396,14 +1396,14 @@ function composePadChangesets(padId, startNum, endNum, callback) function(callback) { var changesetsNeeded=[]; - - //create a array for all changesets, we will + + //create a array for all changesets, we will //replace the values with the changeset later for(var r=startNum;r -1) { //span an abiword process to perform the conversion var abiword = spawn(settings.abiword, ["--to=" + task.destFile, task.srcFile]); - + //delegate the processing of stdout to another function abiword.stdout.on('data', function (data) { @@ -44,7 +44,7 @@ if(os.type().indexOf("Windows") > -1) }); //append error messages to the buffer - abiword.stderr.on('data', function (data) + abiword.stderr.on('data', function (data) { stdoutBuffer += data.toString(); }); @@ -64,7 +64,7 @@ if(os.type().indexOf("Windows") > -1) callback(); }); } - + exports.convertFile = function(srcFile, destFile, type, callback) { doConvertTask({"srcFile": srcFile, "destFile": destFile, "type": type}, callback); @@ -80,16 +80,16 @@ else var spawnAbiword = function (){ abiword = spawn(settings.abiword, ["--plugin", "AbiCommand"]); var stdoutBuffer = ""; - var firstPrompt = true; + var firstPrompt = true; //append error messages to the buffer - abiword.stderr.on('data', function (data) + abiword.stderr.on('data', function (data) { stdoutBuffer += data.toString(); }); //abiword died, let's restart abiword and return an error with the callback - abiword.on('exit', function (code) + abiword.on('exit', function (code) { spawnAbiword(); stdoutCallback("Abiword died with exit code " + code); @@ -100,16 +100,16 @@ else { //add data to buffer stdoutBuffer+=data.toString(); - + //we're searching for the prompt, cause this means everything we need is in the buffer if(stdoutBuffer.search("AbiWord:>") != -1) { //filter the feedback message var err = stdoutBuffer.search("OK") != -1 ? null : stdoutBuffer; - + //reset the buffer stdoutBuffer = ""; - + //call the callback with the error message //skip the first prompt if(stdoutCallback != null && !firstPrompt) @@ -117,7 +117,7 @@ else stdoutCallback(err); stdoutCallback = null; } - + firstPrompt = false; } }); @@ -127,7 +127,7 @@ else doConvertTask = function(task, callback) { abiword.stdin.write("convert " + task.srcFile + " " + task.destFile + " " + task.type + "\n"); - + //create a callback that calls the task callback and the caller callback stdoutCallback = function (err) { @@ -136,12 +136,12 @@ else task.callback(err); }; } - + //Queue with the converts we have to do var queue = async.queue(doConvertTask, 1); - + exports.convertFile = function(srcFile, destFile, type, callback) - { + { queue.push({"srcFile": srcFile, "destFile": destFile, "type": type, "callback": callback}); }; } diff --git a/src/node/utils/ExportDokuWiki.js b/src/node/utils/ExportDokuWiki.js index d2f71236b..2b9dfcb9d 100644 --- a/src/node/utils/ExportDokuWiki.js +++ b/src/node/utils/ExportDokuWiki.js @@ -1,12 +1,12 @@ /** * Copyright 2011 Adrian Lang - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS-IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 354030133..4d12c9ac8 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -1,12 +1,12 @@ /** * Copyright 2009 Google Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS-IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -142,7 +142,7 @@ function getHTMLFromAtext(pad, atext) assem.append(tags[i]); assem.append('>'); } - + function orderdCloseTags(tags2close) { for(var i=0;i= 0; i--) { @@ -283,7 +283,7 @@ function getHTMLFromAtext(pad, atext) propVals[i] = false; } } - + orderdCloseTags(tags2close); } // end processNextChars if (urls) @@ -317,7 +317,7 @@ function getHTMLFromAtext(pad, atext) { var line = _analyzeLine(textLines[i], attribLines[i], apool); var lineContent = getLineHTML(line.text, line.aline); - + if (line.listLevel)//If we are inside a list { // do list stuff @@ -401,8 +401,8 @@ function getHTMLFromAtext(pad, atext) pieces.push(''); } lists.length--; - } - var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport", + } + var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport", { line: line, apool: apool, @@ -412,14 +412,14 @@ function getHTMLFromAtext(pad, atext) if (lineContentFromHook) { pieces.push(lineContentFromHook, ''); - } - else + } + else { pieces.push(lineContent, '
'); - } + } } } - + for (var k = lists.length - 1; k >= 0; k--) { if(lists[k][1] == "number") @@ -480,14 +480,14 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) { if(ERR(err, callback)) return; - var head = - (noDocType ? '' : '\n') + - '\n' + (noDocType ? '' : '\n' + + var head = + (noDocType ? '' : '\n') + + '\n' + (noDocType ? '' : '\n' + '' + Security.escapeHTML(padId) + '\n' + - '\n' + - '\n' + '\n') + + '\n' + '\n') + ''; var foot = '\n\n'; diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index 5fc8accbb..b2a25c484 100644 --- a/src/node/utils/Minify.js +++ b/src/node/utils/Minify.js @@ -1,7 +1,7 @@ /** - * This Module manages all /minified/* requests. It controls the - * minification && compression of Javascript and CSS. - */ + * This Module manages all /minified/* requests. It controls the + * minification && compression of Javascript and CSS. + */ /* * 2011 Peter 'Pita' Martischka (Primary Technology Ltd) @@ -149,7 +149,7 @@ function minify(req, res, next) } else { res.writeHead(404, {}); res.end(); - return; + return; } /* Handle static files for plugins/libraries: diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 4cc22045a..8ba6e53ba 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -1,5 +1,5 @@ /** - * The Settings Modul reads the settings out of settings.json and provides + * The Settings Modul reads the settings out of settings.json and provides * this information to the other modules */ @@ -43,7 +43,7 @@ exports.favicon = "favicon.ico"; * The IP ep-lite should listen to */ exports.ip = "0.0.0.0"; - + /** * The Port ep-lite should listen to */ diff --git a/src/node/utils/customError.js b/src/node/utils/customError.js index 5ca7a7a41..c18743485 100644 --- a/src/node/utils/customError.js +++ b/src/node/utils/customError.js @@ -5,11 +5,11 @@ function customError(message, errorName) { this.name = errorName || "Error"; this.message = message; - + var stackParts = new Error().stack.split("\n"); stackParts.splice(0,2); stackParts.unshift(this.name + ": " + message); - + this.stack = stackParts.join("\n"); } customError.prototype = Error.prototype; diff --git a/src/package.json b/src/package.json index c3c4968a6..79114e6c3 100644 --- a/src/package.json +++ b/src/package.json @@ -5,7 +5,7 @@ "keywords" : ["etherpad", "realtime", "collaborative", "editor"], "author" : "Peter 'Pita' Martischka - Primary Technology Ltd", "contributors" : [ - { "name": "John McLear" }, + { "name": "John McLear" }, { "name": "Hans Pinckaers" }, { "name": "Robin Buse" }, { "name": "Marcel Klehr" } @@ -43,6 +43,6 @@ }, "engines" : { "node" : ">=0.6.0", "npm" : ">=1.0" - }, + }, "version" : "1.1.4" } diff --git a/src/static/css/admin.css b/src/static/css/admin.css index b91850a65..9bf550027 100644 --- a/src/static/css/admin.css +++ b/src/static/css/admin.css @@ -1,130 +1,130 @@ -body { - margin: 0; - color: #333; - font: 14px helvetica, sans-serif; - background: #ddd; - background: -webkit-radial-gradient(circle,#aaa,#eee 60%) center fixed; - background: -moz-radial-gradient(circle,#aaa,#eee 60%) center fixed; - background: -ms-radial-gradient(circle,#aaa,#eee 60%) center fixed; - background: -o-radial-gradient(circle,#aaa,#eee 60%) center fixed; - border-top: 8px solid rgba(51,51,51,.8); -} -#wrapper { - margin-top: 160px; - padding: 15px; - background: #fff; - opacity: .9; - box-shadow: 0px 1px 8px rgba(0,0,0,0.3); - max-width: 700px; - margin: auto; - border-radius: 0 0 7px 7px; -} -h1 { - font-size: 29px; -} -h2 { - font-size: 24px; -} -.separator { - margin: 10px 0; - height: 1px; - background: #aaa; - background: -webkit-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); - background: -moz-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); - background: -ms-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); - background: -o-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); -} -form { - margin-bottom: 0; -} -#inner { - width: 300px; - margin: 0 auto; -} -input { - font-weight: bold; - font-size: 15px; -} -input[type="button"] { - padding: 4px 6px; - margin: 0; -} -input[type="button"].do-install, input[type="button"].do-uninstall { - float: right; - width: 100px; -} -input[type="button"]#do-search { - display: block; -} -input[type="text"] { - border-radius: 3px; - box-sizing: border-box; - -moz-box-sizing: border-box; - padding: 10px; - *padding: 0; /* IE7 hack */ - width: 100%; - outline: none; - border: 1px solid #ddd; - margin: 0 0 5px 0; - max-width: 500px; -} -table { - border: 1px solid #ddd; - border-radius: 3px; - border-spacing: 0; - width: 100%; - margin: 20px 0; -} -table thead tr { - background: #eee; -} -td, th { - padding: 5px; -} -.template { - display: none; -} -.dialog { - display: none; - position: absolute; - left: 50%; - top: 50%; - width: 700px; - height: 500px; - margin-left: -350px; - margin-top: -250px; - border: 3px solid #999; - background: #eee; -} -.dialog .title { - margin: 0; - padding: 2px; - border-bottom: 3px solid #999; - font-size: 24px; - line-height: 24px; - height: 24px; - overflow: hidden; -} -.dialog .title .close { - float: right; - padding: 1px 10px; -} -.dialog .history { - background: #222; - color: #eee; - position: absolute; - top: 41px; - bottom: 10px; - left: 10px; - right: 10px; - padding: 2px; - overflow: auto; -} -.settings { - margin-top:10px; - width:100%; - min-height:600px; -} -#response{ - display:inline; -} +body { + margin: 0; + color: #333; + font: 14px helvetica, sans-serif; + background: #ddd; + background: -webkit-radial-gradient(circle,#aaa,#eee 60%) center fixed; + background: -moz-radial-gradient(circle,#aaa,#eee 60%) center fixed; + background: -ms-radial-gradient(circle,#aaa,#eee 60%) center fixed; + background: -o-radial-gradient(circle,#aaa,#eee 60%) center fixed; + border-top: 8px solid rgba(51,51,51,.8); +} +#wrapper { + margin-top: 160px; + padding: 15px; + background: #fff; + opacity: .9; + box-shadow: 0px 1px 8px rgba(0,0,0,0.3); + max-width: 700px; + margin: auto; + border-radius: 0 0 7px 7px; +} +h1 { + font-size: 29px; +} +h2 { + font-size: 24px; +} +.separator { + margin: 10px 0; + height: 1px; + background: #aaa; + background: -webkit-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); + background: -moz-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); + background: -ms-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); + background: -o-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff); +} +form { + margin-bottom: 0; +} +#inner { + width: 300px; + margin: 0 auto; +} +input { + font-weight: bold; + font-size: 15px; +} +input[type="button"] { + padding: 4px 6px; + margin: 0; +} +input[type="button"].do-install, input[type="button"].do-uninstall { + float: right; + width: 100px; +} +input[type="button"]#do-search { + display: block; +} +input[type="text"] { + border-radius: 3px; + box-sizing: border-box; + -moz-box-sizing: border-box; + padding: 10px; + *padding: 0; /* IE7 hack */ + width: 100%; + outline: none; + border: 1px solid #ddd; + margin: 0 0 5px 0; + max-width: 500px; +} +table { + border: 1px solid #ddd; + border-radius: 3px; + border-spacing: 0; + width: 100%; + margin: 20px 0; +} +table thead tr { + background: #eee; +} +td, th { + padding: 5px; +} +.template { + display: none; +} +.dialog { + display: none; + position: absolute; + left: 50%; + top: 50%; + width: 700px; + height: 500px; + margin-left: -350px; + margin-top: -250px; + border: 3px solid #999; + background: #eee; +} +.dialog .title { + margin: 0; + padding: 2px; + border-bottom: 3px solid #999; + font-size: 24px; + line-height: 24px; + height: 24px; + overflow: hidden; +} +.dialog .title .close { + float: right; + padding: 1px 10px; +} +.dialog .history { + background: #222; + color: #eee; + position: absolute; + top: 41px; + bottom: 10px; + left: 10px; + right: 10px; + padding: 2px; + overflow: auto; +} +.settings { + margin-top:10px; + width:100%; + min-height:600px; +} +#response{ + display:inline; +} diff --git a/src/static/css/iframe_editor.css b/src/static/css/iframe_editor.css index bca00ff42..65983c9ba 100644 --- a/src/static/css/iframe_editor.css +++ b/src/static/css/iframe_editor.css @@ -78,7 +78,7 @@ ul.list-indent8 { list-style-type: none; } body { margin: 0; white-space: nowrap; -} +} #outerdocbody { background-color: #fff; diff --git a/src/static/css/pad.css b/src/static/css/pad.css index 5ee6b3c56..20294eb1d 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -775,7 +775,7 @@ input[type=checkbox] { border-left: 1px solid #ccc !important; width: 185px !important; } -@media screen and (max-width: 600px) { +@media screen and (max-width: 600px) { .toolbar ul li.separator { display: none; } @@ -784,13 +784,13 @@ input[type=checkbox] { } } @media screen and (max-width: 400px){ - #editorcontainer { + #editorcontainer { top: 68px; } - #editbar { + #editbar { height: 62px; } - .toolbar ul.menu_right { + .toolbar ul.menu_right { float: left; margin-top:2px; } diff --git a/src/static/js/AttributeManager.js b/src/static/js/AttributeManager.js index 2d523f6aa..92182ed92 100644 --- a/src/static/js/AttributeManager.js +++ b/src/static/js/AttributeManager.js @@ -4,23 +4,23 @@ var _ = require('./underscore'); var lineMarkerAttribute = 'lmkr'; -// If one of these attributes are set to the first character of a +// If one of these attributes are set to the first character of a // line it is considered as a line attribute marker i.e. attributes -// set on this marker are applied to the whole line. +// set on this marker are applied to the whole line. // The list attribute is only maintained for compatibility reasons var lineAttributes = [lineMarkerAttribute,'list']; /* - The Attribute manager builds changesets based on a document + The Attribute manager builds changesets based on a document representation for setting and removing range or line-based attributes. - + @param rep the document representation to be used - @param applyChangesetCallback this callback will be called + @param applyChangesetCallback this callback will be called once a changeset has been built. - - - A document representation contains - - an array `alines` containing 1 attributes string for each line + + + A document representation contains + - an array `alines` containing 1 attributes string for each line - an Attribute pool `apool` - a SkipList `lines` containing the text lines of the document. */ @@ -30,7 +30,7 @@ var AttributeManager = function(rep, applyChangesetCallback) this.rep = rep; this.applyChangesetCallback = applyChangesetCallback; this.author = ''; - + // If the first char in a line has one of the following attributes // it will be considered as a line marker }; @@ -38,19 +38,19 @@ var AttributeManager = function(rep, applyChangesetCallback) AttributeManager.lineAttributes = lineAttributes; AttributeManager.prototype = _(AttributeManager.prototype).extend({ - + applyChangeset: function(changeset){ if(!this.applyChangesetCallback) return changeset; - + var cs = changeset.toString(); if (!Changeset.isIdentity(cs)) { this.applyChangesetCallback(cs); } - + return changeset; }, - + /* Sets attributes on a range @param start [row, col] tuple pointing to the start of the range @@ -65,22 +65,22 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({ return this.applyChangeset(builder); }, - /* + /* Returns if the line already has a line marker @param lineNum: the number of the line */ lineHasMarker: function(lineNum){ var that = this; - + return _.find(lineAttributes, function(attribute){ - return that.getAttributeOnLine(lineNum, attribute) != ''; + return that.getAttributeOnLine(lineNum, attribute) != ''; }) !== undefined; }, - + /* Gets a specified attribute on a line @param lineNum: the number of the line to set the attribute for - @param attributeKey: the name of the attribute to get, e.g. list + @param attributeKey: the name of the attribute to get, e.g. list */ getAttributeOnLine: function(lineNum, attributeName){ // get `attributeName` attribute of first char of line @@ -95,26 +95,26 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({ } return ''; }, - + /* Sets a specified attribute on a line @param lineNum: the number of the line to set the attribute for @param attributeKey: the name of the attribute to set, e.g. list @param attributeValue: an optional parameter to pass to the attribute (e.g. indention level) - + */ setAttributeOnLine: function(lineNum, attributeName, attributeValue){ var loc = [0,0]; var builder = Changeset.builder(this.rep.lines.totalWidth()); var hasMarker = this.lineHasMarker(lineNum); - + ChangesetUtils.buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 0])); if(hasMarker){ ChangesetUtils.buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 1]), [ [attributeName, attributeValue] ], this.rep.apool); - }else{ + }else{ // add a line marker builder.insert('*', [ ['author', this.author], @@ -123,10 +123,10 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({ [attributeName, attributeValue] ], this.rep.apool); } - + return this.applyChangeset(builder); }, - + /* Removes a specified attribute on a line @param lineNum: the number of the affected line @@ -134,19 +134,19 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({ */ removeAttributeOnLine: function(lineNum, attributeName, attributeValue){ - + var loc = [0,0]; var builder = Changeset.builder(this.rep.lines.totalWidth()); var hasMarker = this.lineHasMarker(lineNum); - + if(hasMarker){ ChangesetUtils.buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 0])); ChangesetUtils.buildRemoveRange(this.rep, builder, loc, (loc = [lineNum, 1])); } - + return this.applyChangeset(builder); }, - + /* Sets a specified attribute on a line @param lineNum: the number of the line to set the attribute for @@ -157,7 +157,7 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({ return this.getAttributeOnLine(attributeName) ? this.removeAttributeOnLine(lineNum, attributeName) : this.setAttributeOnLine(lineNum, attributeName, attributeValue); - + } }); diff --git a/src/static/js/AttributePool.js b/src/static/js/AttributePool.js index f5990c07d..5f364eafe 100644 --- a/src/static/js/AttributePool.js +++ b/src/static/js/AttributePool.js @@ -91,6 +91,6 @@ AttributePool.prototype.fromJsonable = function (obj) { } return this; }; - + module.exports = AttributePool; \ No newline at end of file diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index cfea43625..6094e3436 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -42,7 +42,7 @@ exports.error = function error(msg) { }; /** - * This method is user for assertions with Messages + * This method is user for assertions with Messages * if assert fails, the error function called. * @param b {boolean} assertion condition * @param msgParts {string} error to be passed if it fails @@ -76,7 +76,7 @@ exports.numToString = function (num) { * Converts stuff before $ to base 10 * @obsolete not really used anywhere?? * @param cs {string} the string - * @return integer + * @return integer */ exports.toBaseTen = function (cs) { var dollarIndex = cs.indexOf('$'); @@ -93,10 +93,10 @@ exports.toBaseTen = function (cs) { */ /** - * returns the required length of the text before changeset + * returns the required length of the text before changeset * can be applied * @param cs {string} String representation of the Changeset - */ + */ exports.oldLen = function (cs) { return exports.unpack(cs).oldLen; }; @@ -104,16 +104,16 @@ exports.oldLen = function (cs) { /** * returns the length of the text after changeset is applied * @param cs {string} String representation of the Changeset - */ + */ exports.newLen = function (cs) { return exports.unpack(cs).newLen; }; /** * this function creates an iterator which decodes string changeset operations - * @param opsStr {string} String encoding of the change operations to be performed - * @param optStartIndex {int} from where in the string should the iterator start - * @return {Op} type object iterator + * @param opsStr {string} String encoding of the change operations to be performed + * @param optStartIndex {int} from where in the string should the iterator start + * @return {Op} type object iterator */ exports.opIterator = function (opsStr, optStartIndex) { //print(opsStr); @@ -131,7 +131,7 @@ exports.opIterator = function (opsStr, optStartIndex) { if (result[0] == '?') { exports.error("Hit error opcode in op stream"); } - + return result; } var regexResult = nextRegexMatch(); @@ -504,7 +504,7 @@ exports.opAssembler = function () { /** * A custom made String Iterator * @param str {string} String to be iterated over - */ + */ exports.stringIterator = function (str) { var curIndex = 0; @@ -542,7 +542,7 @@ exports.stringIterator = function (str) { }; /** - * A custom made StringBuffer + * A custom made StringBuffer */ exports.stringAssembler = function () { var pieces = []; @@ -820,12 +820,12 @@ exports.textLinesMutator = function (lines) { }; /** - * Function allowing iterating over two Op strings. + * Function allowing iterating over two Op strings. * @params in1 {string} first Op string * @params idx1 {int} integer where 1st iterator should start * @params in2 {string} second Op string * @params idx2 {int} integer where 2nd iterator should start - * @params func {function} which decides how 1st or 2nd iterator + * @params func {function} which decides how 1st or 2nd iterator * advances. When opX.opcode = 0, iterator X advances to * next element * func has signature f(op1, op2, opOut) @@ -882,7 +882,7 @@ exports.unpack = function (cs) { }; /** - * Packs Changeset object into a string + * Packs Changeset object into a string * @params oldLen {int} Old length of the Changeset * @params newLen {int] New length of the Changeset * @params opsStr {string} String encoding of the changes to be made @@ -958,8 +958,8 @@ exports.mutateTextLines = function (cs, lines) { * Composes two attribute strings (see below) into one. * @param att1 {string} first attribute string * @param att2 {string} second attribue string - * @param resultIsMutaton {boolean} - * @param pool {AttribPool} attribute pool + * @param resultIsMutaton {boolean} + * @param pool {AttribPool} attribute pool */ exports.composeAttributes = function (att1, att2, resultIsMutation, pool) { // att1 and att2 are strings like "*3*f*1c", asMutation is a boolean. @@ -1019,8 +1019,8 @@ exports.composeAttributes = function (att1, att2, resultIsMutation, pool) { }; /** - * Function used as parameter for applyZip to apply a Changeset to an - * attribute + * Function used as parameter for applyZip to apply a Changeset to an + * attribute */ exports._slicerZipperFunc = function (attOp, csOp, opOut, pool) { // attOp is the op from the sequence that is being operated on, either an @@ -1337,7 +1337,7 @@ exports.compose = function (cs1, cs2, pool) { * returns a function that tests if a string of attributes * (e.g. *3*4) contains a given attribute key,value that * is already present in the pool. - * @param attribPair array [key,value] of the attribute + * @param attribPair array [key,value] of the attribute * @param pool {AttribPool} Attribute pool */ exports.attributeTester = function (attribPair, pool) { @@ -1369,9 +1369,9 @@ exports.identity = function (N) { /** - * creates a Changeset which works on oldFullText and removes text - * from spliceStart to spliceStart+numRemoved and inserts newText - * instead. Also gives possibility to add attributes optNewTextAPairs + * creates a Changeset which works on oldFullText and removes text + * from spliceStart to spliceStart+numRemoved and inserts newText + * instead. Also gives possibility to add attributes optNewTextAPairs * for the new text. * @param oldFullText {string} old text * @param spliecStart {int} where splicing starts @@ -1407,7 +1407,7 @@ exports.makeSplice = function (oldFullText, spliceStart, numRemoved, newText, op * @param cs Changeset */ exports.toSplices = function (cs) { - // + // var unpacked = exports.unpack(cs); var splices = []; @@ -1438,7 +1438,7 @@ exports.toSplices = function (cs) { }; /** - * + * */ exports.characterRangeFollow = function (cs, startChar, endChar, insertionsAfter) { var newStartChar = startChar; @@ -1524,7 +1524,7 @@ exports.makeAttribution = function (text) { * and runs function func on them * @param cs {Changeset} changeset * @param func {function} function to be called - */ + */ exports.eachAttribNumber = function (cs, func) { var dollarPos = cs.indexOf('$'); if (dollarPos < 0) { @@ -1543,16 +1543,16 @@ exports.eachAttribNumber = function (cs, func) { * callable on a exports, attribution string, or attribs property of an op, * though it may easily create adjacent ops that can be merged. * @param cs {Changeset} changeset to be filtered - * @param filter {function} fnc which returns true if an + * @param filter {function} fnc which returns true if an * attribute X (int) should be kept in the Changeset - */ + */ exports.filterAttribNumbers = function (cs, filter) { return exports.mapAttribNumbers(cs, filter); }; /** - * does exactly the same as exports.filterAttribNumbers - */ + * does exactly the same as exports.filterAttribNumbers + */ exports.mapAttribNumbers = function (cs, func) { var dollarPos = cs.indexOf('$'); if (dollarPos < 0) { @@ -1577,7 +1577,7 @@ exports.mapAttribNumbers = function (cs, func) { /** * Create a Changeset going from Identity to a certain state * @params text {string} text of the final change - * @attribs attribs {string} optional, operations which insert + * @attribs attribs {string} optional, operations which insert * the text and also puts the right attributes */ exports.makeAText = function (text, attribs) { @@ -1588,9 +1588,9 @@ exports.makeAText = function (text, attribs) { }; /** - * Apply a Changeset to a AText + * Apply a Changeset to a AText * @param cs {Changeset} Changeset to be applied - * @param atext {AText} + * @param atext {AText} * @param pool {AttribPool} Attribute Pool to add to */ exports.applyToAText = function (cs, atext, pool) { @@ -1602,7 +1602,7 @@ exports.applyToAText = function (cs, atext, pool) { /** * Clones a AText structure - * @param atext {AText} + * @param atext {AText} */ exports.cloneAText = function (atext) { return { @@ -1613,7 +1613,7 @@ exports.cloneAText = function (atext) { /** * Copies a AText structure from atext1 to atext2 - * @param atext {AText} + * @param atext {AText} */ exports.copyAText = function (atext1, atext2) { atext2.text = atext1.text; @@ -1622,7 +1622,7 @@ exports.copyAText = function (atext1, atext2) { /** * Append the set of operations from atext to an assembler - * @param atext {AText} + * @param atext {AText} * @param assem Assembler like smartOpAssembler */ exports.appendATextToAssembler = function (atext, assem) { @@ -1660,7 +1660,7 @@ exports.appendATextToAssembler = function (atext, assem) { /** * Creates a clone of a Changeset and it's APool - * @param cs {Changeset} + * @param cs {Changeset} * @param pool {AtributePool} */ exports.prepareForWire = function (cs, pool) { @@ -1681,8 +1681,8 @@ exports.isIdentity = function (cs) { }; /** - * returns all the values of attributes with a certain key - * in an Op attribs string + * returns all the values of attributes with a certain key + * in an Op attribs string * @param attribs {string} Attribute string of a Op * @param key {string} string to be seached for * @param pool {AttribPool} attribute pool @@ -1692,8 +1692,8 @@ exports.opAttributeValue = function (op, key, pool) { }; /** - * returns all the values of attributes with a certain key - * in an attribs string + * returns all the values of attributes with a certain key + * in an attribs string * @param attribs {string} Attribute string * @param key {string} string to be seached for * @param pool {AttribPool} attribute pool @@ -1711,7 +1711,7 @@ exports.attribsAttributeValue = function (attribs, key, pool) { }; /** - * Creates a Changeset builder for a string with initial + * Creates a Changeset builder for a string with initial * length oldLen. Allows to add/remove parts of it * @param oldLen {int} Old length */ diff --git a/src/static/js/ace.js b/src/static/js/ace.js index 83ad9447b..58c638470 100644 --- a/src/static/js/ace.js +++ b/src/static/js/ace.js @@ -1,5 +1,5 @@ /** - * This code is mostly from the old Etherpad. Please help us to comment this code. + * This code is mostly from the old Etherpad. Please help us to comment this code. * This helps other people to understand this code better and helps them to improve it. * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED */ @@ -86,7 +86,7 @@ function Ace2Editor() }); actionsPendingInit = []; } - + ace2.registry[info.id] = info; // The following functions (prefixed by 'ace_') are exposed by editor, but @@ -97,7 +97,7 @@ function Ace2Editor() 'applyChangesToBase', 'applyPreparedChangesetToBase', 'setUserChangeNotificationCallback', 'setAuthorInfo', 'setAuthorSelectionRange', 'callWithAce', 'execCommand', 'replaceRange']; - + _.each(aceFunctionsPendingInit, function(fnName,i){ var prefix = 'ace_'; var name = prefix + fnName; @@ -105,18 +105,18 @@ function Ace2Editor() info[prefix + fnName].apply(this, arguments); }); }); - + editor.exportText = function() { if (!loaded) return "(awaiting init)\n"; return info.ace_exportText(); }; - + editor.getFrame = function() { return info.frame || null; }; - + editor.getDebugProperty = function(prop) { return info.ace_getDebugProperty(prop); @@ -221,16 +221,16 @@ function Ace2Editor() // calls to these functions ($$INCLUDE_...) are replaced when this file is processed // and compressed, putting the compressed code from the named file directly into the // source here. - // these lines must conform to a specific format because they are passed by the build script: + // these lines must conform to a specific format because they are passed by the build script: var includedCSS = []; var $$INCLUDE_CSS = function(filename) {includedCSS.push(filename)}; $$INCLUDE_CSS("../static/css/iframe_editor.css"); $$INCLUDE_CSS("../static/css/pad.css"); $$INCLUDE_CSS("../static/custom/pad.css"); - + var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){ return '../static/plugins/' + path }); includedCSS = includedCSS.concat(additionalCSS); - + pushStyleTagsFor(iframeHTML, includedCSS); if (!Ace2Editor.EMBEDED && Ace2Editor.EMBEDED[KERNEL_SOURCE]) { @@ -304,11 +304,11 @@ window.onload = function () {\n\ $$INCLUDE_CSS("../static/css/iframe_editor.css"); $$INCLUDE_CSS("../static/css/pad.css"); $$INCLUDE_CSS("../static/custom/pad.css"); - - + + var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){ return '../static/plugins/' + path }); includedCSS = includedCSS.concat(additionalCSS); - + pushStyleTagsFor(outerHTML, includedCSS); // bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly diff --git a/src/static/js/ace2_common.js b/src/static/js/ace2_common.js index 8a7d16ee3..68be1a60e 100644 --- a/src/static/js/ace2_common.js +++ b/src/static/js/ace2_common.js @@ -1,5 +1,5 @@ /** - * This code is mostly from the old Etherpad. Please help us to comment this code. + * This code is mostly from the old Etherpad. Please help us to comment this code. * This helps other people to understand this code better and helps them to improve it. * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED */ diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 2e56b950f..0d4b1684d 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -1,5 +1,5 @@ /** - * This code is mostly from the old Etherpad. Please help us to comment this code. + * This code is mostly from the old Etherpad. Please help us to comment this code. * This helps other people to understand this code better and helps them to improve it. * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED */ @@ -36,10 +36,10 @@ var isNodeText = Ace2Common.isNodeText, htmlPrettyEscape = Ace2Common.htmlPrettyEscape, noop = Ace2Common.noop; var hooks = require('./pluginfw/hooks'); - + function Ace2Inner(){ - + var makeChangesetTracker = require('./changesettracker').makeChangesetTracker; var colorutils = require('./colorutils').colorutils; var makeContentCollector = require('./contentcollector').makeContentCollector; @@ -53,9 +53,9 @@ function Ace2Inner(){ var undoModule = require('./undomodule').undoModule; var makeVirtualLineView = require('./virtual_lines').makeVirtualLineView; var AttributeManager = require('./AttributeManager'); - + var DEBUG = false; //$$ build script replaces the string "var DEBUG=true;//$$" with "var DEBUG=false;" - // changed to false + // changed to false var isSetUp = false; var THE_TAB = ' '; //4 @@ -83,9 +83,9 @@ function Ace2Inner(){ initLineNumbers(); var outsideKeyDown = noop; - + var outsideKeyPress = function(){return true;}; - + var outsideNotifyDirty = noop; // selFocusAtStart -- determines whether the selection extends "backwards", so that the focus @@ -101,7 +101,7 @@ function Ace2Inner(){ alines: [], apool: new AttribPool() }; - + // lines, alltext, alines, and DOM are set up in setup() if (undoModule.enabled) { @@ -113,7 +113,7 @@ function Ace2Inner(){ var doesWrap = true; var hasLineNumbers = true; var isStyled = true; - + // space around the innermost iframe element var iframePadLeft = MIN_LINEDIV_WIDTH + LINE_NUMBER_PADDING_RIGHT + EDIT_BODY_PADDING_LEFT; var iframePadTop = EDIT_BODY_PADDING_TOP; @@ -122,7 +122,7 @@ function Ace2Inner(){ var console = (DEBUG && window.console); var documentAttributeManager; - + if (!window.console) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; @@ -158,7 +158,7 @@ function Ace2Inner(){ var textFace = 'monospace'; var textSize = 12; - + function textLineHeight() { @@ -231,15 +231,15 @@ function Ace2Inner(){ { bgcolor = fadeColor(bgcolor, info.fade); } - + var authorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector( getAuthorClassName(author))); var anchorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector( getAuthorClassName(author))+' > a') - + // author color authorStyle.backgroundColor = bgcolor; - + // text contrast if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5) { @@ -247,7 +247,7 @@ function Ace2Inner(){ }else{ authorStyle.color = null; } - + // anchor text contrast if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.55) { @@ -540,8 +540,8 @@ function Ace2Inner(){ { return rep.lines.atOffset(charOffset).key; } - - + + function dispose() { disposed = true; @@ -896,14 +896,14 @@ function Ace2Inner(){ editorInfo.ace_doReturnKey = doReturnKey; editorInfo.ace_isBlockElement = isBlockElement; editorInfo.ace_getLineListType = getLineListType; - + editorInfo.ace_callWithAce = function(fn, callStack, normalize) { var wrapper = function() { return fn(editorInfo); }; - + if (normalize !== undefined) { var wrapper1 = wrapper; @@ -929,14 +929,14 @@ function Ace2Inner(){ // @param value the value to set to editorInfo.ace_setProperty = function(key, value) { - - // Convinience function returning a setter for a class on an element + + // Convinience function returning a setter for a class on an element var setClassPresenceNamed = function(element, cls){ return function(value){ setClassPresence(element, cls, !! value) } }; - + // These properties are exposed var setters = { wraps: setWraps, @@ -951,7 +951,7 @@ function Ace2Inner(){ }, grayedout: setClassPresenceNamed(outerWin.document.body, "grayedout"), dmesg: function(){ dmesg = window.dmesg = value; }, - userauthor: function(value){ + userauthor: function(value){ thisAuthor = String(value); documentAttributeManager.author = thisAuthor; }, @@ -960,10 +960,10 @@ function Ace2Inner(){ textsize: setTextSize, rtlistrue: setClassPresenceNamed(root, "rtl") }; - + var setter = setters[key.toLowerCase()]; - - // check if setter is present + + // check if setter is present if(setter !== undefined){ setter(value) } @@ -1067,7 +1067,7 @@ function Ace2Inner(){ return false; } }; - + isTimeUp.elapsed = function() { return now() - startTime; @@ -1448,7 +1448,7 @@ function Ace2Inner(){ var p = PROFILER("getSelection", false); var selection = getSelection(); p.end(); - + function topLevel(n) { if ((!n) || n == root) return null; @@ -1458,7 +1458,7 @@ function Ace2Inner(){ } return n; } - + if (selection) { var node1 = topLevel(selection.startPoint.node); @@ -1704,7 +1704,7 @@ function Ace2Inner(){ root:root, point:selection.startPoint, documentAttributeManager: documentAttributeManager - }); + }); selStart = (selStartFromHook==null||selStartFromHook.length==0)?getLineAndCharForPoint(selection.startPoint):selStartFromHook; } if (selection && !selEnd) @@ -1717,7 +1717,7 @@ function Ace2Inner(){ point:selection.endPoint, documentAttributeManager: documentAttributeManager }); - selEnd = (selEndFromHook==null||selEndFromHook.length==0)?getLineAndCharForPoint(selection.endPoint):selEndFromHook; + selEnd = (selEndFromHook==null||selEndFromHook.length==0)?getLineAndCharForPoint(selection.endPoint):selEndFromHook; } // selection from content collection can, in various ways, extend past final @@ -1738,7 +1738,7 @@ function Ace2Inner(){ // update rep if we have a new selection // NOTE: IE loses the selection when you click stuff in e.g. the // editbar, so removing the selection when it's lost is not a good - // idea. + // idea. if (selection) repSelectionChange(selStart, selEnd, selection && selection.focusAtStart); // update browser selection p.mark("browsel"); @@ -1873,19 +1873,19 @@ function Ace2Inner(){ return rep.selStart[0]; } editorInfo.ace_caretLine = caretLine; - + function caretColumn() { return rep.selStart[1]; } editorInfo.ace_caretColumn = caretColumn; - + function caretDocChar() { return rep.lines.offsetOfIndex(caretLine()) + caretColumn(); } editorInfo.ace_caretDocChar = caretDocChar; - + function handleReturnIndentation() { // on return, indent to level of previous line @@ -2314,8 +2314,8 @@ function Ace2Inner(){ documentAttributeManager.setAttributesOnRange(lineAndColumnFromChar(start), lineAndColumnFromChar(end), attribs); } editorInfo.ace_performDocumentApplyAttributesToCharRange = performDocumentApplyAttributesToCharRange; - - + + function setAttributeOnSelection(attributeName, attributeValue) { if (!(rep.selStart && rep.selEnd)) return; @@ -2879,7 +2879,7 @@ function Ace2Inner(){ { if (lineClass !== null) lineElem.className = lineClass; }; - + result.prepareForAdd = writeClass; result.finishUpdate = writeClass; result.getInnerHTML = function() @@ -3241,7 +3241,7 @@ function Ace2Inner(){ { return (n.tagName || '').toLowerCase() == "a" && n.href; } - + // only want to catch left-click if ((!evt.ctrlKey) && (evt.button != 2) && (evt.button != 3)) { @@ -3277,7 +3277,7 @@ function Ace2Inner(){ { return; } - + var lineNum = rep.selStart[0]; var listType = getLineListType(lineNum); @@ -3287,7 +3287,7 @@ function Ace2Inner(){ listType = /([a-z]+)([12345678])/.exec(listType); var type = listType[1]; var level = Number(listType[2]); - + //detect empty list item; exclude indentation if(text === '*' && type !== "indent") { @@ -3401,9 +3401,9 @@ function Ace2Inner(){ var thisLineListType = getLineListType(theLine); var prevLineEntry = (theLine > 0 && rep.lines.atIndex(theLine - 1)); var prevLineBlank = (prevLineEntry && prevLineEntry.text.length == prevLineEntry.lineMarker); - + var thisLineHasMarker = documentAttributeManager.lineHasMarker(theLine); - + if (thisLineListType) { // this line is a list @@ -3478,7 +3478,7 @@ function Ace2Inner(){ return !!REGEX_WORDCHAR.exec(c); } editorInfo.ace_isWordChar = isWordChar; - + function isSpaceChar(c) { return !!REGEX_SPACE.exec(c); @@ -4011,7 +4011,7 @@ function Ace2Inner(){ maxIndex: tn.nodeValue.length }; }; - + var selection = {}; if (origSelectionRange.compareEndPoints("StartToEnd", origSelectionRange) === 0) { @@ -4875,9 +4875,9 @@ function Ace2Inner(){ } } } - + var listAttributeName = 'list'; - + function getLineListType(lineNum) { return documentAttributeManager.getAttributeOnLine(lineNum, listAttributeName) @@ -4890,7 +4890,7 @@ function Ace2Inner(){ }else{ documentAttributeManager.setAttributeOnLine(lineNum, listAttributeName, listType); } - + //if the list has been removed, it is necessary to renumber //starting from the *next* line because the list may have been //separated. If it returns null, it means that the list was not cut, try @@ -4900,7 +4900,7 @@ function Ace2Inner(){ renumberList(lineNum); } } - + function renumberList(lineNum){ //1-check we are in a list var type = getLineListType(lineNum); @@ -4913,7 +4913,7 @@ function Ace2Inner(){ { return null; } - + //2-find the first line of the list while(lineNum-1 >= 0 && (type=getLineListType(lineNum-1))) { @@ -4922,7 +4922,7 @@ function Ace2Inner(){ break; lineNum--; } - + //3-renumber every list item of the same level from the beginning, level 1 //IMPORTANT: never skip a level because there imbrication may be arbitrary var builder = Changeset.builder(rep.lines.totalWidth()); @@ -4949,7 +4949,7 @@ function Ace2Inner(){ ChangesetUtils.buildKeepRange(rep, builder, loc, (loc = [line, 1]), [ ['start', position] ], rep.apool); - + position++; line++; } @@ -4964,19 +4964,19 @@ function Ace2Inner(){ } return line; } - + applyNumberList(lineNum, 1); var cs = builder.toString(); if (!Changeset.isIdentity(cs)) { performDocumentApplyChangeset(cs); } - + //4-apply the modifications - - + + } - + function doInsertList(type) { @@ -5014,12 +5014,12 @@ function Ace2Inner(){ var t = getLineListType(n); mods.push([n, allLinesAreList ? 'indent' + level : (t ? type + level : type + '1')]); } - + _.each(mods, function(mod){ setLineListType(mod[0], mod[1]); }); } - + function doInsertUnorderedList(){ doInsertList('bullet'); } @@ -5353,7 +5353,7 @@ function Ace2Inner(){ } }; })()); - + var lineNumbersShown; var sideDivInner; @@ -5369,11 +5369,11 @@ function Ace2Inner(){ var newNumLines = rep.lines.length(); if (newNumLines < 1) newNumLines = 1; //update height of all current line numbers - + var a = sideDivInner.firstChild; var b = doc.body.firstChild; var n = 0; - + if (currentCallStack && currentCallStack.domClean) { @@ -5403,8 +5403,8 @@ function Ace2Inner(){ b = b.nextSibling; n++; } - } - + } + if (newNumLines != lineNumbersShown) { var container = sideDivInner; @@ -5414,21 +5414,21 @@ function Ace2Inner(){ { lineNumbersShown++; var n = lineNumbersShown; - var div = odoc.createElement("DIV"); + var div = odoc.createElement("DIV"); //calculate height for new line number var h = (b.clientHeight || b.offsetHeight); - + if (b.nextSibling) h = b.nextSibling.offsetTop - b.offsetTop; - + if(h) // apply style to div div.style.height = h +"px"; - + div.appendChild(odoc.createTextNode(String(n))); fragment.appendChild(div); b = b.nextSibling; } - + container.appendChild(fragment); while (lineNumbersShown > newNumLines) { @@ -5437,8 +5437,8 @@ function Ace2Inner(){ } } } - - + + // Init documentAttributeManager documentAttributeManager = new AttributeManager(rep, performDocumentApplyChangeset); editorInfo.ace_performDocumentApplyAttributesToRange = function () { @@ -5484,13 +5484,13 @@ function Ace2Inner(){ bindTheEventHandlers(); }); - + hooks.callAll('aceInitialized', { editorInfo: editorInfo, rep: rep, documentAttributeManager: documentAttributeManager }); - + scheduler.setTimeout(function() { parent.readyFunc(); // defined in code that sets up the inner iframe diff --git a/src/static/js/admin/jquery.autosize.js b/src/static/js/admin/jquery.autosize.js index 8c8ab1a8f..a8f02d68d 100644 --- a/src/static/js/admin/jquery.autosize.js +++ b/src/static/js/admin/jquery.autosize.js @@ -1,180 +1,180 @@ -// Autosize 1.13 - jQuery plugin for textareas -// (c) 2012 Jack Moore - jacklmoore.com -// license: www.opensource.org/licenses/mit-license.php - -(function ($) { - var - defaults = { - className: 'autosizejs', - append: "", - callback: false - }, - hidden = 'hidden', - borderBox = 'border-box', - lineHeight = 'lineHeight', - copy = ' - - -
- - - + + + Settings manager + + + + + + + + + + +
+ + <% if (errors.length) { %> +
+ <% errors.forEach(function (item) { %> +
<%= item.toString() %>
+ <% }) %> +
+ <% } %> + + +

Etherpad Lite Settings

+ Example production settings template + Example development settings template + + + +
+
+ + diff --git a/src/templates/index.html b/src/templates/index.html index 23c3c7755..3ee7a29db 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -29,7 +29,7 @@ */ - + @@ -111,7 +111,7 @@ input[type="text"] { border-radius: 3px; box-sizing: border-box; - -moz-box-sizing: border-box; + -moz-box-sizing: border-box; padding: 0 45px 0 10px; *padding: 0; /* IE7 hack */ width: 100%; @@ -137,53 +137,53 @@ margin-top: 0; } #inner { - width: 95%; + width: 95%; } #label { text-align: center; } } - +
New Pad
-
or create/open a Pad with the name
-
- +
or create/open a Pad with the name
+ +
- diff --git a/src/templates/pad.html b/src/templates/pad.html index 6136d8954..d3ca4b638 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -247,7 +247,7 @@ <% e.end_block(); %> - +