diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-01-09 21:00:42 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-01-09 21:00:42 -1000 |
commit | 586eda18f1e610c47d1a7d0e02fc7fcf81eadbc7 (patch) | |
tree | 554de3360fe14c41073833e9bbec009ae48784d1 /lib/render-msg.js | |
parent | 3995d586a0d20ef009f8a98587482c5f7f47ff58 (diff) | |
parent | ebe6b4c381e0ff7ae283f5abeadb2c6b5c2685fc (diff) | |
download | patchfoo-586eda18f1e610c47d1a7d0e02fc7fcf81eadbc7.tar.gz patchfoo-586eda18f1e610c47d1a7d0e02fc7fcf81eadbc7.zip |
Merge branch 'git-lib'
Diffstat (limited to 'lib/render-msg.js')
-rw-r--r-- | lib/render-msg.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index d4ad670..1603d24 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,33 @@ 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('a', { + href: self.toUrl('/git/line-comment/' + + encodeURIComponent(self.msg.key || JSON.stringify(self.msg))) + }, h('code', self.c.filePath + ':' + self.c.line)) + )), + self.c.text ? + h('div', {innerHTML: self.render.markdown(self.c.text)}) : ''), cb) + }) +} |