aboutsummaryrefslogtreecommitdiff
path: root/lib/render-msg.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-11-04 10:49:14 -0400
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-11-04 10:49:14 -0400
commitd6cace514bdf76e8846bfe8838636ac8c4d15b4e (patch)
tree6e86e62d7ac38675ad90074ed30b0b066bfc0815 /lib/render-msg.js
parent50d9fe635e506d222dd0aaf5be18680692f55e99 (diff)
downloadpatchfoo-d6cace514bdf76e8846bfe8838636ac8c4d15b4e.tar.gz
patchfoo-d6cace514bdf76e8846bfe8838636ac8c4d15b4e.zip
Show unknown About properties
Diffstat (limited to 'lib/render-msg.js')
-rw-r--r--lib/render-msg.js46
1 files changed, 39 insertions, 7 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index f7c2281..72ab73b 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -281,7 +281,7 @@ RenderMsg.prototype.markdownSource = function (text, mentions) {
h('pre', String(text)),
mentions ? [
h('div', h('em', 'mentions:')),
- this.valueTable(mentions, function () {})
+ this.valueTable(mentions, 2, function () {})
] : ''
).innerHTML
}
@@ -441,6 +441,23 @@ function dateTime(d) {
// d.epoch
}
+// TODO: make more DRY
+var knownAboutProps = {
+ type: true,
+ root: true,
+ about: true,
+ attendee: true,
+ about: true,
+ image: true,
+ description: true,
+ name: true,
+ title: true,
+ attendee: true,
+ startDateTime: true,
+ endDateTime: true,
+ location: true,
+}
+
RenderMsg.prototype.about = function (cb) {
var done = multicb({pluck: 1, spread: true})
var elCb = done()
@@ -456,6 +473,14 @@ RenderMsg.prototype.about = function (cb) {
return done(cb)
}
+ var extras
+ for (var k in this.c) {
+ if (!knownAboutProps[k]) {
+ if (!extras) extras = {}
+ extras[k] = this.c[k]
+ }
+ }
+
var img = u.linkDest(this.c.image)
// if there is a description, it is likely to be multi-line
var hasDescription = this.c.description != null
@@ -465,6 +490,9 @@ RenderMsg.prototype.about = function (cb) {
var showComputedName = !isSelf && !this.c.name
wrap.call(this, [
+ this.c.root ? h('div',
+ h('small', '> ', this.link1(this.c.root, done()))
+ ) : '',
isSelf
? hasDescription ? 'self-describes' : 'self-identifies'
: [hasDescription ? 'describes' : 'identifies', ' ',
@@ -490,7 +518,9 @@ RenderMsg.prototype.about = function (cb) {
h('img.ssb-avatar-image', {
src: this.render.imageUrl(img),
alt: ' ',
- })) : ''
+ })) : '',
+ extras ? this.valueTable(extras, 1, done())
+ : ''
], elCb)
done(cb)
}
@@ -649,12 +679,13 @@ RenderMsg.prototype.object = function (cb) {
var done = multicb({pluck: 1, spread: true})
var elCb = done()
this.wrap([
- this.valueTable(this.c, done()),
+ this.valueTable(this.c, 1, done()),
], elCb)
done(cb)
}
-RenderMsg.prototype.valueTable = function (val, cb) {
+RenderMsg.prototype.valueTable = function (val, depth, cb) {
+ var isContent = depth === 1
var self = this
switch (typeof val) {
case 'object':
@@ -662,7 +693,7 @@ RenderMsg.prototype.valueTable = function (val, cb) {
var done = multicb({pluck: 1, spread: true})
var el = Array.isArray(val)
? h('ul', val.map(function (item) {
- return h('li', self.valueTable(item, done()))
+ return h('li', self.valueTable(item, depth + 1, done()))
}))
: h('table.ssb-object', Object.keys(val).map(function (key) {
if (key === 'text') {
@@ -672,7 +703,8 @@ RenderMsg.prototype.valueTable = function (val, cb) {
innerHTML: self.render.markdown(val.text, val.mentions)
}))
)
- } else if (key === 'type') {
+ } else if (isContent && key === 'type') {
+ // TODO: also link to images by type, using links2
var type = val.type
return h('tr',
h('td', h('strong', 'type')),
@@ -681,7 +713,7 @@ RenderMsg.prototype.valueTable = function (val, cb) {
}
return h('tr',
h('td', h('strong', key)),
- h('td', self.valueTable(val[key], done()))
+ h('td', self.valueTable(val[key], depth + 1, done()))
)
}))
done(cb)