From 12b3e229c3fd0d4a79c5521170f6ed855f4a6a03 Mon Sep 17 00:00:00 2001 From: noffle Date: Wed, 4 Mar 2020 23:13:39 -0800 Subject: threads navpage --- lib/app.js | 1 + lib/serve.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'lib') diff --git a/lib/app.js b/lib/app.js index c841ab0..03e3010 100644 --- a/lib/app.js +++ b/lib/app.js @@ -95,6 +95,7 @@ function App(sbot, config) { this.navLinks = conf.nav || [ 'new', 'public', + 'threads', this.sbot.private && 'private', 'mentions', 'peers', diff --git a/lib/serve.js b/lib/serve.js index 5f873e2..a7b05aa 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -452,6 +452,7 @@ Serve.prototype.path = function (url) { switch (m[1]) { case '/new': return this.new(m[2]) case '/public': return this.public(m[2]) + case '/threads': return this.threads(m[2]) case '/private': return this.private(m[2]) case '/mentions': return this.mentions(m[2]) case '/search': return this.search(m[2]) @@ -529,6 +530,31 @@ Serve.prototype.public = function (ext) { ) } +Serve.prototype.threads = function (ext) { + var q = this.query + var opts = { + reverse: !q.forwards, + sortByTimestamp: q.sort === 'claimed', + lt: Number(q.lt) || Date.now(), + gt: Number(q.gt) || -Infinity, + filter: q.filter, + } + + pull( + this.app.createLogStream(opts), + pull.filter(msg => { + return msg.value.content.type === 'post' && !msg.value.content.root + }), + this.renderThreadPaginated(opts, null, q), + this.wrapMessages(), + this.wrapPublic(), + this.wrapPage('threads'), + this.respondSink(200, { + 'Content-Type': ctype(ext) + }) + ) +} + Serve.prototype.setCookie = function (key, value, options) { var header = key + '=' + value if (options) for (var k in options) { -- cgit v1.2.3