user name on home.tpl

v1.18.x
Baris Usakli 12 years ago
parent 9e7654fa9a
commit 7f12d568ff

@ -3,7 +3,7 @@
<!-- BEGIN topics -->
<a href="topic/{topics.slug}"><li class="topic-row">
<h4>{topics.title}</h4>
<p>Posted {topics.relativeTime} by user <span class="username">{topics.uid}</span>. {topics.post_count} posts.</p>
<p>Posted {topics.relativeTime} by <span class="username">{topics.uid}</span>. {topics.post_count} posts.</p>
</li></a>
<!-- END topics -->
</ul>
@ -17,13 +17,13 @@ jQuery('document').ready(function() {
jQuery('.username').each(function() {
var userId = this.innerHTML;
socket.on('api:user.get', function(userObj) {
console.log("derp");
console.log(userObj);
(function(span){
socket.on('api:user.getNameByUid', function(username) {
span.innerHTML = username;
});
})(this);
socket.emit('api:user.get', { fields: [ 'uid' ], 'uid': userId });
socket.emit('api:user.getNameByUid', { fields: [ 'username' ], 'uid': userId });
})

@ -262,6 +262,10 @@ var config = require('../config.js'),
RDB.get('username:' + username + ':uid', callback);
};
User.get_username_by_uid = function(uid, callback) {
RDB.get('uid:' + uid+ ':username', callback);
};
User.get_uid_by_email = function(email, callback) {
RDB.get('email:' + email, callback)
};

@ -70,7 +70,13 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
// BEGIN: API calls (todo: organize)
// julian: :^)
socket.on('api:user.get', function(data) {
modules.user.get(socket, data.uid || uid, data.fields);
modules.user.get(socket, uid, data.fields);
});
socket.on('api:user.getNameByUid', function(data) {
modules.user.get_username_by_uid(data.uid, function(data){
socket.emit('api:user.getNameByUid', data);
});
});
socket.on('user.exists', function(data) {

Loading…
Cancel
Save