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

v1.18.x
Julian Lam 11 years ago
commit 2f1707e772

@ -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
});
});
});
});
};

@ -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;
});

@ -168,4 +168,4 @@ categoriesController.get = function(req, res, next) {
});
};
module.exports = categoriesController;
module.exports = categoriesController;

@ -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;
}

@ -102,8 +102,6 @@ function getRecentPosts(req, res, next) {
module.exports = function(app, middleware, controllers) {
app.namespace('/api', function () {
app.all('*', middleware.updateLastOnlineTime, middleware.prepareAPI);
app.get('/config', controllers.api.getConfig);
app.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);

@ -12,118 +12,124 @@ var nconf = require('nconf'),
pluginRoutes = require('./plugins');
module.exports = function(app, middleware) {
app.namespace(nconf.get('relative_path'), function() {
adminRoutes(app, middleware, controllers);
metaRoutes(app, middleware, controllers);
apiRoutes(app, middleware, controllers);
feedRoutes(app, middleware, controllers);
pluginRoutes(app, middleware, controllers);
/**
* Every view has an associated API route.
*
*/
function mainRoutes(app, middleware, controllers) {
/* Main */
app.get('/', middleware.buildHeader, controllers.home);
app.get('/api/home', controllers.home);
app.get('/login', middleware.redirectToAccountIfLoggedIn, middleware.buildHeader, controllers.login);
app.get('/api/login', middleware.redirectToAccountIfLoggedIn, controllers.login);
/**
* Every view has an associated API route.
*
*/
/* Main */
app.get('/', middleware.buildHeader, controllers.home);
app.get('/api/home', controllers.home);
app.get('/register', middleware.redirectToAccountIfLoggedIn, middleware.buildHeader, controllers.register);
app.get('/api/register', middleware.redirectToAccountIfLoggedIn, controllers.register);
app.get('/login', middleware.redirectToAccountIfLoggedIn, middleware.buildHeader, controllers.login);
app.get('/api/login', middleware.redirectToAccountIfLoggedIn, controllers.login);
app.get('/confirm/:code', middleware.buildHeader, controllers.confirmEmail);
app.get('/api/confirm/:code', controllers.confirmEmail);
app.get('/register', middleware.redirectToAccountIfLoggedIn, middleware.buildHeader, controllers.register);
app.get('/api/register', middleware.redirectToAccountIfLoggedIn, controllers.register);
app.get('/outgoing', middleware.buildHeader, controllers.outgoing);
app.get('/api/outgoing', controllers.outgoing);
app.get('/confirm/:code', middleware.buildHeader, controllers.confirmEmail);
app.get('/api/confirm/:code', controllers.confirmEmail);
app.get('/search/:term?', middleware.buildHeader, middleware.guestSearchingAllowed, controllers.search);
app.get('/api/search/:term', middleware.guestSearchingAllowed, controllers.search);
app.get('/outgoing', middleware.buildHeader, controllers.outgoing);
app.get('/api/outgoing', controllers.outgoing);
app.get('/reset/:code?', middleware.buildHeader, controllers.reset);
app.get('/api/reset/:code?', controllers.reset);
app.get('/search/:term?', middleware.buildHeader, middleware.guestSearchingAllowed, controllers.search);
app.get('/api/search/:term', middleware.guestSearchingAllowed, controllers.search);
/* Static Pages */
app.get('/404', middleware.buildHeader, controllers.static['404']);
app.get('/api/404', controllers.static['404']);
app.get('/reset/:code?', middleware.buildHeader, controllers.reset);
app.get('/api/reset/:code?', controllers.reset);
app.get('/403', middleware.buildHeader, controllers.static['403']);
app.get('/api/403', controllers.static['403']);
/* Static Pages */
app.get('/404', middleware.buildHeader, controllers.static['404']);
app.get('/api/404', controllers.static['404']);
app.get('/500', middleware.buildHeader, controllers.static['500']);
app.get('/api/500', controllers.static['500']);
app.get('/403', middleware.buildHeader, controllers.static['403']);
app.get('/api/403', controllers.static['403']);
/* Topics */
app.get('/topic/:topic_id/:slug?', middleware.buildHeader, controllers.topics.get);
app.get('/api/topic/:topic_id/:slug?', controllers.topics.get);
app.get('/500', middleware.buildHeader, controllers.static['500']);
app.get('/api/500', controllers.static['500']);
/* Categories */
app.get('/popular/:set?', middleware.buildHeader, controllers.categories.popular);
app.get('/api/popular/:set?', controllers.categories.popular);
/* Topics */
app.get('/topic/:topic_id/:slug?', middleware.buildHeader, controllers.topics.get);
app.get('/api/topic/:topic_id/:slug?', controllers.topics.get);
app.get('/recent/:term?', middleware.buildHeader, controllers.categories.recent);
app.get('/api/recent/:term?', controllers.categories.recent);
/* Categories */
app.get('/popular/:set?', middleware.buildHeader, controllers.categories.popular);
app.get('/api/popular/:set?', controllers.categories.popular);
app.get('/unread/', middleware.buildHeader, middleware.authenticate, controllers.categories.unread);
app.get('/api/unread/', middleware.authenticate, controllers.categories.unread);
app.get('/recent/:term?', middleware.buildHeader, controllers.categories.recent);
app.get('/api/recent/:term?', controllers.categories.recent);
app.get('/unread/total', middleware.buildHeader, middleware.authenticate, controllers.categories.unreadTotal);
app.get('/api/unread/total', middleware.authenticate, controllers.categories.unreadTotal);
app.get('/unread/', middleware.buildHeader, middleware.authenticate, controllers.categories.unread);
app.get('/api/unread/', middleware.authenticate, controllers.categories.unread);
app.get('/category/:category_id/:slug?', middleware.buildHeader, controllers.categories.get);
app.get('/api/category/:category_id/:slug?', controllers.categories.get);
app.get('/unread/total', middleware.buildHeader, middleware.authenticate, controllers.categories.unreadTotal);
app.get('/api/unread/total', middleware.authenticate, controllers.categories.unreadTotal);
/* Accounts */
app.get('/user/:userslug', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getAccount);
app.get('/api/user/:userslug', middleware.checkGlobalPrivacySettings, controllers.accounts.getAccount);
app.get('/category/:category_id/:slug?', middleware.buildHeader, controllers.categories.get);
app.get('/api/category/:category_id/:slug?', controllers.categories.get);
app.get('/user/:userslug/following', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowing);
app.get('/api/user/:userslug/following', middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowing);
/* Accounts */
app.get('/user/:userslug', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getAccount);
app.get('/api/user/:userslug', middleware.checkGlobalPrivacySettings, controllers.accounts.getAccount);
app.get('/user/:userslug/followers', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowers);
app.get('/api/user/:userslug/followers', middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowers);
app.get('/user/:userslug/following', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowing);
app.get('/api/user/:userslug/following', middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowing);
app.get('/user/:userslug/favourites', middleware.buildHeader, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.getFavourites);
app.get('/api/user/:userslug/favourites', middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.getFavourites);
app.get('/user/:userslug/followers', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowers);
app.get('/api/user/:userslug/followers', middleware.checkGlobalPrivacySettings, controllers.accounts.getFollowers);
app.get('/user/:userslug/posts', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getPosts);
app.get('/api/user/:userslug/posts', middleware.checkGlobalPrivacySettings, controllers.accounts.getPosts);
app.get('/user/:userslug/favourites', middleware.buildHeader, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.getFavourites);
app.get('/api/user/:userslug/favourites', middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.getFavourites);
app.get('/user/:userslug/edit', middleware.buildHeader, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountEdit);
app.get('/api/user/:userslug/edit', middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountEdit);
app.get('/user/:userslug/posts', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.accounts.getPosts);
app.get('/api/user/:userslug/posts', middleware.checkGlobalPrivacySettings, controllers.accounts.getPosts);
// todo: admin recently gained access to this page, pls check if it actually works
app.get('/user/:userslug/settings', middleware.buildHeader, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountSettings);
app.get('/api/user/:userslug/settings', middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountSettings);
app.get('/user/:userslug/edit', middleware.buildHeader, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountEdit);
app.get('/api/user/:userslug/edit', middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountEdit);
app.get('/notifications', middleware.buildHeader, middleware.authenticate, controllers.accounts.getNotifications);
app.get('/api/notifications', middleware.authenticate, controllers.accounts.getNotifications);
// todo: admin recently gained access to this page, pls check if it actually works
app.get('/user/:userslug/settings', middleware.buildHeader, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountSettings);
app.get('/api/user/:userslug/settings', middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.accountSettings);
/* Users */
app.get('/users', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/api/users', middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/notifications', middleware.buildHeader, middleware.authenticate, controllers.accounts.getNotifications);
app.get('/api/notifications', middleware.authenticate, controllers.accounts.getNotifications);
// was this duped by accident or purpose?
app.get('/users/online', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/api/users/online', middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
/* Users */
app.get('/users', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/api/users', middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/users/sort-posts', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByPosts);
app.get('/api/users/sort-posts', middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByPosts);
// was this duped by accident or purpose?
app.get('/users/online', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/api/users/online', middleware.checkGlobalPrivacySettings, controllers.users.getOnlineUsers);
app.get('/users/sort-reputation', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByReputation);
app.get('/api/users/sort-reputation', middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByReputation);
app.get('/users/sort-posts', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByPosts);
app.get('/api/users/sort-posts', middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByPosts);
app.get('/users/latest', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByJoinDate);
app.get('/api/users/latest', middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByJoinDate);
app.get('/users/sort-reputation', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByReputation);
app.get('/api/users/sort-reputation', middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByReputation);
app.get('/users/search', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersForSearch);
app.get('/api/users/search', middleware.checkGlobalPrivacySettings, controllers.users.getUsersForSearch);
}
app.get('/users/latest', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByJoinDate);
app.get('/api/users/latest', middleware.checkGlobalPrivacySettings, controllers.users.getUsersSortedByJoinDate);
app.get('/users/search', middleware.buildHeader, middleware.checkGlobalPrivacySettings, controllers.users.getUsersForSearch);
app.get('/api/users/search', middleware.checkGlobalPrivacySettings, controllers.users.getUsersForSearch);
module.exports = function(app, middleware) {
app.namespace(nconf.get('relative_path'), function() {
adminRoutes(app, middleware, controllers);
plugins.ready(function() {
app.all('/api/*', middleware.updateLastOnlineTime, middleware.prepareAPI);
plugins.fireHook('action:app.load', app, middleware, controllers);
metaRoutes(app, middleware, controllers);
apiRoutes(app, middleware, controllers);
feedRoutes(app, middleware, controllers);
pluginRoutes(app, middleware, controllers);
mainRoutes(app, middleware, controllers);
});
if (process.env.NODE_ENV === 'development') {

@ -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;

@ -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;

@ -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
});

Loading…
Cancel
Save