git ssb

30+

cel / git-ssb-web



Commit 707a9d074871552af7ea3d78771130b8e21e0b43

Render new issues in feed

Charles Lehner committed on 3/26/2016, 6:42:20 PM
Parent: db21c527b861c7c35e5a6ad60990403a8147b01b

Files changed

index.jschanged
index.jsView
@@ -193,9 +193,10 @@
193193 }
194194
195195 var msgTypes = {
196196 'git-repo': true,
197- 'git-update': true
197+ 'git-update': true,
198+ 'issue': true
198199 }
199200
200201 var refLabels = {
201202 heads: 'Branches',
@@ -407,42 +408,38 @@
407408 msg.value.timestamp < Date.now()
408409 }),
409410 pull.take(20),
410411 addAuthorName(about),
411- pull.asyncMap(function (msg, cb) {
412- switch (msg.value.content.type) {
413- case 'git-repo': return renderRepoCreated(msg, cb)
414- case 'git-update': return renderUpdate(msg, cb)
415- }
416- })
412+ pull.asyncMap(renderFeedItem)
417413 )
418414 }
419415
420- function renderRepoCreated(msg, cb) {
416+ function renderFeedItem(msg, cb) {
417+ var c = msg.value.content
421418 var msgLink = link([msg.key],
422419 new Date(msg.value.timestamp).toLocaleString())
423- var authorLink = link([msg.value.author], msg.authorName)
424420 var author = msg.value.author
425- getRepoName(about, author, msg.key, function (err, repoName) {
426- if (err) return cb(err)
427- var repoLink = link([msg.key], repoName)
428- cb(null, '<section class="collapse">' + msgLink + '<br>' +
429- authorLink + ' created repo ' + repoLink + '</section>')
430- })
431- }
432-
433- function renderUpdate(msg, cb) {
434- var msgLink = link([msg.key],
435- new Date(msg.value.timestamp).toLocaleString())
436421 var authorLink = link([msg.value.author], msg.authorName)
437- var repoId = msg.value.content.repo
438- var author = msg.value.author
439- getRepoName(about, author, repoId, function (err, repoName) {
440- if (err) return cb(err)
441- var repoLink = link([msg.value.content.repo], repoName)
442- cb(null, '<section class="collapse">' + msgLink + '<br>' +
443- authorLink + ' pushed to ' + repoLink + '</section>')
444- })
422+ switch (c.type) {
423+ case 'git-repo':
424+ return getRepoName(about, author, msg.key, function (err, repoName) {
425+ if (err) return cb(err)
426+ var repoLink = link([msg.key], repoName)
427+ cb(null, '<section class="collapse">' + msgLink + '<br>' +
428+ authorLink + ' created repo ' + repoLink + '</section>')
429+ })
430+ case 'git-update':
431+ return getRepoName(about, author, c.repo, function (err, repoName) {
432+ if (err) return cb(err)
433+ var repoLink = link([c.repo], repoName)
434+ cb(null, '<section class="collapse">' + msgLink + '<br>' +
435+ authorLink + ' pushed to ' + repoLink + '</section>')
436+ })
437+ case 'issue':
438+ var issueLink = link([msg.key], c.title)
439+ return cb(null, '<section class="collapse">' + msgLink + '<br>' +
440+ authorLink + ' opened issue ' + issueLink + '</section>')
441+ }
445442 }
446443
447444 /* Index */
448445

Built with git-ssb-web