aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-06-18 13:49:42 -0400
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-06-18 13:49:42 -0400
commitd51ccc5142d4429b324bedb37b96fd5e2bcee4f0 (patch)
tree996342ac1325d9624f0a58106a2352b444cd5d8d
parent462de772ed178e879d70a437689893ff60d1f99e (diff)
downloadpatchfoo-d51ccc5142d4429b324bedb37b96fd5e2bcee4f0.tar.gz
patchfoo-d51ccc5142d4429b324bedb37b96fd5e2bcee4f0.zip
Render tag messages
-rw-r--r--lib/about.js4
-rw-r--r--lib/render-msg.js48
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/about.js b/lib/about.js
index 6d04355..29ec125 100644
--- a/lib/about.js
+++ b/lib/about.js
@@ -93,6 +93,10 @@ About.prototype.get = function (dest, cb) {
var author = msg.value.author
var c = msg.value.content
if (!c) return
+ if (msg.key === dest && c.type === 'about') {
+ // don't describe an about message with itself
+ return
+ }
var about = aboutByFeed[author] || (aboutByFeed[author] = {})
if (c.name) about.name = c.name
if (c.title) about.title = c.title
diff --git a/lib/render-msg.js b/lib/render-msg.js
index cda8eab..afbdc00 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -299,6 +299,7 @@ RenderMsg.prototype.message = function (cb) {
case 'position': if (this.c.version === 'v1') return this.pollPosition(cb)
case 'scat_message': return this.scat(cb)
case 'share': return this.share(cb)
+ case 'tag': return this.tag(cb)
default: return this.object(cb)
}
}
@@ -426,6 +427,8 @@ RenderMsg.prototype.title1 = function (cb) {
cb(null, self.c.name)
else if (self.c.type === 'talenet-idea-create')
self.app.getIdeaTitle(self.msg.key, cb)
+ else if (self.c.type === 'tag')
+ self.tagTitle(cb)
else
self.app.getAbout(self.msg.key, function (err, about) {
if (err) return cb(err)
@@ -1827,3 +1830,48 @@ RenderMsg.prototype.share = function (cb) {
], cb)
})
}
+
+RenderMsg.prototype.tag = function (cb) {
+ var done = multicb({pluck: 1, spread: true})
+ var self = this
+ if (self.c.message || self.c.root) {
+ self.link(self.c.root, done())
+ self.link(self.c.message, done())
+ self.links(self.c.branch, done())
+ done(function (err, rootLink, msgLink, branchLinks) {
+ if (err) return self.wrap(u.renderError(err), cb)
+ return self.wrap(h('div',
+ branchLinks.map(function (a, i) {
+ return h('div', h('small', h('span.symbol', '  ↳'), ' ', a))
+ }),
+ h('p',
+ self.c.tagged ? 'tagged ' : 'untagged ',
+ msgLink,
+ rootLink ? [' as ', rootLink] : ''
+ ),
+ ), cb)
+ })
+ } else {
+ self.wrapMini('tag', cb)
+ }
+}
+
+RenderMsg.prototype.tagTitle = function (cb) {
+ var self = this
+ if (!self.c.message && !self.c.root) {
+ return self.app.getAbout(self.msg.key, function (err, about) {
+ if (err) return cb(err)
+ var name = about.name || about.title
+ || (about.description && mdInline(about.description))
+ cb(null, truncate(name ? name.replace(/^%/, '') : self.msg.key, 72))
+ })
+ }
+ var done = multicb({pluck: 1, spread: true})
+ self.getName(self.c.root, done())
+ self.getName(self.c.message, done())
+ done(function (err, rootName, msgName) {
+ if (err) return cb(null, err.stack)
+ cb(null, (self.c.tagged ? 'tagged ' : 'untagged ')
+ + msgName + ' as ' + rootName)
+ })
+}