From aaaffb823f352f9f85793f482e3ff8a64d90a09c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 7 Dec 2013 13:11:59 -0500 Subject: [PATCH 1/7] upgrading markdown minver --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af257f5775..c7ba9b9586 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "uglify-js": "~2.4.0", "validator": "~1.5.1", "nodebb-plugin-mentions": "~0.1.15", - "nodebb-plugin-markdown": "~0.1.9", + "nodebb-plugin-markdown": "~0.2.0", "nodebb-theme-vanilla": "~0.0.9", "nodebb-theme-cerulean": "0.0.10", "cron": "~1.0.1" From 40e71299a1b61137abdf9a18aaf4f065311929bb Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Mon, 9 Dec 2013 12:39:36 -0500 Subject: [PATCH 2/7] closes #642 --- src/upgrade.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/upgrade.js b/src/upgrade.js index 75265c4643..d3b938743e 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -38,7 +38,8 @@ Upgrade.upgrade = function(callback) { Upgrade.upgradeRedis = function(callback) { - var RDB = db.client; + var RDB = db.client, + updatesMade = false; winston.info('Beginning Redis database schema update'); @@ -52,6 +53,7 @@ Upgrade.upgradeRedis = function(callback) { function(next) { thisSchemaDate = new Date(2013, 9, 3).getTime(); if (schemaDate < thisSchemaDate) { + updatesMade = true; async.series([ function(next) { RDB.keys('uid:*:notifications:flag', function(err, keys) { @@ -110,6 +112,7 @@ Upgrade.upgradeRedis = function(callback) { function(next) { thisSchemaDate = new Date(2013, 9, 23).getTime(); if (schemaDate < thisSchemaDate) { + updatesMade = true; RDB.keys('notifications:*', function(err, keys) { keys = keys.filter(function(key) { @@ -139,6 +142,7 @@ Upgrade.upgradeRedis = function(callback) { function(next) { thisSchemaDate = new Date(2013, 10, 11).getTime(); if (schemaDate < thisSchemaDate) { + updatesMade = true; RDB.hset('config', 'postDelay', 10, function(err, success) { winston.info('[2013/11/11] Updated postDelay to 10 seconds.'); next(); @@ -151,6 +155,7 @@ Upgrade.upgradeRedis = function(callback) { function(next) { thisSchemaDate = new Date(2013, 10, 22).getTime(); if (schemaDate < thisSchemaDate) { + updatesMade = true; RDB.keys('category:*', function(err, categories) { async.each(categories, function(categoryStr, next) { var hex; @@ -197,6 +202,7 @@ Upgrade.upgradeRedis = function(callback) { function(next) { thisSchemaDate = new Date(2013, 10, 26).getTime(); if (schemaDate < thisSchemaDate) { + updatesMade = true; categories.getAllCategories(0, function(err, categories) { function updateIcon(category, next) { @@ -237,7 +243,7 @@ Upgrade.upgradeRedis = function(callback) { thisSchemaDate = new Date(2013, 11, 2).getTime(); if (schemaDate < thisSchemaDate) { - + updatesMade = true; var keys = [ 'global:next_user_id', 'next_topic_id', @@ -276,14 +282,18 @@ Upgrade.upgradeRedis = function(callback) { winston.info('[2013/12/2] Update to global keys skipped'); next(); } - }, + } // Add new schema updates here // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 12!!! ], function(err) { if (!err) { RDB.set('schemaDate', thisSchemaDate, function(err) { if (!err) { - winston.info('[upgrade] Redis schema update complete!'); + if(updatesMade) { + winston.info('[upgrade] Redis schema update complete!'); + } else { + winston.info('[upgrade] Redis schema already up to date!'); + } if (callback) { callback(err); } else { From 35f17db141bbeac40ea4bde36389c2fef0046841 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 9 Dec 2013 12:52:12 -0500 Subject: [PATCH 3/7] added button in admin to upload favicon + show current favicon image --- public/src/forum/admin/settings.js | 9 ++++++++- public/templates/admin/settings.tpl | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/public/src/forum/admin/settings.js b/public/src/forum/admin/settings.js index 8e8fc359df..44994930b6 100644 --- a/public/src/forum/admin/settings.js +++ b/public/src/forum/admin/settings.js @@ -75,13 +75,20 @@ define(['uploader'], function(uploader) { }); $('#uploadLogoBtn').on('click', function() { - uploader.open(RELATIVE_PATH + '/admin/uploadlogo', function(image) { $('#logoUrl').val(image); }); uploader.hideAlerts(); }); + + $('#uploadLogoBtn').on('click', function() { + uploader.open(RELATIVE_PATH + '/admin/uploadfavicon', function() { + $('#favicon').attr('src', './../favicon.ico?v=' + new Date().getTime()); + }); + + uploader.hideAlerts(); + }); }; Settings.remove = function(key) { diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl index a5e6192b1b..325d27a71b 100644 --- a/public/templates/admin/settings.tpl +++ b/public/templates/admin/settings.tpl @@ -12,11 +12,14 @@

-
+

