From 1eeb202272fd2411123b980aa782f457c6835d76 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Sat, 23 Jan 2021 12:15:56 -0500 Subject: added logbook action, with filter according to date of publishing --- lib/serve.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/serve.js b/lib/serve.js index f7e8330..7237a88 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -517,6 +517,7 @@ Serve.prototype.path = function (url) { switch (m[1]) { case '/new': return this.new(m[2]) case '/public': return this.public(m[2]) + case '/logbook': return this.logbook(m[2]) case '/threads': return this.threads(m[2]) case '/private': return this.private(m[2]) case '/mentions': return this.mentions(m[2]) @@ -575,6 +576,32 @@ Serve.prototype.home = function () { ) } +Serve.prototype.logbook = function (ext) { + var q = this.query + var opts = { + reverse: !q.forwards, + //sortByTimestamp: q.sort === 'claimed', + 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.vote + }), + this.renderThreadPaginated(opts, null, q), + this.wrapMessages(), + this.wrapPublic(), + this.wrapPage('public'), + this.respondSink(200, { + 'Content-Type': ctype(ext) + }) + ) +} + Serve.prototype.public = function (ext) { var q = this.query var opts = { -- cgit v1.2.3