Node.js based forum software built for the modern web
changes for live streaming of posts
barisusakli813b3d6fcca0
diff --git a/public/src/app.js b/public/src/app.jsindex f3d5459bb1..7e16757f83 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -4,7 +4,8 @@ var socket,'username': null,'uid': null,'isFocused': true,- 'currentRoom': null+ 'currentRoom': null,+ 'widgets': {}};(function () {@@ -661,11 +662,11 @@ var socket,app.processPage();ajaxify.renderWidgets(tpl_url, url);-+ajaxify.loadScript(tpl_url, function() {$(window).trigger('action:ajaxify.end', {url: url- });+ });});});};diff --git a/public/src/forum/home.js b/public/src/forum/home.jsindex 62d4b8298f..efaaba4033 100644--- a/public/src/forum/home.js+++ b/public/src/forum/home.js@@ -3,23 +3,29 @@define(function() {var home = {};+ $(window).on('action:ajaxify.end', function(ev, data) {+ if (data.url === '') {+ socket.removeListener('event:new_topic', home.onNewTopic);+ socket.removeListener('event:new_post', home.onNewPost);+ }+ });++home.init = function() {app.enterRoom('home');- ajaxify.register_events([- 'event:new_topic',- 'event:new_post'- ]);+ socket.on('event:new_topic', home.onNewTopic);+ socket.on('event:new_post', home.onNewPost);+ };- socket.on('event:new_topic', function(data) {+ home.onNewTopic = function(data) {- });+ };- socket.on('event:new_post', function(data) {+ home.onNewPost = function(data) {- });- }+ };return home;});diff --git a/src/controllers/categories.js b/src/controllers/categories.jsindex 5d186b37a1..2f2a1e35a9 100644--- a/src/controllers/categories.js+++ b/src/controllers/categories.js@@ -168,4 +168,4 @@ categoriesController.get = function(req, res, next) {});};-module.exports = categoriesController;\ No newline at end of file+module.exports = categoriesController;diff --git a/src/posts.js b/src/posts.jsindex 565f4b867f..f732116334 100644--- a/src/posts.js+++ b/src/posts.js@@ -329,7 +329,7 @@ var db = require('./database'),if(stripTags) {var s = S(content);- postData.content = s.stripTags.apply(s, utils.getTagsExcept(['img', 'i'])).s;+ postData.content = s.stripTags.apply(s, utils.getTagsExcept(['img', 'i', 'p'])).s;} else {postData.content = content;}diff --git a/src/socket.io/posts.js b/src/socket.io/posts.jsindex c359244154..9f592b4fc1 100644--- a/src/socket.io/posts.js+++ b/src/socket.io/posts.js@@ -71,10 +71,7 @@ SocketPosts.reply = function(socket, data, callback) {posts: [postData]};- var rooms = ['recent_posts', 'home', 'topic_' + postData.tid, 'user/' + postData.uid];- rooms.forEach(function(room) {- index.server.sockets.in(room).emit('event:new_post', socketData);- });+ index.server.sockets.emit('event:new_post', socketData);callback();}@@ -326,4 +323,9 @@ SocketPosts.loadMoreUserPosts = function(socket, data, callback) {posts.getPostsByUid(socket.uid, data.uid, start, end, callback);};+SocketPosts.getRecentPosts = function(socket, term, callback) {+ posts.getRecentPosts(socket.uid, 0, 19, term, callback);+};++module.exports = SocketPosts;\ No newline at end of filediff --git a/src/socket.io/tools.js b/src/socket.io/tools.jsindex 27aa6f071e..a4907b2e7d 100644--- a/src/socket.io/tools.js+++ b/src/socket.io/tools.js@@ -3,7 +3,7 @@ var winston = require('winston');var SocketTools = {};SocketTools.log = function(socket, data, callback) {- winston.info("captured console.log:", data)+ //winston.info("captured console.log:", data)};module.exports = SocketTools;\ No newline at end of filediff --git a/src/socket.io/topics.js b/src/socket.io/topics.jsindex 6a3b4ea086..0185ac60bc 100644--- a/src/socket.io/topics.js+++ b/src/socket.io/topics.js@@ -61,6 +61,9 @@ SocketTopics.post = function(socket, data, callback) {index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result.topicData);index.server.sockets.in('recent_posts').emit('event:new_topic', result.topicData);index.server.sockets.in('home').emit('event:new_topic', result.topicData);+ index.server.sockets.in('home').emit('event:new_post', {+ posts: result.postData+ });index.server.sockets.in('user/' + socket.uid).emit('event:new_post', {posts: result.postData});