aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-08 19:11:15 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-08 19:11:15 -1000
commitcbf9a1d87eb43eaea73e6c019e7b4a2dca3bbaa6 (patch)
tree24636f66aece489ca88a0bb05f96ee02a51855fe /lib
parent498eaa3edf1241abdc6180410db97254c70e2185 (diff)
downloadpatchfoo-cbf9a1d87eb43eaea73e6c019e7b4a2dca3bbaa6.tar.gz
patchfoo-cbf9a1d87eb43eaea73e6c019e7b4a2dca3bbaa6.zip
Render line-comment messages
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js2
-rw-r--r--lib/render-msg.js36
-rw-r--r--lib/serve.js1
3 files changed, 38 insertions, 1 deletions
diff --git a/lib/app.js b/lib/app.js
index 1d9b80f..21f45a4 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -101,7 +101,7 @@ App.prototype.error = console.error.bind(console, logPrefix)
App.prototype.unboxMsg = function (msg, cb) {
var self = this
- var c = msg.value && msg.value.content
+ var c = msg && msg.value && msg.value.content
if (typeof c !== 'string') cb(null, msg)
else self.unboxContent(c, function (err, content) {
if (err) {
diff --git a/lib/render-msg.js b/lib/render-msg.js
index d4ad670..0835fee 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -10,6 +10,7 @@ function RenderMsg(render, app, msg, opts) {
this.render = render
this.app = app
this.msg = msg
+ this.serve = opts.serve
this.value = msg && msg.value || {}
var content = this.value.content
this.c = content || {}
@@ -20,6 +21,13 @@ function RenderMsg(render, app, msg, opts) {
this.shouldWrap = this.opts.wrap !== false
}
+RenderMsg.prototype.getMsg = function (id, cb) {
+ if (!id) return cb()
+ return this.serve
+ ? this.serve.getMsgDecryptedMaybeOoo(id, cb)
+ : this.app.getMsgDecryptedOoo(id, cb)
+}
+
RenderMsg.prototype.toUrl = function (href) {
return this.render.toUrl(href)
}
@@ -287,6 +295,7 @@ RenderMsg.prototype.message = function (cb) {
case 'talenet-idea-comment':
case 'talenet-idea-comment_reply': return this.ideaComment(cb)
case 'about-resource': return this.aboutResource(cb)
+ case 'line-comment': return this.lineComment(cb)
default: return this.object(cb)
}
}
@@ -1638,3 +1647,30 @@ RenderMsg.prototype.aboutResource = function (cb) {
h('blockquote', {innerHTML: self.render.markdown(self.c.description)})
), cb)
}
+
+RenderMsg.prototype.lineComment = function (cb) {
+ var self = this
+ var done = multicb({pluck: 1, spread: true})
+ self.link(self.c.repo, done())
+ self.getMsg(self.c.updateId, done())
+ done(function (err, repoLink, updateMsg) {
+ if (err) return cb(err)
+ return self.wrap(h('div',
+ h('div', h('small', '> ',
+ repoLink, ' ',
+ h('a', {
+ href: self.toUrl(self.c.updateId)
+ },
+ updateMsg
+ ? htime(new Date(updateMsg.value.timestamp))
+ : String(self.c.updateId)
+ ), ' ',
+ h('a', {
+ href: self.toUrl('/git/commit/' + self.c.commitId + '?msg=' + encodeURIComponent(self.c.updateId))
+ }, String(self.c.commitId).substr(0, 8)), ' ',
+ h('code', self.c.filePath + ':' + self.c.line)
+ )),
+ self.c.text ?
+ h('div', {innerHTML: self.render.markdown(self.c.text)}) : ''), cb)
+ })
+}
diff --git a/lib/serve.js b/lib/serve.js
index fb57bf7..f191b77 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1276,6 +1276,7 @@ Serve.prototype.renderThread = function (opts) {
msgId: opts && opts.msgId,
filter: this.query.filter,
limit: Number(this.query.limit),
+ serve: this,
}),
pull.map(u.toHTML)
)