aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-11-22 12:19:23 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-11-22 12:23:54 -1000
commitbd97292b635469091b048141038936cceb42ff7c (patch)
tree14115a3b462f109001f349d27cb3c653f70d7bd4 /lib
parent0c537c2e6a31554a9b388405a6b47c7b2a866b44 (diff)
downloadpatchfoo-bd97292b635469091b048141038936cceb42ff7c.tar.gz
patchfoo-bd97292b635469091b048141038936cceb42ff7c.zip
Default render {name,link} more compactly
Diffstat (limited to 'lib')
-rw-r--r--lib/render-msg.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index dd35b06..78b3570 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -839,6 +839,11 @@ RenderMsg.prototype.object = function (cb) {
done(cb)
}
+function linkName(link) {
+ if (link.link[0] === '@' && link.name[0] !== '@') return '@' + link.name
+ return link.name
+}
+
RenderMsg.prototype.valueTable = function (val, depth, cb) {
var isContent = depth === 1
var self = this
@@ -846,11 +851,14 @@ RenderMsg.prototype.valueTable = function (val, depth, cb) {
case 'object':
if (val === null) return cb(), ''
var done = multicb({pluck: 1, spread: true})
+ var keys
var el = Array.isArray(val)
? h('ul', val.map(function (item) {
return h('li', self.valueTable(item, depth + 1, done()))
}))
- : h('table.ssb-object', Object.keys(val).map(function (key) {
+ : (keys = Object.keys(val)).sort().join() === 'link,name' && val.link && val.name
+ ? h('a', {href: self.toUrl(val.link)}, linkName(val))
+ : h('table.ssb-object', keys.map(function (key) {
if (key === 'text') {
return h('tr',
h('td', h('strong', 'text')),