Skip to content

Node.js based forum software built for the modern web

added real username to posts

psychobunnyedf58693cc0b
diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl
index 76f46a15be..a2271ea2ac 100644
--- a/public/templates/topic.tpl
+++ b/public/templates/topic.tpl
@@ -18,7 +18,7 @@
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
<!--<p>Posted {posts.relativeTime} by user {posts.uid}.</p>-->
<div class="profile-block">
- posted by <strong>psychobunny</strong> {posts.relativeTime}
+ posted by <strong>{posts.userName}</strong> {posts.relativeTime}
<span class="post-buttons">
<div id="quote_{posts.pid}" class="quote"><i class="icon-quote-left"></i></div>
<div class="favourite"><i class="icon-star-empty"></i></div>
diff --git a/src/posts.js b/src/posts.js
index dc83f5f0b3..5bc0d23410 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -1,6 +1,7 @@
var RDB = require('./redis.js'),
utils = require('./utils.js'),
- marked = require('marked');
+ marked = require('marked'),
+ user = require('./user.js');
(function(Posts) {
//data structure
@@ -41,18 +42,21 @@ var RDB = require('./redis.js'),
uid = replies[1];
timestamp = replies[2];
- var posts = [];
- for (var i=0, ii=content.length; i<ii; i++) {
- posts.push({
- 'pid' : pid[i],
- 'content' : marked(content[i]),
- 'uid' : uid[i],
- 'timestamp' : timestamp[i],
- 'relativeTime': utils.relativeTime(timestamp[i])
- });
- }
-
- callback({'topic_name':topic_name, 'topic_id': tid, 'posts': posts});
+ user.get_usernames_by_uids(uid, function(userNames) {
+ var posts = [];
+ for (var i=0, ii=content.length; i<ii; i++) {
+ posts.push({
+ 'pid' : pid[i],
+ 'content' : marked(content[i]),
+ 'uid' : uid[i],
+ 'userName' : userNames[i] || 'anonymous',
+ 'timestamp' : timestamp[i],
+ 'relativeTime': utils.relativeTime(timestamp[i])
+ });
+ }
+
+ callback({'topic_name':topic_name, 'topic_id': tid, 'posts': posts});
+ });
});
} else {
callback({});