diff --git a/bin/installDeps.sh b/bin/installDeps.sh index 9f691e0af..4e268caa5 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -41,20 +41,6 @@ if [ ! $NODE_V_MINOR = "v0.8" ] && [ ! $NODE_V_MINOR = "v0.6" ]; then exit 1 fi -#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..." ( mkdir -p node_modules diff --git a/bin/installOnWindows.bat b/bin/installOnWindows.bat index 159c517f9..aeef16ef2 100644 --- a/bin/installOnWindows.bat +++ b/bin/installOnWindows.bat @@ -30,9 +30,5 @@ echo _ echo Clearing cache. del /S var\minified* -echo _ -echo Setting up settings.json... -IF NOT EXIST settings.json copy settings.json.template settings.json - echo _ echo Installed Etherpad-lite! \ No newline at end of file diff --git a/settings.json.template b/settings.json.template deleted file mode 100644 index 7d175a34e..000000000 --- a/settings.json.template +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file must be valid JSON. But comments are allowed - - Please edit settings.json, not settings.json.template -*/ -{ - //Ip and port which etherpad should bind at - "ip": "0.0.0.0", - "port" : 9001, - - //The Type of the database. You can choose between dirty, postgres, sqlite and mysql - //You shouldn't use "dirty" for for anything else than testing or development - "dbType" : "dirty", - //the database specific settings - "dbSettings" : { - "filename" : "var/dirty.db" - }, - - /* An Example of MySQL Configuration - "dbType" : "mysql", - "dbSettings" : { - "user" : "root", - "host" : "localhost", - "password": "", - "database": "store" - }, - */ - - //the default text of a pad - "defaultPadText" : "Welcome to Etherpad Lite!\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 Lite on Github: http:\/\/j.mp/ep-lite\n", - - /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */ - "requireSession" : false, - - /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */ - "editOnly" : false, - - /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, - but makes it impossible to debug the javascript/css */ - "minify" : true, - - /* How long may clients use served javascript code (in seconds)? Without versioning this - may cause problems during deployment. Set to 0 to disable caching */ - "maxAge" : 21600, // 60 * 60 * 6 = 6 hours - - /* This is the path to the Abiword executable. Setting it to null, disables abiword. - Abiword is needed to enable the import/export of pads*/ - "abiword" : null, - - /* This setting is used if you require authentication of all users. - Note: /admin always requires authentication. */ - "requireAuthentication": false, - - /* Require authorization by a module, or a user with is_admin set, see below. */ - "requireAuthorization": false, - - /* Users for basic authentication. is_admin = true gives access to /admin. - If you do not uncomment this, /admin will not be available! */ - /* - "users": { - "admin": { - "password": "changeme1", - "is_admin": true - }, - "user": { - "password": "changeme1", - "is_admin": false - } - }, - */ - - /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ - "loglevel": "INFO" -} diff --git a/settings.yml.example b/settings.yml.example new file mode 100644 index 000000000..ada16193b --- /dev/null +++ b/settings.yml.example @@ -0,0 +1,77 @@ +--- +#Ip and port which etherpad should bind at + +ip : 0.0.0.0 +port : 9001 + + +#The Type of the database. You can choose between dirty, postgres, sqlite and mysql +#You shouldn't use "dirty" for for anything else than testing or development +dbType : dirty + + +#the database specific settings +dbSettings : + filename : var/dirty.db + + +# An Example of MySQL Configuration +# dbType" : "mysql" +# dbSettings" : +# user : root +# host : localhost +# password : +# database : store + + +#the default text of a pad +defaultPadText : | + Welcome to Etherpad Lite! + This 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! + + Etherpad Lite on Github: http://j.mp/ep-lite + +# Users must have a session to access pads. This effectively allows only group pads to be accessed. +requireSession : false + +# Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. +editOnly : false + + +# if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, +# but makes it impossible to debug the javascript/css +minify : true + + +# How long may clients use served javascript code (in seconds)? Without versioning this +# may cause problems during deployment. Set to 0 to disable caching +# 60 * 60 * 6 = 6 hours +maxAge : 21600 + +# This is the path to the Abiword executable. Setting it to null, disables abiword. +# Abiword is needed to enable the import/export of pads +abiword : null + + +# This setting is used if you require authentication of all users. +# Note: /admin always requires authentication. +requireAuthentication : false + + +# Require authorization by a module, or a user with is_admin set, see below. +requireAuthorization : false + + +# Users for basic authentication. is_admin = true gives access to /admin. +# If you do not uncomment this, /admin will not be available! + +# users: +# admin: { +# password : changeme1, +# is_admin : true +# user : +# password : changeme1, +# is_admin : false + +# The log level we are using, can be: DEBUG, INFO, WARN, ERROR +loglevel : INFO diff --git a/src/node/hooks/express.js b/src/node/hooks/express.js index 1f4a6f2cc..ad94bc0b5 100644 --- a/src/node/hooks/express.js +++ b/src/node/hooks/express.js @@ -36,7 +36,7 @@ exports.createServer = function () { console.log("The plugin admin page is at http://" + settings.ip + ":" + settings.port + "/admin/plugins"); } else{ - console.warn("Admin username and password not set in settings.json. To access admin please uncomment and edit 'users' in settings.json"); + console.warn("Admin username and password not set in settings.yml. To access admin please uncomment and edit 'users' in settings.yml"); } } diff --git a/src/node/hooks/express/importexport.js b/src/node/hooks/express/importexport.js index 9e78f34d7..67cb0755e 100644 --- a/src/node/hooks/express/importexport.js +++ b/src/node/hooks/express/importexport.js @@ -15,7 +15,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { //if abiword is disabled, and this is a format we only support with abiword, output a message if (settings.abiword == null && ["odt", "pdf", "doc"].indexOf(req.params.type) !== -1) { - res.send("Abiword is not enabled at this Etherpad Lite instance. Set the path to Abiword in settings.json to enable this feature"); + res.send("Abiword is not enabled at this Etherpad Lite instance. Set the path to Abiword in settings.yml to enable this feature"); return; } diff --git a/src/node/utils/Cli.js b/src/node/utils/Cli.js index 0c7947e91..fdf44b312 100644 --- a/src/node/utils/Cli.js +++ b/src/node/utils/Cli.js @@ -29,7 +29,7 @@ var arg, prevArg; for ( var i = 0; i < argv.length; i++ ) { arg = argv[i]; - // Override location of settings.json file + // Override location of settings.yml file if ( prevArg == '--settings' || prevArg == '-s' ) { exports.argv.settings = arg; } diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index e60446df4..11b8b09d0 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -1,5 +1,5 @@ /** - * The Settings Modul reads the settings out of settings.json and provides + * The Settings Modul reads the settings out of settings.yml and provides * this information to the other modules */ @@ -24,6 +24,7 @@ var os = require("os"); var path = require('path'); var argv = require('./Cli').argv; var npm = require("npm/lib/npm.js"); +var yaml = require('js-yaml'); /* Root path of the installation */ exports.root = path.normalize(path.join(npm.dir, "..")); @@ -101,7 +102,7 @@ exports.abiwordAvailable = function() } // Discover where the settings file lives -var settingsFilename = argv.settings || "settings.json"; +var settingsFilename = argv.settings || "settings.yml"; if (settingsFilename.charAt(0) != '/') { settingsFilename = path.normalize(path.join(root, settingsFilename)); } @@ -111,22 +112,18 @@ try{ //read the settings sync settingsStr = fs.readFileSync(settingsFilename).toString(); } catch(e){ - console.warn('No settings file found. Using defaults.'); - settingsStr = '{}'; + console.error('No settings file found. If you were using a settings.json file, cosider converting it using \'./bin/settings2yml settings.json > settings.yml\''); + process.exit(1); } -//remove all comments -settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,""); - -//try to parse the settings var settings; try { - settings = JSON.parse(settingsStr); + settings = yaml.load(settingsStr); } catch(e) { - console.error("There is a syntax error in your settings.json file"); + console.error("There is a syntax error in your settings.ym file"); console.error(e.message); process.exit(1); } diff --git a/src/package.json b/src/package.json index 002d05aba..0efb7c117 100644 --- a/src/package.json +++ b/src/package.json @@ -30,7 +30,8 @@ "graceful-fs" : "1.1.5", "slide" : "1.1.3", "semver" : "1.0.13", - "underscore" : "1.3.1" + "underscore" : "1.3.1", + "js-yaml" : "1.x" }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": {