Skip to content

Node.js based forum software built for the modern web

edit labels, and fixing responsive layout in topic view

Julian Lamb244da724ef0
diff --git a/public/templates/footer.tpl b/public/templates/footer.tpl
index 24d2e3001b..26075111d5 100644
--- a/public/templates/footer.tpl
+++ b/public/templates/footer.tpl
@@ -2,7 +2,7 @@
</div><!--END container -->
<!-- START Forum Info -->
- <div id="footer" class="container" style="padding-top: 50px; display: none">
+ <div id="footer" class="container hidden-phone" style="padding-top: 50px; display: none">
<div class="alert alert-info">
<span id="active_users"></span>; <span id="active_record"></span><br />
<span id="number_of_users"></span><br />
diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl
index e783276202..4e1756fca0 100644
--- a/public/templates/topic.tpl
+++ b/public/templates/topic.tpl
@@ -3,7 +3,7 @@
<li><a href="/">Home</a><span class="divider">/</span></li>
<li><a href="/category/{category_slug}">{category_name}</a><span class="divider">/</span></li>
<li class="active">{topic_name}</li>
- <div id="thread_active_users"></div>
+ <div id="thread_active_users" class="hidden-phone"></div>
</ul>
</div>
@@ -21,7 +21,6 @@
<div class="post-block">
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
<div class="profile-block">
- <img class="hidden-desktop" src="{posts.gravatar}10" align="left" /> posted by <strong><a href="/users/{posts.username}">{posts.username}</a></strong> {posts.relativeTime} ago
<span class="post-buttons">
<div id="ids_{posts.pid}_{posts.uid}" class="edit {posts.display_moderator_tools} hidden-phone"><i class="icon-pencil"></i></div>
<div id="ids_{posts.pid}_{posts.uid}" class="delete {posts.display_moderator_tools} hidden-phone"><i class="icon-trash"></i></div>
@@ -29,6 +28,9 @@
<div id="favs_{posts.pid}_{posts.uid}" class="favourite hidden-phone"><span class="post_rep_{posts.pid}">{posts.post_rep}</span><i class="{posts.fav_star_class}"></i></div>
<div class="post_reply">Reply <i class="icon-reply"></i></div>
</span>
+ <img class="hidden-desktop" src="{posts.gravatar}?s=10" align="left" /> posted by <strong><a href="/users/{posts.username}">{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}"><i class="icon-edit visible-phone" title="edited by {posts.editor} {posts.relativeEditTime} ago"></i></span>
</div>
</div>
</div>
diff --git a/src/posts.js b/src/posts.js
index 6d97a7cf59..953b16e188 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -17,7 +17,7 @@ var RDB = require('./redis.js'),
//compile thread after all data is asynchronously called
function generateThread() {
- if (!post_data ||! user_data || !thread_data || !vote_data || !viewer_data) return;
+ if (!post_data || !user_data || !thread_data || !vote_data || !viewer_data) return;
var posts = [];
@@ -36,7 +36,10 @@ var RDB = require('./redis.js'),
'user_rep' : user_data[uid].reputation || 0,
'gravatar' : user_data[uid].picture,
'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
- 'display_moderator_tools' : uid == current_user ? 'show' : 'none'
+ 'display_moderator_tools' : uid == current_user ? 'show' : 'none',
+ 'edited-class': post_data.editor[i] !== null ? '' : 'none',
+ 'editor': post_data.editor[i] !== null ? user_data[post_data.editor[i]].username : '',
+ 'relativeEditTime': post_data.editTime !== null ? utils.relativeTime(post_data.editTime[i]) : ''
});
}
@@ -58,13 +61,15 @@ var RDB = require('./redis.js'),
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
RDB.handle(err);
- var content = [], uid = [], timestamp = [], pid = [], post_rep = [];
+ var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [];
for (var i=0, ii=pids.length; i<ii; i++) {
content.push('pid:' + pids[i] + ':content');
uid.push('pid:' + pids[i] + ':uid');
timestamp.push('pid:' + pids[i] + ':timestamp');
- post_rep.push('pid:' + pids[i] + ':rep');
+ post_rep.push('pid:' + pids[i] + ':rep');
+ editor.push('pid:' + pids[i] + ':editor');
+ editTime.push('pid:' + pids[i] + ':edited');
pid.push(pids[i]);
}
@@ -84,13 +89,17 @@ var RDB = require('./redis.js'),
.get('tid:' + tid + ':category_slug')
.get('tid:' + tid + ':deleted')
.get('tid:' + tid + ':pinned')
+ .mget(editor)
+ .mget(editTime)
.exec(function(err, replies) {
post_data = {
pid: pids,
content: replies[0],
uid: replies[1],
timestamp: replies[2],
- reputation: replies[3]
+ reputation: replies[3],
+ editor: replies[10],
+ editTime: replies[11]
};
thread_data = {
@@ -102,6 +111,13 @@ var RDB = require('./redis.js'),
pinned: replies[9] || 0
};
+ // Add any editors to the user_data object
+ for(var x=0,numPosts=replies[10].length;x<numPosts;x++) {
+ if (replies[10][x] !== null && post_data.uid.indexOf(replies[10][x]) === -1) {
+ post_data.uid.push(replies[10][x]);
+ }
+ }
+
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture'], function(user_details){
user_data = user_details;
generateThread();
@@ -268,9 +284,12 @@ var RDB = require('./redis.js'),
});
}
- Posts.edit = function(pid, content) {
+ Posts.edit = function(uid, pid, content) {
RDB.get('pid:' + pid + ':tid', function(err, tid) {
RDB.set('pid:' + pid + ':content', content);
+ RDB.set('pid:' + pid + ':edited', new Date().getTime());
+ RDB.set('pid:' + pid + ':editor', uid);
+
io.sockets.in('topic_' + tid).emit('event:post_edited', { pid: pid, content: marked(content || '') });
});
}
diff --git a/src/topics.js b/src/topics.js
index 92d50acd66..05d3127135 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -97,7 +97,6 @@ var RDB = require('./redis.js'),
topics = topics.sort(function(a, b) {
if (a.pinned !== b.pinned) return b.pinned - a.pinned;
else {
- console.log('here');
// Sort by datetime descending
return b.timestamp - a.timestamp;
}
diff --git a/src/websockets.js b/src/websockets.js
index 0a67ea35cf..a0dacd9bcf 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -220,7 +220,7 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
});
socket.on('api:posts.edit', function(data) {
- modules.posts.edit(data.pid, data.content);
+ modules.posts.edit(uid, data.pid, data.content);
});
});