git ssb

30+

cel / git-ssb-web



Commit 1e037ccc8434cb8581b844f9bd08d330a7b76067

Render author name for repo updates

Charles Lehner committed on 9/30/2016, 9:27:55 PM
Parent: c0c4a89445a7f748556d6403dee36babb70ad67f

Files changed

lib/repos/index.jschanged
lib/repos/index.jsView
@@ -279,9 +279,9 @@
279279 rel: 'repo',
280280 values: true,
281281 reverse: true
282282 }),
283- pull.map(renderRepoUpdate.bind(self, req, repo))
283 + pull.asyncMap(renderRepoUpdate.bind(self, req, repo, false))
284284 ),
285285 u.readOnce(function (cb) {
286286 var done = multicb({ pluck: 1, spread: true })
287287 self.web.about.getName(repo.feed, done())
@@ -297,9 +297,9 @@
297297 })
298298 ]))
299299 }
300300
301-function renderRepoUpdate(req, repo, msg, full) {
301 +function renderRepoUpdate(req, repo, full, msg, cb) {
302302 var c = msg.value.content
303303
304304 if (c.type != 'git-update') {
305305 return ''
@@ -316,25 +316,31 @@
316316 }
317317 var numObjects = c.objects ? Object.keys(c.objects).length : 0
318318
319319 var dateStr = new Date(msg.value.timestamp).toLocaleString(req._locale)
320- return '<section class="collapse">' +
321- u.link([msg.key], dateStr) + '<br>' +
322- branches.map(function (update) {
323- if (!update.value) {
324- return '<s>' + u.escape(update.name) + '</s><br/>'
325- } else {
326- var commitLink = u.link([repo.id, 'commit', update.value])
327- var branchLink = u.link([repo.id, 'tree', update.name])
328- return branchLink + ' &rarr; <tt>' + commitLink + '</tt><br/>'
329- }
330- }).join('') +
331- tags.map(function (update) {
332- return update.value
333- ? u.link([repo.id, 'tag', update.value], update.name)
334- : '<s>' + u.escape(update.name) + '</s>'
335- }).join(', ') +
336- '</section>'
320 +
321 + this.web.about.getName(msg.value.author, function (err, name) {
322 + if (err) return cb(err)
323 + cb(null, '<section class="collapse">' +
324 + u.link([msg.key], dateStr) + '<br>' +
325 + u.link([msg.value.author], name) + '<br>' +
326 +
327 + branches.map(function (update) {
328 + if (!update.value) {
329 + return '<s>' + u.escape(update.name) + '</s><br/>'
330 + } else {
331 + var commitLink = u.link([repo.id, 'commit', update.value])
332 + var branchLink = u.link([repo.id, 'tree', update.name])
333 + return branchLink + ' &rarr; <tt>' + commitLink + '</tt><br/>'
334 + }
335 + }).join('') +
336 + tags.map(function (update) {
337 + return update.value
338 + ? u.link([repo.id, 'tag', update.value], update.name)
339 + : '<s>' + u.escape(update.name) + '</s>'
340 + }).join(', ') +
341 + '</section>')
342 + })
337343 }
338344
339345 /* Repo commits */
340346
@@ -775,10 +781,13 @@
775781
776782 return self.renderRepoPage(req, repo, 'activity', null, title, cat([
777783 pull.once('<a href="?raw" class="raw-link header-align">' +
778784 req._t('Data') + '</a>' +
779- '<h3>' + req._t('Update') + '</h3>' +
780- renderRepoUpdate(req, repo, {key: id, value: msg}, true)),
785 + '<h3>' + req._t('Update') + '</h3>'),
786 + pull(
787 + pull.once({key: id, value: msg}),
788 + pull.asyncMap(renderRepoUpdate.bind(self, req, repo, true))
789 + ),
781790 (msg.content.objects || msg.content.packs) &&
782791 pull.once('<h3>' + req._t('Commits') + '</h3>'),
783792 pull(commits, pull.map(function (commit) {
784793 return renderCommit(req, repo, commit)

Built with git-ssb-web