diff --git a/README.md b/README.md index d2745b43f..d476c9616 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,8 @@ The Node.js version of your Linux repository might be too old/new. Please compil 2. Install npm `curl http://npmjs.org/install.sh | sh` 3. Ensure you have installed the sqlite develob libraries, gzip and git `apt-get install libsqlite3-dev gzip git-core` 4. Clone the git repository `git clone 'git://github.com/Pita/etherpad-lite.git'` -5. Install the dependencies `cd etherpad-lite && npm install` -6. Start it with `bin/run.sh` -7. Open your web browser and visit +5. Start it with `bin/run.sh` (the first run will install all dependencies) +6. Open your web browser and visit # Next Steps You can modify the settings in the file settings.json @@ -60,4 +59,4 @@ You can join the [mailinglist](http://groups.google.com/group/etherpad-lite-dev) You also help the project, if you only host a ep-lite instance and share your experience with us. # License -[Apache License v2](http://www.apache.org/licenses/LICENSE-2.0.html) \ No newline at end of file +[Apache License v2](http://www.apache.org/licenses/LICENSE-2.0.html) diff --git a/bin/debugRun.sh b/bin/debugRun.sh new file mode 100755 index 000000000..fede0b50b --- /dev/null +++ b/bin/debugRun.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +#Move to the folder where ep-lite is installed +FOLDER=$(dirname $(readlink -f $0)) +cd $FOLDER + +#Was this script started in the bin folder? if yes move out +if [ -d "../bin" ]; then + cd "../" +fi + +#prepare the enviroment +bin/installDeps.sh || exit 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 +} + +node-inspector & + +echo "If you new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8" + +cd "node" +node --debug server.js + +#kill node-inspector before ending +kill $! diff --git a/bin/generateJsDoc.sh b/bin/generateJsDoc.sh index c9424b740..1667c1ccc 100755 --- a/bin/generateJsDoc.sh +++ b/bin/generateJsDoc.sh @@ -1,15 +1,20 @@ -#!/bin/bash +#!/bin/sh +#Move to the folder where ep-lite is installed +FOLDER=$(dirname $(readlink -f $0)) +cd $FOLDER + +#Was this script started in the bin folder? if yes move out if [ -d "../bin" ]; then cd "../" fi -type -P node &>/dev/null || { +hash node > /dev/null 2>&1 || { echo "You need to install node!" >&2 exit 1 } -type -P doc.md &>/dev/null || { +hash doc.md > /dev/null 2>&1 || { echo "You need to install doc.md! npm install -g doc.md" >&2 exit 1 } diff --git a/bin/installDeps.sh b/bin/installDeps.sh new file mode 100755 index 000000000..2c880896c --- /dev/null +++ b/bin/installDeps.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +#Move to the folder where ep-lite is installed +FOLDER=$(dirname $(readlink -f $0)) +cd $FOLDER + +#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 node installed? +hash node > /dev/null 2>&1 || { + echo "Please install node.js ( http://nodesjs.org )" >&2 + exit 1 +} + +#Is npm installed? +hash npm > /dev/null 2>&1 || { + echo "Please install npm ( http://npmjs.org )" >&2 + exit 1 +} + +#Does a settings.json exist? if no copy the template +if [ ! -f "settings.json" ]; then + echo "Copy the settings template to settings.json..." + cp -v settings.json.template settings.json || exit 1 +fi + +echo "Ensure that all dependencies are up to date..." +npm install || exit 1 + +echo "Ensure jQuery is downloaded and up to date..." +DOWNLOAD_JQUERY="true" +NEEDED_VERSION="1.6.2" +if [ -f "static/js/jquery.min.js" ]; then + VERSION=$(cat static/js/jquery.min.js | head -n 2 | tail -n 1 | grep -o "v[0-9]*\.[0-9]*\.[0-9]*"); + + if [ ${VERSION#v} = $NEEDED_VERSION ]; then + DOWNLOAD_JQUERY="false" + fi +fi + +if [ $DOWNLOAD_JQUERY = "true" ]; then + wget -O static/js/jquery.min.js http://code.jquery.com/jquery-$NEEDED_VERSION.min.js || exit 1 +fi + +#Remove all minified data to force node creating it new +echo "Clear minfified cache..." +rm -f var/minified* + +echo "ensure custom css/js files are created..." + +for f in "index" "pad" "timeslider" +do + if [ ! -f "static/custom/$f.js" ]; then + cp -v "static/custom/js.template" "static/custom/$f.js" || exit 1 + fi + + if [ ! -f "static/custom/$f.css" ]; then + cp -v "static/custom/css.template" "static/custom/$f.css" || exit 1 + fi +done + +exit 0 diff --git a/bin/run.sh b/bin/run.sh index 0b72dc3f7..e89e3af95 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh #Move to the folder where ep-lite is installed FOLDER=$(dirname $(readlink -f $0)) @@ -10,51 +10,14 @@ if [ -d "../bin" ]; then fi #Stop the script if its started as root -if [[ $EUID -eq 0 ]]; then +if [ "$(id -u)" -eq 0 ]; then echo "You shouldn't start Etherpad-Lite as root!" 1>&2 echo "Use authbind if you want to use a port lower than 1024 -> http://en.wikipedia.org/wiki/Authbind" 1>&2 exit 1 fi -#Is node installed? -type -P node &>/dev/null || { - echo "You need to install node to run Etherpad-Lite!" >&2 - exit 1 -} - -#Is npm installed? -type -P npm &>/dev/null || { - echo "You need to install npm to run Etherpad-Lite!" >&2 - exit 1 -} - -#Does a settings.json exist? if no copy the template -if [ ! -f "settings.json" ]; then - echo "Copy the settings template to settings.json..." - cp -v settings.json.template settings.json -fi - -echo "Ensure that all dependencies are up to date..." -npm install - -echo "Ensure jQuery is downloaded and up to date..." -DOWNLOAD_JQUERY="true" -NEEDED_VERSION="1.6.2" -if [ -f "static/js/jquery.min.js" ]; then - VERSION=$(cat static/js/jquery.min.js | head -n 2 | tail -n 1 | grep -o "v[0-9]*\.[0-9]*\.[0-9]*"); - - if [[ ${VERSION:1} = $NEEDED_VERSION ]]; then - DOWNLOAD_JQUERY="false" - fi -fi - -if [[ $DOWNLOAD_JQUERY = "true" ]]; then - wget -O static/js/jquery.min.js http://code.jquery.com/jquery-$NEEDED_VERSION.min.js -fi - -#Remove all minified data to force node creating it new -echo "Clear minfified cache..." -rm var/minified* 2> /dev/null +#prepare the enviroment +bin/installDeps.sh || exit 1 #Move to the node folder and start echo "start..." diff --git a/bin/runDebug.sh b/bin/runDebug.sh deleted file mode 100755 index 46eec8e8d..000000000 --- a/bin/runDebug.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -type -P node-inspector &>/dev/null || { - echo "You need to install node-inspector to run the tests!" >&2 - echo "You can install it with npm" >&2 - echo "Run: npm install node-inspector" >&2 - exit 1 -} - -node-inspector & - -echo "If you new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8" - -if [ -d "../bin" ]; then - cd "../" -fi - -cd "node" -node --debug server.js diff --git a/bin/runTests.sh b/bin/runTests.sh deleted file mode 100755 index f22004e37..000000000 --- a/bin/runTests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -type -P nodeunit &>/dev/null || { - echo "You need to install Nodeunit to run the tests!" >&2 - echo "You can install it with npm" >&2 - echo "Run: npm install nodeunit" >&2 - exit 1 -} - -if [ -d "../bin" ]; then - cd "../" -fi - -nodeunit tests diff --git a/bin/runSafe.sh b/bin/safeRun.sh similarity index 86% rename from bin/runSafe.sh rename to bin/safeRun.sh index 180de1fe3..d7d2b99cc 100755 --- a/bin/runSafe.sh +++ b/bin/safeRun.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh #This script ensures that ep-lite is automatically restarting after an error happens @@ -49,12 +49,12 @@ do bin/run.sh >>$1 2>>$1 #Send email - if [ $ERROR_HANDLING == 1 ]; then + 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 - echo -e "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 + 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 diff --git a/doc/jsdoc/AuthorManager.md b/doc/jsdoc/db/AuthorManager.md similarity index 81% rename from doc/jsdoc/AuthorManager.md rename to doc/jsdoc/db/AuthorManager.md index 9493a9d82..257d112c9 100644 --- a/doc/jsdoc/AuthorManager.md +++ b/doc/jsdoc/db/AuthorManager.md @@ -1,10 +1,17 @@ -# AuthorManager -`require("./AuthorManager");` +# db/AuthorMana +`require("./db/AuthorManager");` The AuthorManager controlls all information about the Pad authors ## Functions +- - - +### getAuthor (author, callback) +Internal function that creates the database entry for an author + +* **author** *(String)* The id of the author +* **callback** *(Function)* callback(err, authorObj) + - - - ### getAuthor4Token (token, callback) Returns the Author Id for a token. If the token is unkown, diff --git a/doc/jsdoc/db.md b/doc/jsdoc/db/DB.md similarity index 94% rename from doc/jsdoc/db.md rename to doc/jsdoc/db/DB.md index be08850cf..6acfd826c 100644 --- a/doc/jsdoc/db.md +++ b/doc/jsdoc/db/DB.md @@ -1,5 +1,5 @@ # db -`require("./db");` +`require("./db/DB");` The DB Module provides a database initalized with the settings provided by the settings module diff --git a/doc/jsdoc/Models/Pad.md b/doc/jsdoc/db/Pad.md similarity index 87% rename from doc/jsdoc/Models/Pad.md rename to doc/jsdoc/db/Pad.md index e67dcc560..54b122b7d 100644 --- a/doc/jsdoc/Models/Pad.md +++ b/doc/jsdoc/db/Pad.md @@ -1,5 +1,5 @@ -# Mod -`require("./Models/Pad");` +# db/ +`require("./db/Pad");` The pad object, defined with joose diff --git a/doc/jsdoc/PadManager.md b/doc/jsdoc/db/PadManager.md similarity index 82% rename from doc/jsdoc/PadManager.md rename to doc/jsdoc/db/PadManager.md index 2f476f3e4..7721b3e86 100644 --- a/doc/jsdoc/PadManager.md +++ b/doc/jsdoc/db/PadManager.md @@ -1,5 +1,5 @@ -# PadManager -`require("./PadManager");` +# db/PadMana +`require("./db/PadManager");` The Pad Manager is a Factory for pad Objects diff --git a/doc/jsdoc/db/ReadOnlyManager.md b/doc/jsdoc/db/ReadOnlyManager.md new file mode 100644 index 000000000..4b6fc8afd --- /dev/null +++ b/doc/jsdoc/db/ReadOnlyManager.md @@ -0,0 +1,21 @@ +# db/ReadOnlyMana +`require("./db/ReadOnlyManager");` + +The ReadOnlyManager manages the database and rendering releated to read only pads + +## Functions + +- - - +### getPadId (readOnlyId, callback) +returns a the padId for a read only id + +* **readOnlyId** *(String)* read only id +* **callback** *No description* + +- - - +### getReadOnlyId (padId, callback) +returns a read only id for a pad + +* **padId** *(String)* the id of the pad +* **callback** *No description* + diff --git a/doc/jsdoc/handler/ExportHandler.md b/doc/jsdoc/handler/ExportHandler.md new file mode 100644 index 000000000..7117715f7 --- /dev/null +++ b/doc/jsdoc/handler/ExportHandler.md @@ -0,0 +1,16 @@ +# handler/Expor +`require("./handler/ExportHandler");` + +Handles the export requests + +## Functions + +- - - +### doExport (req, res, padId, type) +do a requested export + +* **req** *No description* +* **res** *No description* +* **padId** *No description* +* **type** *No description* + diff --git a/doc/jsdoc/handler/ImportHandler.md b/doc/jsdoc/handler/ImportHandler.md new file mode 100644 index 000000000..e255586f1 --- /dev/null +++ b/doc/jsdoc/handler/ImportHandler.md @@ -0,0 +1,15 @@ +# handler/Impor +`require("./handler/ImportHandler");` + +Handles the import requests + +## Functions + +- - - +### doImport (req, res, padId) +do a requested import + +* **req** *No description* +* **res** *No description* +* **padId** *No description* + diff --git a/doc/jsdoc/handler/PadMessageHandler.md b/doc/jsdoc/handler/PadMessageHandler.md new file mode 100644 index 000000000..a17df95fd --- /dev/null +++ b/doc/jsdoc/handler/PadMessageHandler.md @@ -0,0 +1,38 @@ +# handler/PadMessag +`require("./handler/PadMessageHandler");` + +The MessageHandler handles all Messages that comes from Socket.IO and controls the sessions + +## Functions + +- - - +### handleConnect (client) +Handles the connection of a new user + +* **client** the new client + +- - - +### handleDisconnect (client) +Handles the disconnection of a user + +* **client** the client that leaves + +- - - +### handleMessage (client, message) +Handles a message from a user + +* **client** the client that send this message +* **message** the message from the client + +- - - +### setSocketIO (socket_io) +A associative array that translates a session to a pad + +* **socket_io** The Socket + +- - - +### updatePadClients (pad, callback) + +* **pad** *No description* +* **callback** *No description* + diff --git a/doc/jsdoc/handler/SocketIORouter.md b/doc/jsdoc/handler/SocketIORouter.md new file mode 100644 index 000000000..8effc96d6 --- /dev/null +++ b/doc/jsdoc/handler/SocketIORouter.md @@ -0,0 +1,23 @@ +# handler/Socket +`require("./handler/SocketIORouter");` + +This is the Socket.IO Router. It routes the Messages between the +components of the Server. The components are at the moment: pad and timeslider + +## Functions + +- - - +### addComponent (moduleName, module) +Saves all components +key is the component name +value is the component module + +* **moduleName** *No description* +* **module** *No description* + +- - - +### setSocketIO (_socket) +sets the socket.io and adds event functions for routing + +* **_socket** *No description* + diff --git a/doc/jsdoc/MessageHandler.md b/doc/jsdoc/handler/TimesliderMessageHandler.md similarity index 78% rename from doc/jsdoc/MessageHandler.md rename to doc/jsdoc/handler/TimesliderMessageHandler.md index da6b115c7..ac1edac62 100644 --- a/doc/jsdoc/MessageHandler.md +++ b/doc/jsdoc/handler/TimesliderMessageHandler.md @@ -1,5 +1,5 @@ -# MessageHandler -`require("./MessageHandler");` +# handler/TimesliderMessag +`require("./handler/TimesliderMessageHandler");` The MessageHandler handles all Messages that comes from Socket.IO and controls the sessions @@ -26,7 +26,7 @@ Handles a message from a user - - - ### setSocketIO (socket_io) -A associative array that translates a session to a pad +Saves the Socket class we need to send and recieve data from the client * **socket_io** The Socket diff --git a/doc/jsdoc/utils/Abiword.md b/doc/jsdoc/utils/Abiword.md new file mode 100644 index 000000000..680e24992 --- /dev/null +++ b/doc/jsdoc/utils/Abiword.md @@ -0,0 +1,15 @@ +# utils/A +`require("./utils/Abiword");` + +Controls the communication with the Abiword application + +## Functions + +- - - +### convertFile (srcFile, destFile, type, callback) + +* **srcFile** *No description* +* **destFile** *No description* +* **type** *No description* +* **callback** *No description* + diff --git a/doc/jsdoc/AttributePoolFactory.md b/doc/jsdoc/utils/AttributePoolFactory.md similarity index 86% rename from doc/jsdoc/AttributePoolFactory.md rename to doc/jsdoc/utils/AttributePoolFactory.md index 64ac3a221..4f52fcc3f 100644 --- a/doc/jsdoc/AttributePoolFactory.md +++ b/doc/jsdoc/utils/AttributePoolFactory.md @@ -1,5 +1,5 @@ -# AttributePoolFactory -`require("./AttributePoolFactory");` +# utils/AttributePoolF +`require("./utils/AttributePoolFactory");` This code represents the Attribute Pool Object of the original Etherpad. 90% of the code is still like in the original Etherpad diff --git a/doc/jsdoc/Changeset.md b/doc/jsdoc/utils/Changeset.md similarity index 99% rename from doc/jsdoc/Changeset.md rename to doc/jsdoc/utils/Changeset.md index 066fc1991..6f08514a2 100644 --- a/doc/jsdoc/Changeset.md +++ b/doc/jsdoc/utils/Changeset.md @@ -1,5 +1,5 @@ -# Changeset -`require("./Changeset");` +# utils/Cha +`require("./utils/Changeset");` ## Functions diff --git a/doc/jsdoc/utils/ExportHtml.md b/doc/jsdoc/utils/ExportHtml.md new file mode 100644 index 000000000..8c56abbc4 --- /dev/null +++ b/doc/jsdoc/utils/ExportHtml.md @@ -0,0 +1,24 @@ +# utils/Expo +`require("./utils/ExportHtml");` + +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. +See the License for the specific language governing permissions and +limitations under the License. + +## Functions + +- - - +### getPadHTMLDocument (padId, revNum, noDocType, callback) + +* **padId** *No description* +* **revNum** *No description* +* **noDocType** *No description* +* **callback** *No description* + diff --git a/doc/jsdoc/minify.md b/doc/jsdoc/utils/Minify.md similarity index 54% rename from doc/jsdoc/minify.md rename to doc/jsdoc/utils/Minify.md index ead833f49..b2d1cba31 100644 --- a/doc/jsdoc/minify.md +++ b/doc/jsdoc/utils/Minify.md @@ -1,5 +1,5 @@ -# minify -`require("./minify");` +# utils/ +`require("./utils/Minify");` This Module manages all /minified/* requests. It controls the minification && compression of Javascript and CSS. @@ -7,9 +7,10 @@ minification && compression of Javascript and CSS. ## Functions - - - -### padJS (req, res) -Answers a http request for the pad javascript +### minifyJS (req, res, jsFilename) +creates the minifed javascript for the given minified name * **req** the Express request * **res** the Express response +* **jsFilename** *No description* diff --git a/doc/jsdoc/settings.md b/doc/jsdoc/utils/Settings.md similarity index 77% rename from doc/jsdoc/settings.md rename to doc/jsdoc/utils/Settings.md index ad97c4f30..1750c4382 100644 --- a/doc/jsdoc/settings.md +++ b/doc/jsdoc/utils/Settings.md @@ -1,11 +1,15 @@ -# settings -`require("./settings");` +# utils/Se +`require("./utils/Settings");` The Settings Modul reads the settings out of settings.json and provides this information to the other modules ##Variables +- - - +### abiword +The path of the abiword executable + - - - ### dbSettings This setting is passed with dbType to ueberDB to set up the database @@ -18,6 +22,10 @@ This setting is passed with dbType to ueberDB to set up the database ### defaultPadText The default Text of a new pad +- - - +### ip +The IP ep-lite should listen to + - - - ### logHTTP A flag that shows if http requests should be loged to stdout diff --git a/node/README.md b/node/README.md new file mode 100644 index 000000000..031810f6f --- /dev/null +++ b/node/README.md @@ -0,0 +1,13 @@ +# About the folder structure + +* **db** - all modules that are accesing the data structure and are communicating directly to the database +* **handler** - all modules that responds directly to requests/messages of the browser +* **utils** - helper modules + +# Module name conventions + +Module file names starts with a capital letter and uses camelCase + +# Where does it start? + +server.js is started directly diff --git a/node/AuthorManager.js b/node/db/AuthorManager.js similarity index 63% rename from node/AuthorManager.js rename to node/db/AuthorManager.js index 44eb48b67..6a9064ea9 100644 --- a/node/AuthorManager.js +++ b/node/db/AuthorManager.js @@ -18,7 +18,7 @@ * limitations under the License. */ -var db = require("./db").db; +var db = require("./DB").db; var async = require("async"); /** @@ -32,38 +32,48 @@ exports.getAuthor4Token = function (token, callback) { var author; - async.waterfall([ + async.series([ //try to get the author for this token function(callback) { - db.get("token2author:" + token, callback); + db.get("token2author:" + token, function (err, _author) + { + author = _author; + callback(err); + }); }, - function(value, callback) + function(callback) { //there is no author with this token, so create one - if(value == null) + if(author == null) { - //create the new author name - author = "g." + _randomString(16); - - //set the token2author db entry - db.set("token2author:" + token, author); - - //set the globalAuthors db entry - var authorObj = {colorId : Math.floor(Math.random()*32), name: null, timestamp: new Date().getTime()}; - db.set("globalAuthor:" + author, authorObj); - - callback(null); + createAuthor(token, function(err, _author) + { + author = _author; + callback(err); + }); } //there is a author with this token else { - author = value; - - //update the author time - db.setSub("globalAuthor:" + author, ["timestamp"], new Date().getTime()); - - callback(null); + //check if there is also an author object for this token, if not, create one + db.get("globalAuthor:" + author, function(err, authorObject) + { + if(authorObject == null) + { + createAuthor(token, function(err, _author) + { + author = _author; + callback(err); + }); + } + //the author exists, update the timestamp of this author + else + { + db.setSub("globalAuthor:" + author, ["timestamp"], new Date().getTime()); + callback(); + } + }); } } ], function(err) @@ -72,6 +82,36 @@ exports.getAuthor4Token = function (token, callback) }); } +/** + * Internal function that creates the database entry for an author + * @param {String} token The token + */ +function createAuthor (token, callback) +{ + //create the new author name + var author = "g." + _randomString(16); + + //create the globalAuthors db entry + var authorObj = {colorId : Math.floor(Math.random()*32), name: null, timestamp: new Date().getTime()}; + + //we do this in series to ensure this db entries are written in the correct order + async.series([ + //set the global author db entry + function(callback) + { + db.set("globalAuthor:" + author, authorObj, callback); + }, + //set the token2author db entry + function(callback) + { + db.set("token2author:" + token, author, callback); + } + ], function(err) + { + callback(err, author); + }); +} + /** * Returns the Author Obj of the author * @param {String} author The id of the author diff --git a/node/db.js b/node/db/DB.js similarity index 97% rename from node/db.js rename to node/db/DB.js index c586e1c4c..aa1064ad0 100644 --- a/node/db.js +++ b/node/db/DB.js @@ -20,7 +20,7 @@ */ var ueberDB = require("ueberDB"); -var settings = require("./settings"); +var settings = require("../utils/Settings"); //set database settings var db = new ueberDB.database(settings.dbType, settings.dbSettings); diff --git a/node/Models/Pad.js b/node/db/Pad.js similarity index 89% rename from node/Models/Pad.js rename to node/db/Pad.js index a2353a44e..f52c16c7e 100644 --- a/node/Models/Pad.js +++ b/node/db/Pad.js @@ -2,12 +2,12 @@ * The pad object, defined with joose */ -var Changeset = require("../Changeset"); -var AttributePoolFactory = require("../AttributePoolFactory"); -var db = require("../db").db; +var Changeset = require("../utils/Changeset"); +var AttributePoolFactory = require("../utils/AttributePoolFactory"); +var db = require("./DB").db; var async = require("async"); -var settings = require('../settings'); -var authorManager = require("../AuthorManager"); +var settings = require('../utils/Settings'); +var authorManager = require("./AuthorManager"); /** * Copied from the Etherpad source code. It converts Windows line breaks to Unix line breaks and convert Tabs to spaces @@ -214,7 +214,7 @@ Class('Pad', { db.setSub("pad:"+this.id, ["chatHead"], this.chatHead); }, - getChatMessage: function(entryNum, withName, callback) + getChatMessage: function(entryNum, callback) { var _this = this; var entry; @@ -231,9 +231,9 @@ Class('Pad', { }, //add the authorName function(callback) - { - //skip if we don't need the authorName - if(!withName) + { + //this chat message doesn't exist, return null + if(entry == null) { callback(); return; @@ -287,14 +287,26 @@ Class('Pad', { var entries = []; async.forEach(neededEntries, function(entryObject, callback) { - _this.getChatMessage(entryObject.entryNum, true, function(err, entry) + _this.getChatMessage(entryObject.entryNum, function(err, entry) { entries[entryObject.order] = entry; callback(err); }); }, function(err) { - callback(err, entries); + //sort out broken chat entries + //it looks like in happend in the past that the chat head was + //incremented, but the chat message wasn't added + var cleanedEntries = []; + for(var i=0;i", "contributors": [ { "name": "John McLear", - "name": "Hans Pinckaers"} + "name": "Hans Pinckaers", + "name": "Robin Buse"} ], "dependencies" : { "socket.io" : "0.7.7", - "ueberDB" : "0.0.10", + "ueberDB" : "0.0.12", "async" : "0.1.9", "joose" : "3.18.0", "express" : "2.4.3", "clean-css" : "0.2.4", "uglify-js" : "1.0.6", "gzip" : "0.1.0", - "formidable" : "1.0.2" + "formidable" : "1.0.2", + "log4js" : "0.3.7" }, "version" : "0.0.4" } diff --git a/settings.json.template b/settings.json.template index 6b80021ba..e41df0161 100644 --- a/settings.json.template +++ b/settings.json.template @@ -4,6 +4,8 @@ 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 @@ -23,9 +25,6 @@ }, */ - //if true, every http request will be loged to stdout - "logHTTP" : true, - //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", diff --git a/static/custom/.gitignore b/static/custom/.gitignore new file mode 100644 index 000000000..8cdbf1832 --- /dev/null +++ b/static/custom/.gitignore @@ -0,0 +1,3 @@ +* +!js.template +!css.template \ No newline at end of file diff --git a/static/custom/css.template b/static/custom/css.template new file mode 100644 index 000000000..b47c7fc0d --- /dev/null +++ b/static/custom/css.template @@ -0,0 +1,5 @@ +/* + You may have to use !important to override css attributs, for example: + + * {color: blue !important;} +*/ diff --git a/static/custom/js.template b/static/custom/js.template new file mode 100644 index 000000000..e857a8bfe --- /dev/null +++ b/static/custom/js.template @@ -0,0 +1,6 @@ +function costumStart() +{ + //define your javascript here + //jquery is avaiable - except index.js + //you can load extra scripts with $.getScript http://api.jquery.com/jQuery.getScript/ +} diff --git a/static/index.html b/static/index.html index 7648e838c..b7085458b 100644 --- a/static/index.html +++ b/static/index.html @@ -81,11 +81,13 @@ width: 40px; } + +
New Pad

