aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/render-msg.js57
-rw-r--r--static/styles.css8
2 files changed, 62 insertions, 3 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 9aee35c..6bc2c52 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -302,9 +302,13 @@ RenderMsg.prototype.title = function (cb) {
} else if (self.c.type === 'git-repo') {
self.getAboutName(self.msg.key, cb)
} else {
- self.message(false, function (err, el) {
+ self.getAboutName(self.msg.key, function (err, name) {
if (err) return cb(err)
- cb(null, title(h('div', el).textContent))
+ if (name) return cb(null, name)
+ self.message(false, function (err, el) {
+ if (err) return cb(err)
+ cb(null, '%' + title(h('div', el).textContent))
+ })
})
}
}
@@ -466,7 +470,54 @@ RenderMsg.prototype.issueEdit = function (cb) {
}
RenderMsg.prototype.object = function (cb) {
- this.wrapMini(h('pre', this.c.type), cb)
+ this.wrap(h('pre', this.linkify(JSON.stringify(this.c, 0, 2))), cb)
+}
+
+RenderMsg.prototype.object = function (cb) {
+ var done = multicb({pluck: 1, spread: true})
+ var elCb = done()
+ this.wrap([
+ this.valueTable(this.c, done()),
+ ], elCb)
+ done(cb)
+}
+
+RenderMsg.prototype.valueTable = function (val, cb) {
+ var self = this
+ switch (typeof val) {
+ case 'object':
+ if (val === null) return 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()))
+ }))
+ : h('table.ssb-object', Object.keys(val).map(function (key) {
+ if (key === 'text') {
+ return h('tr',
+ h('td', h('strong', 'text')),
+ h('td', h('div', {
+ innerHTML: self.render.markdown(val.text, val.mentions)
+ }))
+ )
+ }
+ return h('tr',
+ h('td', h('strong', key)),
+ h('td', self.valueTable(val[key], done()))
+ )
+ }))
+ done(cb)
+ return el
+ case 'string':
+ if (u.isRef(val)) return self.link1(val, cb)
+ return cb(), self.linkify(val)
+ case 'boolean':
+ return cb(), h('input', {
+ type: 'checkbox', disabled: 'disabled', checked: val
+ })
+ default:
+ return cb(), String(val)
+ }
}
RenderMsg.prototype.missing = function (cb) {
diff --git a/static/styles.css b/static/styles.css
index 481bced..5ec6e42 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -144,3 +144,11 @@ td {
.mention-id-input {
width: 60ex;
}
+
+table.ssb-object {
+ border-collapse: collapse;
+}
+
+table.ssb-object td {
+ border: 1px solid black;
+}