diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-06-22 13:47:05 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-06-27 16:27:14 -1000 |
commit | f81b065d0bbbad93c14efff60632681ffc73062e (patch) | |
tree | 9670a4e45da088efa94744f7e87c71ac8c24e8db | |
parent | b4c6d80137b27284ed8384bee00fcc31efa882c5 (diff) | |
download | patchfoo-f81b065d0bbbad93c14efff60632681ffc73062e.tar.gz patchfoo-f81b065d0bbbad93c14efff60632681ffc73062e.zip |
Add status page
-rw-r--r-- | lib/serve.js | 31 |
1 files changed, 31 insertions, 0 deletions
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'), ' ', |