From ccca4d2914269f61b066adaf398f8fcad9de371c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 18 Sep 2013 12:15:29 -0400 Subject: [PATCH 1/3] fixed issue where meta was called before nconf loaded --- app.js | 28 ++++++------ src/install.js | 120 ++++++++++++++++++++++++++++--------------------- 2 files changed, 82 insertions(+), 66 deletions(-) diff --git a/app.js b/app.js index b0f0a02e9c..39476d7015 100644 --- a/app.js +++ b/app.js @@ -16,7 +16,7 @@ along with this program. If not, see . */ -(function() { +(function () { "use strict"; // Configuration setup @@ -25,7 +25,8 @@ var fs = require('fs'), winston = require('winston'), - pkg = require('./package.json'); + pkg = require('./package.json'), + meta; // Runtime environment global.env = process.env.NODE_ENV || 'production'; @@ -41,7 +42,7 @@ }); // TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed - winston.err = function(err) { + winston.err = function (err) { winston.error(err.stack); }; @@ -51,13 +52,13 @@ winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); winston.info(''); - var meta = require('./src/meta.js'); if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.get('upgrade'))) { - // Load server-side config + // Load server-side configs nconf.file({ file: __dirname + '/config.json' }); + 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/'); @@ -68,12 +69,12 @@ winston.info('Base Configuration OK.'); } - meta.configs.init(function() { + meta.configs.init(function () { // Initial setup for Redis & Reds var reds = require('reds'), RDB = require('./src/redis.js'); - reds.createClient = function() { + reds.createClient = function () { return reds.client || (reds.client = RDB); }; @@ -95,19 +96,16 @@ }); } else if (nconf.get('upgrade')) { - nconf.file({ - file: __dirname + '/config.json' - }); + meta = require('./src/meta.js'); - meta.configs.init(function() { + 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 { + } else { winston.warn('Configuration not found, starting NodeBB setup'); } @@ -117,7 +115,7 @@ 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) { + install.setup(function (err) { if (err) { winston.error('There was a problem completing NodeBB setup: ', err.message); } else { @@ -127,4 +125,4 @@ process.exit(); }); } -}()); \ No newline at end of file +}()); diff --git a/src/install.js b/src/install.js index d947ac4a5d..7889a94aec 100644 --- a/src/install.js +++ b/src/install.js @@ -6,7 +6,7 @@ var async = require('async'), prompt = require('prompt'), winston = require('winston'), reds = require('reds'), - nconf = require('nconf'); + nconf = require('nconf'), install = { questions: [{ @@ -41,16 +41,18 @@ var async = require('async'), name: 'redis:password', description: 'Password of your Redis database' }], - setup: function(callback) { + setup: function (callback) { async.series([ - function(next) { + function (next) { // prompt prepends "prompt: " to questions, let's clear that. prompt.start(); prompt.message = ''; prompt.delimiter = ''; - prompt.get(install.questions, function(err, config) { - if (!config) return next(new Error('aborted')); + prompt.get(install.questions, function (err, config) { + if (!config) { + return next(new Error('aborted')); + } // Translate redis properties into redis object config.redis = { @@ -63,9 +65,9 @@ var async = require('async'), delete config['redis:password']; // Add hardcoded values - config['bcrypt_rounds'] = 12, - config['upload_path'] = '/public/uploads'; - config['use_port'] = (config['use_port'].slice(0, 1) === 'y') ? true : false; + config.bcrypt_rounds = 12; + config.upload_path = '/public/uploads'; + config.use_port = (config.use_port.slice(0, 1) === 'y') ? true : false; var urlObject = url.parse(config.base_url), relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '', @@ -86,9 +88,9 @@ var async = require('async'), install.save(server_conf, client_conf, next); }); }, - function(next) { + function (next) { // Applying default database configs - winston.info('Populating database with default configs, if not already set...') + winston.info('Populating database with default configs, if not already set...'); var meta = require('./meta'), defaults = [{ field: 'postDelay', @@ -113,48 +115,57 @@ var async = require('async'), value: '' }]; - async.each(defaults, function(configObj, next) { + async.each(defaults, function (configObj, next) { meta.configs.setOnEmpty(configObj.field, configObj.value, next); - }, function(err) { + }, function (err) { meta.configs.init(next); }); }, - function(next) { + function (next) { // Check if an administrator needs to be created var Groups = require('./groups'); - Groups.getGidFromName('Administrators', function(err, gid) { - if (err) return next(err.message); + Groups.getGidFromName('Administrators', function (err, gid) { + if (err) { + return next(err.message); + } if (gid) { - Groups.get(gid, {}, function(err, groupObj) { + Groups.get(gid, {}, function (err, groupObj) { if (groupObj.count > 0) { winston.info('Administrator found, skipping Admin setup'); next(); - } else install.createAdmin(next); + } else { + install.createAdmin(next); + } }); - } else install.createAdmin(next); + } else { + install.createAdmin(next); + } }); }, - function(next) { + function (next) { // Categories var Categories = require('./categories'), admin = { categories: require('./admin/categories') }; - categories.getAllCategories(function(data) { + Categories.getAllCategories(function (data) { if (data.categories.length === 0) { - winston.warn('No categories found, populating instance with default categories') + winston.warn('No categories found, populating instance with default categories'); - fs.readFile(path.join(__dirname, '../', 'install/data/categories.json'), function(err, default_categories) { + fs.readFile(path.join(__dirname, '../', 'install/data/categories.json'), function (err, default_categories) { default_categories = JSON.parse(default_categories); - async.eachSeries(default_categories, function(category, next) { + async.eachSeries(default_categories, function (category, next) { admin.categories.create(category, next); - }, function(err) { - if (!err) next(); - else winston.error('Could not set up categories'); + }, function (err) { + if (!err) { + next(); + } else { + winston.error('Could not set up categories'); + } }); }); } else { @@ -163,7 +174,7 @@ var async = require('async'), } }); }, - function(next) { + function (next) { // Default plugins var Plugins = require('./plugins'); @@ -173,24 +184,28 @@ var async = require('async'), 'nodebb-plugin-markdown', 'nodebb-plugin-mentions' ]; - async.each(defaultEnabled, function(pluginId, next) { - Plugins.isActive(pluginId, function(err, active) { + async.each(defaultEnabled, function (pluginId, next) { + Plugins.isActive(pluginId, function (err, active) { if (!active) { - Plugins.toggleActive(pluginId, function() { + Plugins.toggleActive(pluginId, function () { next(); }); - } else next(); - }) + } else { + next(); + } + }); }, next); } - ], function(err) { + ], function (err) { if (err) { winston.warn('NodeBB Setup Aborted.'); process.exit(); - } else callback(); + } else { + callback(); + } }); }, - createAdmin: function(callback) { + createAdmin: function (callback) { var User = require('./user'), Groups = require('./groups'); @@ -212,21 +227,24 @@ var async = require('async'), hidden: true, type: 'string' }], - getAdminInfo = function(callback) { - prompt.get(questions, function(err, results) { - if (!results) return callback(new Error('aborted')); + getAdminInfo = function (callback) { + prompt.get(questions, function (err, results) { + if (!results) { + return callback(new Error('aborted')); + } nconf.set('bcrypt_rounds', 12); - User.create(results.username, results.password, results.email, function(err, uid) { + User.create(results.username, results.password, results.email, function (err, uid) { if (err) { winston.warn(err.message + ' Please try again.'); return getAdminInfo(); } - Groups.getGidFromName('Administrators', function(err, gid) { - if (gid) Groups.join(gid, uid, callback); - else { - Groups.create('Administrators', 'Forum Administrators', function(err, groupObj) { + Groups.getGidFromName('Administrators', function (err, gid) { + if (gid) { + Groups.join(gid, uid, callback); + } else { + Groups.create('Administrators', 'Forum Administrators', function (err, groupObj) { Groups.join(groupObj.gid, uid, callback); }); } @@ -237,20 +255,20 @@ var async = require('async'), getAdminInfo(callback); }, - save: function(server_conf, client_conf, callback) { + save: function (server_conf, client_conf, callback) { // Server Config async.parallel([ - function(next) { - fs.writeFile(path.join(__dirname, '../', 'config.json'), JSON.stringify(server_conf, null, 4), function(err) { + function (next) { + fs.writeFile(path.join(__dirname, '../', 'config.json'), JSON.stringify(server_conf, null, 4), function (err) { next(err); }); }, - function(next) { - fs.writeFile(path.join(__dirname, '../', 'public', 'config.json'), JSON.stringify(client_conf, null, 4), function(err) { + function (next) { + fs.writeFile(path.join(__dirname, '../', 'public', 'config.json'), JSON.stringify(client_conf, null, 4), function (err) { next(err); }); } - ], function(err) { + ], function (err) { winston.info('Configuration Saved OK'); nconf.file({ @@ -258,9 +276,9 @@ var async = require('async'), }); var RDB = require('./redis'); - reds.createClient = function() { + reds.createClient = function () { return reds.client || (reds.client = RDB); - } + }; callback(err); }); From 8ec3371139779b57dd3773f693b88a563a8f1d3c Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 18 Sep 2013 12:45:31 -0400 Subject: [PATCH 2/3] cerulean theme: new users view --- app.js | 2 +- public/templates/users.tpl | 22 +++++++------ public/themes/cerulean/users.less | 52 ++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index 39476d7015..33c765a012 100644 --- a/app.js +++ b/app.js @@ -125,4 +125,4 @@ process.exit(); }); } -}()); +}()); \ No newline at end of file diff --git a/public/templates/users.tpl b/public/templates/users.tpl index 5cf004d8b4..363c853257 100644 --- a/public/templates/users.tpl +++ b/public/templates/users.tpl @@ -23,16 +23,18 @@ -
- {users.username} -
-
- {users.reputation} - -
-
- {users.postcount} - +
+
diff --git a/public/themes/cerulean/users.less b/public/themes/cerulean/users.less index 36736bfccb..097e697139 100644 --- a/public/themes/cerulean/users.less +++ b/public/themes/cerulean/users.less @@ -1 +1,51 @@ -@import "../vanilla/users"; \ No newline at end of file +@import "../vanilla/users"; + +.users { + .users-container { + padding-top: 20px; // might be better off in vanilla + padding-left: 6px; + } + + .users-box { + padding: 0; + margin: 0px; + margin-left: -6px; // todo: check why do I have to do this? + max-width: 164px; + width: 164px; + height: 164px; + + a { + padding: 0; + margin: 0; + + img { + padding: 0; + margin: 0; + width: 164px; + height: 164px; + border: 1px solid #777; + border-radius: 0; + + } + } + + position: relative; + .user-info { + background: rgba(0,0,0,0.65); + padding: 2px; + position: absolute; + bottom: 0px; + width: 164px; + a, span, i { + color: white; + } + a { + font-weight: 700; + } + } + + .post-count, .reputation { + display: inline-block; + } + } +} \ No newline at end of file From 0d55f2ef32856a85bd4678bd59aa18d78fdeb675 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 18 Sep 2013 14:47:38 -0400 Subject: [PATCH 3/3] cerulean: switched to lucida grande / tahoma --- public/themes/cerulean/style.less | 2 ++ public/themes/cerulean/users.less | 12 ++++++------ public/themes/vanilla/home.less | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/public/themes/cerulean/style.less b/public/themes/cerulean/style.less index c32476509f..a32751e9e1 100644 --- a/public/themes/cerulean/style.less +++ b/public/themes/cerulean/style.less @@ -2,6 +2,8 @@ body { background: #fdfdfd; + font-family: 'lucida grande',tahoma,verdana,arial,sans-serif; + font-size: 16px; } .jumbotron { diff --git a/public/themes/cerulean/users.less b/public/themes/cerulean/users.less index 097e697139..3b188629db 100644 --- a/public/themes/cerulean/users.less +++ b/public/themes/cerulean/users.less @@ -10,9 +10,9 @@ padding: 0; margin: 0px; margin-left: -6px; // todo: check why do I have to do this? - max-width: 164px; - width: 164px; - height: 164px; + max-width: 163px; + width: 163px; + height: 163px; a { padding: 0; @@ -21,8 +21,8 @@ img { padding: 0; margin: 0; - width: 164px; - height: 164px; + width: 163px; + height: 163px; border: 1px solid #777; border-radius: 0; @@ -35,7 +35,7 @@ padding: 2px; position: absolute; bottom: 0px; - width: 164px; + width: 163px; a, span, i { color: white; } diff --git a/public/themes/vanilla/home.less b/public/themes/vanilla/home.less index cd6e514171..6d47c1302e 100644 --- a/public/themes/vanilla/home.less +++ b/public/themes/vanilla/home.less @@ -3,7 +3,7 @@ h4 { font-weight: 700; - line-height: 20px; + line-height: 21px; text-align: left; white-space: nowrap; overflow: hidden;