From 39bc588ae74bad3f1ccd22c3726e0ecf1246fd17 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Thu, 11 Aug 2011 14:46:25 +0100 Subject: [PATCH 01/16] Improved the readme a bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c752fe99..64e978f8 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Visit to test it live.
You can find the same ins **As any user (we recommend creating a separate user called etherpad-lite):**
    -
  1. Clone the git repository git clone 'git://github.com/Pita/etherpad-lite.git'
     
  2. +
  3. Move to a folder where you want to install Etherpad Lite. Clone the git repository git clone 'git://github.com/Pita/etherpad-lite.git'
     
  4. Install the dependencies with bin/installDeps.sh (if you have problems at this step, look at the section Troubleshooting below)
     
  5. Start it with bin/run.sh
     
  6. Open your web browser and visit http://localhost:9001. You like it? Look at the 'Next Steps' section below
  7. From 4b892ae4ff9f79ae753031cc69fc5293842b9890 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Thu, 11 Aug 2011 15:09:05 +0100 Subject: [PATCH 02/16] check node and npm version on install --- bin/installDeps.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/installDeps.sh b/bin/installDeps.sh index ece5b7aa..cb367606 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -20,12 +20,26 @@ hash node > /dev/null 2>&1 || { exit 1 } +#check node version +NODE_VERSION=$(node --version) +if [ ! $(echo $NODE_VERSION | cut -d "." -f 1-2) = "v0.4" ]; then + echo "You're running a wrong version of node, you're using $NODE_VERSION, we need v0.4.x" >&2 + exit 1 +fi + #Is npm installed? hash npm > /dev/null 2>&1 || { echo "Please install npm ( http://npmjs.org )" >&2 exit 1 } +#check npm version +NPM_VERSION=$(npm --version) +if [ ! $(echo $NPM_VERSION | cut -d "." -f 1-2) = "1.0" ]; then + echo "You're running a wrong version of npm, you're using $NPM_VERSION, we need 1.0.x" >&2 + exit 1 +fi + #Does a settings.json exist? if no copy the template if [ ! -f "settings.json" ]; then echo "Copy the settings template to settings.json..." From 38801fa3b295b1f38948c5c532dfd331472e0b79 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Thu, 11 Aug 2011 15:16:26 +0100 Subject: [PATCH 03/16] added a ugly favicon, to motivate people creating a better one ;) --- static/favicon.ico | Bin 0 -> 1150 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/favicon.ico diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..2529c923f30e7ad806630c1ec40c4ca9db439d64 GIT binary patch literal 1150 zcmc)J&q@MO6vy$S1hx=!5ki9KvS?#%+GrSr&;ukPRNI#A16OVW-ABDZi(Vj6(kE!u zDk!3;Aczo+Bx?E|?p(O&6ye4rAJ6^cZ^ju%kr1zVTzJpO-jql}MCQQ~D`uVcTWzuN zjV9Wt;0ztux?*tZPr`H$m$-oDyKw72`Me((H?QA8jhio#P5+T^v$um=4A8?JmZ0Z- zgzo9>&cUrkCRrp=7!qT?=BzQCXsvK|y&mg;@q$064V4%5#AWXPC!Z=~7aLf|14hfu z>e%Gp>C0F}1VwzHfn%g#Dmbslxxo|Wp!rv9LyvI}Q^9%tZD*0e3^f0YB&v9Uso=c5 yciQ#;qu0^L7p}1hQ=@siGm(CHByxTN+oyRDxC*QOCelK4U!=|x-9nAA-Twi9>5l{e literal 0 HcmV?d00001 From 53cdd893affea8947a325392b107355c64095b74 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Thu, 11 Aug 2011 22:00:52 +0100 Subject: [PATCH 04/16] added a buildForWindows script --- .gitignore | 5 ++- bin/buildForWindows.sh | 73 ++++++++++++++++++++++++++++++++++ package.json | 2 +- settings.json.template_windows | 38 ++++++++++++++++++ start.bat | 2 + 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100755 bin/buildForWindows.sh create mode 100644 settings.json.template_windows create mode 100644 start.bat diff --git a/.gitignore b/.gitignore index df6d75be..13f01feb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ node_modules settings.json -static/js/jquery.min.js \ No newline at end of file +static/js/jquery.min.js +bin/abiword.exe +bin/node.exe +etherpad-lite-win.zip diff --git a/bin/buildForWindows.sh b/bin/buildForWindows.sh new file mode 100755 index 00000000..f3442488 --- /dev/null +++ b/bin/buildForWindows.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +NODE_VERSION="0.5.3" + +#Move to the folder where ep-lite is installed +cd `dirname $0` + +#Was this script started in the bin folder? if yes move out +if [ -d "../bin" ]; then + cd "../" +fi + +#Is wget installed? +hash wget > /dev/null 2>&1 || { + echo "Please install wget" >&2 + exit 1 +} + +#Is zip installed? +hash zip > /dev/null 2>&1 || { + echo "Please install zip" >&2 + exit 1 +} + +#Is zip installed? +hash unzip > /dev/null 2>&1 || { + echo "Please install unzip" >&2 + exit 1 +} + +START_FOLDER=$(pwd); + +echo "create a clean enviroment in /tmp/etherpad-lite-win..." +rm -rf /tmp/etherpad-lite-win +cp -ar . /tmp/etherpad-lite-win +cd /tmp/etherpad-lite-win +rm -rf node_modules +rm -f etherpad-lite-win.zip + +echo "do a normal unix install first..." +bin/installDeps.sh || exit 1 + +echo "copy the windows settings template..." +cp settings.json.template_windows settings.json + +echo "resolve symbolic links..." +cp -rL node_modules node_modules_resolved +rm -rf node_modules +mv node_modules_resolved node_modules + +echo "remove sqlite, cause we can't use it with windows..." +rm -rf node_modules/ueberDB/node_modules/sqlite3 + +echo "replace log4js with a patched log4js, this log4js runs on windows too..." +rm -rf node_modules/log4js/* +wget https://github.com/Pita/log4js-node/zipball/master -O log4js.zip +unzip log4js.zip +mv Pita-log4js-node*/* node_modules/log4js +rm -rf log4js.zip Pita-log4js-node* + +echo "download windows node..." +cd bin +wget "http://nodejs.org/dist/v$NODE_VERSION/node.exe" -O node.exe + +echo "create the zip..." +cd /tmp +zip -9 -r etherpad-lite-win.zip etherpad-lite-win +mv etherpad-lite-win.zip $START_FOLDER + +echo "clean up..." +rm -rf /tmp/etherpad-lite-win + +echo "finished. You can find the zip in the etherpad lite root folder, its called etherpad-lite-win.zip" diff --git a/package.json b/package.json index 4ae1a087..6005e5fb 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "dependencies" : { "socket.io" : "0.7.8", - "ueberDB" : "0.0.14", + "ueberDB" : "0.0.15", "async" : "0.1.9", "joose" : "3.18.0", "express" : "2.4.4", diff --git a/settings.json.template_windows b/settings.json.template_windows new file mode 100644 index 00000000..235ec71a --- /dev/null +++ b/settings.json.template_windows @@ -0,0 +1,38 @@ +/* + This file must be valid JSON. But comments are allowed + + Please edit settings.json, not settings.json.template +*/ +{ + //Ip and port which etherpad should bind at + "ip": "0.0.0.0", + "port" : 9001, + + //The Type of the database. You can choose between sqlite and mysql + "dbType" : "dirty", + //the database specific settings + "dbSettings" : { + "filename" : "../var/dirty.db" + }, + + /* An Example of MySQL Configuration + "dbType" : "mysql", + "dbSettings" : { + "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\nEtherpad Lite on Github: http:\/\/j.mp/ep-lite\n", + + /* 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" : false, + + /* 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" : null +} diff --git a/start.bat b/start.bat new file mode 100644 index 00000000..cf6a60f1 --- /dev/null +++ b/start.bat @@ -0,0 +1,2 @@ +cd node +..\bin\node server.js From f8081352011ad374b11af27d5cf5700494830969 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Fri, 12 Aug 2011 14:57:24 +0100 Subject: [PATCH 05/16] added Windows installation instructions --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 64e978f8..b13f6304 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,16 @@ Visit to test it live.
    You can find the same ins # Installation + +# Windows + +1) Download +2) Extract the file +3) Open the extracted folder and double click `start.bat` +4) Open your web browser and browse to + +# Linux + **As root:**
      From 8deb853be64aeaa97878152e03db8a2c62c81ff5 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Fri, 12 Aug 2011 15:03:01 +0100 Subject: [PATCH 06/16] updated node for windows to 0.5.4 --- bin/buildForWindows.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/buildForWindows.sh b/bin/buildForWindows.sh index f3442488..faad735e 100755 --- a/bin/buildForWindows.sh +++ b/bin/buildForWindows.sh @@ -1,6 +1,6 @@ #!/bin/sh -NODE_VERSION="0.5.3" +NODE_VERSION="0.5.4" #Move to the folder where ep-lite is installed cd `dirname $0` From a5b84f1b6e5819a1d3efdb31954ea247f30498ec Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Fri, 12 Aug 2011 15:08:27 +0100 Subject: [PATCH 07/16] fixed readme markdown --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b13f6304..232c29c7 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ Visit to test it live.
      You can find the same ins # Windows -1) Download -2) Extract the file -3) Open the extracted folder and double click `start.bat` -4) Open your web browser and browse to +1. Download +2. Extract the file +3. Open the extracted folder and double click `start.bat` +4. Open your web browser and browse to # Linux From fb593c1d5c16957109b5f3e521857fad000776bb Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 12 Aug 2011 16:00:09 +0100 Subject: [PATCH 08/16] Began adding support for passing parameters via the URL and removed a location redirect that was no longer needed --- static/js/pad2.js | 48 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index f442607d..1dd49049 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -20,18 +20,9 @@ var socket; $(document).ready(function() { - //test if the url is proper, means without any ? or # that doesn't belong to a url - //if it isn't proper, clean the url a do a redirect - var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1); - var expectedURL = document.location.href.substring(0,document.location.href.lastIndexOf("/") ) + "/" + padId; - if(expectedURL != document.location.href) - { - document.location = expectedURL; - } - //start the costum js if(typeof costumStart == "function") costumStart(); - + getParams(); handshake(); }); @@ -78,6 +69,42 @@ function randomString() return "t." + randomstring; } +function getParams() +{ + var showControls = getUrlVars()["showControls"]; + var showChat = getUrlVars()["showChat"]; + var userName = getUrlVars()["userName"]; + if(showControls) + { + if(showControls == "false") + { + $('#editbar').hide(); + $('#editorcontainer').css({"top":"0px"}); + } + } + + if(showChat) + { + if(showChat == "false"){$('#chaticon').hide();} + +//cake + } + +} + +function getUrlVars() +{ + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++) + { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + return vars; +} + function handshake() { var loc = document.location; @@ -95,7 +122,6 @@ function handshake() socket.once('connect', function() { var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1); - document.title = document.title + " | " + padId; var token = readCookie("token"); From 5252bee124e6a50c45c1bd7c969d21231e669c47 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 13:02:27 +0100 Subject: [PATCH 09/16] fixed abiword on windows --- node/utils/Abiword.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/utils/Abiword.js b/node/utils/Abiword.js index 3a99f56b..87bbb58d 100644 --- a/node/utils/Abiword.js +++ b/node/utils/Abiword.js @@ -24,12 +24,14 @@ var async = require("async"); var settings = require("./Settings"); var os = require('os'); +var doConvertTask; + //on windows we have to spawn a process for each convertion, cause the plugin abicommand doesn't exist on this platform if(os.type().indexOf("Windows") > -1) { var stdoutBuffer = ""; - function doConvertTask(task, callback) + doConvertTask = function(task, callback) { //span an abiword process to perform the conversion var abiword = spawn(settings.abiword, ["--to=" + task.destFile, task.srcFile]); @@ -123,7 +125,7 @@ else } } - function doConvertTask(task, callback) + doConvertTask = function(task, callback) { abiword.stdin.write("convert " + task.srcFile + " " + task.destFile + " " + task.type + "\n"); From 7ff8814fd7c7640c1b514a001782e529a1500e88 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 13:03:07 +0100 Subject: [PATCH 10/16] added the dirty db file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 13f01feb..325e11ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ static/js/jquery.min.js bin/abiword.exe bin/node.exe etherpad-lite-win.zip +var/dirty.db \ No newline at end of file From 3a77d96c98d72b1755573beee3976acc48a95f07 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 13:11:48 +0100 Subject: [PATCH 11/16] use the temp enviroment variable for windows --- node/handler/ExportHandler.js | 2 +- node/handler/ImportHandler.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/handler/ExportHandler.js b/node/handler/ExportHandler.js index 674950f4..fd6d26e4 100644 --- a/node/handler/ExportHandler.js +++ b/node/handler/ExportHandler.js @@ -34,7 +34,7 @@ var tempDirectory = "/tmp"; //tempDirectory changes if the operating system is windows if(os.type().indexOf("Windows") > -1) { - tempDirectory = "c:\\Temp"; + tempDirectory = process.env.TEMP; } /** diff --git a/node/handler/ImportHandler.js b/node/handler/ImportHandler.js index c02c9f50..935e95fd 100644 --- a/node/handler/ImportHandler.js +++ b/node/handler/ImportHandler.js @@ -35,7 +35,7 @@ var tempDirectory = "/tmp/"; //tempDirectory changes if the operating system is windows if(os.type().indexOf("Windows") > -1) { - tempDirectory = "c:\\Temp\\"; + tempDirectory = process.env.TEMP; } /** From 8db0c12bbe7cbe0fada49c31bd200cf8daafd524 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Aug 2011 18:37:44 +0100 Subject: [PATCH 12/16] Add support for removing line numbers using the jQuery API and stopped it publishing that change back if the param is set --- static/js/pad2.js | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index 1dd49049..1364b5e7 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -17,6 +17,7 @@ /* global $, window */ var socket; +var LineNumbersDisabled = false; $(document).ready(function() { @@ -74,6 +75,7 @@ function getParams() var showControls = getUrlVars()["showControls"]; var showChat = getUrlVars()["showChat"]; var userName = getUrlVars()["userName"]; + var showLineNumbers = getUrlVars()["showLineNumbers"]; if(showControls) { if(showControls == "false") @@ -85,11 +87,20 @@ function getParams() if(showChat) { - if(showChat == "false"){$('#chaticon').hide();} - -//cake + if(showChat == "false") + { + $('#chaticon').hide(); + } } + if(showLineNumbers) + { + if(showLineNumbers == "false") + { + // pad.changeViewOption('showLineNumbers', false); + LineNumbersDisabled = true; + } + } } function getUrlVars() @@ -138,7 +149,6 @@ function handshake() "token": token, "protocolVersion": 2 }; - socket.json.send(msg); }); @@ -159,8 +169,12 @@ function handshake() clientVars.collab_client_vars.clientAgent = "Anonymous"; pad.init(); - initalized = true; + if (LineNumbersDisabled == true) + { + // cake + pad.changeViewOption('showLineNumbers', false); $ + } } //This handles every Message after the clientVars else @@ -374,12 +388,15 @@ var pad = { }; options.view[key] = value; pad.handleOptionsChange(options); - pad.collabClient.sendClientMessage( + if (key != "showLineNumbers") { - type: 'padoptions', - options: options, - changedBy: pad.myUserInfo.name || "unnamed" - }); + pad.collabClient.sendClientMessage( + { + type: 'padoptions', + options: options, + changedBy: pad.myUserInfo.name || "unnamed" + }); + } }, handleOptionsChange: function(opts) { From 7f288896601f5be5d623ebaf8faa1ee1d7780abc Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Aug 2011 18:38:00 +0100 Subject: [PATCH 13/16] Removed my cake commit that I used as a placemarker --- static/js/pad2.js | 1 - 1 file changed, 1 deletion(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index 1364b5e7..5705218d 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -172,7 +172,6 @@ function handshake() initalized = true; if (LineNumbersDisabled == true) { - // cake pad.changeViewOption('showLineNumbers', false); $ } } From bba9cd515b8a4fe601c20a3a09e33a3712253111 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Aug 2011 19:53:02 +0100 Subject: [PATCH 14/16] Added support for changing username from the URL ie ?userName=JohnMcLear -- doesnt urldecode etc. needs checking for vulnerabilities too --- static/js/pad2.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index 5705218d..1fe56b12 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -18,6 +18,7 @@ var socket; var LineNumbersDisabled = false; +var globalUserName = false; $(document).ready(function() { @@ -97,10 +98,15 @@ function getParams() { if(showLineNumbers == "false") { - // pad.changeViewOption('showLineNumbers', false); LineNumbersDisabled = true; } } + + if(userName) + { + // If the username is set as a parameter we should set a global value that we can call once we have initiated the pad. + globalUserName = userName; + } } function getUrlVars() @@ -170,10 +176,20 @@ function handshake() pad.init(); initalized = true; + + // If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers if (LineNumbersDisabled == true) { - pad.changeViewOption('showLineNumbers', false); $ + pad.changeViewOption('showLineNumbers', false); } + + // if the globalUserName value is set we need to tell the server and the client about the new authorname + if (globalUserName !== false) + { + pad.notifyChangeName(globalUserName); // Notifies the server + $('#myusernameedit').attr({"value":globalUserName}); // Updates the current users UI + } + } //This handles every Message after the clientVars else From 2b266ee82ad60dbfa7e962dba67656748e2f18d8 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 20:06:38 +0100 Subject: [PATCH 15/16] updated socket.io --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6005e5fb..735f9b72 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "name": "Robin Buse"} ], "dependencies" : { - "socket.io" : "0.7.8", + "socket.io" : "0.7.9", "ueberDB" : "0.0.15", "async" : "0.1.9", "joose" : "3.18.0", From 4730c3b46ee0dd9b99b1873c167055738ef7a45c Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 20:20:30 +0100 Subject: [PATCH 16/16] added a error message for invalid padIDs --- node/server.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/node/server.js b/node/server.js index 0d8cc303..a429cd31 100644 --- a/node/server.js +++ b/node/server.js @@ -162,7 +162,7 @@ async.waterfall([ //ensure the padname is valid and the url doesn't end with a / if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) { - next(); + res.send('Such a padname is forbidden', 404); return; } @@ -177,7 +177,7 @@ async.waterfall([ //ensure the padname is valid and the url doesn't end with a / if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) { - next(); + res.send('Such a padname is forbidden', 404); return; } @@ -189,6 +189,13 @@ async.waterfall([ //serve timeslider.html under /p/$padname/timeslider app.get('/p/:pad/export/:type', function(req, res, next) { + //ensure the padname is valid and the url doesn't end with a / + if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) + { + res.send('Such a padname is forbidden', 404); + return; + } + var types = ["pdf", "doc", "txt", "html", "odt"]; //send a 404 if we don't support this filetype if(types.indexOf(req.params.type) == -1) @@ -211,6 +218,13 @@ async.waterfall([ //handle import requests app.post('/p/:pad/import', function(req, res, next) { + //ensure the padname is valid and the url doesn't end with a / + if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) + { + res.send('Such a padname is forbidden', 404); + return; + } + //if abiword is disabled, skip handling this request if(settings.abiword == null) {