Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 12 years ago
commit facacc65aa

@ -4,25 +4,27 @@ define(['composer'], function(composer) {
Category.init = function() { Category.init = function() {
var cid = templates.get('category_id'), var cid = templates.get('category_id'),
categoryName = templates.get('category_name'),
twitterEl = jQuery('#twitter-intent'), twitterEl = jQuery('#twitter-intent'),
facebookEl = jQuery('#facebook-share'), facebookEl = jQuery('#facebook-share'),
googleEl = jQuery('#google-share'), googleEl = jQuery('#google-share'),
twitter_url = templates.get('twitter-intent-url'), categoryUrl = encodeURIComponent(window.location.href),
facebook_url = templates.get('facebook-share-url'), twitterUrl = "https://twitter.com/intent/tweet?url=" + categoryUrl + "&text=" + encodeURIComponent(categoryName),
google_url = templates.get('google-share-url'); facebookUrl = "https://www.facebook.com/sharer/sharer.php?u=" + categoryUrl,
googleUrl = "https://plus.google.com/share?url=" + categoryUrl;
app.enterRoom('category_' + cid); app.enterRoom('category_' + cid);
twitterEl.on('click', function () { 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; return false;
}); });
facebookEl.on('click', function () { 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; return false;
}); });
googleEl.on('click', function () { 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; return false;
}); });

@ -118,6 +118,4 @@
</div> </div>
<input type="hidden" template-variable="category_id" value="{category_id}" /> <input type="hidden" template-variable="category_id" value="{category_id}" />
<input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" /> <input type="hidden" template-variable="category_name" value="{category_name}" />
<input type="hidden" template-variable="facebook-share-url" value="{facebook-share-url}" />
<input type="hidden" template-variable="google-share-url" value="{google-share-url}" />

@ -5,9 +5,6 @@
<input type="hidden" template-variable="pinned" value="{pinned}" /> <input type="hidden" template-variable="pinned" value="{pinned}" />
<input type="hidden" template-variable="topic_name" value="{topic_name}" /> <input type="hidden" template-variable="topic_name" value="{topic_name}" />
<input type="hidden" template-variable="postcount" value="{postcount}" /> <input type="hidden" template-variable="postcount" value="{postcount}" />
<input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" />
<input type="hidden" template-variable="facebook-share-url" value="{facebook-share-url}" />
<input type="hidden" template-variable="google-share-url" value="{google-share-url}" />
<div class="topic"> <div class="topic">

@ -82,9 +82,6 @@ var db = require('./database.js'),
'active_users': [], 'active_users': [],
'topics': [], 'topics': [],
'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false, '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 'sidebars': sidebars
}; };
@ -397,8 +394,8 @@ var db = require('./database.js'),
}; };
Categories.moveActiveUsers = function(tid, oldCid, cid, callback) { Categories.moveActiveUsers = function(tid, oldCid, cid, callback) {
function updateUser(uid) { function updateUser(uid, timestamp) {
Categories.addActiveUser(cid, uid, Date.now()); Categories.addActiveUser(cid, uid, timestamp);
Categories.isUserActiveIn(oldCid, uid, function(err, active) { Categories.isUserActiveIn(oldCid, uid, function(err, active) {
if (!err && !active) { if (!err && !active) {
@ -407,11 +404,15 @@ var db = require('./database.js'),
}); });
} }
topics.getUids(tid, function(err, uids) { topics.getTopicField(tid, 'timestamp', function(err, timestamp) {
if (!err && uids) { if(!err) {
for (var i = 0; i < uids.length; ++i) { topics.getUids(tid, function(err, uids) {
updateUser(uids[i]); if (!err && uids) {
} for (var i = 0; i < uids.length; ++i) {
updateUser(uids[i], timestamp);
}
}
});
} }
}); });
}; };

@ -19,7 +19,8 @@ var nconf = require('nconf'),
Admin.isAdmin = function (req, res, next) { Admin.isAdmin = function (req, res, next) {
user.isAdministrator((req.user && req.user.uid) ? req.user.uid : 0, function (err, isAdmin) { user.isAdministrator((req.user && req.user.uid) ? req.user.uid : 0, function (err, isAdmin) {
if (!isAdmin) { if (!isAdmin) {
res.redirect(403, '/403'); res.status(403);
res.redirect('/403');
} else { } else {
next(); next();
} }

@ -188,11 +188,7 @@ var winston = require('winston'),
} }
}); });
categories.moveActiveUsers(tid, oldCid, cid, function(err, data) { categories.moveActiveUsers(tid, oldCid, cid);
if (err) {
winston.err(err);
}
});
categories.incrementCategoryFieldBy(oldCid, 'topic_count', -1); categories.incrementCategoryFieldBy(oldCid, 'topic_count', -1);
categories.incrementCategoryFieldBy(cid, 'topic_count', 1); categories.incrementCategoryFieldBy(cid, 'topic_count', 1);

Loading…
Cancel
Save