From 98d42b0ade9c35a0ac6937d2f6cc5f8c03edddd4 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 14 Jan 2014 14:30:09 -0500 Subject: [PATCH 1/3] moving social sharing parsing code from server side to client side & cleaned up templates --- public/src/forum/category.js | 14 ++++++++------ public/templates/category.tpl | 4 +--- public/templates/topic.tpl | 3 --- src/categories.js | 3 --- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 6eca83187a..3e2fe29b92 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -4,25 +4,27 @@ define(['composer'], function(composer) { Category.init = function() { var cid = templates.get('category_id'), + categoryName = templates.get('category_name'), twitterEl = jQuery('#twitter-intent'), facebookEl = jQuery('#facebook-share'), googleEl = jQuery('#google-share'), - twitter_url = templates.get('twitter-intent-url'), - facebook_url = templates.get('facebook-share-url'), - google_url = templates.get('google-share-url'); + categoryUrl = encodeURIComponent(window.location.href), + twitterUrl = "https://twitter.com/intent/tweet?url=" + categoryUrl + "&text=" + encodeURIComponent(categoryName), + facebookUrl = "https://www.facebook.com/sharer/sharer.php?u=" + categoryUrl, + googleUrl = "https://plus.google.com/share?url=" + categoryUrl; app.enterRoom('category_' + cid); twitterEl.on('click', function () { - window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no'); + window.open(twitterUrl, '_blank', 'width=550,height=420,scrollbars=no,status=no'); return false; }); facebookEl.on('click', function () { - window.open(facebook_url, '_blank', 'width=626,height=436,scrollbars=no,status=no'); + window.open(facebookUrl, '_blank', 'width=626,height=436,scrollbars=no,status=no'); return false; }); googleEl.on('click', function () { - window.open(google_url, '_blank', 'width=500,height=570,scrollbars=no,status=no'); + window.open(googleUrl, '_blank', 'width=500,height=570,scrollbars=no,status=no'); return false; }); diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 79bbcd7412..849c042d9a 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -118,6 +118,4 @@ - - - + \ No newline at end of file diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 5c05b35101..0ea7354ec0 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -5,9 +5,6 @@ - - -
diff --git a/src/categories.js b/src/categories.js index a29b5ad357..939073ffcb 100644 --- a/src/categories.js +++ b/src/categories.js @@ -82,9 +82,6 @@ var db = require('./database.js'), 'active_users': [], 'topics': [], 'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false, - 'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(nconf.get('url') + 'category/' + categoryData.slug) + '&text=' + encodeURIComponent(categoryData.name), - 'facebook-share-url': 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(nconf.get('url') + 'category/' + categoryData.slug), - 'google-share-url': 'https://plus.google.com/share?url=' + encodeURIComponent(nconf.get('url') + 'category/' + categoryData.slug), 'sidebars': sidebars }; From 8c5a458798935e1b6d98214c47566a3437205c72 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 14 Jan 2014 14:33:43 -0500 Subject: [PATCH 2/3] fixed 403 redirect from logged out /admin --- src/routes/admin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/admin.js b/src/routes/admin.js index 3b07dd83f5..2eea4aec46 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -19,7 +19,8 @@ var nconf = require('nconf'), Admin.isAdmin = function (req, res, next) { user.isAdministrator((req.user && req.user.uid) ? req.user.uid : 0, function (err, isAdmin) { if (!isAdmin) { - res.redirect(403, '/403'); + res.status(403); + res.redirect('/403'); } else { next(); } From 442c543d27334713e16ec2ed13fcd4b30eb25d1d Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 14 Jan 2014 17:02:54 -0500 Subject: [PATCH 3/3] fixed #776 --- public/src/forum/unread.js | 3 ++- src/socket.io/topics.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/public/src/forum/unread.js b/public/src/forum/unread.js index 5151eb37cb..3abafa1521 100644 --- a/public/src/forum/unread.js +++ b/public/src/forum/unread.js @@ -7,7 +7,8 @@ define(function() { ajaxify.register_events([ 'event:new_topic', - 'event:new_post' + 'event:new_post', + 'api:topics.markAllRead' ]); var newTopicCount = 0, diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index c597fc88db..43e8b8e127 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -72,6 +72,7 @@ SocketTopics.markAllRead = function(data, callback, sessionData) { topics.markAllRead(sessionData.uid, function(err, success) { if (!err && success) { callback(true); + sessionData.server.sockets.in('uid_' + sessionData.uid).emit('event:unread.updateCount', 0); } else { callback(false); }