git ssb

30+

cel / git-ssb-web



Commit 3b7fb07ebf965857f1104c75a902ed61ce3be03d

Add forks page

Charles Lehner committed on 4/7/2016, 5:15:34 AM
Parent: 0195a494a9de4868b88311db38de11d614b6da6d

Files changed

index.jschanged
index.jsView
@@ -1013,8 +1013,10 @@
10131013 case 'raw':
10141014 return serveRepoRaw(repo, branch, filePath)
10151015 case 'digs':
10161016 return serveRepoDigs(repo)
1017+ case 'forks':
1018+ return serveRepoForks(repo)
10171019 case 'issues':
10181020 switch (path[1]) {
10191021 case 'new':
10201022 if (filePath.length == 0)
@@ -1076,9 +1078,10 @@
10761078 '<strong>' + link(digsPath, votes.upvotes) + '</strong> ' +
10771079 (isPublic ? '' :
10781080 '<button class="btn" type="submit" name="fork">' +
10791081 '<i>⑂</i> Fork' +
1080- '</button>') +
1082+ '</button>') + ' ' +
1083+ link([repo.id, 'forks'], '+', false, ' title="Forks"') +
10811084 '</form>' +
10821085 renderNameForm(!isPublic, repo.id, repoName, 'repo-name', null,
10831086 'Rename the repo',
10841087 '<h2>' + link([repo.feed], authorName) + ' / ' +
@@ -1639,8 +1642,48 @@
16391642 })
16401643 })
16411644 }
16421645
1646+ /* Forks */
1647+
1648+ function serveRepoForks(repo) {
1649+ var hasForks
1650+ return renderRepoPage(repo, null, null, cat([
1651+ pull.once('<h3>Forks</h3>'),
1652+ pull(
1653+ ssb.links({
1654+ dest: repo.id,
1655+ values: true,
1656+ rel: 'upstream'
1657+ }),
1658+ pull.filter(function (msg) {
1659+ var c = msg.value.content
1660+ return (c && c.type == 'git-repo')
1661+ }),
1662+ paramap(function (msg, cb) {
1663+ hasForks = true
1664+ var author = msg.value.author
1665+ var done = multicb({ pluck: 1, spread: true })
1666+ getRepoName(about, author, msg.key, done())
1667+ about.getName(author, done())
1668+ done(function (err, repoName, authorName) {
1669+ if (err) return cb(err)
1670+ var authorLink = link([author], authorName)
1671+ var repoLink = link([msg.key], repoName)
1672+ cb(null, '<section class="collapse">' +
1673+ authorLink + ' / ' + repoLink +
1674+ '<span class="right-bar">' +
1675+ timestamp(msg.value.timestamp) +
1676+ '</span></section>')
1677+ })
1678+ }, 8)
1679+ ),
1680+ readOnce(function (cb) {
1681+ cb(null, hasForks ? '' : 'No forks')
1682+ })
1683+ ]))
1684+ }
1685+
16431686 /* Issues */
16441687
16451688 function serveRepoIssues(req, repo, issueId, path) {
16461689 var numIssues = 0

Built with git-ssb-web