Skip to content

Node.js based forum software built for the modern web

started to add real data to the topics listing, got latest post working per topic

psychobunnya7cefe35f8c7
diff --git a/public/css/style.less b/public/css/style.less
index 843655f481..4ddb0fee5b 100644
--- a/public/css/style.less
+++ b/public/css/style.less
@@ -170,70 +170,65 @@ footer.footer {
}
}
- @media (max-width: 767px)
- {
-
- }
-
-}
-
-.category {
ul {
margin-left: 0;
}
-}
-.topic-row {
- border-radius: 5px;
-}
-.latest-post {
- float: right;
- padding-top: 2px;
- margin-right: 30px;
- width: 50%;
- .pull-right {
+ .topic-row {
+ border-radius: 5px;
width: 100%;
- height: 50px;
- line-height: 16px;
- margin-left: 1px;
- padding: 5px;
- border-left: 1px solid #bbb;
padding-left: 20px;
- img {
- display: block;
- float: left;
- }
- p {
- display: block;
- float: left;
- width: 70%;
- margin-left: 10px;
- overflow: hidden;
- height: 50px;
+ h3 {
+ padding: 0;
+ margin: 0;
+ margin-top: 4px;
+ line-height: 30px;
+ color: rgb(0, 136, 204);
+
+ small {
+ vertical-align: 2px;
+ strong {
+ color: #666;
+ }
+ }
}
}
-}
-.topic-row {
- width: 100%;
- padding-left: 20px;
-
- h3 {
- padding: 0;
- margin: 0;
- margin-top: 4px;
- line-height: 30px;
- color: rgb(0, 136, 204);
+ .latest-post {
+ float: right;
+ padding-top: 2px;
+ margin-right: 30px;
+ width: 50%;
- small {
- vertical-align: 3px;
+ .pull-right {
+ width: 100%;
+ height: 50px;
+ line-height: 16px;
+ margin-left: 1px;
+ padding: 5px;
+ border-left: 1px solid #bbb;
+ padding-left: 20px;
+
+ img {
+ display: block;
+ float: left;
+ }
+ p {
+ display: block;
+ float: left;
+ width: 70%;
+ margin-left: 10px;
+ overflow: hidden;
+ height: 50px;
+ }
}
}
}
+
.post-container {
list-style-type: none;
padding: 0;
diff --git a/public/templates/category.tpl b/public/templates/category.tpl
index 148c328788..0b5e1f7bae 100644
--- a/public/templates/category.tpl
+++ b/public/templates/category.tpl
@@ -13,15 +13,17 @@
<a href="../../topic/{topics.slug}"><li>
<div class="row-fluid">
<div class="span12 topic-row img-polaroid">
- <div class="latest-post visible-desktop visible-tablet">
+ <div class="latest-post visible-desktop">
<div class="pull-right">
- <img class="hidden-tablet" src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=50" />
- <p><strong>psychobunny</strong>: Some post content goes here, the latest posts of course blah blahposts of course blah blahposts of course blah blahposts of course blah blah</p>
+ <img src="{topics.recent_picture}?s=50" />
+ <p><strong>{topics.recent_author}</strong>: {topics.recent_post}</p>
</div>
</div>
<div>
- <h3><span class="badge {topics.badgeclass}">{topics.post_count}</span> {topics.title} <small>24<i class="icon-star"></i><br />Posted {topics.relativeTime} ago by
- <span class="username">{topics.username}</span>.</small></h3>
+ <h3><span class="badge {topics.badgeclass}">{topics.post_count}</span> {topics.title} <small>24<i class="icon-star"></i><br />
+ <strong><i class="{topics.pin-icon}"></i><i class="{topics.lock-icon}"></i></strong>
+ Posted {topics.relativeTime} ago by
+ <strong>{topics.username}</strong>.</small></h3>
</div>
</div>
</div>
diff --git a/src/posts.js b/src/posts.js
index bc5d531343..ff8baab9a3 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -212,6 +212,14 @@ marked.setOptions({
RDB.set('pid:' + pid + ':tid', tid);
RDB.incr('tid:' + tid + ':postcount');
+
+
+ user.getUserFields(uid, ['username','picture'], function(data){
+ RDB.set('tid:' + tid + ':recent:post', content);
+ RDB.set('tid:' + tid + ':recent:author', data.username);
+ RDB.set('tid:' + tid + ':recent:picture', data.picture);
+ });
+
// User Details - move this out later
RDB.lpush('uid:' + uid + ':posts', pid);
diff --git a/src/topics.js b/src/topics.js
index 05d3127135..74e44e182c 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -27,7 +27,10 @@ var RDB = require('./redis.js'),
postcount = [],
locked = [],
deleted = [],
- pinned = [];
+ pinned = [],
+ recent_post = [],
+ recent_author = [],
+ recent_picture = [];
for (var i=0, ii=tids.length; i<ii; i++) {
title.push('tid:' + tids[i] + ':title');
@@ -38,6 +41,9 @@ var RDB = require('./redis.js'),
locked.push('tid:' + tids[i] + ':locked');
deleted.push('tid:' + tids[i] + ':deleted');
pinned.push('tid:' + tids[i] + ':pinned');
+ recent_post.push('tid:' + tids[i] + ':recent:post');
+ recent_author.push('tid:' + tids[i] + ':recent:author');
+ recent_picture.push('tid:' + tids[i] + ':recent:picture');
}
var multi = RDB.multi()
@@ -53,6 +59,9 @@ var RDB = require('./redis.js'),
.mget(locked)
.mget(deleted)
.mget(pinned)
+ .mget(recent_post)
+ .mget(recent_author)
+ .mget(recent_picture)
}
@@ -69,6 +78,9 @@ var RDB = require('./redis.js'),
locked = replies[6];
deleted = replies[7];
pinned = replies[8];
+ recent_post = replies[9];
+ recent_author = replies[10];
+ recent_picture = replies[11];
var usernames,
has_read;
@@ -76,6 +88,7 @@ var RDB = require('./redis.js'),
function generate_topic() {
if (!usernames || !has_read) return;
+
for (var i=0, ii=title.length; i<ii; i++) {
topics.push({
'title' : title[i],
@@ -89,7 +102,10 @@ var RDB = require('./redis.js'),
'deleted': deleted[i],
'pinned': parseInt(pinned[i] || 0), // For sorting purposes
'pin-icon': pinned[i] === '1' ? 'icon-pushpin' : 'none',
- 'badgeclass' : (has_read[i] && current_user !=0) ? '' : 'badge-important'
+ 'badgeclass' : (has_read[i] && current_user !=0) ? '' : 'badge-important',
+ 'recent_post' : recent_post[i],
+ 'recent_author' : recent_author[i],
+ 'recent_picture' : recent_picture[i]
});
}