diff options
-rw-r--r-- | lib/serve.js | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/lib/serve.js b/lib/serve.js index b61505b..21f08ac 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -25,6 +25,9 @@ var split = require('pull-split') var utf8 = require('pull-utf8-decoder') var webresolve = require('ssb-web-resolver') var Url = require('url') +var many = require('pull-many') +var merge = require('pull-merge') +var pSort = require('pull-sort') module.exports = Serve @@ -576,28 +579,41 @@ Serve.prototype.home = function () { ) } +compareMsgs = function(a, b) { + return -(a.value.timestamp - b.value.timestamp) +} + Serve.prototype.logbook = function (ext) { + var channel = "logbook" var q = this.query + var gt = Number(q.gt) || -Infinity + var lt = Number(q.lt) || Date.now() var opts = { + sortByTimestamp: q.sort === 'claimed', reverse: !q.forwards, - //sortByTimestamp: q.sort === 'claimed', - sortByTimestamp: q.sort || 'claimed', - lt: Number(q.lt) || Date.now(), - gt: Number(q.gt) || -Infinity, + lt: lt, + gt: gt, + channel: channel, filter: q.filter, } + var wordSearchQ = String(channel).toLowerCase() + var opts2 = { + query: wordSearchQ, + } + var outOpts = {} pull( - this.app.createLogStream(opts), - pull.filter(msg => { - return !msg.value.content.vote - }), + merge( + pull(this.app.streamChannel(opts), pSort(compareMsgs)), + pull(this.app.sbot.search.query(opts2), pSort(compareMsgs)), + compareMsgs + ), this.renderThreadPaginated(opts, null, q), this.wrapMessages(), - this.wrapPublic(), - this.wrapPage('public'), + this.wrapChannel(channel), + this.wrapPage('#' + channel), this.respondSink(200, { - 'Content-Type': ctype(ext) + 'Content-Type': ctype('html') }) ) } |