index.jsView |
---|
996 | 996 … | return serveUserRepos(req, feedId) |
997 | 997 … | } |
998 | 998 … | } |
999 | 999 … | |
1000 | | - function renderUserPage(req, feedId, page, body) { |
1001 | | - return serveTemplate(req, feedId)(cat([ |
1002 | | - readOnce(function (cb) { |
1003 | | - about.getName(feedId, function (err, name) { |
1004 | | - cb(null, '<h2>' + link([feedId], name) + |
| 1000 … | + function renderUserPage(req, feedId, page, titleTemplate, body) { |
| 1001 … | + return readNext(function (cb) { |
| 1002 … | + about.getName(feedId, function (err, name) { |
| 1003 … | + if (err) return cb(err) |
| 1004 … | + var title = titleTemplate ? titleTemplate |
| 1005 … | + .replace(/\%{name\}/g, escapeHTML(name)) |
| 1006 … | + : escapeHTML(name) |
| 1007 … | + cb(null, serveTemplate(req, title)(cat([ |
| 1008 … | + pull.once('<h2>' + link([feedId], name) + |
1005 | 1009 … | '<code class="user-id">' + feedId + '</code></h2>' + |
1006 | 1010 … | nav([ |
1007 | 1011 … | [[feedId], req._t('Activity'), 'activity'], |
1008 | 1012 … | [[feedId, 'repos'], req._t('Repos'), 'repos'] |
1009 | | - ], page)) |
1010 | | - }) |
1011 | | - }), |
1012 | | - body, |
1013 | | - ])) |
| 1013 … | + ], page)), |
| 1014 … | + body |
| 1015 … | + ]))) |
| 1016 … | + }) |
| 1017 … | + }) |
1014 | 1018 … | } |
1015 | 1019 … | |
1016 | 1020 … | function serveUserActivity(req, feedId) { |
1017 | | - return renderUserPage(req, feedId, 'activity', renderFeed(req, feedId)) |
| 1021 … | + return renderUserPage(req, feedId, 'activity', null, |
| 1022 … | + renderFeed(req, feedId)) |
1018 | 1023 … | } |
1019 | 1024 … | |
1020 | 1025 … | function serveUserRepos(req, feedId) { |
1021 | | - return renderUserPage(req, feedId, 'repos', pull( |
| 1026 … | + var title = req._t('UsersRepos', {name: '%{name}'}) |
| 1027 … | + return renderUserPage(req, feedId, 'repos', title, pull( |
1022 | 1028 … | cat([ |
1023 | 1029 … | ssb.messagesByType({ |
1024 | 1030 … | type: 'git-update', |
1025 | 1031 … | reverse: true |
1262 | 1268 … | '<pre>' + escapeHTML(err.stack) + '</pre>' |
1263 | 1269 … | ])) |
1264 | 1270 … | } |
1265 | 1271 … | |
1266 | | - function renderRepoPage(req, repo, page, branch, body) { |
| 1272 … | + function renderRepoPage(req, repo, page, branch, titleTemplate, body) { |
1267 | 1273 … | var gitUrl = 'ssb://' + repo.id |
1268 | 1274 … | var gitLink = '<input class="clone-url" readonly="readonly" ' + |
1269 | 1275 … | 'value="' + gitUrl + '" size="45" ' + |
1270 | 1276 … | 'onclick="this.select()"/>' |
1286 | 1292 … | if (err) return cb(null, serveError(req, err)) |
1287 | 1293 … | var upvoted = votes.upvoters[myId] > 0 |
1288 | 1294 … | var upstreamLink = !repo.upstream ? '' : |
1289 | 1295 … | link([repo.upstream]) |
1290 | | - cb(null, serveTemplate(req, repo.id)(cat([ |
| 1296 … | + var title = titleTemplate ? titleTemplate |
| 1297 … | + .replace(/%\{repo\}/g, repoName) |
| 1298 … | + .replace(/%\{author\}/g, authorName) |
| 1299 … | + : authorName + '/' + repoName |
| 1300 … | + cb(null, serveTemplate(req, title)(cat([ |
1291 | 1301 … | pull.once( |
1292 | 1302 … | '<div class="repo-title">' + |
1293 | 1303 … | '<form class="right-bar" action="" method="post">' + |
1294 | 1304 … | '<button class="btn" name="action" value="vote" ' + |
1330 | 1340 … | } |
1331 | 1341 … | |
1332 | 1342 … | function serveEmptyRepo(req, repo) { |
1333 | 1343 … | if (repo.feed != myId) |
1334 | | - return renderRepoPage(req, repo, 'code', null, pull.once( |
| 1344 … | + return renderRepoPage(req, repo, 'code', null, null, pull.once( |
1335 | 1345 … | '<section>' + |
1336 | 1346 … | '<h3>' + req._t('EmptyRepo') + '</h3>' + |
1337 | 1347 … | '</section>')) |
1338 | 1348 … | |
1339 | 1349 … | var gitUrl = 'ssb://' + repo.id |
1340 | | - return renderRepoPage(req, repo, 'code', null, pull.once( |
| 1350 … | + return renderRepoPage(req, repo, 'code', null, null, pull.once( |
1341 | 1351 … | '<section>' + |
1342 | 1352 … | '<h3>' + req._t('initRepo.GettingStarted') + '</h3>' + |
1343 | 1353 … | '<h4>' + req._t('initRepo.CreateNew') + '</h4><pre>' + |
1344 | 1354 … | 'touch ' + req._t('initRepo.README') + '.md\n' + |
1355 | 1365 … | |
1356 | 1366 … | function serveRepoTree(req, repo, rev, path) { |
1357 | 1367 … | if (!rev) return serveEmptyRepo(req, repo) |
1358 | 1368 … | var type = repo.isCommitHash(rev) ? 'Tree' : 'Branch' |
1359 | | - return renderRepoPage(req, repo, 'code', rev, cat([ |
| 1369 … | + var title = (path.length ? path.join('/') + ' · ' : '') + |
| 1370 … | + '%{author}/%{repo}' + |
| 1371 … | + (repo.head == 'refs/heads/' + rev ? '' : '@' + rev) |
| 1372 … | + return renderRepoPage(req, repo, 'code', rev, title, cat([ |
1360 | 1373 … | pull.once('<section><form action="" method="get">' + |
1361 | 1374 … | '<h3>' + req._t(type) + ': ' + rev + ' '), |
1362 | 1375 … | revMenu(req, repo, rev), |
1363 | 1376 … | pull.once('</h3></form>'), |
1419 | 1432 … | |
1420 | 1433 … | |
1421 | 1434 … | |
1422 | 1435 … | function serveRepoActivity(req, repo, branch) { |
1423 | | - return renderRepoPage(req, repo, 'activity', branch, cat([ |
| 1436 … | + var title = req._t('Activity') + ' · %{author}/%{repo}' |
| 1437 … | + return renderRepoPage(req, repo, 'activity', branch, title, cat([ |
1424 | 1438 … | pull.once('<h3>' + req._t('Activity') + '</h3>'), |
1425 | 1439 … | pull( |
1426 | 1440 … | ssb.links({ |
1427 | 1441 … | dest: repo.id, |
1489 | 1503 … | |
1490 | 1504 … | |
1491 | 1505 … | function serveRepoCommits(req, repo, branch) { |
1492 | 1506 … | var query = req._u.query |
1493 | | - return renderRepoPage(req, repo, 'commits', branch, cat([ |
| 1507 … | + var title = req._t('Commits') + ' · %{author}/%{repo}' |
| 1508 … | + return renderRepoPage(req, repo, 'commits', branch, title, cat([ |
1494 | 1509 … | pull.once('<h3>' + req._t('Commits') + '</h3>'), |
1495 | 1510 … | pull( |
1496 | 1511 … | repo.readLog(query.start || branch), |
1497 | 1512 … | pull.take(20), |
1666 | 1681 … | |
1667 | 1682 … | |
1668 | 1683 … | |
1669 | 1684 … | function serveRepoCommit(req, repo, rev) { |
1670 | | - return renderRepoPage(req, repo, null, rev, cat([ |
1671 | | - readNext(function (cb) { |
1672 | | - repo.getCommitParsed(rev, function (err, commit) { |
1673 | | - if (err) return cb(err) |
1674 | | - var commitPath = [repo.id, 'commit', commit.id] |
1675 | | - var treePath = [repo.id, 'tree', commit.id] |
1676 | | - cb(null, cat([pull.once( |
1677 | | - '<h3>' + link(commitPath, |
1678 | | - req._t('CommitRev', {rev: rev})) + '</h3>' + |
1679 | | - '<section class="collapse">' + |
1680 | | - '<div class="right-bar">' + |
1681 | | - link(treePath, req._t('BrowseFiles')) + |
1682 | | - '</div>' + |
1683 | | - '<h4>' + linkify(escapeHTML(commit.title)) + '</h4>' + |
1684 | | - (commit.body ? linkify(pre(commit.body)) : '') + |
1685 | | - (commit.separateAuthor ? req._t('AuthoredOn', { |
1686 | | - name: escapeHTML(commit.author.name), |
1687 | | - date: commit.author.date.toLocaleString(req._locale) |
1688 | | - }) + '<br/>' : '') + |
1689 | | - req._t('CommittedOn', { |
1690 | | - name: escapeHTML(commit.committer.name), |
1691 | | - date: commit.committer.date.toLocaleString(req._locale) |
1692 | | - }) + '<br/>' + |
1693 | | - commit.parents.map(function (id) { |
1694 | | - return req._t('Parent') + ': ' + |
1695 | | - link([repo.id, 'commit', id], id) |
1696 | | - }).join('<br>') + |
1697 | | - '</section>' + |
1698 | | - '<section><h3>' + req._t('FilesChanged') + '</h3>'), |
1699 | | - |
1700 | | - renderDiffStat(req, [repo, repo], [commit.parents[0], commit.id]), |
1701 | | - pull.once('</section>') |
1702 | | - ])) |
1703 | | - }) |
| 1685 … | + return readNext(function (cb) { |
| 1686 … | + repo.getCommitParsed(rev, function (err, commit) { |
| 1687 … | + if (err) return cb(err) |
| 1688 … | + var commitPath = [repo.id, 'commit', commit.id] |
| 1689 … | + var treePath = [repo.id, 'tree', commit.id] |
| 1690 … | + var title = escapeHTML(commit.title) + ' · ' + |
| 1691 … | + '%{author}/%{repo}@' + commit.id.substr(0, 8) |
| 1692 … | + cb(null, renderRepoPage(req, repo, null, rev, title, cat([ |
| 1693 … | + pull.once( |
| 1694 … | + '<h3>' + link(commitPath, |
| 1695 … | + req._t('CommitRev', {rev: rev})) + '</h3>' + |
| 1696 … | + '<section class="collapse">' + |
| 1697 … | + '<div class="right-bar">' + |
| 1698 … | + link(treePath, req._t('BrowseFiles')) + |
| 1699 … | + '</div>' + |
| 1700 … | + '<h4>' + linkify(escapeHTML(commit.title)) + '</h4>' + |
| 1701 … | + (commit.body ? linkify(pre(commit.body)) : '') + |
| 1702 … | + (commit.separateAuthor ? req._t('AuthoredOn', { |
| 1703 … | + name: escapeHTML(commit.author.name), |
| 1704 … | + date: commit.author.date.toLocaleString(req._locale) |
| 1705 … | + }) + '<br/>' : '') + |
| 1706 … | + req._t('CommittedOn', { |
| 1707 … | + name: escapeHTML(commit.committer.name), |
| 1708 … | + date: commit.committer.date.toLocaleString(req._locale) |
| 1709 … | + }) + '<br/>' + |
| 1710 … | + commit.parents.map(function (id) { |
| 1711 … | + return req._t('Parent') + ': ' + |
| 1712 … | + link([repo.id, 'commit', id], id) |
| 1713 … | + }).join('<br>') + |
| 1714 … | + '</section>' + |
| 1715 … | + '<section><h3>' + req._t('FilesChanged') + '</h3>'), |
| 1716 … | + |
| 1717 … | + renderDiffStat(req, [repo, repo], [commit.parents[0], commit.id]), |
| 1718 … | + pull.once('</section>') |
| 1719 … | + ]))) |
1704 | 1720 … | }) |
1705 | | - ])) |
| 1721 … | + }) |
1706 | 1722 … | } |
1707 | 1723 … | |
1708 | 1724 … | |
1709 | 1725 … | |
1710 | 1726 … | function serveRepoTag(req, repo, rev) { |
1711 | | - return renderRepoPage(req, repo, 'tags', rev, readNext(function (cb) { |
| 1727 … | + return readNext(function (cb) { |
1712 | 1728 … | repo.getTagParsed(rev, function (err, tag) { |
1713 | 1729 … | if (err) return cb(err) |
| 1730 … | + var title = req._t('TagName', { |
| 1731 … | + tag: escapeHTML(tag.tag) |
| 1732 … | + }) + ' · %{author}/%{repo}' |
1714 | 1733 … | var body = (tag.title + '\n\n' + |
1715 | 1734 … | tag.body.replace(/-----BEGIN PGP SIGNATURE-----\n[^.]*?\n-----END PGP SIGNATURE-----\s*$/, '')).trim() |
1716 | | - cb(null, pull.once( |
| 1735 … | + cb(null, renderRepoPage(req, repo, 'tags', tag.object, title, pull.once( |
1717 | 1736 … | '<section class="collapse">' + |
1718 | 1737 … | '<h3>' + link([repo.id, 'tag', rev], tag.tag) + '</h3>' + |
1719 | 1738 … | req._t('TaggedOn', { |
1720 | 1739 … | name: escapeHTML(tag.tagger.name), |
1721 | 1740 … | date: tag.tagger.date.toLocaleString(req._locale) |
1722 | 1741 … | }) + '<br/>' + |
1723 | 1742 … | link([repo.id, tag.type, tag.object]) + |
1724 | 1743 … | linkify(pre(body)) + |
1725 | | - '</section>')) |
| 1744 … | + '</section>'))) |
1726 | 1745 … | }) |
1727 | | - })) |
| 1746 … | + }) |
1728 | 1747 … | } |
1729 | 1748 … | |
1730 | 1749 … | |
1731 | 1750 … | |
1833 | 1852 … | |
1834 | 1853 … | |
1835 | 1854 … | |
1836 | 1855 … | function serveRepoSomething(req, repo, id, msg, path) { |
1837 | | - return renderRepoPage(req, repo, null, null, |
| 1856 … | + return renderRepoPage(req, repo, null, null, null, |
1838 | 1857 … | pull.once('<section><h3>' + link([id]) + '</h3>' + |
1839 | 1858 … | json(msg) + '</section>')) |
1840 | 1859 … | } |
1841 | 1860 … | |
1851 | 1870 … | } |
1852 | 1871 … | |
1853 | 1872 … | function serveRepoUpdate(req, repo, id, msg, path) { |
1854 | 1873 … | var raw = req._u.query.raw != null |
| 1874 … | + var title = req._t('Update') + ' · %{author}/%{repo}' |
1855 | 1875 … | |
1856 | 1876 … | if (raw) |
1857 | | - return renderRepoPage(req, repo, 'activity', null, pull.once( |
| 1877 … | + return renderRepoPage(req, repo, 'activity', null, title, pull.once( |
1858 | 1878 … | '<a href="?" class="raw-link header-align">' + |
1859 | 1879 … | req._t('Info') + '</a>' + |
1860 | 1880 … | '<h3>' + req._t('Update') + '</h3>' + |
1861 | 1881 … | '<section class="collapse">' + |
1903 | 1923 … | pull.filter() |
1904 | 1924 … | ) |
1905 | 1925 … | ]) |
1906 | 1926 … | |
1907 | | - return renderRepoPage(req, repo, 'activity', null, cat([ |
| 1927 … | + return renderRepoPage(req, repo, 'activity', null, title, cat([ |
1908 | 1928 … | pull.once('<a href="?raw" class="raw-link header-align">' + |
1909 | 1929 … | req._t('Data') + '</a>' + |
|
1910 | 1930 … | '<h3>' + req._t('Update') + '</h3>' + |
1911 | 1931 … | renderRepoUpdate(req, repo, {key: id, value: msg}, true)), |
1929 | 1949 … | var rawFilePath = [repo.id, 'raw', rev].concat(path) |
1930 | 1950 … | var dirPath = path.slice(0, path.length-1) |
1931 | 1951 … | var filename = path[path.length-1] |
1932 | 1952 … | var extension = getExtension(filename) |
1933 | | - cb(null, renderRepoPage(req, repo, 'code', rev, cat([ |
| 1953 … | + var title = (path.length ? path.join('/') + ' · ' : '') + |
| 1954 … | + '%{author}/%{repo}' + |
| 1955 … | + (repo.head == 'refs/heads/' + rev ? '' : '@' + rev) |
| 1956 … | + cb(null, renderRepoPage(req, repo, 'code', rev, title, cat([ |
1934 | 1957 … | pull.once('<section><form action="" method="get">' + |
1935 | 1958 … | '<h3>' + req._t(type) + ': ' + rev + ' '), |
1936 | 1959 … | revMenu(req, repo, rev), |
1937 | 1960 … | pull.once('</h3></form>'), |
2010 | 2033 … | |
2011 | 2034 … | |
2012 | 2035 … | function serveRepoDigs(req, repo) { |
2013 | 2036 … | return readNext(function (cb) { |
| 2037 … | + var title = req._t('Digs') + ' · %{author}/%{repo}' |
2014 | 2038 … | getVotes(repo.id, function (err, votes) { |
2015 | | - cb(null, renderRepoPage(req, repo, null, null, cat([ |
| 2039 … | + cb(null, renderRepoPage(req, repo, null, null, title, cat([ |
2016 | 2040 … | pull.once('<section><h3>' + req._t('Digs') + '</h3>' + |
2017 | 2041 … | '<div>' + req._t('Total') + ': ' + votes.upvotes + '</div>'), |
2018 | 2042 … | pull( |
2019 | 2043 … | pull.values(Object.keys(votes.upvoters)), |
2066 | 2090 … | } |
2067 | 2091 … | |
2068 | 2092 … | function serveRepoForks(req, repo) { |
2069 | 2093 … | var hasForks |
2070 | | - return renderRepoPage(req, repo, null, null, cat([ |
| 2094 … | + var title = req._t('Forks') + ' · %{author}/%{repo}' |
| 2095 … | + return renderRepoPage(req, repo, null, null, title, cat([ |
2071 | 2096 … | pull.once('<h3>' + req._t('Forks') + '</h3>'), |
2072 | 2097 … | pull( |
2073 | 2098 … | getForks(repo), |
2074 | 2099 … | pull.map(function (msg) { |
2087 | 2112 … | ])) |
2088 | 2113 … | } |
2089 | 2114 … | |
2090 | 2115 … | function serveRepoForkPrompt(req, repo) { |
2091 | | - return renderRepoPage(req, repo, null, null, pull.once( |
| 2116 … | + var title = req._t('Fork') + ' · %{author}/%{repo}' |
| 2117 … | + return renderRepoPage(req, repo, null, null, title, pull.once( |
2092 | 2118 … | '<form action="" method="post" onreset="history.back()">' + |
2093 | 2119 … | '<h3>' + req._t('ForkRepoPrompt') + '</h3>' + |
2094 | 2120 … | '<p>' + hiddenInputs({ id: repo.id }) + |
2095 | 2121 … | '<button class="btn open" type="submit" name="action" value="fork">' + |
2106 | 2132 … | function serveRepoIssues(req, repo, isPRs) { |
2107 | 2133 … | var count = 0 |
2108 | 2134 … | var state = req._u.query.state || 'open' |
2109 | 2135 … | var newPath = isPRs ? [repo.id, 'compare'] : [repo.id, 'issues', 'new'] |
2110 | | - return renderRepoPage(req, repo, isPRs ? 'pulls' : 'issues', null, cat([ |
| 2136 … | + var title = req._t('Issues') + ' · %{author}/%{repo}' |
| 2137 … | + return renderRepoPage(req, repo, isPRs ? 'pulls' : 'issues', null, title, cat([ |
2111 | 2138 … | pull.once( |
2112 | 2139 … | (isPublic ? '' : |
2113 | 2140 … | '<form class="right-bar" method="get"' + |
2114 | 2141 … | ' action="' + encodeLink(newPath) + '">' + |
2154 | 2181 … | |
2155 | 2182 … | |
2156 | 2183 … | |
2157 | 2184 … | function serveRepoNewIssue(req, repo, issueId, path) { |
2158 | | - return renderRepoPage(req, repo, 'issues', null, pull.once( |
| 2185 … | + var title = req._t('issue.New') + ' · %{author}/%{repo}' |
| 2186 … | + return renderRepoPage(req, repo, 'issues', null, title, pull.once( |
2159 | 2187 … | '<h3>' + req._t('issue.New') + '</h3>' + |
2160 | 2188 … | '<section><form action="" method="post">' + |
2161 | 2189 … | '<input type="hidden" name="action" value="new-issue">' + |
2162 | 2190 … | '<p><input class="wide-input" name="title" placeholder="' + |
2170 | 2198 … | |
2171 | 2199 … | function serveRepoIssue(req, repo, issue, path, postId) { |
2172 | 2200 … | var isAuthor = (myId == issue.author) || (myId == repo.feed) |
2173 | 2201 … | var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}} |
2174 | | - return renderRepoPage(req, repo, 'issues', null, cat([ |
| 2202 … | + var title = escapeHTML(issue.title) + ' · %{author}/%{repo}' |
| 2203 … | + return renderRepoPage(req, repo, 'issues', null, title, cat([ |
2175 | 2204 … | pull.once( |
2176 | 2205 … | renderNameForm(req, !isPublic, issue.id, issue.title, 'issue-title', |
2177 | 2206 … | null, req._t('issue.Rename'), |
2178 | 2207 … | '<h3>' + link([issue.id], issue.title) + '</h3>') + |
2323 | 2352 … | |
2324 | 2353 … | function serveRepoPullReq(req, repo, pr, path, postId) { |
2325 | 2354 … | var headRepo, authorLink |
2326 | 2355 … | var page = path[0] || 'activity' |
2327 | | - return renderRepoPage(req, repo, 'pulls', null, cat([ |
| 2356 … | + var title = escapeHTML(pr.title) + ' · %{author}/%{repo}' |
| 2357 … | + return renderRepoPage(req, repo, 'pulls', null, title, cat([ |
2328 | 2358 … | pull.once('<div class="pull-request">' + |
2329 | 2359 … | renderNameForm(req, !isPublic, pr.id, pr.title, 'issue-title', null, |
2330 | 2360 … | req._t('pullRequest.Rename'), |
2331 | 2361 … | '<h3>' + link([pr.id], pr.title) + '</h3>') + |
2515 | 2545 … | function serveRepoCompare(req, repo) { |
2516 | 2546 … | var query = req._u.query |
2517 | 2547 … | var base |
2518 | 2548 … | var count = 0 |
| 2549 … | + var title = req._t('CompareChanges') + ' · %{author}/%{repo}' |
2519 | 2550 … | |
2520 | | - return renderRepoPage(req, repo, 'pulls', null, cat([ |
| 2551 … | + return renderRepoPage(req, repo, 'pulls', null, title, cat([ |
2521 | 2552 … | pull.once('<h3>' + req._t('CompareChanges') + '</h3>' + |
2522 | 2553 … | '<form action="' + encodeLink(repo.id) + '/comparing" method="get">' + |
2523 | 2554 … | '<section>'), |
2524 | 2555 … | pull.once(req._t('BaseBranch') + ': '), |
2597 | 2628 … | var headBranch = s[1] |
2598 | 2629 … | var baseLink = link([repo.id, 'tree', baseBranch]) |
2599 | 2630 … | var headBranchLink = link([headRepoId, 'tree', headBranch]) |
2600 | 2631 … | var backHref = encodeLink([repo.id, 'compare']) + req._u.search |
| 2632 … | + var title = req._t(query.expand ? 'OpenPullRequest': 'ComparingChanges') |
| 2633 … | + var pageTitle = title + ' · %{author}/%{repo}' |
2601 | 2634 … | |
2602 | | - return renderRepoPage(req, repo, 'pulls', null, cat([ |
2603 | | - pull.once('<h3>' + |
2604 | | - req._t(query.expand ? 'OpenPullRequest': 'ComparingChanges') + |
2605 | | - '</h3>'), |
| 2635 … | + return renderRepoPage(req, repo, 'pulls', null, pageTitle, cat([ |
| 2636 … | + pull.once('<h3>' + title + '</h3>'), |
2606 | 2637 … | readNext(function (cb) { |
2607 | 2638 … | getRepo(headRepoId, function (err, headRepo) { |
2608 | 2639 … | if (err) return cb(err) |
2609 | 2640 … | getRepoFullName(about, headRepo.feed, headRepo.id, |