- +
+
+   +
From 1b843fba9c800214fef1a700248d9fafbfd2c783 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 9 Dec 2013 13:01:57 -0500 Subject: [PATCH 4/7] added admin route to upload favicon --- public/src/forum/admin/settings.js | 2 +- public/templates/admin/settings.tpl | 2 +- src/routes/admin.js | 47 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/public/src/forum/admin/settings.js b/public/src/forum/admin/settings.js index 44994930b6..d241508fdc 100644 --- a/public/src/forum/admin/settings.js +++ b/public/src/forum/admin/settings.js @@ -82,7 +82,7 @@ define(['uploader'], function(uploader) { uploader.hideAlerts(); }); - $('#uploadLogoBtn').on('click', function() { + $('#uploadFaviconBtn').on('click', function() { uploader.open(RELATIVE_PATH + '/admin/uploadfavicon', function() { $('#favicon').attr('src', './../favicon.ico?v=' + new Date().getTime()); }); diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl index 325d27a71b..3b9d7b973e 100644 --- a/public/templates/admin/settings.tpl +++ b/public/templates/admin/settings.tpl @@ -18,7 +18,7 @@

-   +  
diff --git a/src/routes/admin.js b/src/routes/admin.js index 495b341a31..40c3364a36 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -145,6 +145,53 @@ var nconf = require('nconf'), is.pipe(os); }); + app.post('/uploadfavicon', function(req, res) { + if (!req.user) + return res.redirect('/403'); + + var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon']; + + if (allowedTypes.indexOf(req.files.userPhoto.type) === -1) { + res.send({ + error: 'You can only upload icon file type!' + }); + return; + } + + var tempPath = req.files.userPhoto.path; + var extension = path.extname(req.files.userPhoto.name); + + if (!extension) { + res.send({ + error: 'Error uploading file! Error : Invalid extension!' + }); + return; + } + + var filename = 'favicon.ico'; + var uploadPath = path.join(nconf.get('base_dir'), 'public', filename); + + winston.info('Attempting upload to: ' + uploadPath); + + var is = fs.createReadStream(tempPath); + var os = fs.createWriteStream(uploadPath); + + is.on('end', function () { + fs.unlinkSync(tempPath); + + res.json({ + path: nconf.get('upload_url') + filename + }); + }); + + os.on('error', function (err) { + fs.unlinkSync(tempPath); + winston.err(err); + }); + + is.pipe(os); + }); + app.post('/uploadlogo', function(req, res) { if (!req.user) From a3734f2e15f70d55117c3dd75af0cd1c07b4ffc1 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 9 Dec 2013 13:18:31 -0500 Subject: [PATCH 5/7] completed custom favicon upload, closes #643 --- public/src/forum/admin/settings.js | 4 ++-- public/templates/admin/settings.tpl | 2 +- public/templates/header.tpl | 2 +- src/routes/admin.js | 2 +- src/webserver.js | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/public/src/forum/admin/settings.js b/public/src/forum/admin/settings.js index d241508fdc..b384b3b378 100644 --- a/public/src/forum/admin/settings.js +++ b/public/src/forum/admin/settings.js @@ -83,8 +83,8 @@ define(['uploader'], function(uploader) { }); $('#uploadFaviconBtn').on('click', function() { - uploader.open(RELATIVE_PATH + '/admin/uploadfavicon', function() { - $('#favicon').attr('src', './../favicon.ico?v=' + new Date().getTime()); + uploader.open(RELATIVE_PATH + '/admin/uploadfavicon', function(icon) { + $('#faviconUrl').val(icon); }); uploader.hideAlerts(); diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl index 3b9d7b973e..4a72c95fcc 100644 --- a/public/templates/admin/settings.tpl +++ b/public/templates/admin/settings.tpl @@ -18,7 +18,7 @@

-   +

diff --git a/public/templates/header.tpl b/public/templates/header.tpl index f08ff9680f..b726e79288 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -25,8 +25,8 @@ } }); - + diff --git a/src/routes/admin.js b/src/routes/admin.js index 40c3364a36..cd3994f144 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -169,7 +169,7 @@ var nconf = require('nconf'), } var filename = 'favicon.ico'; - var uploadPath = path.join(nconf.get('base_dir'), 'public', filename); + var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename); winston.info('Attempting upload to: ' + uploadPath); diff --git a/src/webserver.js b/src/webserver.js index ad8614911d..f2a1c4f858 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -90,6 +90,7 @@ var path = require('path'), description: meta.config.description || '', 'brand:logo': meta.config['brand:logo'] || '', 'brand:logo:display': meta.config['brand:logo']?'':'hide', + 'brand:favicon': meta.config['brand:favicon'] || nconf.get('relative_path') + 'favicon.ico', browserTitle: meta.config.title || 'NodeBB', csrf: options.res.locals.csrf_token, relative_path: nconf.get('relative_path'), From b27478876e454f48f0622d1cb60f2d69eb5441f4 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 9 Dec 2013 13:32:24 -0500 Subject: [PATCH 6/7] moved favicon link to top of header --- public/templates/header.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/header.tpl b/public/templates/header.tpl index b726e79288..9b7eff5db2 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -3,6 +3,7 @@ {browserTitle} {meta_tags} + {link_tags} @@ -26,7 +27,6 @@ }); - From 0f254c0b6cb2ba348959b707f3c2788b971e9ef0 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 9 Dec 2013 13:33:06 -0500 Subject: [PATCH 7/7] moved theme.css to top --- public/templates/header.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 9b7eff5db2..bd7a330b6c 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -6,6 +6,7 @@ + {link_tags} @@ -26,7 +27,6 @@ } }); -