aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)