Commit 3b7fb07ebf965857f1104c75a902ed61ce3be03d
Add forks page
Charles Lehner committed on 4/7/2016, 5:15:34 AMParent: 0195a494a9de4868b88311db38de11d614b6da6d
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -1013,8 +1013,10 @@ | ||
1013 | 1013 | case 'raw': |
1014 | 1014 | return serveRepoRaw(repo, branch, filePath) |
1015 | 1015 | case 'digs': |
1016 | 1016 | return serveRepoDigs(repo) |
1017 | + case 'forks': | |
1018 | + return serveRepoForks(repo) | |
1017 | 1019 | case 'issues': |
1018 | 1020 | switch (path[1]) { |
1019 | 1021 | case 'new': |
1020 | 1022 | if (filePath.length == 0) |
@@ -1076,9 +1078,10 @@ | ||
1076 | 1078 | '<strong>' + link(digsPath, votes.upvotes) + '</strong> ' + |
1077 | 1079 | (isPublic ? '' : |
1078 | 1080 | '<button class="btn" type="submit" name="fork">' + |
1079 | 1081 | '<i>⑂</i> Fork' + |
1080 | - '</button>') + | |
1082 | + '</button>') + ' ' + | |
1083 | + link([repo.id, 'forks'], '+', false, ' title="Forks"') + | |
1081 | 1084 | '</form>' + |
1082 | 1085 | renderNameForm(!isPublic, repo.id, repoName, 'repo-name', null, |
1083 | 1086 | 'Rename the repo', |
1084 | 1087 | '<h2>' + link([repo.feed], authorName) + ' / ' + |
@@ -1639,8 +1642,48 @@ | ||
1639 | 1642 | }) |
1640 | 1643 | }) |
1641 | 1644 | } |
1642 | 1645 | |
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 | + | |
1643 | 1686 | /* Issues */ |
1644 | 1687 | |
1645 | 1688 | function serveRepoIssues(req, repo, issueId, path) { |
1646 | 1689 | var numIssues = 0 |
Built with git-ssb-web