mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
skins: the settings class understands skinName. Send skinName value to the client
skinName must be a single string (no directory separators in it) pointing to an existing directory under /src/static/skins. In case these conditions are not met, its value is rewritten to "no-skin". Also, the value of skinName if sent to the client via clientVars for allowing its use it in the browser.
This commit is contained in:
parent
7edc0fea16
commit
e34c74b24d
2 changed files with 45 additions and 0 deletions
|
@ -1268,6 +1268,7 @@ function handleClientReady(client, message)
|
||||||
// client is read only you would open a security hole 1 swedish
|
// client is read only you would open a security hole 1 swedish
|
||||||
// mile wide...
|
// mile wide...
|
||||||
var clientVars = {
|
var clientVars = {
|
||||||
|
"skinName": settings.skinName,
|
||||||
"accountPrivs": {
|
"accountPrivs": {
|
||||||
"maxRevisions": 100
|
"maxRevisions": 100
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,6 +47,14 @@ exports.favicon = "favicon.ico";
|
||||||
exports.faviconPad = "../" + exports.favicon;
|
exports.faviconPad = "../" + exports.favicon;
|
||||||
exports.faviconTimeslider = "../../" + exports.favicon;
|
exports.faviconTimeslider = "../../" + exports.favicon;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Skin name.
|
||||||
|
*
|
||||||
|
* Initialized to null, so we can spot an old configuration file and invite the
|
||||||
|
* user to update it before falling back to the default.
|
||||||
|
*/
|
||||||
|
exports.skinName = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IP ep-lite should listen to
|
* The IP ep-lite should listen to
|
||||||
*/
|
*/
|
||||||
|
@ -439,6 +447,42 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
process.env['DEBUG'] = 'socket.io:' + exports.loglevel; // Used by SocketIO for Debug
|
process.env['DEBUG'] = 'socket.io:' + exports.loglevel; // Used by SocketIO for Debug
|
||||||
log4js.replaceConsole();
|
log4js.replaceConsole();
|
||||||
|
|
||||||
|
if (!exports.skinName) {
|
||||||
|
console.warn(`No "skinName" parameter found. Please consult settings.json.template and update your settings.json. Falling back to the default "no-skin".`);
|
||||||
|
exports.skinName = "no-skin";
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks if skinName has an acceptable value, otherwise falls back to "no-skin"
|
||||||
|
if (exports.skinName) {
|
||||||
|
const skinBasePath = path.join(exports.root, "src", "static", "skins");
|
||||||
|
const countPieces = exports.skinName.split(path.sep).length;
|
||||||
|
|
||||||
|
if (countPieces != 1) {
|
||||||
|
console.error(`skinName must be the name of a directory under "${skinBasePath}". This is not valid: "${exports.skinName}". Falling back to the default "no-skin".`);
|
||||||
|
|
||||||
|
exports.skinName = "no-skin";
|
||||||
|
}
|
||||||
|
|
||||||
|
// informative variable, just for the log messages
|
||||||
|
var skinPath = path.normalize(path.join(skinBasePath, exports.skinName));
|
||||||
|
|
||||||
|
// what if someone sets skinName == ".." or "."? We catch him!
|
||||||
|
if (absolutePaths.isSubdir(skinBasePath, skinPath) === false) {
|
||||||
|
console.error(`Skin path ${skinPath} must be a subdirectory of ${skinBasePath}. Falling back to the default "no-skin".`);
|
||||||
|
|
||||||
|
exports.skinName = "no-skin";
|
||||||
|
skinPath = path.join(skinBasePath, exports.skinName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync(skinPath) === false) {
|
||||||
|
console.error(`Skin path ${skinPath} does not exist. Falling back to the default "no-skin".`);
|
||||||
|
exports.skinName = "no-skin";
|
||||||
|
skinPath = path.join(skinBasePath, exports.skinName);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info(`Using skin "${exports.skinName}" in dir: ${skinPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
if(exports.abiword){
|
if(exports.abiword){
|
||||||
// Check abiword actually exists
|
// Check abiword actually exists
|
||||||
if(exports.abiword != null)
|
if(exports.abiword != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue