diff options
author | noffle <sww@eight45.net> | 2020-03-04 23:13:39 -0800 |
---|---|---|
committer | noffle <sww@eight45.net> | 2020-03-04 23:13:39 -0800 |
commit | 12b3e229c3fd0d4a79c5521170f6ed855f4a6a03 (patch) | |
tree | c096b44e5c40fdeacfeeb9721014e08f9534e8b6 /lib/serve.js | |
parent | 67dfa43e8df1dbf3a3238a452531c10da46325b8 (diff) | |
download | patchfoo-12b3e229c3fd0d4a79c5521170f6ed855f4a6a03.tar.gz patchfoo-12b3e229c3fd0d4a79c5521170f6ed855f4a6a03.zip |
threads navpage
Diffstat (limited to 'lib/serve.js')
-rw-r--r-- | lib/serve.js | 26 |
1 files changed, 26 insertions, 0 deletions
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) { |