Merge branch 'master' of .git into api

This commit is contained in:
Peter 'Pita' Martischka 2011-08-09 11:08:27 +01:00
commit 1a824bd130
12 changed files with 196 additions and 107 deletions

View file

@ -7,7 +7,7 @@ documented codebase makes it easier for developers to improve the code. Etherpad
to be easy embeddable. Look at our [FAQ Page](https://github.com/Pita/etherpad-lite/wiki/FAQ) to be easy embeddable. Look at our [FAQ Page](https://github.com/Pita/etherpad-lite/wiki/FAQ)
**Online demo**<br> **Online demo**<br>
Visit <http://pitapoison.de:9001> to test it live. You can find the same instance behind a nginx, with ssl and in a subpath here -> [https://pad.pitapoison.de/pad/](https://pad.pitapoison.de/pad/) Visit <http://pitapoison.de:9001> to test it live. <br>You can find the same instance behind a nginx, with ssl and in a subpath here -> [https://pad.pitapoison.de/pad/](https://pad.pitapoison.de/pad/)
# Etherpad vs Etherpad Lite # Etherpad vs Etherpad Lite
<table> <table>
@ -31,26 +31,36 @@ Visit <http://pitapoison.de:9001> to test it live. You can find the same instanc
# Installation # Installation
**As root:** **As root:**
1. Download the latest **0.4.x** node.js release from <http://nodejs.org/#download>, extract it and build it with `./configure && make && make install`. <br> <ol>
The Node.js version of your Linux repository might be too old/new. Please compile from the source to get sure you have the correct version. <li>Install all dependencies. We need the sqlite develob libraries, gzip, git, curl, libssl develop libraries and python <br><code>apt-get install libsqlite3-dev gzip git-core curl python libssl-dev</code></li><br>
2. Install npm `curl http://npmjs.org/install.sh | sh` <li>Install node.js
3. Ensure you have installed the sqlite develob libraries, gzip and git `apt-get install libsqlite3-dev gzip git-core` <ol type="a">
<li>Download the latest <b>0.4.x</b> node.js release from <a href="http://nodejs.org/#download">http://nodejs.org/#download</a></li>
<li>Extract it with <code>tar xf node-v0.4*</code></li>
<li>move into the node folder <code>cd node-v0.4*</code> and build node with <code>./configure && make && make install</code></li>
</ol>
</li>
<li>Install npm <code>curl http://npmjs.org/install.sh | sh</code></li>
</ol>
**As any user (we recommend creating a seperate user called etherpad-lite):** **As any user (we recommend creating a seperate user called etherpad-lite):**
4. Clone the git repository `git clone 'git://github.com/Pita/etherpad-lite.git'` <ol start="4">
5. Start it with `bin/run.sh` (the first run will install all dependencies) <li> Clone the git repository <code>git clone 'git://github.com/Pita/etherpad-lite.git'</code><br>&nbsp;</li>
6. Open your web browser and visit <http://localhost:9001> <li> Install the dependencies with <code>bin/installDeps.sh</code> <i>(if you have problems at this step, look at the section Troubleshooting below)</i><br>&nbsp;</li>
<li> Start it with <code>bin/run.sh</code><br>&nbsp;</li>
<li> Open your web browser and visit <a href="http://localhost:9001">http://localhost:9001</a>. You like it? Look at the 'Next Steps' section below</li>
</ol>
## Troubleshooting ## Troubleshooting
### It fails while installing the sqlite dependency ### It fails while installing the sqlite dependency
The sqlite package of some linux versions (including debian lenny) is too old. You have to use a PPA or debian backports The sqlite package of some linux versions (including debian lenny) is too old. We need sqlite >=3.6. You have to use a PPA or debian backports. You find sqlite packages for Ubuntu Hardy [here](https://launchpad.net/~mirabilos/+archive/ppa/+sourcepub/1304941/+listing-archive-extra), Debian Backports can be found [here](http://backports-master.debian.org/Instructions/#index1h2)
### It fails while installing the express dependency, it says my node version is wrong ### It fails while installing the express dependency, it says my node version is wrong
You might have installed node.js version 0.5. You can check that with `node --version`. Please reinstall node 0.4.x You might have installed node.js version 0.5. You can check that with `node --version`. Please reinstall node 0.4.x
### I stopped the installing process, now it doesn't work anymore, what can I do? ### My installation process stopped, now it doesn't work anymore, what can I do?
Remove the node_modules folder. This forces run.sh to reinstall all dependencies Remove the node_modules folder. This forces run.sh to reinstall all dependencies
## Next Steps ## Next Steps
@ -59,6 +69,7 @@ You can modify the settings in the file settings.json
You can update to the latest version with `git pull origin`. The next start with bin/run.sh will update the dependencies You can update to the latest version with `git pull origin`. The next start with bin/run.sh will update the dependencies
Look at this wiki pages: Look at this wiki pages:
* [How to deploy Etherpad Lite as a service](https://github.com/Pita/etherpad-lite/wiki/How-to-deploy-Etherpad-Lite-as-a-service) * [How to deploy Etherpad Lite as a service](https://github.com/Pita/etherpad-lite/wiki/How-to-deploy-Etherpad-Lite-as-a-service)
* [How to put Etherpad Lite behind a reverse Proxy](https://github.com/Pita/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy) * [How to put Etherpad Lite behind a reverse Proxy](https://github.com/Pita/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy)
* [How to customize your Etherpad Lite installation](https://github.com/Pita/etherpad-lite/wiki/How-to-customize-your-Etherpad-Lite-installation) * [How to customize your Etherpad Lite installation](https://github.com/Pita/etherpad-lite/wiki/How-to-customize-your-Etherpad-Lite-installation)

View file

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
#Move to the folder where ep-lite is installed #Move to the folder where ep-lite is installed
FOLDER=$(dirname $(readlink -f $0)) cd `dirname $0`
cd $FOLDER
#Was this script started in the bin folder? if yes move out #Was this script started in the bin folder? if yes move out
if [ -d "../bin" ]; then if [ -d "../bin" ]; then
@ -21,7 +20,7 @@ hash node-inspector > /dev/null 2>&1 || {
node-inspector & node-inspector &
echo "If you new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8" echo "If you are new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8"
cd "node" cd "node"
node --debug server.js node --debug server.js

View file

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
#Move to the folder where ep-lite is installed #Move to the folder where ep-lite is installed
FOLDER=$(dirname $(readlink -f $0)) cd `dirname $0`
cd $FOLDER
#Was this script started in the bin folder? if yes move out #Was this script started in the bin folder? if yes move out
if [ -d "../bin" ]; then if [ -d "../bin" ]; then

View file

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
#Move to the folder where ep-lite is installed #Move to the folder where ep-lite is installed
FOLDER=$(dirname $(readlink -f $0)) cd `dirname $0`
cd $FOLDER
#Was this script started in the bin folder? if yes move out #Was this script started in the bin folder? if yes move out
if [ -d "../bin" ]; then if [ -d "../bin" ]; then
@ -10,8 +9,8 @@ if [ -d "../bin" ]; then
fi fi
#Is wget installed? #Is wget installed?
hash wget > /dev/null 2>&1 || { hash curl > /dev/null 2>&1 || {
echo "Please install wget" >&2 echo "Please install curl" >&2
exit 1 exit 1
} }
@ -34,7 +33,7 @@ if [ ! -f "settings.json" ]; then
fi fi
echo "Ensure that all dependencies are up to date..." echo "Ensure that all dependencies are up to date..."
npm install || exit 1 npm install || rm -rf node_modules; exit 1
echo "Ensure jQuery is downloaded and up to date..." echo "Ensure jQuery is downloaded and up to date..."
DOWNLOAD_JQUERY="true" DOWNLOAD_JQUERY="true"
@ -48,7 +47,7 @@ if [ -f "static/js/jquery.min.js" ]; then
fi fi
if [ $DOWNLOAD_JQUERY = "true" ]; then if [ $DOWNLOAD_JQUERY = "true" ]; then
wget -O static/js/jquery.min.js http://code.jquery.com/jquery-$NEEDED_VERSION.min.js || exit 1 curl -lo static/js/jquery.min.js http://code.jquery.com/jquery-$NEEDED_VERSION.min.js || exit 1
fi fi
#Remove all minified data to force node creating it new #Remove all minified data to force node creating it new

View file

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
#Move to the folder where ep-lite is installed #Move to the folder where ep-lite is installed
FOLDER=$(dirname $(readlink -f $0)) cd `dirname $0`
cd $FOLDER
#Was this script started in the bin folder? if yes move out #Was this script started in the bin folder? if yes move out
if [ -d "../bin" ]; then if [ -d "../bin" ]; then
@ -16,7 +15,7 @@ if [ "$(id -u)" -eq 0 ]; then
read rocks read rocks
if [ ! $rocks = "Etherpad Lite rocks my socks" ] if [ ! $rocks = "Etherpad Lite rocks my socks" ]
then then
echo "You're input was wrong" echo "Your input was incorrect"
exit 1 exit 1
fi fi
fi fi

View file

@ -18,8 +18,7 @@ TIME_BETWEEN_EMAILS=600 # 10 minutes
LAST_EMAIL_SEND=0 LAST_EMAIL_SEND=0
#Move to the folder where ep-lite is installed #Move to the folder where ep-lite is installed
FOLDER=$(dirname $(readlink -f $0)) cd `dirname $0`
cd $FOLDER
#Was this script started in the bin folder? if yes move out #Was this script started in the bin folder? if yes move out
if [ -d "../bin" ]; then if [ -d "../bin" ]; then

View file

@ -23,11 +23,20 @@ var padManager = require("../db/PadManager");
var async = require("async"); var async = require("async");
var fs = require("fs"); var fs = require("fs");
var settings = require('../utils/Settings'); var settings = require('../utils/Settings');
var os = require('os');
//load abiword only if its enabled //load abiword only if its enabled
if(settings.abiword != null) if(settings.abiword != null)
var abiword = require("../utils/Abiword"); var abiword = require("../utils/Abiword");
var tempDirectory = "/tmp";
//tempDirectory changes if the operating system is windows
if(os.type().indexOf("Windows") > -1)
{
tempDirectory = "c:\\Temp";
}
/** /**
* do a requested export * do a requested export
*/ */
@ -76,7 +85,7 @@ exports.doExport = function(req, res, padId, type)
else else
{ {
randNum = Math.floor(Math.random()*new Date().getTime()); randNum = Math.floor(Math.random()*new Date().getTime());
srcFile = "/tmp/eplite_export_" + randNum + ".html"; srcFile = tempDirectory + "/eplite_export_" + randNum + ".html";
fs.writeFile(srcFile, html, callback); fs.writeFile(srcFile, html, callback);
} }
}, },
@ -86,7 +95,7 @@ exports.doExport = function(req, res, padId, type)
//ensure html can be collected by the garbage collector //ensure html can be collected by the garbage collector
html = null; html = null;
destFile = "/tmp/eplite_export_" + randNum + "." + type; destFile = tempDirectory + "/eplite_export_" + randNum + "." + type;
abiword.convertFile(srcFile, destFile, type, callback); abiword.convertFile(srcFile, destFile, type, callback);
}, },
//send the file //send the file
@ -103,8 +112,12 @@ exports.doExport = function(req, res, padId, type)
fs.unlink(srcFile, callback); fs.unlink(srcFile, callback);
}, },
function(callback) function(callback)
{
//100ms delay to accomidate for slow windows fs
setTimeout(function()
{ {
fs.unlink(destFile, callback); fs.unlink(destFile, callback);
}, 100);
} }
], callback); ], callback);
} }

