git ssb

30+

cel / git-ssb-web



Commit 7de0259e18a5afbfea5e9cb0ce2545040440b56e

Show active repo tab

Charles Lehner committed on 3/30/2016, 10:17:40 PM
Parent: 1e73dbc22e7cbacbfcbbc499676d04157d8499de

Files changed

index.jschanged
index.jsView
@@ -913,12 +913,17 @@
913913 renderNameForm(!isPublic, repo.id, repoName, 'repo-name', null,
914914 'Rename the repo',
915915 '<h2>' + link([repo.feed], authorName) + ' / ' +
916916 link([repo.id], repoName) + '</h2>') +
917- '</div><nav>' + link([repo.id], 'Code') +
918- link([repo.id, 'activity'], 'Activity') +
919- link([repo.id, 'commits', branch || ''], 'Commits') +
920- link([repo.id, 'issues'], 'Issues') +
917+ '</div><nav>' +
918+ link([repo.id], 'Code', true,
919+ page == 'code' ? ' class="active"' : '') +
920+ link([repo.id, 'activity'], 'Activity', true,
921+ page == 'activity' ? ' class="active"' : '') +
922+ link([repo.id, 'commits', branch || ''], 'Commits', true,
923+ page == 'commits' ? ' class="active"' : '') +
924+ link([repo.id, 'issues'], 'Issues', true,
925+ page == 'issues' ? ' class="active"' : '') +
921926 gitLink +
922927 '</nav>'),
923928 body
924929 ])))
@@ -927,15 +932,15 @@
927932 }
928933
929934 function serveEmptyRepo(repo) {
930935 if (repo.feed != myId)
931- return renderRepoPage(repo, null, pull.once(
936+ return renderRepoPage(repo, 'code', null, pull.once(
932937 '<section>' +
933938 '<h3>Empty repository</h3>' +
934939 '</section>'))
935940
936941 var gitUrl = 'ssb://' + repo.id
937- return renderRepoPage(repo, null, pull.once(
942+ return renderRepoPage(repo, 'code', null, pull.once(
938943 '<section>' +
939944 '<h3>Getting started</h3>' +
940945 '<h4>Create a new repository</h4><pre>' +
941946 'touch README.md\n' +
@@ -952,9 +957,9 @@
952957
953958 function serveRepoTree(repo, rev, path) {
954959 if (!rev) return serveEmptyRepo(repo)
955960 var type = repo.isCommitHash(rev) ? 'Tree' : 'Branch'
956- return renderRepoPage(repo, rev, cat([
961+ return renderRepoPage(repo, 'code', rev, cat([
957962 pull.once('<section><form action="" method="get">' +
958963 '<h3>' + type + ': ' + rev + ' '),
959964 revMenu(repo, rev),
960965 pull.once('</h3></form>'),
@@ -968,9 +973,9 @@
968973
969974 /* Repo activity */
970975
971976 function serveRepoActivity(repo, branch) {
972- return renderRepoPage(repo, branch, cat([
977+ return renderRepoPage(repo, 'activity', branch, cat([
973978 pull.once('<h3>Activity</h3>'),
974979 pull(
975980 ssb.links({
976981 type: 'git-update',
@@ -1012,9 +1017,9 @@
10121017
10131018 /* Repo commits */
10141019
10151020 function serveRepoCommits(repo, branch) {
1016- return renderRepoPage(repo, branch, cat([
1021+ return renderRepoPage(repo, 'commits', branch, cat([
10171022 pull.once('<h3>Commits</h3>'),
10181023 pull(
10191024 repo.readLog(branch),
10201025 paramap(function (hash, cb) {
@@ -1139,9 +1144,9 @@
11391144
11401145 /* Repo commit */
11411146
11421147 function serveRepoCommit(repo, rev) {
1143- return renderRepoPage(repo, rev, cat([
1148+ return renderRepoPage(repo, null, rev, cat([
11441149 pull.once('<h3>Commit ' + rev + '</h3>'),
11451150 readOnce(function (cb) {
11461151 repo.getCommitParsed(rev, function (err, commit) {
11471152 if (err) return cb(err)
@@ -1168,9 +1173,9 @@
11681173
11691174 /* An unknown message linking to a repo */
11701175
11711176 function serveRepoSomething(req, repo, id, msg, path) {
1172- return renderRepoPage(repo, null,
1177+ return renderRepoPage(repo, null, null,
11731178 pull.once('<section><h3>' + link([id]) + '</h3>' +
11741179 json(msg) + '</section>'))
11751180 }
11761181
@@ -1188,9 +1193,9 @@
11881193 function serveRepoUpdate(req, repo, id, msg, path) {
11891194 var raw = req._u.query.raw != null
11901195
11911196 if (raw)
1192- return renderRepoPage(repo, null, pull.once(
1197+ return renderRepoPage(repo, 'activity', null, pull.once(
11931198 '<a href="?" class="raw-link header-align">Info</a>' +
11941199 '<h3>Update</h3>' +
11951200 '<section class="collapse">' + json({key: id, value: msg}) + '</section>'))
11961201
@@ -1203,9 +1208,9 @@
12031208 }
12041209 }
12051210 }
12061211
1207- return renderRepoPage(repo, null, cat([
1212+ return renderRepoPage(repo, 'activity', null, cat([
12081213 pull.once(
12091214 '<a href="?raw" class="raw-link header-align">Data</a>' +
12101215 '<h3>Update</h3>' +
12111216 renderRepoUpdate(repo, {key: id, value: msg}, true) +
@@ -1268,9 +1273,9 @@
12681273 ': ' + linkPath([repo.id, 'tree'], [rev].concat(path))
12691274 var rawFilePath = [repo.id, 'raw', rev].concat(path)
12701275 var filename = path[path.length-1]
12711276 var extension = filename.split('.').pop()
1272- cb(null, renderRepoPage(repo, rev, cat([
1277+ cb(null, renderRepoPage(repo, 'code', rev, cat([
12731278 pull.once('<section><form action="" method="get">' +
12741279 '<h3>' + type + ': ' + rev + ' '),
12751280 revMenu(repo, rev),
12761281 pull.once('</h3></form>'),
@@ -1344,9 +1349,9 @@
13441349
13451350 function serveRepoDigs(repo) {
13461351 return readNext(function (cb) {
13471352 getVotes(repo.id, function (err, votes) {
1348- cb(null, renderRepoPage(repo, '', cat([
1353+ cb(null, renderRepoPage(repo, null, null, cat([
13491354 pull.once('<section><h3>Digs</h3>' +
13501355 '<div>Total: ' + votes.upvotes + '</div>'),
13511356 pull(
13521357 pull.values(Object.keys(votes.upvoters)),
@@ -1368,9 +1373,9 @@
13681373
13691374 function serveRepoIssues(req, repo, issueId, path) {
13701375 var numIssues = 0
13711376 var state = req._u.query.state || 'open'
1372- return renderRepoPage(repo, '', cat([
1377+ return renderRepoPage(repo, 'issues', null, cat([
13731378 pull.once(
13741379 (isPublic ? '' :
13751380 '<div class="right-bar">' + link([repo.id, 'issues', 'new'],
13761381 '<button class="btn">&plus; New Issue</button>', true) +
@@ -1412,9 +1417,9 @@
14121417
14131418 /* New Issue */
14141419
14151420 function serveRepoNewIssue(repo, issueId, path) {
1416- return renderRepoPage(repo, '', pull.once(
1421+ return renderRepoPage(repo, 'issues', null, pull.once(
14171422 '<h3>New Issue</h3>' +
14181423 '<section><form action="" method="post">' +
14191424 '<input type="hidden" name="action" value="new-issue">' +
14201425 '<p><input class="wide-input" name="title" placeholder="Issue Title" size="77" /></p>' +
@@ -1427,9 +1432,9 @@
14271432
14281433 function serveRepoIssue(req, repo, issue, path, postId) {
14291434 var isAuthor = (myId == issue.author) || (myId == repo.feed)
14301435 var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}}
1431- return renderRepoPage(repo, null, cat([
1436+ return renderRepoPage(repo, 'issues', null, cat([
14321437 pull.once(
14331438 renderNameForm(!isPublic, issue.id, issue.title, 'issue-title', null,
14341439 'Rename the issue',
14351440 '<h3>' + link([issue.id], issue.title) + '</h3>') +

Built with git-ssb-web