Commit 7de0259e18a5afbfea5e9cb0ce2545040440b56e
Show active repo tab
Charles Lehner committed on 3/30/2016, 10:17:40 PMParent: 1e73dbc22e7cbacbfcbbc499676d04157d8499de
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -913,12 +913,17 @@ | ||
913 | 913 | renderNameForm(!isPublic, repo.id, repoName, 'repo-name', null, |
914 | 914 | 'Rename the repo', |
915 | 915 | '<h2>' + link([repo.feed], authorName) + ' / ' + |
916 | 916 | 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"' : '') + | |
921 | 926 | gitLink + |
922 | 927 | '</nav>'), |
923 | 928 | body |
924 | 929 | ]))) |
@@ -927,15 +932,15 @@ | ||
927 | 932 | } |
928 | 933 | |
929 | 934 | function serveEmptyRepo(repo) { |
930 | 935 | if (repo.feed != myId) |
931 | - return renderRepoPage(repo, null, pull.once( | |
936 | + return renderRepoPage(repo, 'code', null, pull.once( | |
932 | 937 | '<section>' + |
933 | 938 | '<h3>Empty repository</h3>' + |
934 | 939 | '</section>')) |
935 | 940 | |
936 | 941 | var gitUrl = 'ssb://' + repo.id |
937 | - return renderRepoPage(repo, null, pull.once( | |
942 | + return renderRepoPage(repo, 'code', null, pull.once( | |
938 | 943 | '<section>' + |
939 | 944 | '<h3>Getting started</h3>' + |
940 | 945 | '<h4>Create a new repository</h4><pre>' + |
941 | 946 | 'touch README.md\n' + |
@@ -952,9 +957,9 @@ | ||
952 | 957 | |
953 | 958 | function serveRepoTree(repo, rev, path) { |
954 | 959 | if (!rev) return serveEmptyRepo(repo) |
955 | 960 | var type = repo.isCommitHash(rev) ? 'Tree' : 'Branch' |
956 | - return renderRepoPage(repo, rev, cat([ | |
961 | + return renderRepoPage(repo, 'code', rev, cat([ | |
957 | 962 | pull.once('<section><form action="" method="get">' + |
958 | 963 | '<h3>' + type + ': ' + rev + ' '), |
959 | 964 | revMenu(repo, rev), |
960 | 965 | pull.once('</h3></form>'), |
@@ -968,9 +973,9 @@ | ||
968 | 973 | |
969 | 974 | /* Repo activity */ |
970 | 975 | |
971 | 976 | function serveRepoActivity(repo, branch) { |
972 | - return renderRepoPage(repo, branch, cat([ | |
977 | + return renderRepoPage(repo, 'activity', branch, cat([ | |
973 | 978 | pull.once('<h3>Activity</h3>'), |
974 | 979 | pull( |
975 | 980 | ssb.links({ |
976 | 981 | type: 'git-update', |
@@ -1012,9 +1017,9 @@ | ||
1012 | 1017 | |
1013 | 1018 | /* Repo commits */ |
1014 | 1019 | |
1015 | 1020 | function serveRepoCommits(repo, branch) { |
1016 | - return renderRepoPage(repo, branch, cat([ | |
1021 | + return renderRepoPage(repo, 'commits', branch, cat([ | |
1017 | 1022 | pull.once('<h3>Commits</h3>'), |
1018 | 1023 | pull( |
1019 | 1024 | repo.readLog(branch), |
1020 | 1025 | paramap(function (hash, cb) { |
@@ -1139,9 +1144,9 @@ | ||
1139 | 1144 | |
1140 | 1145 | /* Repo commit */ |
1141 | 1146 | |
1142 | 1147 | function serveRepoCommit(repo, rev) { |
1143 | - return renderRepoPage(repo, rev, cat([ | |
1148 | + return renderRepoPage(repo, null, rev, cat([ | |
1144 | 1149 | pull.once('<h3>Commit ' + rev + '</h3>'), |
1145 | 1150 | readOnce(function (cb) { |
1146 | 1151 | repo.getCommitParsed(rev, function (err, commit) { |
1147 | 1152 | if (err) return cb(err) |
@@ -1168,9 +1173,9 @@ | ||
1168 | 1173 | |
1169 | 1174 | /* An unknown message linking to a repo */ |
1170 | 1175 | |
1171 | 1176 | function serveRepoSomething(req, repo, id, msg, path) { |
1172 | - return renderRepoPage(repo, null, | |
1177 | + return renderRepoPage(repo, null, null, | |
1173 | 1178 | pull.once('<section><h3>' + link([id]) + '</h3>' + |
1174 | 1179 | json(msg) + '</section>')) |
1175 | 1180 | } |
1176 | 1181 | |
@@ -1188,9 +1193,9 @@ | ||
1188 | 1193 | function serveRepoUpdate(req, repo, id, msg, path) { |
1189 | 1194 | var raw = req._u.query.raw != null |
1190 | 1195 | |
1191 | 1196 | if (raw) |
1192 | - return renderRepoPage(repo, null, pull.once( | |
1197 | + return renderRepoPage(repo, 'activity', null, pull.once( | |
1193 | 1198 | '<a href="?" class="raw-link header-align">Info</a>' + |
1194 | 1199 | '<h3>Update</h3>' + |
1195 | 1200 | '<section class="collapse">' + json({key: id, value: msg}) + '</section>')) |
1196 | 1201 | |
@@ -1203,9 +1208,9 @@ | ||
1203 | 1208 | } |
1204 | 1209 | } |
1205 | 1210 | } |
1206 | 1211 | |
1207 | - return renderRepoPage(repo, null, cat([ | |
1212 | + return renderRepoPage(repo, 'activity', null, cat([ | |
1208 | 1213 | pull.once( |
1209 | 1214 | '<a href="?raw" class="raw-link header-align">Data</a>' + |
1210 | 1215 | '<h3>Update</h3>' + |
1211 | 1216 | renderRepoUpdate(repo, {key: id, value: msg}, true) + |
@@ -1268,9 +1273,9 @@ | ||
1268 | 1273 | ': ' + linkPath([repo.id, 'tree'], [rev].concat(path)) |
1269 | 1274 | var rawFilePath = [repo.id, 'raw', rev].concat(path) |
1270 | 1275 | var filename = path[path.length-1] |
1271 | 1276 | var extension = filename.split('.').pop() |
1272 | - cb(null, renderRepoPage(repo, rev, cat([ | |
1277 | + cb(null, renderRepoPage(repo, 'code', rev, cat([ | |
1273 | 1278 | pull.once('<section><form action="" method="get">' + |
1274 | 1279 | '<h3>' + type + ': ' + rev + ' '), |
1275 | 1280 | revMenu(repo, rev), |
1276 | 1281 | pull.once('</h3></form>'), |
@@ -1344,9 +1349,9 @@ | ||
1344 | 1349 | |
1345 | 1350 | function serveRepoDigs(repo) { |
1346 | 1351 | return readNext(function (cb) { |
1347 | 1352 | getVotes(repo.id, function (err, votes) { |
1348 | - cb(null, renderRepoPage(repo, '', cat([ | |
1353 | + cb(null, renderRepoPage(repo, null, null, cat([ | |
1349 | 1354 | pull.once('<section><h3>Digs</h3>' + |
1350 | 1355 | '<div>Total: ' + votes.upvotes + '</div>'), |
1351 | 1356 | pull( |
1352 | 1357 | pull.values(Object.keys(votes.upvoters)), |
@@ -1368,9 +1373,9 @@ | ||
1368 | 1373 | |
1369 | 1374 | function serveRepoIssues(req, repo, issueId, path) { |
1370 | 1375 | var numIssues = 0 |
1371 | 1376 | var state = req._u.query.state || 'open' |
1372 | - return renderRepoPage(repo, '', cat([ | |
1377 | + return renderRepoPage(repo, 'issues', null, cat([ | |
1373 | 1378 | pull.once( |
1374 | 1379 | (isPublic ? '' : |
1375 | 1380 | '<div class="right-bar">' + link([repo.id, 'issues', 'new'], |
1376 | 1381 | '<button class="btn">+ New Issue</button>', true) + |
@@ -1412,9 +1417,9 @@ | ||
1412 | 1417 | |
1413 | 1418 | /* New Issue */ |
1414 | 1419 | |
1415 | 1420 | function serveRepoNewIssue(repo, issueId, path) { |
1416 | - return renderRepoPage(repo, '', pull.once( | |
1421 | + return renderRepoPage(repo, 'issues', null, pull.once( | |
1417 | 1422 | '<h3>New Issue</h3>' + |
1418 | 1423 | '<section><form action="" method="post">' + |
1419 | 1424 | '<input type="hidden" name="action" value="new-issue">' + |
1420 | 1425 | '<p><input class="wide-input" name="title" placeholder="Issue Title" size="77" /></p>' + |
@@ -1427,9 +1432,9 @@ | ||
1427 | 1432 | |
1428 | 1433 | function serveRepoIssue(req, repo, issue, path, postId) { |
1429 | 1434 | var isAuthor = (myId == issue.author) || (myId == repo.feed) |
1430 | 1435 | var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}} |
1431 | - return renderRepoPage(repo, null, cat([ | |
1436 | + return renderRepoPage(repo, 'issues', null, cat([ | |
1432 | 1437 | pull.once( |
1433 | 1438 | renderNameForm(!isPublic, issue.id, issue.title, 'issue-title', null, |
1434 | 1439 | 'Rename the issue', |
1435 | 1440 | '<h3>' + link([issue.id], issue.title) + '</h3>') + |
Built with git-ssb-web