diff --git a/.jsbeautifyrc b/.jsbeautifyrc index 2245d6adb6..5102dfec5f 100644 --- a/.jsbeautifyrc +++ b/.jsbeautifyrc @@ -5,7 +5,7 @@ "indent_with_tabs": false, "preserve_newlines": true, "max_preserve_newlines": 10, - "jslint_happy": false, + "jslint_happy": true, "brace_style": "collapse", "keep_array_indentation": false, "keep_function_indentation": false, diff --git a/.jshintrc b/.jshintrc index 1981c254c5..f5b67ad0bc 100644 --- a/.jshintrc +++ b/.jshintrc @@ -24,7 +24,7 @@ // "single" : require single quotes // "double" : require double quotes "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used + "unused" : false, // true: Require all defined variables be used TODO: Set this to true, update codebase. "strict" : true, // true: Requires all functions run in ES5 Strict Mode "trailing" : false, // true: Prohibit trailing whitespaces "maxparams" : false, // {int} Max number of formal params allowed per function diff --git a/app.js b/app.js index 546ea1c8a2..b0f0a02e9c 100644 --- a/app.js +++ b/app.js @@ -16,114 +16,115 @@ along with this program. If not, see . */ -// Configuration setup -nconf = require('nconf'); -nconf.argv().env(); +(function() { + "use strict"; -var fs = require('fs'), - winston = require('winston'), - pkg = require('./package.json'), - url = require('url'); + // Configuration setup + var nconf = require('nconf'); + nconf.argv().env(); -// Runtime environment -global.env = process.env.NODE_ENV || 'production'; + var fs = require('fs'), + winston = require('winston'), + pkg = require('./package.json'); + // Runtime environment + global.env = process.env.NODE_ENV || 'production'; + winston.remove(winston.transports.Console); + winston.add(winston.transports.Console, { + colorize: true + }); -winston.remove(winston.transports.Console); -winston.add(winston.transports.Console, { - colorize: true -}); - -winston.add(winston.transports.File, { - filename: 'error.log', - level: 'error' -}); - -// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed -winston.err = function(err) { - winston.error(err.stack); -}; + winston.add(winston.transports.File, { + filename: 'error.log', + level: 'error' + }); -// Log GNU copyright info along with server info -winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013 DesignCreatePlay Inc.'); -winston.info('This program comes with ABSOLUTELY NO WARRANTY.'); -winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); -winston.info(''); + // TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed + winston.err = function(err) { + winston.error(err.stack); + }; -if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.get('upgrade'))) { - // Load server-side config - nconf.file({ - file: __dirname + '/config.json' - }); + // Log GNU copyright info along with server info + winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013 DesignCreatePlay Inc.'); + winston.info('This program comes with ABSOLUTELY NO WARRANTY.'); + winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); + winston.info(''); var meta = require('./src/meta.js'); - nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/'); - nconf.set('upload_url', nconf.get('url') + 'uploads/'); + if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.get('upgrade'))) { + // Load server-side config + nconf.file({ + file: __dirname + '/config.json' + }); + + nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/'); + nconf.set('upload_url', nconf.get('url') + 'uploads/'); - winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using Redis store at ' + nconf.get('redis:host') + ':' + nconf.get('redis:port') + '.'); - if (process.env.NODE_ENV === 'development') winston.info('Base Configuration OK.'); + winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using Redis store at ' + nconf.get('redis:host') + ':' + nconf.get('redis:port') + '.'); - meta.configs.init(function() { - // Initial setup for Redis & Reds - var reds = require('reds'); - RDB = require('./src/redis.js'); - reds.createClient = function() { - return reds.client || (reds.client = RDB); + if (process.env.NODE_ENV === 'development') { + winston.info('Base Configuration OK.'); } - var categories = require('./src/categories.js'), - templates = require('./public/src/templates.js'), - webserver = require('./src/webserver.js'), - websockets = require('./src/websockets.js'), - plugins = require('./src/plugins'), // Don't remove this - plugins initializes itself - admin = { - 'categories': require('./src/admin/categories.js') - }; + meta.configs.init(function() { + // Initial setup for Redis & Reds + var reds = require('reds'), + RDB = require('./src/redis.js'); - global.templates = {}; - templates.init([ - 'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index', - 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext', - 'emails/header', 'emails/footer', + reds.createClient = function() { + return reds.client || (reds.client = RDB); + }; - 'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic' - ]); + var templates = require('./public/src/templates.js'), + webserver = require('./src/webserver.js'), + websockets = require('./src/websockets.js'), + plugins = require('./src/plugins'); // Don't remove this - plugins initializes itself + + global.templates = {}; + templates.init([ + 'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index', + 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext', + 'emails/header', 'emails/footer', + + 'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic' + ]); + + templates.ready(webserver.init); + }); + + } else if (nconf.get('upgrade')) { + nconf.file({ + file: __dirname + '/config.json' + }); + + meta.configs.init(function() { + require('./src/upgrade').upgrade(); + }); + } else { + // New install, ask setup questions + if (nconf.get('setup')) { + winston.info('NodeBB Setup Triggered via Command Line'); + } + else { + winston.warn('Configuration not found, starting NodeBB setup'); + } - templates.ready(webserver.init); - }); + var install = require('./src/install'); -} else if (nconf.get('upgrade')) { - nconf.file({ - file: __dirname + '/config.json' - }); - var meta = require('./src/meta.js'); + winston.info('Welcome to NodeBB!'); + winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.'); + winston.info('Press enter to accept the default setting (shown in brackets).'); - meta.configs.init(function() { - require('./src/upgrade').upgrade(); - }); -} else { - // New install, ask setup questions - if (nconf.get('setup')) winston.info('NodeBB Setup Triggered via Command Line'); - else winston.warn('Configuration not found, starting NodeBB setup'); - - var install = require('./src/install'), - meta = { - config: {} - }; - - winston.info('Welcome to NodeBB!'); - winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.'); - winston.info('Press enter to accept the default setting (shown in brackets).'); - - install.setup(function(err) { - if (err) { - winston.error('There was a problem completing NodeBB setup: ', err.message); - } else { - winston.info('NodeBB Setup Completed.'); - } + install.setup(function(err) { + if (err) { + winston.error('There was a problem completing NodeBB setup: ', err.message); + } else { + winston.info('NodeBB Setup Completed.'); + } - process.exit(); - }); -} \ No newline at end of file + process.exit(); + }); + } +}()); \ No newline at end of file diff --git a/package.json b/package.json index af8c787d61..d34cef3a13 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "main": "app.js", "dependencies": { - "socket.io": "~0.9.14", + "socket.io": "~0.9.16", "redis": "0.8.3", "express": "3.2.0", "express-namespace": "0.1.1", diff --git a/public/templates/followers.tpl b/public/templates/followers.tpl index f2fa798853..205355aef8 100644 --- a/public/templates/followers.tpl +++ b/public/templates/followers.tpl @@ -1,5 +1,5 @@ -
+