View file

@ -24,11 +24,20 @@ var async = require("async");
var fs = require("fs"); var fs = require("fs");
var settings = require('../utils/Settings'); var settings = require('../utils/Settings');
var formidable = require('formidable'); var formidable = require('formidable');
var os = require("os");
//load abiword only if its enabled //load abiword only if its enabled
if(settings.abiword != null) if(settings.abiword != null)
var abiword = require("../utils/Abiword"); var abiword = require("../utils/Abiword");
var tempDirectory = "/tmp/";
//tempDirectory changes if the operating system is windows
if(os.type().indexOf("Windows") > -1)
{
tempDirectory = "c:\\Temp\\";
}
/** /**
* do a requested import * do a requested import
*/ */
@ -48,6 +57,7 @@ exports.doImport = function(req, res, padId)
{ {
var form = new formidable.IncomingForm(); var form = new formidable.IncomingForm();
form.keepExtensions = true; form.keepExtensions = true;
form.uploadDir = tempDirectory;
form.parse(req, function(err, fields, files) form.parse(req, function(err, fields, files)
{ {
@ -94,7 +104,7 @@ exports.doImport = function(req, res, padId)
function(callback) function(callback)
{ {
var randNum = Math.floor(Math.random()*new Date().getTime()); var randNum = Math.floor(Math.random()*new Date().getTime());
destFile = "/tmp/eplite_import_" + randNum + ".txt"; destFile = tempDirectory + "eplite_import_" + randNum + ".txt";
abiword.convertFile(srcFile, destFile, "txt", callback); abiword.convertFile(srcFile, destFile, "txt", callback);
}, },
@ -114,7 +124,13 @@ exports.doImport = function(req, res, padId)
fs.readFile(destFile, "utf8", function(err, _text) fs.readFile(destFile, "utf8", function(err, _text)
{ {
text = _text; text = _text;
//node on windows has a delay on releasing of the file lock.
//We add a 100ms delay to work around this
setTimeout(function()
{
callback(err); callback(err);
}, 100);
}); });
}, },

View file

@ -22,7 +22,56 @@ var util = require('util');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var async = require("async"); var async = require("async");
var settings = require("./Settings"); var settings = require("./Settings");
var os = require('os');
//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)
{
//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)
{
//add data to buffer
stdoutBuffer+=data.toString();
});
//append error messages to the buffer
abiword.stderr.on('data', function (data)
{
stdoutBuffer += data.toString();
});
//throw exceptions if abiword is dieing
abiword.on('exit', function (code)
{
if(code != 0) {
throw "Abiword died with exit code " + code;
}
if(stdoutBuffer != "")
{
console.log(stdoutBuffer);
}
callback();
});
}
exports.convertFile = function(srcFile, destFile, type, callback)
{
doConvertTask({"srcFile": srcFile, "destFile": destFile, "type": type}, callback);
};
}
//on unix operating systems, we can start abiword with abicommand and communicate with it via stdin/stdout
//thats much faster, about factor 10
else
{
//Queue with the converts we have to do //Queue with the converts we have to do
var queue = async.queue(doConvertTask, 1); var queue = async.queue(doConvertTask, 1);
@ -90,3 +139,4 @@ exports.convertFile = function(srcFile, destFile, type, callback)
{ {
queue.push({"srcFile": srcFile, "destFile": destFile, "type": type, "callback": callback}); queue.push({"srcFile": srcFile, "destFile": destFile, "type": type, "callback": callback});
}; };
}

View file

@ -29,6 +29,7 @@ var path = require('path');
var Buffer = require('buffer').Buffer; var Buffer = require('buffer').Buffer;
var gzip = require('gzip'); var gzip = require('gzip');
var server = require('../server'); var server = require('../server');
var os = require('os');
var padJS = ["jquery.min.js", "pad_utils.js", "plugins.js", "undo-xpopup.js", "json2.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "ace.js", "collab_client.js", "pad_userlist.js", "pad_impexp.js", "pad_savedrevs.js", "pad_connectionstatus.js", "pad2.js", "jquery-ui.js", "chat.js"]; var padJS = ["jquery.min.js", "pad_utils.js", "plugins.js", "undo-xpopup.js", "json2.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "ace.js", "collab_client.js", "pad_userlist.js", "pad_impexp.js", "pad_savedrevs.js", "pad_connectionstatus.js", "pad2.js", "jquery-ui.js", "chat.js"];
@ -221,6 +222,9 @@ exports.minifyJS = function(req, res, jsFilename)
}, },
//write the results compressed in a file //write the results compressed in a file
function(callback) function(callback)
{
//spawn a gzip process if we're on a unix system
if(os.type().indexOf("Windows") == -1)
{ {
gzip(result, 9, function(err, compressedResult){ gzip(result, 9, function(err, compressedResult){
if(err) {callback(err); return} if(err) {callback(err); return}
@ -228,6 +232,12 @@ exports.minifyJS = function(req, res, jsFilename)
fs.writeFile("../var/minified_" + jsFilename + ".gz", compressedResult, callback); fs.writeFile("../var/minified_" + jsFilename + ".gz", compressedResult, callback);
}); });
} }
//skip this step on windows
else
{
callback();
}
}
],callback); ],callback);
} }
], function(err) ], function(err)
@ -238,7 +248,7 @@ exports.minifyJS = function(req, res, jsFilename)
var gzipSupport = req.header('Accept-Encoding', '').indexOf('gzip') != -1; var gzipSupport = req.header('Accept-Encoding', '').indexOf('gzip') != -1;
var pathStr; var pathStr;
if(gzipSupport) if(gzipSupport && os.type().indexOf("Windows") == -1)
{ {
pathStr = path.normalize(__dirname + "/../../var/minified_" + jsFilename + ".gz"); pathStr = path.normalize(__dirname + "/../../var/minified_" + jsFilename + ".gz");
res.header('Content-Encoding', 'gzip'); res.header('Content-Encoding', 'gzip');

View file

@ -10,11 +10,11 @@
"name": "Robin Buse"} "name": "Robin Buse"}
], ],
"dependencies" : { "dependencies" : {
"socket.io" : "0.7.7", "socket.io" : "0.7.8",
"ueberDB" : "0.0.13", "ueberDB" : "0.0.14",
"async" : "0.1.9", "async" : "0.1.9",
"joose" : "3.18.0", "joose" : "3.18.0",
"express" : "2.4.3", "express" : "2.4.4",
"clean-css" : "0.2.4", "clean-css" : "0.2.4",
"uglify-js" : "1.0.6", "uglify-js" : "1.0.6",
"gzip" : "0.1.0", "gzip" : "0.1.0",

View file

@ -57,14 +57,8 @@
#button:active { #button:active {
box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.9); box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.9);
background: #444; background: #444;
/*
background: -webkit-linear-gradient(#565656, #4C4C4C 50%, #424242 51%, #2D2D2D);
background: -moz-linear-gradient(#565656, #4C4C4C 50%, #424242 51%, #2D2D2D);
background: -ms-linear-gradient(#565656, #4C4C4C 50%, #424242 51%, #2D2D2D);
background: -o-linear-gradient(#565656, #4C4C4C 50%, #424242 51%, #2D2D2D);
*/
} }
.label { #label {
text-align: left; text-align: left;
margin: 0 auto; margin: 0 auto;
width: 300px; width: 300px;
@ -86,7 +80,7 @@
<div id="container"> <div id="container">
<div id="button" onclick="go2Random()">New Pad</div> <div id="button" onclick="go2Random()">New Pad</div>
<br> <br>
<div class="label">or create/open a Pad with the name</div> <div id="label">or create/open a Pad with the name</div>
<form action="#" onsubmit="go2Name();return false;"> <form action="#" onsubmit="go2Name();return false;">
<input type="text" id="padname" autofocus> <input type="text" id="padname" autofocus>
<input type="submit" value="OK"> <input type="submit" value="OK">