Merge commit '64f04670efd582230e693a1c6b3c91bc8df27299' into cleanup-ace-fix

Conflicts:
	static/js/ace2_inner.js
This commit is contained in:
Matthias Bartelmeß 2012-02-24 20:22:32 +01:00
commit 0191c248b5
9 changed files with 131 additions and 81 deletions

View File

@ -81,6 +81,8 @@ Here is the **[FAQ](https://github.com/Pita/etherpad-lite/wiki/FAQ)**
## Next Steps ## Next Steps
You can modify the settings in the file `settings.json` 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 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 You can update to the latest version with `git pull origin`. The next start with bin/run.sh will update the dependencies

View File

@ -40,10 +40,18 @@ if [ ! $(echo $NODE_VERSION | cut -d "." -f 1-2) = "v0.6" ]; then
exit 1 exit 1
fi fi
#Does a settings.json exist? if no copy the template #Get the name of the settings file
if [ ! -f "settings.json" ]; then settings="settings.json"
echo "Copy the settings template to settings.json..." a='';
cp -v settings.json.template settings.json || exit 1 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 fi
echo "Ensure that all dependencies are up to date..." echo "Ensure that all dependencies are up to date..."

View File

@ -21,9 +21,9 @@ if [ "$(id -u)" -eq 0 ]; then
fi fi
#prepare the enviroment #prepare the enviroment
bin/installDeps.sh || exit 1 bin/installDeps.sh $* || exit 1
#Move to the node folder and start #Move to the node folder and start
echo "start..." echo "start..."
cd "node" cd "node"
node server.js node server.js $*

38
node/utils/Cli.js Normal file
View File

@ -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;
}

View File

@ -22,6 +22,7 @@
var fs = require("fs"); var fs = require("fs");
var os = require("os"); var os = require("os");
var path = require('path'); var path = require('path');
var argv = require('./Cli').argv;
/** /**
* The IP ep-lite should listen to * 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 //read the settings sync
var settingsPath = path.normalize(__dirname + "/../../"); var settingsStr = fs.readFileSync(settingsPath + settingsFilename).toString();
var settingsStr = fs.readFileSync(settingsPath + "settings.json").toString();
//remove all comments //remove all comments
settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,""); settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,"");

View File

@ -1,5 +1,8 @@
/* /*
You may have to use !important to override css attributs, for example: custom css files are loaded after core css files. Simply use the same selector to override a style.
Example:
* {color: blue !important;} #editbar LI {border:1px solid #000;}
overrides
#editbar LI {border:1px solid #d5d5d5;}
from pad.css
*/ */

View File

