mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-18 21:42:55 +01:00
Merge branch 'master' of https://github.com/psychobunny/NodeBB
This commit is contained in:
@@ -36,6 +36,7 @@ var socket,
|
||||
$('#disconnect-modal').show();
|
||||
$('#reload-button').on('click',function(){
|
||||
$('#disconnect-modal').hide();
|
||||
console.log(window.location.href);
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,6 +40,7 @@ var templates = {};
|
||||
for (var t in templatesToLoad) {
|
||||
(function(file) {
|
||||
$.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) {
|
||||
|
||||
var template = function() {
|
||||
this.toString = function() {
|
||||
return this.html;
|
||||
@@ -168,6 +169,12 @@ function load_template(callback, url, template) {
|
||||
|
||||
jQuery.get(API_URL + url, function(data) {
|
||||
|
||||
console.log(data);
|
||||
if(!data) {
|
||||
window.location.href = '/403';
|
||||
return;
|
||||
}
|
||||
|
||||
var tpl = templates.get_custom_map(url);
|
||||
|
||||
if (tpl == false && !templates[url]) {
|
||||
|
||||
@@ -284,7 +284,8 @@
|
||||
'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room',
|
||||
'event:topic_deleted', 'event:topic_restored', 'event:topic:locked',
|
||||
'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned',
|
||||
'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored'
|
||||
'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored',
|
||||
'api:posts.favourite'
|
||||
]);
|
||||
socket.on('api:get_users_in_room', function(users) {
|
||||
var anonymous = users.anonymous,
|
||||
@@ -374,6 +375,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:posts.favourite', function(data) {
|
||||
if (data.status !== 'ok' && data.pid) {
|
||||
var favEl = document.querySelector('.post_rep_' + data.pid).nextSibling;
|
||||
if (favEl) favEl.className = 'icon-star-empty';
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:post_deleted', function(data) {
|
||||
if (data.pid) toggle_post_delete_state(data.pid, true);
|
||||
});
|
||||
@@ -424,7 +432,6 @@
|
||||
pid = ids[0],
|
||||
uid = ids[1];
|
||||
|
||||
|
||||
if (thread_state.locked !== '1') {
|
||||
if (this.children[1].className == 'icon-star-empty') {
|
||||
this.children[1].className = 'icon-star';
|
||||
|
||||
12
src/posts.js
12
src/posts.js
@@ -12,6 +12,7 @@ marked.setOptions({
|
||||
(function(Posts) {
|
||||
|
||||
Posts.get = function(callback, tid, current_user, start, end) {
|
||||
|
||||
if (start == null) start = 0;
|
||||
if (end == null) end = start + 10;
|
||||
|
||||
@@ -74,7 +75,7 @@ marked.setOptions({
|
||||
// get all data for thread in asynchronous fashion
|
||||
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
|
||||
RDB.handle(err);
|
||||
|
||||
|
||||
var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [], deleted = [];
|
||||
|
||||
for (var i=0, ii=pids.length; i<ii; i++) {
|
||||
@@ -277,6 +278,11 @@ marked.setOptions({
|
||||
type: 'error',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
socket.emit('api:posts.favourite', {
|
||||
status: 'error',
|
||||
pid: pid
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,6 +299,10 @@ marked.setOptions({
|
||||
if (room_id) {
|
||||
io.sockets.in(room_id).emit('event:rep_up', {uid: uid !== uid_of_poster ? uid_of_poster : 0, pid: pid});
|
||||
}
|
||||
|
||||
socket.emit('api:posts.favourite', {
|
||||
status: 'ok'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,8 +101,6 @@ var user = require('./../user.js'),
|
||||
var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
|
||||
var type = req.files.userPhoto.type;
|
||||
|
||||
console.log(req.files.userPhoto);
|
||||
|
||||
if(allowedTypes.indexOf(type) === -1) {
|
||||
res.send({
|
||||
error: 'Allowed image types are png, jpg and gif!'
|
||||
@@ -284,9 +282,9 @@ var user = require('./../user.js'),
|
||||
|
||||
user.getUserData(uid, function(data) {
|
||||
if(data) {
|
||||
console.log(data.joindate);
|
||||
|
||||
data.joindate = utils.relativeTime(data.joindate);
|
||||
console.log(data.joindate);
|
||||
|
||||
if(!data.birthday)
|
||||
data.age = '';
|
||||
else
|
||||
|
||||
@@ -20,6 +20,12 @@ var RDB = require('./redis.js'),
|
||||
var range_var = (category_id) ? 'categories:' + category_id + ':tid' : 'topics:tid';
|
||||
|
||||
RDB.smembers(range_var, function(err, tids) {
|
||||
|
||||
if(tids.length === 0) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var title = [],
|
||||
uid = [],
|
||||
timestamp = [],
|
||||
|
||||
@@ -80,7 +80,7 @@ var config = require('../config.js'),
|
||||
for(var i=0,ii=fields.length; i<ii; ++i) {
|
||||
key = fields[i];
|
||||
if(data[key] !== undefined) {
|
||||
console.log(data[key]);
|
||||
|
||||
User.setUserField(uid, key, data[key]);
|
||||
|
||||
if(key === 'email') {
|
||||
|
||||
@@ -154,26 +154,46 @@ var express = require('express'),
|
||||
break;
|
||||
case 'topic' :
|
||||
posts.get(function(data) {
|
||||
if(!data) {
|
||||
res.send(false);
|
||||
return;
|
||||
}
|
||||
res.send(JSON.stringify(data));
|
||||
}, req.params.id, (req.user) ? req.user.uid : 0);
|
||||
break;
|
||||
case 'category' :
|
||||
topics.get(function(data) {
|
||||
if(!data) {
|
||||
res.send(false);
|
||||
return;
|
||||
}
|
||||
res.send(JSON.stringify(data));
|
||||
}, req.params.id, (req.user) ? req.user.uid : 0);
|
||||
break;
|
||||
case 'latest' :
|
||||
topics.get(function(data) {
|
||||
if(!data) {
|
||||
res.send(false);
|
||||
return;
|
||||
}
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
break;
|
||||
case 'popular' :
|
||||
topics.get(function(data) {
|
||||
if(!data) {
|
||||
res.send(false);
|
||||
return;
|
||||
}
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
break;
|
||||
case 'active' :
|
||||
topics.get(function(data) {
|
||||
if(!data) {
|
||||
res.send(false);
|
||||
return;
|
||||
}
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user