Skip to content

Node.js based forum software built for the modern web

fixed ajaxify bug that was rendering pages twice (solved flicker issue); fixed entering rooms that was casuing rep/streaming posts to not work; fixed /accounts to work by adding get data route; fixed bug that preventing gravatars from loading if there was more than one post in the thread

psychobunny8a2c18de5b75
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index 97907a8b86..c4aea9a599 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -33,7 +33,9 @@ var ajaxify = {};
if (templates[tpl_url]) {
window.history.pushState({}, url, "/" + url);
- jQuery('#content, #footer').fadeOut(100, function() {
+
+ jQuery('#footer').fadeOut(100);
+ jQuery('#content').fadeOut(100, function() {
load_template(function() {
exec_body_scripts(content);
diff --git a/src/posts.js b/src/posts.js
index 05783591ab..34f60642b8 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -47,7 +47,7 @@ var RDB = require('./redis.js'),
post_rep = replies[3];
user.get_user_postdetails(uid, function(user_details) {
- user.get_gravatars_by_uids([uid], '', function(gravatars) {
+ user.get_gravatars_by_uids(uid, '', function(gravatars) {
var posts = [];
var callbacks = content.length;
@@ -100,8 +100,8 @@ var RDB = require('./redis.js'),
timeout: 2000
});
- user.get_user_postdetails([uid], function(user_details) {
- user.get_gravatars_by_uids([uid], '', function(gravatars) {
+ user.get_user_postdetails(uid, function(user_details) {
+ user.get_gravatars_by_uids(uid, '', function(gravatars) {
var timestamp = new Date().getTime();
socket.in('topic_' + tid).emit('event:new_post', {
diff --git a/src/user.js b/src/user.js
index 6cdf65414b..ab0eb2298e 100644
--- a/src/user.js
+++ b/src/user.js
@@ -52,10 +52,11 @@ var config = require('../config.js'),
User.get_gravatars_by_uids = function(uids, size, callback) {
var gravatars = [];
-
+
for(var i=0, ii=uids.length; i<ii; ++i) {
-
+
User.getUserField(uids[i], 'picture', function(picture) {
+ console.log(picture);
gravatars.push(picture);
if(gravatars.length >= uids.length)
callback(gravatars);
diff --git a/src/webserver.js b/src/webserver.js
index e3833a33f2..1db3873f25 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -124,7 +124,7 @@ passport.deserializeUser(function(uid, done) {
// Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section)
(function() {
- var routes = ['', 'login', 'register'];
+ var routes = ['', 'login', 'register', 'account'];
for (var i=0, ii=routes.length; i<ii; i++) {
(function(route) {
@@ -178,6 +178,11 @@ passport.deserializeUser(function(uid, done) {
res.send(JSON.stringify(data));
}, req.params.id, (req.user) ? req.user.uid : 0);
break;
+ case 'account' :
+ get_account_fn(req, res, function(userData) {
+ res.send(JSON.stringify(userData));
+ });
+ break;
case 'confirm':
global.modules.user.email.confirm(req.params.id, function(data) {
if (data.status === 'ok') {
@@ -288,8 +293,9 @@ passport.deserializeUser(function(uid, done) {
});
});
- app.get('/account', function(req, res) {
-
+ //to baris, move this into account.js or sth later - just moved this out here for you to utilize client side tpl parsing
+ //I didn't want to change too much so you should probably sort out the params etc
+ function get_account_fn(req, res, callback) {
console.log("GOING TO ACCOUNT");
if (req.user === undefined)
@@ -301,13 +307,11 @@ passport.deserializeUser(function(uid, done) {
console.log("user data" + JSON.stringify(data));
- var account = templates['account'];
var userData = {user:data};
- account = account.parse(userData);
-
- res.send(templates['header'] + account + templates['footer']);
+ callback(userData);
});
- });
+ }
+
app.get('/uid/:uid', function(req, res) {
diff --git a/src/websockets.js b/src/websockets.js
index 8eaf559df1..8c888f11cf 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -70,9 +70,7 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
- socket.on('event:enter_room', function(data) {
- return;
-
+ socket.on('event:enter_room', function(data) {
if (data.leave !== null) socket.leave (data.leave);
socket.join(data.enter);