From 684a05c5f4bc21386aa5f3a7f103836a60cc7f00 Mon Sep 17 00:00:00 2001 From: cel Date: Fri, 14 Apr 2017 20:02:43 -0700 Subject: Render ssb-dns messages --- lib/render-msg.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lib/render-msg.js') diff --git a/lib/render-msg.js b/lib/render-msg.js index 711a759..1873128 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -201,6 +201,7 @@ RenderMsg.prototype.message = function (raw, cb) { case 'issue': return this.issue(cb) case 'issue-edit': return this.issueEdit(cb) case 'music-release-cc': return this.musicRelease(cb) + case 'ssb-dns': return this.dns(cb) case 'ferment/audio': case 'robeson/audio': return this.audio(cb) @@ -302,6 +303,9 @@ RenderMsg.prototype.title = function (cb) { else cb(null, '%' + self.c.type + ': ' + (self.c.title || title(self.c.text))) } else { + if (self.c.type === 'ssb-dns') + cb(null, self.c.record && JSON.stringify(self.c.record.data) || self.msg.key) + else self.app.getAbout(self.msg.key, function (err, about) { if (err) return cb(err) if (about.name) return cb(null, about.name) @@ -652,6 +656,31 @@ RenderMsg.prototype.musicRelease = function (cb) { ], cb) } +RenderMsg.prototype.dns = function (cb) { + var self = this + var record = self.c.record || {} + var done = multicb({pluck: 1, spread: true}) + var elCb = done() + self.wrap([ + h('div', + h('p', + h('ins', {title: 'name'}, record.name), ' ', + h('span', {title: 'ttl'}, record.ttl), ' ', + h('span', {title: 'class'}, record.class), ' ', + h('span', {title: 'type'}, record.type) + ), + h('pre', {title: 'data'}, + JSON.stringify(record.data || record.value, null, 2)), + !self.c.branch ? null : h('div', + 'replaces: ', u.toArray(self.c.branch).map(function (id, i) { + return [self.link1(id, done()), i === 0 ? ', ' : ''] + }) + ) + ) + ], elCb) + done(cb) +} + RenderMsg.prototype.wifiNetwork = function (cb) { var net = this.c.network || {} this.wrap([ -- cgit v1.2.3