From 8ed12c77761dfb3158487c39f4fca5eba5d0bab1 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 11 Apr 2015 21:22:00 +0100 Subject: [PATCH] session key is now ignored and also padOptions are available in settings --- .gitignore | 1 + settings.json.template | 15 +++++++++++++++ src/node/handler/PadMessageHandler.js | 1 + src/node/utils/Settings.js | 17 +++++++++++++++++ src/static/js/pad.js | 15 ++++++++++++++- 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c6ec3f9fb..52d60dca7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules settings.json !settings.json.template APIKEY.txt +SESSIONKEY.txt bin/abiword.exe bin/node.exe etherpad-lite-win.zip diff --git a/settings.json.template b/settings.json.template index 039413d13..39c383eda 100644 --- a/settings.json.template +++ b/settings.json.template @@ -49,6 +49,21 @@ //the default text of a pad "defaultPadText" : "Welcome to Etherpad!\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\nGet involved with Etherpad at http:\/\/etherpad.org\n", + + /* Default Pad behavior, users can override by changing */ + "padOptions": { + "noColors": false, + "showControls": true, + "showChat": true, + "showLineNumbers": true, + "useMonospaceFont": false, + "userName": false, + "userColor": false, + "rtl": false, + "alwaysShowChat": false, + "chatAndUsers": false, + "lang": "en-gb" + }, /* Shoud we suppress errors from being visible in the default Pad Text? */ "suppressErrorsInPadText" : false, diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index c210ab2b3..e15af1a46 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1182,6 +1182,7 @@ function handleClientReady(client, message) "userIsGuest": true, "userColor": authorColorId, "padId": message.padId, + "padOptions": settings.padOptions, "initialTitle": "Pad: " + message.padId, "opts": {}, // tell the client the number of the latest chat-message, which will be diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index bd15a2dfd..3886e6453 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -84,6 +84,23 @@ exports.dbSettings = { "filename" : path.join(exports.root, "dirty.db") }; */ exports.defaultPadText = "Welcome to Etherpad!\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 on Github: http:\/\/j.mp/ep-lite\n"; +/** + * The default Pad Settings for a user (Can be overridden by changing the setting + */ +exports.padOptions = { + "noColors": false, + "showControls": true, + "showChat": true, + "showLineNumbers": true, + "useMonospaceFont": false, + "userName": false, + "userColor": false, + "rtl": false, + "alwaysShowChat": false, + "chatAndUsers": false, + "lang": "en-gb" +} + /** * The toolbar buttons and order. */ diff --git a/src/static/js/pad.js b/src/static/js/pad.js index f1de80f0f..a2c76c08c 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -126,6 +126,18 @@ var getParameters = [ function getParams() { + // Tries server enforced options first.. + for(var i = 0; i < getParameters.length; i++) + { + var setting = getParameters[i]; + var value = clientVars.padOptions[setting.name]; + if(value.toString() === setting.checkVal) + { + setting.callback(value); + } + } + + // Then URL applied stuff var params = getUrlVars() for(var i = 0; i < getParameters.length; i++) @@ -475,7 +487,6 @@ var pad = { { // start the custom js if (typeof customStart == "function") customStart(); - getParams(); handshake(); // To use etherpad you have to allow cookies. @@ -495,6 +506,8 @@ var pad = { //initialize the chat chat.init(this); + getParams(); + padcookie.init(); // initialize the cookies pad.initTime = +(new Date()); pad.padOptions = clientVars.initialOptions;