From ec463ce3d3aabec16e5fcfb576b4ccac80b2e562 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 22 May 2013 12:06:23 -0400 Subject: [PATCH 1/5] added motd support --- config.default.js | 9 +++++++++ public/templates/home.tpl | 8 +------- src/webserver.js | 7 ++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config.default.js b/config.default.js index e7a662b76b..8c5ad2ac63 100644 --- a/config.default.js +++ b/config.default.js @@ -1,3 +1,12 @@ +/** + * READ ME! + * The config directives here are all different based on where NodeBB is installed. + * This config file system will be deprecated soon, and all configs will be moved + * to the redis db, under the hash "config" + * + * As of May 22nd, 2013, this migration hasn't started yet + */ + var config = { // The "secret" is used to encrypt cookie sessions, change this to any random string "secret": 'nodebb-secret', diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 736b993be5..f52cd436c7 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,11 +1,5 @@
-

NodeBB

-

Welcome to NodeBB, the discussion platform of the future.

-

- Get NodeBB - Fork us on Github - @dcplabs -

+ {motd}
diff --git a/src/webserver.js b/src/webserver.js index 9f6c500a32..e19f50e77f 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -6,9 +6,9 @@ var express = require('express'), config = require('../config.js'), redis = require('redis'), redisServer = redis.createClient(config.redis.port, config.redis.host, config.redis.options), + marked = require('marked'), user = require('./user.js'), - categories = require('./categories.js'), posts = require('./posts.js'), topics = require('./topics.js'), @@ -18,7 +18,6 @@ var express = require('express'), userRoute = require('./routes/user.js'), auth = require('./routes/authentication.js'); - (function(app) { var templates = null; @@ -115,6 +114,7 @@ var express = require('express'), break; case 'home' : categories.getAllCategories(function(data) { + data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs"); res.send(JSON.stringify(data)); }, (req.user) ? req.user.uid : 0); break; @@ -191,6 +191,7 @@ var express = require('express'), break; case 'popular' : categories.get(function(data) { + console.log(data); if(!data) { res.send(false); return; @@ -239,7 +240,7 @@ var express = require('express'), app.get('/test', function(req, res) { categories.get(function(category) { res.send(JSON.stringify(category, null, 4)); - }, 2, 2, null, null); + }, null, 2, null, null); }); From 499f840e1edec08d4dcb26431427245c9dfb869e Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 22 May 2013 12:11:44 -0400 Subject: [PATCH 2/5] added toggle in config to switch on and off the motd --- config.default.js | 5 ++++- public/templates/home.tpl | 2 +- src/webserver.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.default.js b/config.default.js index 8c5ad2ac63..7228221310 100644 --- a/config.default.js +++ b/config.default.js @@ -56,7 +56,10 @@ var config = { "privilege_thresholds": { "manage_thread": 1000, "manage_content": 2000 - } + }, + + "show_motd": true, + "motd": undefined } config.url = config.base_url + (config.use_port ? ':' + config.port : '') + '/'; diff --git a/public/templates/home.tpl b/public/templates/home.tpl index f52cd436c7..880b244505 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,4 +1,4 @@ -
+
{motd}
diff --git a/src/webserver.js b/src/webserver.js index e19f50e77f..fe5ebeec28 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -114,6 +114,7 @@ var express = require('express'), break; case 'home' : categories.getAllCategories(function(data) { + data.motd_class = config.show_motd ? '' : 'none'; data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs"); res.send(JSON.stringify(data)); }, (req.user) ? req.user.uid : 0); From 93f3a0e524ab1dfeda71dd5e8a123692fb01e327 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 22 May 2013 13:43:18 -0400 Subject: [PATCH 3/5] adding some default text to meta title and desc --- public/templates/header.tpl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 0a2caf095e..57c77e730e 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -1,8 +1,10 @@ - + NodeBB + + From 6cd65e65986d949eabea8f0c81dc1cb3d69df690 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 22 May 2013 15:15:48 -0400 Subject: [PATCH 4/5] fixing motd so that it shows default motd if config is empty --- src/webserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webserver.js b/src/webserver.js index fe5ebeec28..47901413fc 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -114,7 +114,7 @@ var express = require('express'), break; case 'home' : categories.getAllCategories(function(data) { - data.motd_class = config.show_motd ? '' : 'none'; + data.motd_class = (config.show_motd || config.show_motd === undefined) ? '' : 'none'; data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs"); res.send(JSON.stringify(data)); }, (req.user) ? req.user.uid : 0); From 17cde1902083ab46610b675ffc3410a8ff929636 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 22 May 2013 15:34:44 -0400 Subject: [PATCH 5/5] potential fix for templates bug --- public/src/templates.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 9c88fc271f..34b8784be6 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -2,8 +2,7 @@ (function (module) { - var ready_callback, - config = {}, + var config = {}, templates, fs = null, available_templates = []; @@ -35,8 +34,19 @@ }; templates.ready = function(callback) { - if (callback == null && ready_callback) ready_callback(); - else ready_callback = callback; + if (callback == null) { + if (this.ready_callback) { + this.ready_callback(); + } else { + this.loaded = true; + } + } else { + if (this.loaded == true) { + callback(); + } else { + this.ready_callback = callback; + } + } }; templates.prepare = function(raw_tpl, data) {