Commit 707a9d074871552af7ea3d78771130b8e21e0b43
Render new issues in feed
Charles Lehner committed on 3/26/2016, 6:42:20 PMParent: db21c527b861c7c35e5a6ad60990403a8147b01b
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -193,9 +193,10 @@ | ||
193 | 193 | } |
194 | 194 | |
195 | 195 | var msgTypes = { |
196 | 196 | 'git-repo': true, |
197 | - 'git-update': true | |
197 | + 'git-update': true, | |
198 | + 'issue': true | |
198 | 199 | } |
199 | 200 | |
200 | 201 | var refLabels = { |
201 | 202 | heads: 'Branches', |
@@ -407,42 +408,38 @@ | ||
407 | 408 | msg.value.timestamp < Date.now() |
408 | 409 | }), |
409 | 410 | pull.take(20), |
410 | 411 | 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) | |
417 | 413 | ) |
418 | 414 | } |
419 | 415 | |
420 | - function renderRepoCreated(msg, cb) { | |
416 | + function renderFeedItem(msg, cb) { | |
417 | + var c = msg.value.content | |
421 | 418 | var msgLink = link([msg.key], |
422 | 419 | new Date(msg.value.timestamp).toLocaleString()) |
423 | - var authorLink = link([msg.value.author], msg.authorName) | |
424 | 420 | 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()) | |
436 | 421 | 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 | + } | |
445 | 442 | } |
446 | 443 | |
447 | 444 | /* Index */ |
448 | 445 |
Built with git-ssb-web