mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 04:21:17 +01:00
Merge branch 'master' into notif_pruning
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
define(function () {
|
||||
var Category = {},
|
||||
cid = templates.get('category_id');
|
||||
var Category = {};
|
||||
|
||||
Category.init = function() {
|
||||
var room = 'category_' + cid,
|
||||
var cid = templates.get('category_id'),
|
||||
room = 'category_' + cid,
|
||||
twitterEl = document.getElementById('twitter-intent'),
|
||||
facebookEl = document.getElementById('facebook-share'),
|
||||
googleEl = document.getElementById('google-share'),
|
||||
@@ -85,7 +86,7 @@ define(function () {
|
||||
}),
|
||||
topic = $(html),
|
||||
container = $('#topics-container'),
|
||||
topics = $('#topics-container').children(),
|
||||
topics = $('#topics-container').children('.category-item'),
|
||||
numTopics = topics.length;
|
||||
|
||||
jQuery('#topics-container, .category-sidebar').removeClass('hidden');
|
||||
@@ -104,7 +105,7 @@ define(function () {
|
||||
topic.hide().fadeIn('slow');
|
||||
}
|
||||
|
||||
socket.emit('api:categories.getRecentReplies', cid);
|
||||
socket.emit('api:categories.getRecentReplies', templates.get('category_id'));
|
||||
$('#topics-container span.timeago').timeago();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,38 @@ define(function() {
|
||||
deleted: templates.get('deleted'),
|
||||
pinned: templates.get('pinned')
|
||||
},
|
||||
topic_name = templates.get('topic_name');
|
||||
topic_name = templates.get('topic_name'),
|
||||
twitter_url = templates.get('twitter-intent-url'),
|
||||
facebook_url = templates.get('facebook-share-url'),
|
||||
google_url = templates.get('google-share-url');
|
||||
|
||||
|
||||
jQuery('document').ready(function() {
|
||||
|
||||
app.addCommasToNumbers();
|
||||
|
||||
|
||||
var room = 'topic_' + tid,
|
||||
adminTools = document.getElementById('thread-tools');
|
||||
|
||||
app.enter_room(room);
|
||||
|
||||
|
||||
$('.twitter-share').on('click', function () {
|
||||
window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.facebook-share').on('click', function () {
|
||||
window.open(facebook_url, '_blank', 'width=626,height=436,scrollbars=no,status=no');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.google-share').on('click', function () {
|
||||
window.open(google_url, '_blank', 'width=500,height=570,scrollbars=no,status=no');
|
||||
return false;
|
||||
});
|
||||
|
||||
// Resetting thread state
|
||||
if (thread_state.locked === '1') set_locked_state(true);
|
||||
if (thread_state.deleted === '1') set_delete_state(true);
|
||||
|
||||
@@ -45,6 +45,7 @@ define(function() {
|
||||
text += ' Click here to reload.';
|
||||
|
||||
$('#new-topics-alert').html(text).removeClass('hide').fadeIn('slow');
|
||||
$('#category-no-topics').addClass('hidden');
|
||||
}
|
||||
|
||||
socket.on('event:new_post', function(data) {
|
||||
@@ -80,12 +81,13 @@ define(function() {
|
||||
$('#category-no-topics').remove();
|
||||
|
||||
container.append(html);
|
||||
$('span.timeago').timeago();
|
||||
}
|
||||
|
||||
function loadMoreTopics() {
|
||||
loadingMoreTopics = true;
|
||||
socket.emit('api:topics.loadMoreUnreadTopics', {
|
||||
after: parseInt($('#topics-container').attr('data-next-start'), 10)
|
||||
after: parseInt($('#topics-container').attr('data-next-start'), 10);
|
||||
}, function(data) {
|
||||
if (data.topics && data.topics.length) {
|
||||
onTopicsLoaded(data.topics);
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
<input class="test1" type="hidden" template-variable="pinned" value="{pinned}" />
|
||||
<input class="test1" type="hidden" template-variable="topic_name" value="{topic_name}" />
|
||||
<input class="test1" 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">
|
||||
<ol class="breadcrumb">
|
||||
@@ -60,12 +63,18 @@
|
||||
<button class="btn btn-sm btn-default quote" type="button" title="[[topic:quote]]"><i class="icon-quote-left"></i></button>
|
||||
<button class="btn btn-sm btn-primary btn post_reply" type="button">[[topic:reply]] <i class="icon-reply"></i></button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="btn-group pull-right post-tools">
|
||||
<button class="btn btn-sm btn-default edit {main_posts.display_moderator_tools}" type="button" title="[[topic:edit]]"><i class="icon-pencil"></i></button>
|
||||
<button class="btn btn-sm btn-default delete {main_posts.display_moderator_tools}" type="button" title="[[topic:delete]]"><i class="icon-trash"></i></button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group pull-right post-tools">
|
||||
<button class="btn btn-sm btn-default link" type="button" title="[[topic:link]]"><i class="icon-link"></i></button>
|
||||
<button class="btn btn-sm btn-default edit {main_posts.display_moderator_tools}" type="button" title="[[topic:edit]]"><i class="icon-pencil"></i></button>
|
||||
<button class="btn btn-sm btn-default delete {main_posts.display_moderator_tools}" type="button" title="[[topic:delete]]"><i class="icon-trash"></i></button>
|
||||
|
||||
<button class="btn btn-sm btn-default facebook-share" type="button" title=""><i class="icon-facebook"></i></button>
|
||||
<button class="btn btn-sm btn-default twitter-share" type="button" title=""><i class="icon-twitter"></i></button>
|
||||
<button class="btn btn-sm btn-default google-share" type="button" title=""><i class="icon-google-plus"></i></button>
|
||||
</div>
|
||||
|
||||
<input id="post_{main_posts.pid}_link" value="" class="pull-right" style="display:none;"></input>
|
||||
|
||||
@@ -71,8 +71,9 @@ var opts = {
|
||||
Logger.open = function(value) {
|
||||
/* Open the streams to log to: either a path or stdout */
|
||||
var stream;
|
||||
if(value)
|
||||
if(value && fs.existsSync(value)) {
|
||||
stream = fs.createWriteStream(value, {flags: 'a'});
|
||||
}
|
||||
else
|
||||
stream = process.stdout;
|
||||
return stream;
|
||||
@@ -113,7 +114,7 @@ var opts = {
|
||||
return opts.express.ofn(req,res,next);
|
||||
}
|
||||
else {
|
||||
return next()
|
||||
return next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
src/login.js
13
src/login.js
@@ -2,7 +2,8 @@ var user = require('./user.js'),
|
||||
bcrypt = require('bcrypt'),
|
||||
RDB = require('./redis.js'),
|
||||
path = require('path'),
|
||||
winston = require('winston');
|
||||
winston = require('winston'),
|
||||
utils = require('./../public/src/utils.js');
|
||||
|
||||
(function(Login) {
|
||||
|
||||
@@ -13,12 +14,14 @@ var user = require('./user.js'),
|
||||
message: 'invalid-user'
|
||||
});
|
||||
} else {
|
||||
user.get_uid_by_username(username, function(err, uid) {
|
||||
|
||||
var userslug = utils.slugify(username);
|
||||
|
||||
user.get_uid_by_userslug(userslug, function(err, uid) {
|
||||
|
||||
if (err) {
|
||||
return next(new Error('redis-error'));
|
||||
}
|
||||
|
||||
if (uid == null) {
|
||||
} else if (uid == null) {
|
||||
return next(new Error('invalid-user'));
|
||||
}
|
||||
|
||||
|
||||
@@ -232,32 +232,13 @@ var fs = require('fs'),
|
||||
});
|
||||
},
|
||||
showInstalled: function(callback) {
|
||||
// TODO: Also check /node_modules
|
||||
var _self = this;
|
||||
localPluginPath = path.join(__dirname, '../plugins'),
|
||||
npmPluginPath = path.join(__dirname, '../node_modules');
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
fs.readdir(localPluginPath, next);
|
||||
},
|
||||
function(next) {
|
||||
fs.readdir(npmPluginPath, next);
|
||||
}
|
||||
], function(err, dirs) {
|
||||
if (err) return next(err);
|
||||
|
||||
dirs[0] = dirs[0].map(function(file) {
|
||||
return path.join(localPluginPath, file);
|
||||
}).filter(function(file) {
|
||||
var stats = fs.statSync(file);
|
||||
if (stats.isDirectory()) return true;
|
||||
else return false;
|
||||
});
|
||||
|
||||
dirs[1] = dirs[1].map(function(file) {
|
||||
fs.readdir(npmPluginPath, function(err, dirs) {
|
||||
dirs = dirs.map(function(file) {
|
||||
return path.join(npmPluginPath, file);
|
||||
}).filter(function(file) {
|
||||
var stats = fs.statSync(file);
|
||||
@@ -265,7 +246,7 @@ var fs = require('fs'),
|
||||
else return false;
|
||||
});
|
||||
|
||||
next(err, dirs[0].concat(dirs[1]));
|
||||
next(err, dirs);
|
||||
});
|
||||
},
|
||||
function(files, next) {
|
||||
|
||||
@@ -38,7 +38,7 @@ var RDB = require('./redis.js'),
|
||||
function isOwnPost(next) {
|
||||
posts.getPostField(pid, 'uid', function(author) {
|
||||
if (author && parseInt(author) > 0) {
|
||||
next(null, author === uid);
|
||||
next(null, parseInt(author, 10) === parseInt(uid, 10));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -46,14 +46,14 @@ var RDB = require('./redis.js'),
|
||||
function hasEnoughRep(next) {
|
||||
user.getUserField(uid, 'reputation', function(err, reputation) {
|
||||
if (err) return next(null, false);
|
||||
next(null, reputation >= meta.config['privileges:manage_content']);
|
||||
next(null, parseInt(reputation, 10) >= parseInt(meta.config['privileges:manage_content'], 10));
|
||||
});
|
||||
}
|
||||
|
||||
async.parallel([getThreadPrivileges, isOwnPost, hasEnoughRep], function(err, results) {
|
||||
callback({
|
||||
editable: results[0].editable || (results.slice(1).indexOf(true) !== -1 ? true : false),
|
||||
view_deleted: results[0].view_deleted || (results.slice(1).indexOf(true) !== -1 ? true : false)
|
||||
editable: results[0].editable || results[1] || results[2],
|
||||
view_deleted: results[0].view_deleted || results[1] || results[2]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,15 +34,15 @@ var RDB = require('./redis.js'),
|
||||
function hasEnoughRep(next) {
|
||||
user.getUserField(uid, 'reputation', function(err, reputation) {
|
||||
if (err) return next(null, false);
|
||||
next(null, reputation >= meta.config['privileges:manage_topic']);
|
||||
next(null, parseInt(reputation, 10) >= parseInt(meta.config['privileges:manage_topic'], 10));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async.parallel([getCategoryPrivileges, hasEnoughRep], function(err, results) {
|
||||
callback({
|
||||
editable: results[0].editable || (results.slice(1).indexOf(true) !== -1 ? true : false),
|
||||
view_deleted: results[0].view_deleted || (results.slice(1).indexOf(true) !== -1 ? true : false)
|
||||
editable: results[0].editable || results[1],
|
||||
view_deleted: results[0].view_deleted || results[1]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ var RDB = require('./redis.js'),
|
||||
meta = require('./meta.js'),
|
||||
reds = require('reds'),
|
||||
topicSearch = reds.createSearch('nodebbtopicsearch'),
|
||||
nconf = require('nconf'),
|
||||
validator = require('validator');
|
||||
|
||||
(function(Topics) {
|
||||
@@ -68,7 +69,7 @@ var RDB = require('./redis.js'),
|
||||
}
|
||||
|
||||
function getPrivileges(next) {
|
||||
threadTools.privileges(tid, current_user, function(privData) {
|
||||
postTools.privileges(tid, current_user, function(privData) {
|
||||
next(null, privData);
|
||||
});
|
||||
}
|
||||
@@ -213,10 +214,12 @@ var RDB = require('./redis.js'),
|
||||
var unreadTids = [],
|
||||
done = false;
|
||||
|
||||
function continueCondition() {
|
||||
return unreadTids.length < 20 && !done;
|
||||
}
|
||||
|
||||
async.whilst(
|
||||
function() {
|
||||
return unreadTids.length < 20 && !done;
|
||||
},
|
||||
continueCondition,
|
||||
function(callback) {
|
||||
RDB.zrevrange('topics:recent', start, stop, function(err, tids) {
|
||||
if (err)
|
||||
@@ -234,12 +237,16 @@ var RDB = require('./redis.js'),
|
||||
Topics.hasReadTopics(tids, uid, function(read) {
|
||||
|
||||
var newtids = tids.filter(function(tid, index, self) {
|
||||
return read[index] === 0;
|
||||
return parseInt(read[index], 10) === 0;
|
||||
});
|
||||
|
||||
unreadTids.push.apply(unreadTids, newtids);
|
||||
start = stop + 1;
|
||||
stop = start + 19;
|
||||
|
||||
if(continueCondition()) {
|
||||
start = stop + 1;
|
||||
stop = start + 19;
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
@@ -404,7 +411,10 @@ var RDB = require('./redis.js'),
|
||||
'topic_id': tid,
|
||||
'expose_tools': privileges.editable ? 1 : 0,
|
||||
'posts': topicPosts,
|
||||
'main_posts': main_posts
|
||||
'main_posts': main_posts,
|
||||
'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(nconf.get('url') + 'topic/' + topicData.slug) + '&text=' + encodeURIComponent(topicData.title),
|
||||
'facebook-share-url': 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(nconf.get('url') + 'topic/' + topicData.slug),
|
||||
'google-share-url': 'https://plus.google.com/share?url=' + encodeURIComponent(nconf.get('url') + 'topic/' + topicData.slug)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user