mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
username to userslug change
This commit is contained in:
@@ -50,7 +50,7 @@ $(document).ready(function() {
|
|||||||
$('#upload-picture-modal').modal('hide');
|
$('#upload-picture-modal').modal('hide');
|
||||||
}, 750);
|
}, 750);
|
||||||
|
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture'] });
|
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
||||||
success('File uploaded successfully!');
|
success('File uploaded successfully!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -90,7 +90,7 @@ $(document).ready(function() {
|
|||||||
$.post('/users/changepicture',
|
$.post('/users/changepicture',
|
||||||
userData,
|
userData,
|
||||||
function(data) {
|
function(data) {
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture'] });
|
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,22 +30,23 @@
|
|||||||
active_record.innerHTML = "most users ever online was <strong>" + data.record + "</strong> on <strong>" + (new Date(parseInt(data.timestamp,10))).toUTCString() + "</strong>";
|
active_record.innerHTML = "most users ever online was <strong>" + data.record + "</strong> on <strong>" + (new Date(parseInt(data.timestamp,10))).toUTCString() + "</strong>";
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture'] });
|
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
||||||
|
|
||||||
socket.on('api:updateHeader', function(data) {
|
socket.on('api:updateHeader', function(data) {
|
||||||
|
|
||||||
var rightMenu = $('#right-menu');
|
var rightMenu = $('#right-menu');
|
||||||
if (data.uid > 0) {
|
if (data.uid > 0) {
|
||||||
|
|
||||||
var userLabel = rightMenu.find('#user_label');
|
var userLabel = rightMenu.find('#user_label');
|
||||||
if(userLabel.length) {
|
if(userLabel.length) {
|
||||||
userLabel.attr('href','/users/'+data['username']);
|
userLabel.attr('href','/users/'+data['userslug']);
|
||||||
|
|
||||||
userLabel.find('img').attr('src',data['picture']+"?s=24&default=identicon");
|
userLabel.find('img').attr('src',data['picture']+"?s=24&default=identicon");
|
||||||
userLabel.find('span').html(data['username']);
|
userLabel.find('span').html(data['username']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var userli = $('<li> \
|
var userli = $('<li> \
|
||||||
<a id="user_label" href="/users/'+data['username']+'"> \
|
<a id="user_label" href="/users/'+data['userslug']+'"> \
|
||||||
<img src="'+data['picture']+"?s=24&default=identicon"+'"/> \
|
<img src="'+data['picture']+"?s=24&default=identicon"+'"/> \
|
||||||
<span>'+data['username']+'</span> \
|
<span>'+data['username']+'</span> \
|
||||||
</a> \
|
</a> \
|
||||||
|
|||||||
@@ -274,10 +274,11 @@
|
|||||||
socket.on('api:get_users_in_room', function(users) {
|
socket.on('api:get_users_in_room', function(users) {
|
||||||
var anonymous = users.anonymous,
|
var anonymous = users.anonymous,
|
||||||
usernames = users.usernames,
|
usernames = users.usernames,
|
||||||
|
userslugs = users.userslugs,
|
||||||
usercount = usernames.length;
|
usercount = usernames.length;
|
||||||
|
|
||||||
for (var i = 0, ii=usercount; i<ii; i++) {
|
for (var i = 0, ii=usercount; i<ii; i++) {
|
||||||
usernames[i] = '<strong>' + '<a href="/users/'+usernames[i]+'">' + usernames[i] + '</a></strong>';
|
usernames[i] = '<strong>' + '<a href="/users/'+userslugs[i]+'">' + usernames[i] + '</a></strong>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// headexplosion.gif for fun, to see if I could do this in one line of code. feel free to refactor haha
|
// headexplosion.gif for fun, to see if I could do this in one line of code. feel free to refactor haha
|
||||||
|
|||||||
@@ -70,8 +70,8 @@
|
|||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
|
|
||||||
// remove accents, swap ñ for n, etc
|
// remove accents, swap ñ for n, etc
|
||||||
var from = "àáäâèéëêìíïîıòóöôùúüûñçş·/_,:;";
|
var from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
|
||||||
var to = "aaaaeeeeiiiiioooouuuuncs------";
|
var to = "aaaaeeeeiiiiioooouuuuncsg------";
|
||||||
for (var i=0, l=from.length ; i<l ; i++) {
|
for (var i=0, l=from.length ; i<l ; i++) {
|
||||||
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
<div class="account-username-box">
|
<div class="account-username-box">
|
||||||
<span class="account-username">
|
<span class="account-username">
|
||||||
<a href="/users/{username}">{username}</a>
|
<a href="/users/{userslug}">{username}</a>
|
||||||
</span>
|
</span>
|
||||||
<div class="account-sub-links inline-block pull-right">
|
<div class="account-sub-links inline-block pull-right">
|
||||||
<span id="followersLink" class="pull-right"><a href="/users/{username}/followers">followers</a></span>
|
<span id="followersLink" class="pull-right"><a href="/users/{userslug}/followers">followers</a></span>
|
||||||
<span id="followingLink" class="pull-right"><a href="/users/{username}/following">following</a></span>
|
<span id="followingLink" class="pull-right"><a href="/users/{userslug}/following">following</a></span>
|
||||||
<span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span>
|
<span id="editLink" class="pull-right"><a href="/users/{userslug}/edit">edit</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -62,13 +62,13 @@
|
|||||||
|
|
||||||
<div class="account-username-box">
|
<div class="account-username-box">
|
||||||
<span class="account-username">
|
<span class="account-username">
|
||||||
<a href="/users/{username}">{username}</a> >
|
<a href="/users/{userslug}">{username}</a> >
|
||||||
<a href="/users/{username}/edit">edit</a>
|
<a href="/users/{userslug}/edit">edit</a>
|
||||||
</span>
|
</span>
|
||||||
<div class="account-sub-links inline-block pull-right">
|
<div class="account-sub-links inline-block pull-right">
|
||||||
<span id="followersLink" class="pull-right"><a href="/users/{username}/followers">followers</a></span>
|
<span id="followersLink" class="pull-right"><a href="/users/{userslug}/followers">followers</a></span>
|
||||||
<span id="followingLink" class="pull-right"><a href="/users/{username}/following">following</a></span>
|
<span id="followingLink" class="pull-right"><a href="/users/{userslug}/following">following</a></span>
|
||||||
<span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span>
|
<span id="editLink" class="pull-right"><a href="/users/{userslug}/edit">edit</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,7 @@
|
|||||||
var isAdmin = adminBtn.attr('data-admin') !== "0";
|
var isAdmin = adminBtn.attr('data-admin') !== "0";
|
||||||
var parent = adminBtn.parents('.users-box');
|
var parent = adminBtn.parents('.users-box');
|
||||||
var uid = parent.attr('data-uid');
|
var uid = parent.attr('data-uid');
|
||||||
console.log(uid);
|
|
||||||
console.log(yourid);
|
|
||||||
if(isAdmin && uid != yourid)
|
if(isAdmin && uid != yourid)
|
||||||
adminBtn.show();
|
adminBtn.show();
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="block-content">
|
<div class="block-content">
|
||||||
<!-- BEGIN active_users -->
|
<!-- BEGIN active_users -->
|
||||||
<a href="/users/{active_users.username}"><img title="{active_users.username}" src="/graph/users/{active_users.username}/picture" class="img-polaroid" /></a>
|
<a href="/users/{active_users.userslug}"><img title="{active_users.username}" src="/graph/users/{active_users.username}/picture" class="img-polaroid" /></a>
|
||||||
<!-- END active_users -->
|
<!-- END active_users -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="block-content">
|
<div class="block-content">
|
||||||
<!-- BEGIN moderators -->
|
<!-- BEGIN moderators -->
|
||||||
<a href="/users/{moderators.username}"><img title="{moderators.username}" src="/graph/users/{moderators.username}/picture" class="img-polaroid" /></a>
|
<a href="/users/{moderators.userslug}"><img title="{moderators.username}" src="/graph/users/{moderators.username}/picture" class="img-polaroid" /></a>
|
||||||
<!-- END moderators -->
|
<!-- END moderators -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
<div class="account-username-box">
|
<div class="account-username-box">
|
||||||
<span class="account-username">
|
<span class="account-username">
|
||||||
<a href="/users/{username}">{username}</a> >
|
<a href="/users/{userslug}">{username}</a> >
|
||||||
<a href="/users/{username}/followers">followers</a>
|
<a href="/users/{userslug}/followers">followers</a>
|
||||||
</span>
|
</span>
|
||||||
<div class="account-sub-links inline-block pull-right">
|
<div class="account-sub-links inline-block pull-right">
|
||||||
<span id="followersLink" class="pull-right"><a href="/users/{username}/followers">followers</a></span>
|
<span id="followersLink" class="pull-right"><a href="/users/{userslug}/followers">followers</a></span>
|
||||||
<span id="followingLink" class="pull-right"><a href="/users/{username}/following">following</a></span>
|
<span id="followingLink" class="pull-right"><a href="/users/{userslug}/following">following</a></span>
|
||||||
<span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span>
|
<span id="editLink" class="pull-right"><a href="/users/{userslug}/edit">edit</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -17,11 +17,11 @@
|
|||||||
<!-- BEGIN followers -->
|
<!-- BEGIN followers -->
|
||||||
|
|
||||||
<div class="users-box well">
|
<div class="users-box well">
|
||||||
<a href="/users/{followers.username}">
|
<a href="/users/{followers.userslug}">
|
||||||
<img src="{followers.picture}" class="user-8080-picture"/>
|
<img src="{followers.picture}" class="user-8080-picture"/>
|
||||||
</a>
|
</a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="/users/{followers.username}">{followers.username}</a>
|
<a href="/users/{followers.userslug}">{followers.username}</a>
|
||||||
<br/>
|
<br/>
|
||||||
<div title="reputation">
|
<div title="reputation">
|
||||||
<span class='reputation'>{followers.reputation}</span>
|
<span class='reputation'>{followers.reputation}</span>
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
<div class="account-username-box">
|
<div class="account-username-box">
|
||||||
<span class="account-username">
|
<span class="account-username">
|
||||||
<a href="/users/{username}">{username}</a> >
|
<a href="/users/{userslug}">{username}</a> >
|
||||||
<a href="/users/{username}/following">following</a>
|
<a href="/users/{userslug}/following">following</a>
|
||||||
</span>
|
</span>
|
||||||
<div class="account-sub-links inline-block pull-right">
|
<div class="account-sub-links inline-block pull-right">
|
||||||
<span id="followersLink" class="pull-right"><a href="/users/{username}/followers">followers</a></span>
|
<span id="followersLink" class="pull-right"><a href="/users/{userslug}/followers">followers</a></span>
|
||||||
<span id="followingLink" class="pull-right"><a href="/users/{username}/following">following</a></span>
|
<span id="followingLink" class="pull-right"><a href="/users/{userslug}/following">following</a></span>
|
||||||
<span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span>
|
<span id="editLink" class="pull-right"><a href="/users/{userslug}/edit">edit</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -19,11 +19,11 @@
|
|||||||
<!-- BEGIN following -->
|
<!-- BEGIN following -->
|
||||||
|
|
||||||
<div class="users-box well">
|
<div class="users-box well">
|
||||||
<a href="/users/{following.username}">
|
<a href="/users/{following.userslug}">
|
||||||
<img src="{following.picture}" class="user-8080-picture"/>
|
<img src="{following.picture}" class="user-8080-picture"/>
|
||||||
</a>
|
</a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="/users/{following.username}">{following.username}</a>
|
<a href="/users/{following.userslug}">{following.username}</a>
|
||||||
<br/>
|
<br/>
|
||||||
<div title="reputation">
|
<div title="reputation">
|
||||||
<span class='reputation'>{following.reputation}</span>
|
<span class='reputation'>{following.reputation}</span>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<li class="row post-row main-post" data-pid="{main_posts.pid}" data-uid="{main_posts.uid}" data-deleted="{main_posts.deleted}">
|
<li class="row post-row main-post" data-pid="{main_posts.pid}" data-uid="{main_posts.uid}" data-deleted="{main_posts.deleted}">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="post-block">
|
<div class="post-block">
|
||||||
<a class="main-avatar" href="/users/{main_posts.username}">
|
<a class="main-avatar" href="/users/{main_posts.userslug}">
|
||||||
<img src="{main_posts.gravatar}?s=80&default=identicon" align="left" /><br />
|
<img src="{main_posts.gravatar}?s=80&default=identicon" align="left" /><br />
|
||||||
<div class="hover-overlay">
|
<div class="hover-overlay">
|
||||||
{main_posts.username}<br />
|
{main_posts.username}<br />
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div class="topic-buttons pull-left">
|
<div class="topic-buttons pull-left">
|
||||||
<a href="/users/{main_posts.username}" class="username-field btn hidden-phone">{main_posts.username}</a>
|
<a href="/users/{main_posts.userslug}" class="username-field btn hidden-phone">{main_posts.username}</a>
|
||||||
<a target="_blank" class="btn hidden-phone" href="../{topic_id}.rss" title="RSS Feed"><i class="icon-rss-sign"></i></a>
|
<a target="_blank" class="btn hidden-phone" href="../{topic_id}.rss" title="RSS Feed"><i class="icon-rss-sign"></i></a>
|
||||||
<button class="btn follow" type="button" title="Be notified of new replies in this topic"><i class="icon-eye-open"></i></button>
|
<button class="btn follow" type="button" title="Be notified of new replies in this topic"><i class="icon-eye-open"></i></button>
|
||||||
<button id="ids_{main_posts.pid}_{main_posts.uid}" class="btn edit {main_posts.display_moderator_tools}" type="button" title="Edit"><i class="icon-pencil"></i></button>
|
<button id="ids_{main_posts.pid}_{main_posts.uid}" class="btn edit {main_posts.display_moderator_tools}" type="button" title="Edit"><i class="icon-pencil"></i></button>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
||||||
<div class="post-signature">{main_posts.signature}</div>
|
<div class="post-signature">{main_posts.signature}</div>
|
||||||
<div class="profile-block">
|
<div class="profile-block">
|
||||||
<img class="hidden-desktop" src="{main_posts.gravatar}?s=10&default=identicon" align="left" /> posted by <strong><a class="" href="/users/{main_posts.username}">{main_posts.username}</a></strong> {main_posts.relativeTime} ago
|
<img class="hidden-desktop" src="{main_posts.gravatar}?s=10&default=identicon" align="left" /> posted by <strong><a class="" href="/users/{main_posts.userslug}">{main_posts.username}</a></strong> {main_posts.relativeTime} ago
|
||||||
<span class="{main_posts.edited-class} hidden-phone">| last edited by <strong><a href="/users/{main_posts.editor}">{main_posts.editor}</a></strong> {main_posts.relativeEditTime} ago</span>
|
<span class="{main_posts.edited-class} hidden-phone">| last edited by <strong><a href="/users/{main_posts.editor}">{main_posts.editor}</a></strong> {main_posts.relativeEditTime} ago</span>
|
||||||
<span class="{main_posts.edited-class}"><i class="icon-edit visible-phone" title="edited by {main_posts.editor} {main_posts.relativeEditTime} ago"></i></span>
|
<span class="{main_posts.edited-class}"><i class="icon-edit visible-phone" title="edited by {main_posts.editor} {main_posts.relativeEditTime} ago"></i></span>
|
||||||
<div class="post-buttons visible-phone">
|
<div class="post-buttons visible-phone">
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<li class="row post-row" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-deleted="{posts.deleted}">
|
<li class="row post-row" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-deleted="{posts.deleted}">
|
||||||
<div class="span1 profile-image-block visible-desktop">
|
<div class="span1 profile-image-block visible-desktop">
|
||||||
<!--<i class="icon-spinner icon-spin icon-2x pull-left"></i>-->
|
<!--<i class="icon-spinner icon-spin icon-2x pull-left"></i>-->
|
||||||
<a href="/users/{posts.username}">
|
<a href="/users/{posts.userslug}">
|
||||||
<img src="{posts.gravatar}?s=80&default=identicon" align="left" />
|
<img src="{posts.gravatar}?s=80&default=identicon" align="left" />
|
||||||
</a>
|
</a>
|
||||||
<i class="icon-star"></i><span class="user_rep_{posts.uid} formatted-number">{posts.user_rep}</span>
|
<i class="icon-star"></i><span class="user_rep_{posts.uid} formatted-number">{posts.user_rep}</span>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<div id="favs_{posts.pid}_{posts.uid}" class="favourite hidden-phone" title="Favourite"><span class="post_rep_{posts.pid}">{posts.post_rep}</span><i class="{posts.fav_star_class}"></i></div>
|
<div id="favs_{posts.pid}_{posts.uid}" class="favourite hidden-phone" title="Favourite"><span class="post_rep_{posts.pid}">{posts.post_rep}</span><i class="{posts.fav_star_class}"></i></div>
|
||||||
<div class="post_reply" title="Reply"><i class="icon-reply"></i></div>
|
<div class="post_reply" title="Reply"><i class="icon-reply"></i></div>
|
||||||
</span>
|
</span>
|
||||||
<img class="hidden-desktop" src="{posts.gravatar}?s=10&default=identicon" align="left" /> posted by <strong><a class="username-field" href="/users/{posts.username}">{posts.username}</a></strong> {posts.relativeTime} ago
|
<img class="hidden-desktop" src="{posts.gravatar}?s=10&default=identicon" align="left" /> posted by <strong><a class="username-field" href="/users/{posts.userslug}">{posts.username}</a></strong> {posts.relativeTime} ago
|
||||||
<span class="{posts.edited-class} hidden-phone">| last edited by <strong><a href="/users/{posts.editor}">{posts.editor}</a></strong> {posts.relativeEditTime} ago</span>
|
<span class="{posts.edited-class} hidden-phone">| last edited by <strong><a href="/users/{posts.editor}">{posts.editor}</a></strong> {posts.relativeEditTime} ago</span>
|
||||||
<span class="{posts.edited-class}"><i class="icon-edit visible-phone" title="edited by {posts.editor} {posts.relativeEditTime} ago"></i></span>
|
<span class="{posts.edited-class}"><i class="icon-edit visible-phone" title="edited by {posts.editor} {posts.relativeEditTime} ago"></i></span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- BEGIN users -->
|
<!-- BEGIN users -->
|
||||||
<div class="users-box well">
|
<div class="users-box well">
|
||||||
<a href="/users/{users.username}">
|
<a href="/users/{users.userslug}">
|
||||||
<img src="{users.picture}" class="user-8080-picture"/>
|
<img src="{users.picture}" class="user-8080-picture"/>
|
||||||
</a>
|
</a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="/users/{users.username}">{users.username}</a>
|
<a href="/users/{users.userslug}">{users.username}</a>
|
||||||
<br/>
|
<br/>
|
||||||
<div title="reputation">
|
<div title="reputation">
|
||||||
<span class='reputation'>{users.reputation}</span>
|
<span class='reputation'>{users.reputation}</span>
|
||||||
|
|||||||
@@ -13,18 +13,13 @@ var RDB = require('./redis.js'),
|
|||||||
.get('cid:' + category_id + ':name')
|
.get('cid:' + category_id + ':name')
|
||||||
.smembers('cid:' + category_id + ':active_users')
|
.smembers('cid:' + category_id + ':active_users')
|
||||||
.exec(function(err, replies) {
|
.exec(function(err, replies) {
|
||||||
category_name = replies[0];
|
var category_name = replies[0];
|
||||||
active_usernames = replies[1];
|
var active_users = replies[1];
|
||||||
|
|
||||||
if (category_name === null) {
|
if (category_name === null) {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var active_users = [];
|
|
||||||
for (var username in active_usernames) {
|
|
||||||
active_users.push({'username': active_usernames[username]});
|
|
||||||
}
|
|
||||||
|
|
||||||
var categoryData = {
|
var categoryData = {
|
||||||
'category_name' : category_name,
|
'category_name' : category_name,
|
||||||
'show_sidebar' : 'show',
|
'show_sidebar' : 'show',
|
||||||
@@ -32,7 +27,7 @@ var RDB = require('./redis.js'),
|
|||||||
'no_topics_message': 'hidden',
|
'no_topics_message': 'hidden',
|
||||||
'topic_row_size': 'span9',
|
'topic_row_size': 'span9',
|
||||||
'category_id': category_id,
|
'category_id': category_id,
|
||||||
'active_users': active_users,
|
'active_users': [],
|
||||||
'topics' : []
|
'topics' : []
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,6 +43,16 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getActiveUsers(next) {
|
||||||
|
user.getMultipleUserFields(active_users, ['username','userslug'], function(users) {
|
||||||
|
var activeUserData = [];
|
||||||
|
for(var uid in users) {
|
||||||
|
activeUserData.push(users[uid]);
|
||||||
|
}
|
||||||
|
next(null, activeUserData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (tids.length === 0) {
|
if (tids.length === 0) {
|
||||||
getModerators(function(err, moderators) {
|
getModerators(function(err, moderators) {
|
||||||
categoryData.moderator_block_class = moderators.length > 0 ? '' : 'none';
|
categoryData.moderator_block_class = moderators.length > 0 ? '' : 'none';
|
||||||
@@ -58,10 +63,11 @@ var RDB = require('./redis.js'),
|
|||||||
callback(categoryData);
|
callback(categoryData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
async.parallel([getTopics, getModerators], function(err, results) {
|
async.parallel([getTopics, getModerators, getActiveUsers], function(err, results) {
|
||||||
categoryData.topics = results[0];
|
categoryData.topics = results[0];
|
||||||
categoryData.moderator_block_class = results[1].length > 0 ? '' : 'none';
|
categoryData.moderator_block_class = results[1].length > 0 ? '' : 'none';
|
||||||
categoryData.moderators = results[1];
|
categoryData.moderators = results[1];
|
||||||
|
categoryData.active_users = results[2];
|
||||||
callback(categoryData);
|
callback(categoryData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ marked.setOptions({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture', 'signature'], function(user_details) {
|
user.getMultipleUserFields(post_data.uid, ['username', 'userslug', 'reputation', 'picture', 'signature'], function(user_details) {
|
||||||
next(null, {
|
next(null, {
|
||||||
users: user_details,
|
users: user_details,
|
||||||
posts: post_data
|
posts: post_data
|
||||||
@@ -272,7 +272,8 @@ marked.setOptions({
|
|||||||
RDB.spop('cid:' + cid + ':active_users');
|
RDB.spop('cid:' + cid + ':active_users');
|
||||||
}
|
}
|
||||||
|
|
||||||
RDB.sadd('cid:' + cid + ':active_users', data.username);
|
//RDB.sadd('cid:' + cid + ':active_users', data.username);
|
||||||
|
RDB.sadd('cid:' + cid + ':active_users', uid);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,13 +28,14 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users/:username', function(req, res) {
|
app.get('/users/:userslug', function(req, res) {
|
||||||
if(!req.params.username) {
|
|
||||||
|
if(!req.params.userslug) {
|
||||||
res.send("User doesn't exist!");
|
res.send("User doesn't exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.get_uid_by_username(req.params.username, function(uid) {
|
user.get_uid_by_userslug(req.params.userslug, function(uid) {
|
||||||
if(!uid) {
|
if(!uid) {
|
||||||
res.redirect('/404');
|
res.redirect('/404');
|
||||||
return;
|
return;
|
||||||
@@ -42,7 +43,7 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
user.getUserData(uid, function(data) {
|
user.getUserData(uid, function(data) {
|
||||||
if(data) {
|
if(data) {
|
||||||
res.send(app.build_header(res) + app.create_route('users/'+data.username, 'account') + templates['footer']);
|
res.send(app.build_header(res) + app.create_route('users/'+data.userslug, 'account') + templates['footer']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.redirect('/404');
|
res.redirect('/404');
|
||||||
@@ -51,15 +52,15 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users/:username/edit', function(req, res){
|
app.get('/users/:userslug/edit', function(req, res){
|
||||||
|
|
||||||
if(!req.user)
|
if(!req.user)
|
||||||
return res.redirect('/403');
|
return res.redirect('/403');
|
||||||
|
|
||||||
user.getUserField(req.user.uid, 'username', function(username) {
|
user.getUserField(req.user.uid, 'userslug', function(userslug) {
|
||||||
|
|
||||||
if(req.params.username && username === req.params.username)
|
if(req.params.userslug && userslug === req.params.userslug)
|
||||||
res.send(app.build_header(res) + app.create_route('users/'+req.params.username+'/edit','accountedit') + templates['footer']);
|
res.send(app.build_header(res) + app.create_route('users/'+req.params.userslug+'/edit','accountedit') + templates['footer']);
|
||||||
else
|
else
|
||||||
return res.redirect('/404');
|
return res.redirect('/404');
|
||||||
});
|
});
|
||||||
@@ -217,35 +218,35 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users/:username/following', function(req, res) {
|
app.get('/users/:userslug/following', function(req, res) {
|
||||||
|
|
||||||
if(!req.user)
|
if(!req.user)
|
||||||
return res.redirect('/403');
|
return res.redirect('/403');
|
||||||
|
|
||||||
res.send(app.build_header(res) + app.create_route('users/'+req.params.username+'/following','following') + templates['footer']);
|
res.send(app.build_header(res) + app.create_route('users/'+req.params.userslug+'/following','following') + templates['footer']);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users/:username/followers', function(req, res) {
|
app.get('/users/:userslug/followers', function(req, res) {
|
||||||
|
|
||||||
if(!req.user)
|
if(!req.user)
|
||||||
return res.redirect('/403');
|
return res.redirect('/403');
|
||||||
|
|
||||||
res.send(app.build_header(res) + app.create_route('users/'+req.params.username+'/followers','followers') + templates['footer']);
|
res.send(app.build_header(res) + app.create_route('users/'+req.params.userslug+'/followers','followers') + templates['footer']);
|
||||||
});
|
});
|
||||||
|
|
||||||
function api_method(req, res) {
|
function api_method(req, res) {
|
||||||
|
|
||||||
var callerUID = req.user?req.user.uid : 0;
|
var callerUID = req.user?req.user.uid : 0;
|
||||||
|
|
||||||
if (!req.params.section && !req.params.username) {
|
if (!req.params.section && !req.params.userslug) {
|
||||||
|
|
||||||
user.getUserList(function(data){
|
user.getUserList(function(data) {
|
||||||
res.json({users:data});
|
res.json({users:data});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(String(req.params.section).toLowerCase() === 'following') {
|
else if(String(req.params.section).toLowerCase() === 'following') {
|
||||||
|
|
||||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
getUserDataByUserSlug(req.params.userslug, callerUID, function(userData) {
|
||||||
|
|
||||||
user.getFollowing(userData.uid, function(followingData){
|
user.getFollowing(userData.uid, function(followingData){
|
||||||
userData.following = followingData;
|
userData.following = followingData;
|
||||||
@@ -256,7 +257,7 @@ var user = require('./../user.js'),
|
|||||||
}
|
}
|
||||||
else if(String(req.params.section).toLowerCase() === 'followers') {
|
else if(String(req.params.section).toLowerCase() === 'followers') {
|
||||||
|
|
||||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
getUserDataByUserSlug(req.params.userslug, callerUID, function(userData) {
|
||||||
|
|
||||||
user.getFollowers(userData.uid, function(followersData){
|
user.getFollowers(userData.uid, function(followersData){
|
||||||
userData.followers = followersData;
|
userData.followers = followersData;
|
||||||
@@ -266,11 +267,11 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (String(req.params.section).toLowerCase() === 'edit') {
|
else if (String(req.params.section).toLowerCase() === 'edit') {
|
||||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
getUserDataByUserSlug(req.params.userslug, callerUID, function(userData) {
|
||||||
res.json(userData);
|
res.json(userData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
getUserDataByUserSlug(req.params.userslug, callerUID, function(userData) {
|
||||||
|
|
||||||
user.isFollowing(callerUID, userData.theirid, function(isFollowing) {
|
user.isFollowing(callerUID, userData.theirid, function(isFollowing) {
|
||||||
userData.isFollowing = isFollowing;
|
userData.isFollowing = isFollowing;
|
||||||
@@ -285,11 +286,11 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/api/users/:username?/:section?', api_method);
|
app.get('/api/users/:userslug?/:section?', api_method);
|
||||||
|
|
||||||
function getUserDataByUserName(username, callerUID, callback) {
|
function getUserDataByUserSlug(userslug, callerUID, callback) {
|
||||||
|
|
||||||
user.get_uid_by_username(username, function(uid) {
|
user.get_uid_by_userslug(userslug, function(uid) {
|
||||||
|
|
||||||
user.getUserData(uid, function(data) {
|
user.getUserData(uid, function(data) {
|
||||||
if(data) {
|
if(data) {
|
||||||
|
|||||||
@@ -234,7 +234,6 @@ var RDB = require('./redis.js'),
|
|||||||
async.parallel([
|
async.parallel([
|
||||||
function(next) {
|
function(next) {
|
||||||
topics.get_topic(tid, 0, function(threadData) {
|
topics.get_topic(tid, 0, function(threadData) {
|
||||||
// console.log(threadData);
|
|
||||||
notifications.create(threadData.teaser_username + ' has posted a reply to: "' + threadData.title + '"', null, '/topic/' + tid, 'topic:' + tid, function(nid) {
|
notifications.create(threadData.teaser_username + ' has posted a reply to: "' + threadData.title + '"', null, '/topic/' + tid, 'topic:' + tid, function(nid) {
|
||||||
next(null, nid);
|
next(null, nid);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ marked.setOptions({
|
|||||||
'timestamp' : postData.timestamp[i],
|
'timestamp' : postData.timestamp[i],
|
||||||
'relativeTime': utils.relativeTime(postData.timestamp[i]),
|
'relativeTime': utils.relativeTime(postData.timestamp[i]),
|
||||||
'username' : userData[uid].username || 'anonymous',
|
'username' : userData[uid].username || 'anonymous',
|
||||||
|
'userslug' : userData[uid].userslug || '',
|
||||||
'user_rep' : userData[uid].reputation || 0,
|
'user_rep' : userData[uid].reputation || 0,
|
||||||
'gravatar' : userData[uid].picture || 'http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e',
|
'gravatar' : userData[uid].picture || 'http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e',
|
||||||
'signature' : marked(userData[uid].signature || ''),
|
'signature' : marked(userData[uid].signature || ''),
|
||||||
|
|||||||
59
src/user.js
59
src/user.js
@@ -136,6 +136,30 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
User.delete = function(uid, callback) {
|
||||||
|
RDB.exists('user:'+uid, function(err, exists) {
|
||||||
|
if(exists === 1) {
|
||||||
|
console.log('deleting uid ' + uid);
|
||||||
|
|
||||||
|
User.getUserData(uid, function(data) {
|
||||||
|
|
||||||
|
RDB.del('username:' + data['username'] + ':uid');
|
||||||
|
RDB.del('email:' + data['email'] +':uid');
|
||||||
|
RDB.del('userslug:'+ data['userslug'] +':uid');
|
||||||
|
|
||||||
|
RDB.del('user:' + uid);
|
||||||
|
RDB.del('followers:' + uid);
|
||||||
|
RDB.del('following:' + uid);
|
||||||
|
|
||||||
|
RDB.lrem('userlist', 1, uid);
|
||||||
|
|
||||||
|
callback(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
callback(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
User.create = function(username, password, email, callback) {
|
User.create = function(username, password, email, callback) {
|
||||||
|
|
||||||
@@ -144,13 +168,11 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
RDB.handle(err);
|
RDB.handle(err);
|
||||||
|
|
||||||
var gravatar = User.createGravatarURLFromEmail(email);
|
var gravatar = User.createGravatarURLFromEmail(email);
|
||||||
|
var userslug = utils.slugify(username);
|
||||||
var userSlug = utils.slugify(username);
|
|
||||||
|
|
||||||
console.log(userSlug);
|
|
||||||
|
|
||||||
RDB.hmset('user:'+uid, {
|
RDB.hmset('user:'+uid, {
|
||||||
'username' : username,
|
'username' : username,
|
||||||
|
'userslug' : userslug,
|
||||||
'fullname': '',
|
'fullname': '',
|
||||||
'location':'',
|
'location':'',
|
||||||
'birthday':'',
|
'birthday':'',
|
||||||
@@ -169,6 +191,7 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
RDB.set('username:' + username + ':uid', uid);
|
RDB.set('username:' + username + ':uid', uid);
|
||||||
RDB.set('email:' + email +':uid', uid);
|
RDB.set('email:' + email +':uid', uid);
|
||||||
|
RDB.set('userslug:'+ userslug +':uid', uid);
|
||||||
|
|
||||||
if(email)
|
if(email)
|
||||||
User.sendConfirmationEmail(email);
|
User.sendConfirmationEmail(email);
|
||||||
@@ -387,6 +410,13 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
User.get_uid_by_userslug = function(userslug, callback) {
|
||||||
|
RDB.get('userslug:' + userslug + ':uid', function(err, data) {
|
||||||
|
RDB.handle(err);
|
||||||
|
callback(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
User.get_usernames_by_uids = function(uids, callback) {
|
User.get_usernames_by_uids = function(uids, callback) {
|
||||||
var usernames = [];
|
var usernames = [];
|
||||||
|
|
||||||
@@ -394,7 +424,7 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
for(var i=0, ii=uids.length; i<ii; ++i) {
|
for(var i=0, ii=uids.length; i<ii; ++i) {
|
||||||
|
|
||||||
User.getUserField(uids[i],'username', function(username){
|
User.getUserField(uids[i],'username', function(username) {
|
||||||
|
|
||||||
usernames.push(username);
|
usernames.push(username);
|
||||||
|
|
||||||
@@ -402,7 +432,24 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
callback(usernames);
|
callback(usernames);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
User.get_userslugs_by_uids = function(uids, callback) {
|
||||||
|
var userslugs = [];
|
||||||
|
|
||||||
|
if (!Array.isArray(uids)) return callback([]);
|
||||||
|
|
||||||
|
for(var i=0, ii=uids.length; i<ii; ++i) {
|
||||||
|
|
||||||
|
User.getUserField(uids[i],'userslug', function(userslug) {
|
||||||
|
|
||||||
|
userslugs.push(userslug);
|
||||||
|
|
||||||
|
if(userslugs.length >= uids.length)
|
||||||
|
callback(userslugs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
User.get_uid_by_email = function(email, callback) {
|
User.get_uid_by_email = function(email, callback) {
|
||||||
RDB.get('email:' + email + ':uid', function(err, data) {
|
RDB.get('email:' + email + ':uid', function(err, data) {
|
||||||
|
|||||||
@@ -295,7 +295,6 @@ var express = require('express'),
|
|||||||
res.send();
|
res.send();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//START TODO: MOVE TO GRAPH.JS
|
//START TODO: MOVE TO GRAPH.JS
|
||||||
|
|
||||||
app.get('/graph/users/:username/picture', function(req, res) {
|
app.get('/graph/users/:username/picture', function(req, res) {
|
||||||
|
|||||||
@@ -109,11 +109,16 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
|||||||
|
|
||||||
|
|
||||||
user.get_usernames_by_uids(uids, function(usernames) {
|
user.get_usernames_by_uids(uids, function(usernames) {
|
||||||
io.sockets.in(data.enter).emit('api:get_users_in_room', {
|
user.get_userslugs_by_uids(uids, function(userslugs) {
|
||||||
usernames: usernames,
|
|
||||||
uids: uids,
|
io.sockets.in(data.enter).emit('api:get_users_in_room', {
|
||||||
anonymous: anonymous
|
usernames: usernames,
|
||||||
|
userslugs: userslugs,
|
||||||
|
uids: uids,
|
||||||
|
anonymous: anonymous
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.enter != 'admin') io.sockets.in('admin').emit('api:get_all_rooms', io.sockets.manager.rooms);
|
if (data.enter != 'admin') io.sockets.in('admin').emit('api:get_all_rooms', io.sockets.manager.rooms);
|
||||||
|
|||||||
Reference in New Issue
Block a user