From 5569337c4004173cc160c19854a9e63eb333dac9 Mon Sep 17 00:00:00 2001 From: Michael Mitchell Date: Fri, 27 Dec 2013 14:09:27 -0800 Subject: [PATCH 01/26] first --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 96fa3b63ae..7a41deed16 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # NodeBB **NodeBB** is a robust Node.js driven forum built on a redis database. It is powered by web sockets, and is compatible down to IE8. +did this work * [NodeBB Homepage](http://www.nodebb.org/ "NodeBB") * [Demo & Meta Discussion](http://try.nodebb.org) * [Wiki Guides](https://github.com/designcreateplay/NodeBB/wiki) - includes setup for other platforms From 0f0913bfe5c40780b90896bd8b9fca2554658a69 Mon Sep 17 00:00:00 2001 From: Michael Mitchell Date: Fri, 27 Dec 2013 14:18:30 -0800 Subject: [PATCH 02/26] add admin button --- public/src/forum/admin/users.js | 60 ++++++++++++++++++++++++++++++-- public/templates/admin/users.tpl | 3 ++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js index 9269200ddf..93f3ea9e20 100644 --- a/public/src/forum/admin/users.js +++ b/public/src/forum/admin/users.js @@ -19,7 +19,7 @@ define(function() { return parent.attr('data-uid'); } - function updateUserButtons() { + function updateUserBanButtons() { jQuery('.ban-btn').each(function(index, element) { var banBtn = $(element); var uid = getUID(banBtn); @@ -27,15 +27,37 @@ define(function() { banBtn.addClass('disabled'); else if (isUserBanned(banBtn)) banBtn.addClass('btn-warning'); + else if (!isUserAdmin(banBtn)) + banBtn.removeClass('disabled'); else banBtn.removeClass('btn-warning'); + updateUserAdminButtons(); }); } + function updateUserAdminButtons() { + jQuery('.admin-btn').each(function(index, element) { + var banBtn = $(element); + var uid = getUID(banBtn); + if (isUserAdmin(banBtn) || uid === yourid) + + banBtn.attr('value', 'UnMake Admin').html('Remove as Admin'); + + else if (isUserBanned(banBtn)) + banBtn.addClass('disabled'); + else if (!isUserBanned(banBtn)) + banBtn.removeClass('disabled'); + else + banBtn.removeClass('btn-warning'); + + }); + } + function initUsers() { - updateUserButtons(); + updateUserBanButtons(); + updateUserAdminButtons(); $('#users-container').on('click', '.ban-btn', function() { var banBtn = $(this); @@ -49,17 +71,51 @@ define(function() { socket.emit('api:admin.user.unbanUser', uid); banBtn.removeClass('btn-warning'); parent.attr('data-banned', 0); + updateUserAdminButtons(); } else { bootbox.confirm('Do you really want to ban "' + parent.attr('data-username') + '"?', function(confirm) { if (confirm) { socket.emit('api:admin.user.banUser', uid); banBtn.addClass('btn-warning'); parent.attr('data-banned', 1); + updateUserAdminButtons(); } }); } } + return false; + }); + + $('#users-container').on('click', '.admin-btn', function() { + var adminBtn = $(this); + var isAdmin = isUserAdmin(adminBtn); + var parent = adminBtn.parents('.users-box'); + var isBanned = isUserBanned(adminBtn); + var uid = getUID(adminBtn); + + if(uid === yourid){ + alert("you can't remove yourself as admin"); + } + else if (!isAdmin) { + socket.emit('api:admin.user.makeAdmin', uid); + adminBtn.attr('value', 'UnMake Admin').html('Remove as Admin'); + parent.attr('data-admin', 1); + updateUserBanButtons(); + + } else if(uid !== yourid) { + bootbox.confirm('Do you really want to remove this user as admin "' + parent.attr('data-username') + '"?', function(confirm) { + if (confirm) { + socket.emit('api:admin.user.removeAdmin', uid); + adminBtn.attr('value', 'Make Admin').html('Make Admin'); + parent.attr('data-admin', 0); + updateUserBanButtons(); + + } + }); + } + + return false; }); } diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl index b2507828d3..3eea35a9d1 100644 --- a/public/templates/admin/users.tpl +++ b/public/templates/admin/users.tpl @@ -33,6 +33,9 @@ {users.postcount} +
+ Make Admin +
Ban
From aaf6b11dc9dc5ab4c627f60c56d2e7c3774fbe40 Mon Sep 17 00:00:00 2001 From: Michael Mitchell Date: Sat, 28 Dec 2013 08:34:59 -0800 Subject: [PATCH 03/26] removed extraneous --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a41deed16..d1b67fa33c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # NodeBB **NodeBB** is a robust Node.js driven forum built on a redis database. It is powered by web sockets, and is compatible down to IE8. -did this work + * [NodeBB Homepage](http://www.nodebb.org/ "NodeBB") * [Demo & Meta Discussion](http://try.nodebb.org) * [Wiki Guides](https://github.com/designcreateplay/NodeBB/wiki) - includes setup for other platforms From 24907e456d1851fe42b9c1a7a52f923e7b8ec6aa Mon Sep 17 00:00:00 2001 From: Pongsan Sayampol Date: Mon, 30 Dec 2013 11:45:10 +0700 Subject: [PATCH 04/26] Fix the issue that the default values are saved to config.json --- src/install.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/install.js b/src/install.js index b5c4d4b089..ef5aa47e28 100644 --- a/src/install.js +++ b/src/install.js @@ -134,6 +134,11 @@ var async = require('async'), return next(new Error('unknown database : ' + config.database)); } + var allQuestions = install.redisQuestions.concat(install.mongoQuestions); + for(var x=0;x Date: Mon, 30 Dec 2013 11:46:33 +0700 Subject: [PATCH 05/26] Add a way to set social network logins --- src/install.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/install.js b/src/install.js index ef5aa47e28..520970d3e9 100644 --- a/src/install.js +++ b/src/install.js @@ -254,6 +254,21 @@ var async = require('async'), }, function (err) { meta.configs.init(next); }); + + if (install.values) { + if (install.values['social:twitter:key'] && install.values['social:twitter:secret']) { + meta.configs.setOnEmpty('social:twitter:key', install.values['social:twitter:key']); + meta.configs.setOnEmpty('social:twitter:secret', install.values['social:twitter:secret']); + } + if (install.values['social:google:id'] && install.values['social:google:secret']) { + meta.configs.setOnEmpty('social:google:id', install.values['social:google:id']); + meta.configs.setOnEmpty('social:google:secret', install.values['social:google:secret']); + } + if (install.values['social:facebook:key'] && install.values['social:facebook:secret']) { + meta.configs.setOnEmpty('social:facebook:app_id', install.values['social:facebook:app_id']); + meta.configs.setOnEmpty('social:facebook:secret', install.values['social:facebook:secret']); + } + } }, function (next) { // Check if an administrator needs to be created From 08bdbc0bccd82def1e6878670a7bb64f832f1bcf Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 2 Jan 2014 21:44:13 -0500 Subject: [PATCH 06/26] cleanup of PR - fixed some logic bugs and linted --- README.md | 1 - public/src/forum/admin/users.js | 43 ++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 11847141ab..d5fcc5718f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # NodeBB **NodeBB** is a robust Node.js driven forum built on a redis database. It is powered by web sockets, and is compatible down to IE8. - * [NodeBB Homepage](http://www.nodebb.org/ "NodeBB") * [Demo & Meta Discussion](http://try.nodebb.org) * [Wiki Guides](https://github.com/designcreateplay/NodeBB/wiki) - includes setup for other platforms diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js index 93f3ea9e20..1d82b1ae11 100644 --- a/public/src/forum/admin/users.js +++ b/public/src/forum/admin/users.js @@ -19,7 +19,7 @@ define(function() { return parent.attr('data-uid'); } - function updateUserBanButtons() { + function updateUserBanButtons() { jQuery('.ban-btn').each(function(index, element) { var banBtn = $(element); var uid = getUID(banBtn); @@ -31,31 +31,31 @@ define(function() { banBtn.removeClass('disabled'); else banBtn.removeClass('btn-warning'); - updateUserAdminButtons(); - + updateUserAdminButtons(); }); } - function updateUserAdminButtons() { - jQuery('.admin-btn').each(function(index, element) { - var banBtn = $(element); - var uid = getUID(banBtn); - if (isUserAdmin(banBtn) || uid === yourid) - - banBtn.attr('value', 'UnMake Admin').html('Remove as Admin'); - else if (isUserBanned(banBtn)) - banBtn.addClass('disabled'); - else if (!isUserBanned(banBtn)) - banBtn.removeClass('disabled'); + function updateUserAdminButtons() { + jQuery('.admin-btn').each(function(index, element) { + var adminBtn = $(element); + var uid = getUID(adminBtn); + if (isUserAdmin(adminBtn)) { + adminBtn.attr('value', 'UnMake Admin').html('Remove Admin'); + if (uid === yourid) { + adminBtn.addClass('disabled'); + } + } + else if (isUserBanned(adminBtn)) + adminBtn.addClass('disabled'); + else if (!isUserBanned(adminBtn)) + adminBtn.removeClass('disabled'); else - banBtn.removeClass('btn-warning'); + adminBtn.removeClass('btn-warning'); }); } - function initUsers() { - updateUserBanButtons(); updateUserAdminButtons(); @@ -95,11 +95,16 @@ define(function() { var uid = getUID(adminBtn); if(uid === yourid){ - alert("you can't remove yourself as admin"); + app.alert({ + title: 'Error', + message: 'You can\'t remove yourself as Administrator!', + type: 'danger', + timeout: 5000 + }); } else if (!isAdmin) { socket.emit('api:admin.user.makeAdmin', uid); - adminBtn.attr('value', 'UnMake Admin').html('Remove as Admin'); + adminBtn.attr('value', 'UnMake Admin').html('Remove Admin'); parent.attr('data-admin', 1); updateUserBanButtons(); From 03c4a1bc73d280beac912e74d9e3199314d8eba5 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 Jan 2014 15:59:42 -0500 Subject: [PATCH 07/26] remove console.log(file) - no more exploding terminals --- public/src/modules/composer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index f148dc2d49..826911bc97 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -478,7 +478,6 @@ define(['taskbar'], function(taskbar) { $(reader).on('loadend', function(e) { var regex = /^data:.*;base64,(.*)$/; - console.log(file); var matches = this.result.match(regex); var fileData = { From bc8a53aaddc4d1beaa26fd9f89fb0346f6795919 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 Jan 2014 17:09:19 -0500 Subject: [PATCH 08/26] upgrade.js - adding categories.class and categories.link --- src/upgrade.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/upgrade.js b/src/upgrade.js index bf70ec9348..113a93eac6 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -14,7 +14,7 @@ var db = require('./database'), Upgrade.check = function(callback) { // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema - var latestSchema = new Date(2014, 0, 1).getTime(); + var latestSchema = new Date(2014, 0, 3).getTime(); db.get('schemaDate', function(err, value) { if (parseInt(value, 10) >= latestSchema) { @@ -108,6 +108,30 @@ Upgrade.upgrade = function(callback) { winston.info('[2013/12/31] maximumTitleLength skipped'); next(); } + }, + function(next) { + // Custom classes for each category, adding link field for each category + thisSchemaDate = new Date(2014, 0, 3).getTime(); + if (schemaDate < thisSchemaDate) { + updatesMade = true; + + db.getListRange('categories:cid', 0, -1, function(err, cids) { + if(err) { + return next(err); + } + + for (var cid in cids) { + db.setObjectField('category:' + cid, 'link', ''); + db.setObjectField('category:' + cid, 'class', 'col-md-3 col-xs-6'); + } + + winston.info('[2013/12/31] Added categories.class, categories.link fields'); + next(); + }); + } else { + winston.info('[2014/1/3] categories.class, categories.link fields skipped'); + next(); + } } // Add new schema updates here // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!! From 9ef8bb4cdc77cc1bdcff3e3541dae1f8ca56211f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 Jan 2014 17:22:23 -0500 Subject: [PATCH 09/26] woops, fail at iteration --- src/upgrade.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/upgrade.js b/src/upgrade.js index 113a93eac6..3c1dc1bccb 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -121,8 +121,8 @@ Upgrade.upgrade = function(callback) { } for (var cid in cids) { - db.setObjectField('category:' + cid, 'link', ''); - db.setObjectField('category:' + cid, 'class', 'col-md-3 col-xs-6'); + db.setObjectField('category:' + cids[cid], 'link', ''); + db.setObjectField('category:' + cids[cid], 'class', 'col-md-3 col-xs-6'); } winston.info('[2013/12/31] Added categories.class, categories.link fields'); From ebf07626de2e7be8dbea21073087d8a162d4df61 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 Jan 2014 17:22:37 -0500 Subject: [PATCH 10/26] use categories.class instead of hardcoded columns --- public/templates/home.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 13d7bd6caf..98ce2c7dcd 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -4,7 +4,7 @@
-
+