@ -891,57 +891,45 @@ function Ace2Inner(){
} }
}; };
// 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) editorInfo.ace_setProperty = function(key, value)
{ {
var k = key.toLowerCase();
if (k == "wraps") // Convinience function returning a setter for a class on an element
{ var setClassPresenceNamed = function(element, cls){
setWraps(value); return function(value){
} setClassPresence(element, cls, !! value)
else if (k == "showsauthorcolors") }
{ };
setClassPresence(root, "authorColors", !! value);
} // These properties are exposed
else if (k == "showsuserselections") var setters = {
{ wraps: setWraps,
setClassPresence(root, "userSelections", !! value); showsauthorcolors: setClassPresenceNamed(root, "authorColors"),
} showsuserselections: setClassPresenceNamed(root, "userSelections"),
else if (k == "showslinenumbers") showslinenumbers : function(value){
{ hasLineNumbers = !! value;
hasLineNumbers = !! value; // disable line numbers on mobile devices
// disable line numbers on mobile devices if (browser.mobile) hasLineNumbers = false;
if (browser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers);
setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView();
fixView(); },
} grayedout: setClassPresenceNamed(outerWin.document.body, "grayedout"),
else if (k == "grayedout") dmesg: function(){ dmesg = window.dmesg = value; },
{ userauthor: function(value){ thisAuthor = String(value); },
setClassPresence(outerWin.document.body, "grayedout", !! value); styled: setStyled,
} textface: setTextFace,
else if (k == "dmesg") textsize: setTextSize,
{ rtlistrue: setClassPresenceNamed(root, "rtl")
dmesg = value; };
window.dmesg = value;
} var setter = setters[key.toLowerCase()];
else if (k == 'userauthor')
{ // check if setter is present
thisAuthor = String(value); if(setter !== undefined){
} setter(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);
} }
}; };
@ -5596,16 +5584,19 @@ function Ace2Inner(){
{ {
var newNumLines = rep.lines.length(); var newNumLines = rep.lines.length();
if (newNumLines < 1) newNumLines = 1; 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) if (currentCallStack && currentCallStack.domClean)
{ {
var a = sideDivInner.firstChild;
var b = doc.body.firstChild;
var n = 0;
while (a && b) while (a && b)
{ {
if(n > lineNumbersShown) //all updated, break if(n > lineNumbersShown) //all updated, break
break; break;
var h = (b.clientHeight || b.offsetHeight); var h = (b.clientHeight || b.offsetHeight);
if (b.nextSibling) if (b.nextSibling)
@ -5621,12 +5612,12 @@ function Ace2Inner(){
{ {
var hpx = h + "px"; var hpx = h + "px";
if (a.style.height != hpx) { if (a.style.height != hpx) {
a.style.height = hpx; a.style.height = hpx;
} }
} }
a = a.nextSibling; a = a.nextSibling;
b = b.nextSibling; b = b.nextSibling;
n++; n++;
} }
} }
@ -5640,17 +5631,20 @@ function Ace2Inner(){
lineNumbersShown++; lineNumbersShown++;
var n = lineNumbersShown; var n = lineNumbersShown;
var div = odoc.createElement("DIV"); var div = odoc.createElement("DIV");
//calculate height for new line number //calculate height for new line number
var h = (b.clientHeight || b.offsetHeight); var h = (b.clientHeight || b.offsetHeight);
if (b.nextSibling)
h = b.nextSibling.offsetTop - b.offsetTop; if (b.nextSibling)
if(h) // apply style to div h = b.nextSibling.offsetTop - b.offsetTop;
div.style.height = h +"px";
if(h) // apply style to div
div.style.height = h +"px";
div.appendChild(odoc.createTextNode(String(n))); div.appendChild(odoc.createTextNode(String(n)));
fragment.appendChild(div); fragment.appendChild(div);
b = b.nextSibling; b = b.nextSibling;
} }
container.appendChild(fragment); container.appendChild(fragment);
while (lineNumbersShown > newNumLines) while (lineNumbersShown > newNumLines)
{ {
@ -5659,7 +5653,7 @@ function Ace2Inner(){
} }
} }
} }
};
exports.editor = new Ace2Inner(); }
exports.editor = new Ace2Inner();

View File

@ -92,7 +92,7 @@ var chat = (function()
return 'z' + c.charCodeAt(0) + 'z'; 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 */ /* Performs an action if your name is mentioned */
var myName = $('#myusernameedit').val(); var myName = $('#myusernameedit').val();

View File

@ -170,6 +170,7 @@
<input type="file" name="file" size="15" id="importfileinput"> <input type="file" name="file" size="15" id="importfileinput">
<div class="importmessage" id="importmessagefail"></div> <div class="importmessage" id="importmessagefail"></div>
</div> </div>
<div id="import"></div>
<div class="importmessage" id="importmessagesuccess">Successful!</div> <div class="importmessage" id="importmessagesuccess">Successful!</div>
<div class="importformdiv" id="importformsubmitdiv"> <div class="importformdiv" id="importformsubmitdiv">
<input type="hidden" name="padId" value="blpmaXT35R"> <input type="hidden" name="padId" value="blpmaXT35R">