Node.js based forum software built for the modern web
closes #306
Baris Usakliefef9c864c3c
diff --git a/public/src/app.js b/public/src/app.jsindex 7c0849faac..00aaf7c47c 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -284,6 +284,8 @@ var socket,});}+ $('span.timeago').timeago();+setTimeout(function() {window.scrollTo(0, 1); // rehide address bar on mobile after page load completes.}, 100);@@ -346,6 +348,7 @@ var socket,app.populate_online_users();app.addCommasToNumbers();+ $('span.timeago').timeago();}app.infiniteLoaderActive = false;diff --git a/public/src/forum/category.js b/public/src/forum/category.jsindex 24a059ae42..b477083764 100644--- a/public/src/forum/category.js+++ b/public/src/forum/category.js@@ -81,7 +81,7 @@var frag = document.createDocumentFragment(),li = document.createElement('li');for (var i = 0, numPosts = posts.length; i < numPosts; i++) {- var dateString = utils.relativeTime(posts[i].timestamp);+li.setAttribute('data-pid', posts[i].pid);@@ -90,12 +90,13 @@'<p>' +posts[i].content +'</p>' +- '<span><strong>' + posts[i].username + '</strong> - ' + utils.relativeTime(posts[i].timestamp) + ' ago</span>' ++ '<span><strong>' + posts[i].username + '</strong></span> -<span class="timeago" title="' + posts[i].relativeTime + '"></span>' +'</a>';frag.appendChild(li.cloneNode(true));recent_replies.appendChild(frag);}+ $('#category_recent_replies span.timeago').timeago();});function onTopicsLoaded(topics) {@@ -109,8 +110,9 @@jQuery('#category-no-topics').remove();container.append(html);- }+ $('#topics-container span.timeago').timeago();+ }function loadMoreTopics(cid) {@@ -135,4 +137,4 @@});-})();\ No newline at end of file+})();diff --git a/public/templates/account.tpl b/public/templates/account.tplindex b052bf7b49..929771940b 100644--- a/public/templates/account.tpl+++ b/public/templates/account.tpl@@ -47,8 +47,8 @@<span>{age}</span><br/><hr/>- <span class="account-bio-label">member for</span>- <span>{joindate}</span>+ <span class="account-bio-label">joined</span>+ <span class="timeago" title="{joindate}"></span><br/><span class="account-bio-label">profile views</span>@@ -84,7 +84,7 @@<!-- BEGIN posts --><div class="topic-row img-thumbnail clearfix" topic-url="topic/{posts.tid}/#{posts.pid}"><span>{posts.content}</span>- <span class="pull-right">{posts.relativeTime} ago</span>+ <span class="pull-right timeago" title="{posts.relativeTime}"></span></div><!-- END posts --></div>diff --git a/public/templates/category.tpl b/public/templates/category.tplindex e12b3898bc..41f5cbd021 100644--- a/public/templates/category.tpl+++ b/public/templates/category.tpl@@ -36,14 +36,14 @@<div class="pull-right"><img class="img-rounded" style="width: 48px; height: 48px; /*temporary*/" src="{topics.teaser_userpicture}" /><p>{topics.teaser_text}</p>- <span><strong>{topics.teaser_username}</strong> posted {topics.teaser_timestamp} ago</span>+ <span><strong>{topics.teaser_username}</strong> posted</span><span class="timeago" title="{topics.teaser_timestamp}"></span></div></div><div><h3><span class="topic-title"><span class="badge {topics.badgeclass}">{topics.postcount}</span>{topics.title}</span></h3><small><strong><i class="{topics.pin-icon}"></i> <i class="{topics.lock-icon}"></i></strong>- Posted {topics.relativeTime} ago by+ Posted <span class="timeago" title="{topics.relativeTime}"></span> by<strong>{topics.username}</strong>.</small></div>diff --git a/public/templates/favourites.tpl b/public/templates/favourites.tplindex 7bd01e7556..1d124e4710 100644--- a/public/templates/favourites.tpl+++ b/public/templates/favourites.tpl@@ -14,7 +14,7 @@<span><strong>{posts.username}</strong> : </span><span>{posts.content}</span><div>- <span class="pull-right">{posts.relativeTime} ago</span>+ <span class="pull-right timeago" title="{posts.relativeTime}"></span></div></div><br/>diff --git a/public/templates/header.tpl b/public/templates/header.tplindex 13db3b7e57..0efb66394d 100644--- a/public/templates/header.tpl+++ b/public/templates/header.tpl@@ -10,6 +10,7 @@</script><script src="http://code.jquery.com/jquery.js"></script><script src="{relative_path}/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js"></script>+ <script src="{relative_path}/vendor/jquery/js/jquery.timeago.js"></script><script src="{relative_path}/vendor/bootstrap/js/bootstrap.min.js"></script><script src="{relative_path}/socket.io/socket.io.js"></script><script src="{relative_path}/src/app.js"></script>diff --git a/public/templates/recent.tpl b/public/templates/recent.tplindex 020372658a..42463f0bfc 100644--- a/public/templates/recent.tpl+++ b/public/templates/recent.tpl@@ -24,14 +24,15 @@<div class="pull-right"><img style="width: 48px; height: 48px; /*temporary*/" src="{topics.teaser_userpicture}" /><p><strong>{topics.teaser_username}</strong>: {topics.teaser_text}</p>- <span>posted {topics.teaser_timestamp} ago</span>+ <span>posted</span>+ <span class="timeago" title="{topics.teaser_timestamp}"></span></div></div><div><h3><span class="topic-title"><span class="badge {topics.badgeclass}">{topics.postcount}</span>{topics.title}</span></h3><small><strong><i class="{topics.pin-icon}"></i><i class="{topics.lock-icon}"></i></strong>- Posted {topics.relativeTime} ago by+ <span>Posted </span><span class="timeago" title="{topics.relativeTime}"></span><span> by</span><strong>{topics.username}</strong>.</small></div>diff --git a/public/templates/topic.tpl b/public/templates/topic.tplindex b569dbf4d2..3c03a5cad7 100644--- a/public/templates/topic.tpl+++ b/public/templates/topic.tpl@@ -59,8 +59,9 @@<div class="post-signature">{main_posts.signature}</div><div class="post-info"><span class="pull-right">- posted <span class="relativeTimeAgo">{main_posts.relativeTime} ago</span>- <span class="{main_posts.edited-class}">| last edited by <strong><a href="/user/{main_posts.editorslug}">{main_posts.editorname}</a></strong> {main_posts.relativeEditTime} ago</span>+ posted <span class="relativeTimeAgo timeago" title="{main_posts.relativeTime}"></span>+ <span class="{main_posts.edited-class}">| last edited by <strong><a href="/user/{main_posts.editorslug}">{main_posts.editorname}</a></strong></span>+ <span class="timeago" title="{main_posts.relativeEditTime}"></span></span><div style="clear:both;"></div></div>@@ -114,8 +115,9 @@<div class="post-signature">{posts.signature}</div><div class="post-info"><span class="pull-right">- posted <span class="relativeTimeAgo">{posts.relativeTime} ago</span>- <span class="{posts.edited-class}">| last edited by <strong><a href="/user/{posts.editorslug}">{posts.editorname}</a></strong> {posts.relativeEditTime} ago</span>+ posted <span class="relativeTimeAgo timeago" title="{posts.relativeTime}"></span>+ <span class="{posts.edited-class}">| last edited by <strong><a href="/user/{posts.editorslug}">{posts.editorname}</a></strong></span>+ <span class="timeago" title="{posts.relativeEditTime}"></span></span><div style="clear:both;"></div></div>diff --git a/public/themes/vanilla/category.less b/public/themes/vanilla/category.lessindex b9f7c2b78f..f4f230b39d 100644--- a/public/themes/vanilla/category.less+++ b/public/themes/vanilla/category.less@@ -103,7 +103,6 @@span {display: block;float: left;- width: 70%;margin-left: 10px;overflow: hidden;height: 16px;@@ -147,7 +146,6 @@}span {font-size: 12px;- display: block;overflow: hidden;height: 16px;padding-left: 8px;diff --git a/src/admin/categories.js b/src/admin/categories.jsindex 4f4dc682a7..405f180cdc 100644--- a/src/admin/categories.js+++ b/src/admin/categories.js@@ -21,7 +21,6 @@ var RDB = require('./../redis.js'),// reset slugs if name is updatedvar slug = cid + '/' + utils.slugify(category[key]);RDB.hset('category:' + cid, 'slug', slug);- RDB.set('categoryslug:' + slug + ':cid', cid);}}diff --git a/src/posts.js b/src/posts.jsindex aff11e21e9..dee76c0474 100644--- a/src/posts.js+++ b/src/posts.js@@ -70,7 +70,7 @@ var RDB = require('./redis.js'),Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) {if (postData.deleted === '1') return callback(null);else {- postData.relativeTime = utils.relativeTime(postData.timestamp);+ postData.relativeTime = new Date(parseInt(postData.timestamp, 10)).toISOString();next(null, postData);}});@@ -159,10 +159,10 @@ var RDB = require('./redis.js'),async.eachSeries(pids, function(pid, callback) {Posts.getPostData(pid, function(postData) {if (postData) {- postData.relativeTime = utils.relativeTime(postData.timestamp);+ postData.relativeTime = new Date(parseInt(postData.timestamp,10)).toISOString();postData.post_rep = postData.reputation;postData['edited-class'] = postData.editor !== '' ? '' : 'none';- postData['relativeEditTime'] = postData.edited !== '0' ? utils.relativeTime(postData.edited) : '';+ postData['relativeEditTime'] = postData.edited !== '0' ? (new Date(parseInt(postData.edited,10)).toISOString()) : '';postTools.toHTML(postData.content, function(err, content) {postData.content = content;@@ -285,7 +285,7 @@ var RDB = require('./redis.js'),'fav_button_class': '','fav_star_class': 'icon-star-empty','show_banned': 'hide',- 'relativeTime': '0 seconds',+ 'relativeTime': new Date(timestamp).toISOString(),'post_rep': '0','edited-class': 'none','relativeEditTime': ''diff --git a/src/routes/user.js b/src/routes/user.jsindex 8fdfd9a85a..1c60e247d4 100644--- a/src/routes/user.js+++ b/src/routes/user.js@@ -482,7 +482,7 @@ var user = require('./../user.js'),user.getUserData(uid, function(err, data) {if (data) {- data.joindate = utils.relativeTime(data.joindate);+ data.joindate = new Date(parseInt(data.joindate, 10)).toISOString();if (!data.birthday) {data.age = '';diff --git a/src/topics.js b/src/topics.jsindex 49d2274b86..baaa608948 100644--- a/src/topics.js+++ b/src/topics.js@@ -305,14 +305,15 @@ schema = require('./schema.js'),topicData['lock-icon'] = topicData.locked === '1' ? 'icon-lock' : 'none';topicData['deleted-class'] = topicData.deleted === '1' ? 'deleted' : '';- topicData.relativeTime = utils.relativeTime(topicData.timestamp);+ topicData.relativeTime = new Date(parseInt(topicData.timestamp, 10)).toISOString();topicData.username = topicInfo.username;topicData.badgeclass = (topicInfo.hasread && current_user != 0) ? '' : 'badge-important';topicData.teaser_text = topicInfo.teaserInfo.text || '',topicData.teaser_username = topicInfo.teaserInfo.username || '';topicData.teaser_userpicture = topicInfo.teaserInfo.picture || '';- topicData.teaser_timestamp = topicInfo.teaserInfo.timestamp ? utils.relativeTime(topicInfo.teaserInfo.timestamp) : '';++ topicData.teaser_timestamp = topicInfo.teaserInfo.timestamp ? (new Date(parseInt(topicInfo.teaserInfo.timestamp, 10)).toISOString()) : '';if (isTopicVisible(topicData, topicInfo))retrieved_topics.push(topicData);@@ -426,11 +427,11 @@ schema = require('./schema.js'),hasRead = results[1],teaser = results[2];- topicData.relativeTime = utils.relativeTime(topicData.timestamp);+ topicData.relativeTime = new Date(parseInt(topicData.timestamp,10)).toISOString();topicData.badgeclass = hasRead ? '' : 'badge-important';topicData.teaser_text = teaser.text || '';topicData.teaser_username = teaser.username || '';- topicData.teaser_timestamp = teaser.timestamp ? utils.relativeTime(teaser.timestamp) : '';+ topicData.teaser_timestamp = teaser.timestamp ? (new Date(parseInt(teaser.timestamp,10)).toISOString()) : '';topicData.teaser_userpicture = teaser.picture;callback(topicData);