mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Settings.js: trivial reformatting
This commit is contained in:
parent
ee4a27d10e
commit
d526c5ccca
1 changed files with 35 additions and 52 deletions
|
@ -287,29 +287,26 @@ exports.scrollWhenFocusLineIsOutOfViewport = {
|
||||||
//checks if abiword is avaiable
|
//checks if abiword is avaiable
|
||||||
exports.abiwordAvailable = function()
|
exports.abiwordAvailable = function()
|
||||||
{
|
{
|
||||||
if(exports.abiword != null)
|
if (exports.abiword != null) {
|
||||||
{
|
|
||||||
return os.type().indexOf("Windows") != -1 ? "withoutPDF" : "yes";
|
return os.type().indexOf("Windows") != -1 ? "withoutPDF" : "yes";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return "no";
|
return "no";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.sofficeAvailable = function () {
|
exports.sofficeAvailable = function() {
|
||||||
if(exports.soffice != null) {
|
if (exports.soffice != null) {
|
||||||
return os.type().indexOf("Windows") != -1 ? "withoutPDF": "yes";
|
return os.type().indexOf("Windows") != -1 ? "withoutPDF": "yes";
|
||||||
} else {
|
} else {
|
||||||
return "no";
|
return "no";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.exportAvailable = function () {
|
exports.exportAvailable = function() {
|
||||||
var abiword = exports.abiwordAvailable();
|
var abiword = exports.abiwordAvailable();
|
||||||
var soffice = exports.sofficeAvailable();
|
var soffice = exports.sofficeAvailable();
|
||||||
|
|
||||||
if(abiword == "no" && soffice == "no") {
|
if (abiword == "no" && soffice == "no") {
|
||||||
return "no";
|
return "no";
|
||||||
} else if ((abiword == "withoutPDF" && soffice == "no") || (abiword == "no" && soffice == "withoutPDF")) {
|
} else if ((abiword == "withoutPDF" && soffice == "no") || (abiword == "no" && soffice == "withoutPDF")) {
|
||||||
return "withoutPDF";
|
return "withoutPDF";
|
||||||
|
@ -321,8 +318,7 @@ exports.exportAvailable = function () {
|
||||||
// Provide git version if available
|
// Provide git version if available
|
||||||
exports.getGitCommit = function() {
|
exports.getGitCommit = function() {
|
||||||
var version = "";
|
var version = "";
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
var rootPath = path.resolve(npm.dir, '..');
|
var rootPath = path.resolve(npm.dir, '..');
|
||||||
if (fs.lstatSync(rootPath + '/.git').isFile()) {
|
if (fs.lstatSync(rootPath + '/.git').isFile()) {
|
||||||
rootPath = fs.readFileSync(rootPath + '/.git', "utf8");
|
rootPath = fs.readFileSync(rootPath + '/.git', "utf8");
|
||||||
|
@ -334,9 +330,7 @@ exports.getGitCommit = function() {
|
||||||
var refPath = rootPath + "/" + ref.substring(5, ref.indexOf("\n"));
|
var refPath = rootPath + "/" + ref.substring(5, ref.indexOf("\n"));
|
||||||
version = fs.readFileSync(refPath, "utf-8");
|
version = fs.readFileSync(refPath, "utf-8");
|
||||||
version = version.substring(0, 7);
|
version = version.substring(0, 7);
|
||||||
}
|
} catch(e) {
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
console.warn("Can't get git version for server header\n" + e.message)
|
console.warn("Can't get git version for server header\n" + e.message)
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
@ -355,19 +349,19 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
var credentialsFilename = absolutePaths.makeAbsolute(argv.credentials || "credentials.json");
|
var credentialsFilename = absolutePaths.makeAbsolute(argv.credentials || "credentials.json");
|
||||||
|
|
||||||
var settingsStr, credentialsStr;
|
var settingsStr, credentialsStr;
|
||||||
try{
|
try {
|
||||||
//read the settings sync
|
//read the settings sync
|
||||||
settingsStr = fs.readFileSync(settingsFilename).toString();
|
settingsStr = fs.readFileSync(settingsFilename).toString();
|
||||||
console.info(`Settings loaded from: ${settingsFilename}`);
|
console.info(`Settings loaded from: ${settingsFilename}`);
|
||||||
} catch(e){
|
} catch(e) {
|
||||||
console.warn(`No settings file found in ${settingsFilename}. Continuing using defaults!`);
|
console.warn(`No settings file found in ${settingsFilename}. Continuing using defaults!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try {
|
||||||
//read the credentials sync
|
//read the credentials sync
|
||||||
credentialsStr = fs.readFileSync(credentialsFilename).toString();
|
credentialsStr = fs.readFileSync(credentialsFilename).toString();
|
||||||
console.info(`Credentials file read from: ${credentialsFilename}`);
|
console.info(`Credentials file read from: ${credentialsFilename}`);
|
||||||
} catch(e){
|
} catch(e) {
|
||||||
// Doesn't matter if no credentials file found..
|
// Doesn't matter if no credentials file found..
|
||||||
console.info(`No credentials file found in ${credentialsFilename}. Ignoring.`);
|
console.info(`No credentials file found in ${credentialsFilename}. Ignoring.`);
|
||||||
}
|
}
|
||||||
|
@ -376,68 +370,58 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
var settings;
|
var settings;
|
||||||
var credentials;
|
var credentials;
|
||||||
try {
|
try {
|
||||||
if(settingsStr) {
|
if (settingsStr) {
|
||||||
settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
|
settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
|
||||||
settings = JSON.parse(settingsStr);
|
settings = JSON.parse(settingsStr);
|
||||||
}
|
}
|
||||||
}catch(e){
|
} catch(e) {
|
||||||
console.error(`There was an error processing your settings file from ${settingsFilename}:` + e.message);
|
console.error(`There was an error processing your settings file from ${settingsFilename}:` + e.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(credentialsStr) {
|
if (credentialsStr) {
|
||||||
credentialsStr = jsonminify(credentialsStr).replace(",]","]").replace(",}","}");
|
credentialsStr = jsonminify(credentialsStr).replace(",]","]").replace(",}","}");
|
||||||
credentials = JSON.parse(credentialsStr);
|
credentials = JSON.parse(credentialsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//loop trough the settings
|
//loop trough the settings
|
||||||
for(var i in settings)
|
for (var i in settings) {
|
||||||
{
|
|
||||||
//test if the setting start with a lowercase character
|
//test if the setting start with a lowercase character
|
||||||
if(i.charAt(0).search("[a-z]") !== 0)
|
if (i.charAt(0).search("[a-z]") !== 0) {
|
||||||
{
|
|
||||||
console.warn(`Settings should start with a lowercase character: '${i}'`);
|
console.warn(`Settings should start with a lowercase character: '${i}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
//we know this setting, so we overwrite it
|
//we know this setting, so we overwrite it
|
||||||
//or it's a settings hash, specific to a plugin
|
//or it's a settings hash, specific to a plugin
|
||||||
if(exports[i] !== undefined || i.indexOf('ep_')==0)
|
if (exports[i] !== undefined || i.indexOf('ep_') == 0) {
|
||||||
{
|
|
||||||
if (_.isObject(settings[i]) && !_.isArray(settings[i])) {
|
if (_.isObject(settings[i]) && !_.isArray(settings[i])) {
|
||||||
exports[i] = _.defaults(settings[i], exports[i]);
|
exports[i] = _.defaults(settings[i], exports[i]);
|
||||||
} else {
|
} else {
|
||||||
exports[i] = settings[i];
|
exports[i] = settings[i];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
//this setting is unkown, output a warning and throw it away
|
// this setting is unknown, output a warning and throw it away
|
||||||
else
|
|
||||||
{
|
|
||||||
console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
|
console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//loop trough the settings
|
//loop trough the settings
|
||||||
for(var i in credentials)
|
for (var i in credentials) {
|
||||||
{
|
|
||||||
//test if the setting start with a lowercase character
|
//test if the setting start with a lowercase character
|
||||||
if(i.charAt(0).search("[a-z]") !== 0)
|
if (i.charAt(0).search("[a-z]") !== 0) {
|
||||||
{
|
|
||||||
console.warn(`Settings should start with a lowercase character: '${i}'`);
|
console.warn(`Settings should start with a lowercase character: '${i}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
//we know this setting, so we overwrite it
|
//we know this setting, so we overwrite it
|
||||||
//or it's a settings hash, specific to a plugin
|
//or it's a settings hash, specific to a plugin
|
||||||
if(exports[i] !== undefined || i.indexOf('ep_')==0)
|
if (exports[i] !== undefined || i.indexOf('ep_') == 0) {
|
||||||
{
|
|
||||||
if (_.isObject(credentials[i]) && !_.isArray(credentials[i])) {
|
if (_.isObject(credentials[i]) && !_.isArray(credentials[i])) {
|
||||||
exports[i] = _.defaults(credentials[i], exports[i]);
|
exports[i] = _.defaults(credentials[i], exports[i]);
|
||||||
} else {
|
} else {
|
||||||
exports[i] = credentials[i];
|
exports[i] = credentials[i];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
//this setting is unkown, output a warning and throw it away
|
// this setting is unknown, output a warning and throw it away
|
||||||
else
|
|
||||||
{
|
|
||||||
console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
|
console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,14 +467,13 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
console.info(`Using skin "${exports.skinName}" in dir: ${skinPath}`);
|
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) {
|
||||||
{
|
|
||||||
fs.exists(exports.abiword, function(exists) {
|
fs.exists(exports.abiword, function(exists) {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
var abiwordError = "Abiword does not exist at this path, check your settings file";
|
var abiwordError = "Abiword does not exist at this path, check your settings file";
|
||||||
if(!exports.suppressErrorsInPadText){
|
if (!exports.suppressErrorsInPadText) {
|
||||||
exports.defaultPadText = exports.defaultPadText + "\nError: " + abiwordError + suppressDisableMsg;
|
exports.defaultPadText = exports.defaultPadText + "\nError: " + abiwordError + suppressDisableMsg;
|
||||||
}
|
}
|
||||||
console.error(abiwordError);
|
console.error(abiwordError);
|
||||||
|
@ -500,12 +483,12 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(exports.soffice) {
|
if (exports.soffice) {
|
||||||
fs.exists(exports.soffice, function (exists) {
|
fs.exists(exports.soffice, function(exists) {
|
||||||
if(!exists) {
|
if (!exists) {
|
||||||
var sofficeError = "SOffice does not exist at this path, check your settings file";
|
var sofficeError = "SOffice does not exist at this path, check your settings file";
|
||||||
|
|
||||||
if(!exports.suppressErrorsInPadText) {
|
if (!exports.suppressErrorsInPadText) {
|
||||||
exports.defaultPadText = exports.defaultPadText + "\nError: " + sofficeError + suppressDisableMsg;
|
exports.defaultPadText = exports.defaultPadText + "\nError: " + sofficeError + suppressDisableMsg;
|
||||||
}
|
}
|
||||||
console.error(sofficeError);
|
console.error(sofficeError);
|
||||||
|
@ -528,9 +511,9 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
console.warn("Declaring the sessionKey in the settings.json is deprecated. This value is auto-generated now. Please remove the setting from the file.");
|
console.warn("Declaring the sessionKey in the settings.json is deprecated. This value is auto-generated now. Please remove the setting from the file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(exports.dbType === "dirty"){
|
if (exports.dbType === "dirty") {
|
||||||
var dirtyWarning = "DirtyDB is used. This is fine for testing but not recommended for production.";
|
var dirtyWarning = "DirtyDB is used. This is fine for testing but not recommended for production.";
|
||||||
if(!exports.suppressErrorsInPadText){
|
if (!exports.suppressErrorsInPadText) {
|
||||||
exports.defaultPadText = exports.defaultPadText + "\nWarning: " + dirtyWarning + suppressDisableMsg;
|
exports.defaultPadText = exports.defaultPadText + "\nWarning: " + dirtyWarning + suppressDisableMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue