diff --git a/public/src/forum/admin/settings.js b/public/src/forum/admin/settings.js index 6f164115f4..d33a3f720e 100644 --- a/public/src/forum/admin/settings.js +++ b/public/src/forum/admin/settings.js @@ -9,7 +9,7 @@ define(['uploader'], function(uploader) { // Come back in 125ms if the config isn't ready yet if (!app.config) { setTimeout(function() { - Settings.prepare(); + Settings.prepare(callback); }, 125); return; } diff --git a/public/templates/account.tpl b/public/templates/account.tpl new file mode 100644 index 0000000000..24fc37573b --- /dev/null +++ b/public/templates/account.tpl @@ -0,0 +1,165 @@ + +
+ +
+ +
+ +
+ + + +
+
+
+

[[global:recentposts]]

+
+
+ + [[user:has_no_posts]] + + +
+

{posts.content}

+ + + [[global:posted]] + [[global:in]] + + {posts.category.name} + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + + diff --git a/public/templates/accountposts.tpl b/public/templates/accountposts.tpl new file mode 100644 index 0000000000..a407030ea3 --- /dev/null +++ b/public/templates/accountposts.tpl @@ -0,0 +1,45 @@ +
+ +
+ +
+ + +
[[user:has_no_posts]]
+ + +
+
+ +
+
+ + + + + + {posts.username} + +

{posts.content}

+ +
+ + + [[global:posted]] + [[global:in]] + + {posts.category.name} + + + + +
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/public/templates/favourites.tpl b/public/templates/favourites.tpl new file mode 100644 index 0000000000..e793d0475b --- /dev/null +++ b/public/templates/favourites.tpl @@ -0,0 +1,45 @@ +
+ +
+ +
+ + +
[[topic:favourites.has_no_favourites]]
+ + +
+
+ +
+
+ + + + + + {posts.username} + +
{posts.content}
+ +
+ + + [[global:posted]] + [[global:in]] + + {posts.category.name} + + + + +
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/public/templates/search.tpl b/public/templates/search.tpl new file mode 100644 index 0000000000..ceb1082404 --- /dev/null +++ b/public/templates/search.tpl @@ -0,0 +1,88 @@ + + + + + + diff --git a/src/posts.js b/src/posts.js index ac4a3d5e5a..565f4b867f 100644 --- a/src/posts.js +++ b/src/posts.js @@ -197,6 +197,35 @@ var db = require('./database'), }); }; + Posts.getRecentPosts = function(uid, start, stop, term, callback) { + var terms = { + day: 86400000, + week: 604800000, + month: 2592000000 + }; + + var since = terms.day; + if (terms[term]) { + since = terms[term]; + } + + var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1; + + db.getSortedSetRevRangeByScore(['posts:pid', '+inf', Date.now() - since, 'LIMIT', start, count], function(err, pids) { + if(err) { + return callback(err); + } + + async.filter(pids, function(pid, next) { + postTools.privileges(pid, uid, function(err, privileges) { + next(!err && privileges.read); + }); + }, function(pids) { + Posts.getPostSummaryByPids(pids, true, callback); + }); + }); + }; + Posts.addUserInfoToPost = function(post, callback) { user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) { if (err) { @@ -262,10 +291,10 @@ var db = require('./database'), if (parseInt(postData.deleted, 10) === 1) { return callback(null); - } else { - postData.relativeTime = utils.toISOString(postData.timestamp); - next(null, postData); } + + postData.relativeTime = utils.toISOString(postData.timestamp); + next(null, postData); }); }, function(postData, next) { @@ -281,11 +310,9 @@ var db = require('./database'), return callback(null); } categories.getCategoryFields(topicData.cid, ['name', 'icon', 'slug'], function(err, categoryData) { - postData.categoryName = categoryData.name; - postData.categoryIcon = categoryData.icon; - postData.categorySlug = categoryData.slug; - postData.title = validator.escape(topicData.title); - postData.topicSlug = topicData.slug; + postData.category = categoryData; + topicData.title = validator.escape(topicData.title); + postData.topic = topicData; next(null, postData); }); });