From f81b065d0bbbad93c14efff60632681ffc73062e Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 22 Jun 2017 13:47:05 -1000 Subject: Add status page --- lib/serve.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/serve.js b/lib/serve.js index 87ecbb4..19b0ac8 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -281,6 +281,7 @@ Serve.prototype.path = function (url) { case '/advsearch': return this.advsearch(m[2]) case '/vote': return this.vote(m[2]) case '/peers': return this.peers(m[2]) + case '/status': return this.status(m[2]) case '/channels': return this.channels(m[2]) case '/friends': return this.friends(m[2]) case '/live': return this.live(m[2]) @@ -680,6 +681,34 @@ Serve.prototype.peers = function (ext) { ) } +Serve.prototype.status = function (ext) { + var self = this + + if (!self.app.sbot.status) return pull( + pull.once('missing sbot status method'), + this.wrapPage('status'), + self.respondSink(400) + ) + + pull( + ph('section', [ + ph('h3', 'Status'), + pull( + u.readNext(function (cb) { + self.app.sbot.status(function (err, status) { + cb(err, status && pull.once(status)) + }) + }), + pull.map(function (status) { + return h('pre', self.app.render.linkify(JSON.stringify(status, 0, 2))).outerHTML + }) + ) + ]), + this.wrapPage('status'), + this.respondSink(200) + ) +} + Serve.prototype.channels = function (ext) { var self = this var id = self.app.sbot.id @@ -1291,6 +1320,8 @@ Serve.prototype.wrapPage = function (title, searchQ) { h('a', {href: render.toUrl('/private')}, 'private') , ' ', h('a', {href: render.toUrl('/mentions')}, 'mentions') , ' ', h('a', {href: render.toUrl('/peers')}, 'peers') , ' ', + self.app.sbot.status ? + [h('a', {href: render.toUrl('/status')}, 'status'), ' '] : '', h('a', {href: render.toUrl('/channels')}, 'channels') , ' ', h('a', {href: render.toUrl('/friends')}, 'friends'), ' ', h('a', {href: render.toUrl('/advsearch')}, 'search'), ' ', -- cgit v1.2.3