or create/open a Pad with the name
-
+
@@ -111,7 +113,7 @@ function randomPadName() { - var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; + var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; var string_length = 10; var randomstring = ''; for (var i = 0; i < string_length; i++) @@ -121,5 +123,8 @@ } return randomstring; } + + //start the costum js + if(costumStart) costumStart(); - \ No newline at end of file + diff --git a/static/js/cssmanager.js b/static/js/cssmanager.js index 85e5552ce..5601ea25b 100644 --- a/static/js/cssmanager.js +++ b/static/js/cssmanager.js @@ -20,7 +20,7 @@ function makeCSSManager(emptyStylesheetTitle, top) function getSheetByTitle(title, top) { if(top) - var allSheets = window.top.document.styleSheets; + var allSheets = window.parent.parent.document.styleSheets; else var allSheets = document.styleSheets; diff --git a/static/js/pad2.js b/static/js/pad2.js index 4858e0b25..aa1f7ccd7 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -29,6 +29,9 @@ $(document).ready(function() document.location = expectedURL; } + //start the costum js + if(costumStart) costumStart(); + handshake(); }); @@ -64,7 +67,7 @@ function readCookie(name) function randomString() { - var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; + var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; var string_length = 20; var randomstring = ''; for (var i = 0; i < string_length; i++) @@ -126,8 +129,8 @@ function handshake() receivedClientVars = true; clientVars = obj; - clientVars.userAgent = navigator.userAgent; - clientVars.collab_client_vars.clientAgent = navigator.userAgent; + clientVars.userAgent = "Anonymous"; + clientVars.collab_client_vars.clientAgent = "Anonymous"; pad.init(); diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index 75cd7402f..f088eaeb1 100644 --- a/static/js/pad_editbar.js +++ b/static/js/pad_editbar.js @@ -101,13 +101,13 @@ var padeditbar = (function() else if (cmd == 'embed') { var padurl = document.location; - $('#embedinput').val("