From d47978455946c2bd1beaa1feeab567ba457aeb0d Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 20 Feb 2012 01:11:34 +0000 Subject: [PATCH 1/8] Hotfix for issue #467 https://github.com/Pita/etherpad-lite/issues/467 -- probably wants a permafix --- static/js/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/chat.js b/static/js/chat.js index 9f0903cf..fb2acac1 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -92,7 +92,7 @@ var chat = (function() return 'z' + c.charCodeAt(0) + 'z'; }); - var text = padutils.escapeHtmlWithClickableLinks(padutils.escapeHtml(msg.text), "_blank"); + var text = padutils.escapeHtmlWithClickableLinks(msg.text, "_blank"); /* Performs an action if your name is mentioned */ var myName = $('#myusernameedit').val(); From ec2d415a92cf613a1c437e2a728b3845e5455ca8 Mon Sep 17 00:00:00 2001 From: drdla Date: Mon, 20 Feb 2012 22:28:25 +0100 Subject: [PATCH 2/8] Promote proper use of css specificity --- static/custom/css.template | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static/custom/css.template b/static/custom/css.template index b47c7fc0..236251d9 100644 --- a/static/custom/css.template +++ b/static/custom/css.template @@ -1,5 +1,8 @@ /* - You may have to use !important to override css attributs, for example: - - * {color: blue !important;} + custom css files are loaded after core css files. Simply use the same selector to override a style. + Example: + #editbar LI {border:1px solid #000;} + overrides + #editbar LI {border:1px solid #d5d5d5;} + from pad.css */ From 8bac77ff803208b401b67e7fbb4b68bf76c4301b Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 21 Feb 2012 14:20:45 -0500 Subject: [PATCH 3/8] Allow settings filename to be passed as a cli option --- bin/installDeps.sh | 16 ++++++++++++---- bin/run.sh | 4 ++-- node/utils/Cli.js | 38 ++++++++++++++++++++++++++++++++++++++ node/utils/Settings.js | 8 ++++++-- 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 node/utils/Cli.js diff --git a/bin/installDeps.sh b/bin/installDeps.sh index 6767b693..270ec98c 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -40,10 +40,18 @@ if [ ! $(echo $NODE_VERSION | cut -d "." -f 1-2) = "v0.6" ]; then 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..." - cp -v settings.json.template settings.json || exit 1 +#Get the name of the settings file +settings="settings.json" +a=''; +for arg in $*; do + if [ "$a" = "--settings" ] || [ "$a" = "-s" ]; then settings=$arg; fi + a=$arg +done + +#Does a $settings exist? if no copy the template +if [ ! -f $settings ]; then + echo "Copy the settings template to $settings..." + cp -v settings.json.template $settings || exit 1 fi echo "Ensure that all dependencies are up to date..." diff --git a/bin/run.sh b/bin/run.sh index a5245ff7..c409920e 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -21,9 +21,9 @@ if [ "$(id -u)" -eq 0 ]; then fi #prepare the enviroment -bin/installDeps.sh || exit 1 +bin/installDeps.sh $* || exit 1 #Move to the node folder and start echo "start..." cd "node" -node server.js +node server.js $* diff --git a/node/utils/Cli.js b/node/utils/Cli.js new file mode 100644 index 00000000..0c7947e9 --- /dev/null +++ b/node/utils/Cli.js @@ -0,0 +1,38 @@ +/** + * The CLI module handles command line parameters + */ + +/* + * 2012 Jordan Hollinger + * + * 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. + */ + +// An object containing the parsed command-line options +exports.argv = {}; + +var argv = process.argv.slice(2); +var arg, prevArg; + +// Loop through args +for ( var i = 0; i < argv.length; i++ ) { + arg = argv[i]; + + // Override location of settings.json file + if ( prevArg == '--settings' || prevArg == '-s' ) { + exports.argv.settings = arg; + } + + prevArg = arg; +} diff --git a/node/utils/Settings.js b/node/utils/Settings.js index e9570211..efa22694 100644 --- a/node/utils/Settings.js +++ b/node/utils/Settings.js @@ -22,6 +22,7 @@ var fs = require("fs"); var os = require("os"); var path = require('path'); +var argv = require('./Cli').argv; /** * The IP ep-lite should listen to @@ -88,9 +89,12 @@ exports.abiwordAvailable = function() } } +// Discover where the settings file lives +var settingsFilename = argv.settings || "settings.json"; +var settingsPath = settingsFilename.charAt(0) == '/' ? '' : path.normalize(__dirname + "/../../"); + //read the settings sync -var settingsPath = path.normalize(__dirname + "/../../"); -var settingsStr = fs.readFileSync(settingsPath + "settings.json").toString(); +var settingsStr = fs.readFileSync(settingsPath + settingsFilename).toString(); //remove all comments settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,""); From 6467a1a40f5fea7137ec481cfa80681b2258dae8 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 21 Feb 2012 15:36:05 -0500 Subject: [PATCH 4/8] Document the -s|--settings cli option in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4995e852..d593115c 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,8 @@ Here is the **[FAQ](https://github.com/Pita/etherpad-lite/wiki/FAQ)** ## Next Steps You can modify the settings in the file `settings.json` +If you have multiple settings files, you may pass one to `bin/run.sh` using the `-s|--settings` option. This allows you to run multiple Etherpad Lite instances from the same installation. + You should use a dedicated database such as "mysql" if you are planning on using etherpad-lite in a production environment, the "dirty" database driver is only for testing and/or development purposes. You can update to the latest version with `git pull origin`. The next start with bin/run.sh will update the dependencies From eae87fd8351f2c4e53a21eef375f4c3008ace830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Tue, 21 Feb 2012 21:46:25 +0100 Subject: [PATCH 5/8] fixed indention + variable scoping --- static/js/ace2_inner.js | 42 +++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index d2113574..5f343a39 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -5828,16 +5828,19 @@ function OUTER(gscope) { var newNumLines = rep.lines.length(); if (newNumLines < 1) newNumLines = 1; - //update height of all current line numbers + //update height of all current line numbers + + var a = sideDivInner.firstChild; + var b = doc.body.firstChild; + var n = 0; + if (currentCallStack && currentCallStack.domClean) { - var a = sideDivInner.firstChild; - var b = doc.body.firstChild; - var n = 0; + while (a && b) { - if(n > lineNumbersShown) //all updated, break - break; + if(n > lineNumbersShown) //all updated, break + break; var h = (b.clientHeight || b.offsetHeight); if (b.nextSibling) @@ -5853,12 +5856,12 @@ function OUTER(gscope) { var hpx = h + "px"; if (a.style.height != hpx) { - a.style.height = hpx; - } + a.style.height = hpx; + } } a = a.nextSibling; b = b.nextSibling; - n++; + n++; } } @@ -5872,17 +5875,20 @@ function OUTER(gscope) lineNumbersShown++; var n = lineNumbersShown; 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"; + //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; + fragment.appendChild(div); + b = b.nextSibling; } + container.appendChild(fragment); while (lineNumbersShown > newNumLines) { @@ -5891,8 +5897,8 @@ function OUTER(gscope) } } } +} -}; OUTER(this); From 4ef71c353426e3dcad726cb23ee95dd389b1d184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Tue, 21 Feb 2012 22:29:40 +0100 Subject: [PATCH 6/8] documented ace_setProperty --- static/js/ace2_inner.js | 86 ++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 49 deletions(-) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index d2113574..1c703673 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -1123,57 +1123,45 @@ function OUTER(gscope) } } + // This methed exposes a setter for some ace properties + // @param key the name of the parameter + // @param value the value to set to editorInfo.ace_setProperty = function(key, value) { - var k = key.toLowerCase(); - if (k == "wraps") - { - setWraps(value); - } - else if (k == "showsauthorcolors") - { - setClassPresence(root, "authorColors", !! value); - } - else if (k == "showsuserselections") - { - setClassPresence(root, "userSelections", !! value); - } - else if (k == "showslinenumbers") - { - hasLineNumbers = !! value; - // disable line numbers on mobile devices - if (browser.mobile) hasLineNumbers = false; - setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); - fixView(); - } - else if (k == "grayedout") - { - setClassPresence(outerWin.document.body, "grayedout", !! value); - } - else if (k == "dmesg") - { - dmesg = value; - window.dmesg = value; - } - else if (k == 'userauthor') - { - thisAuthor = String(value); - } - else if (k == 'styled') - { - setStyled(value); - } - else if (k == 'textface') - { - setTextFace(value); - } - else if (k == 'textsize') - { - setTextSize(value); - } - else if (k == 'rtlistrue') - { - setClassPresence(root, "rtl", !! value); + + // 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, + showsauthorcolors: setClassPresenceNamed(root, "authorColors"), + showsuserselections: setClassPresenceNamed(root, "userSelections"), + showslinenumbers : function(value){ + hasLineNumbers = !! value; + // disable line numbers on mobile devices + if (browser.mobile) hasLineNumbers = false; + setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); + fixView(); + }, + grayedout: setClassPresenceNamed(outerWin.document.body, "grayedout"), + dmesg: function(){ dmesg = window.dmesg = value; }, + userauthor: function(value){ thisAuthor = String(value); }, + styled: setStyled, + textface: setTextFace, + textsize: setTextSize, + rtlistrue: setClassPresenceNamed(root, "rtl") + }; + + var setter = setters[key.toLowerCase();]; + + // check if setter is present + if(setter !== undefined){ + setter(value) } } From b06f3f69036a0d52b9d248b2deede31f6878fcfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Tue, 21 Feb 2012 23:15:19 +0100 Subject: [PATCH 7/8] removed ";" --- static/js/ace2_inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 1c703673..5d6f5a4d 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -1157,7 +1157,7 @@ function OUTER(gscope) rtlistrue: setClassPresenceNamed(root, "rtl") }; - var setter = setters[key.toLowerCase();]; + var setter = setters[key.toLowerCase()]; // check if setter is present if(setter !== undefined){ From 88744901c076cdfc1226094a2ca8ab22f7ef343c Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 24 Feb 2012 12:23:31 +0000 Subject: [PATCH 8/8] Fixes import major bug caused by removing container required for callback of import --- static/pad.html | 1 + 1 file changed, 1 insertion(+) diff --git a/static/pad.html b/static/pad.html index 0345d65b..710b0f01 100644 --- a/static/pad.html +++ b/static/pad.html @@ -170,6 +170,7 @@
+
Successful!