git ssb

30+

cel / git-ssb-web



Commit 46e89b23632bc4247e6cd362012340b9380c10f0

Set specific page titles

Charles Lehner committed on 4/21/2016, 2:33:01 AM
Parent: 1b7253ee8c5a23c7ec17bd44c7a7753732087c88

Files changed

index.jschanged
locale/en.jsonchanged
locale/eo.jsonchanged
index.jsView
@@ -996,30 +996,36 @@
996996 return serveUserRepos(req, feedId)
997997 }
998998 }
999999
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) +
10051009 '<code class="user-id">' + feedId + '</code></h2>' +
10061010 nav([
10071011 [[feedId], req._t('Activity'), 'activity'],
10081012 [[feedId, 'repos'], req._t('Repos'), 'repos']
1009- ], page))
1010- })
1011- }),
1012- body,
1013- ]))
1013 + ], page)),
1014 + body
1015 + ])))
1016 + })
1017 + })
10141018 }
10151019
10161020 function serveUserActivity(req, feedId) {
1017- return renderUserPage(req, feedId, 'activity', renderFeed(req, feedId))
1021 + return renderUserPage(req, feedId, 'activity', null,
1022 + renderFeed(req, feedId))
10181023 }
10191024
10201025 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(
10221028 cat([
10231029 ssb.messagesByType({
10241030 type: 'git-update',
10251031 reverse: true
@@ -1262,9 +1268,9 @@
12621268 '<pre>' + escapeHTML(err.stack) + '</pre>'
12631269 ]))
12641270 }
12651271
1266- function renderRepoPage(req, repo, page, branch, body) {
1272 + function renderRepoPage(req, repo, page, branch, titleTemplate, body) {
12671273 var gitUrl = 'ssb://' + repo.id
12681274 var gitLink = '<input class="clone-url" readonly="readonly" ' +
12691275 'value="' + gitUrl + '" size="45" ' +
12701276 'onclick="this.select()"/>'
@@ -1286,9 +1292,13 @@
12861292 if (err) return cb(null, serveError(req, err))
12871293 var upvoted = votes.upvoters[myId] > 0
12881294 var upstreamLink = !repo.upstream ? '' :
12891295 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([
12911301 pull.once(
12921302 '<div class="repo-title">' +
12931303 '<form class="right-bar" action="" method="post">' +
12941304 '<button class="btn" name="action" value="vote" ' +
@@ -1330,15 +1340,15 @@
13301340 }
13311341
13321342 function serveEmptyRepo(req, repo) {
13331343 if (repo.feed != myId)
1334- return renderRepoPage(req, repo, 'code', null, pull.once(
1344 + return renderRepoPage(req, repo, 'code', null, null, pull.once(
13351345 '<section>' +
13361346 '<h3>' + req._t('EmptyRepo') + '</h3>' +
13371347 '</section>'))
13381348
13391349 var gitUrl = 'ssb://' + repo.id
1340- return renderRepoPage(req, repo, 'code', null, pull.once(
1350 + return renderRepoPage(req, repo, 'code', null, null, pull.once(
13411351 '<section>' +
13421352 '<h3>' + req._t('initRepo.GettingStarted') + '</h3>' +
13431353 '<h4>' + req._t('initRepo.CreateNew') + '</h4><pre>' +
13441354 'touch ' + req._t('initRepo.README') + '.md\n' +
@@ -1355,9 +1365,12 @@
13551365
13561366 function serveRepoTree(req, repo, rev, path) {
13571367 if (!rev) return serveEmptyRepo(req, repo)
13581368 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([
13601373 pull.once('<section><form action="" method="get">' +
13611374 '<h3>' + req._t(type) + ': ' + rev + ' '),
13621375 revMenu(req, repo, rev),
13631376 pull.once('</h3></form>'),
@@ -1419,9 +1432,10 @@
14191432
14201433 /* Repo activity */
14211434
14221435 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([
14241438 pull.once('<h3>' + req._t('Activity') + '</h3>'),
14251439 pull(
14261440 ssb.links({
14271441 dest: repo.id,
@@ -1489,9 +1503,10 @@
14891503 /* Repo commits */
14901504
14911505 function serveRepoCommits(req, repo, branch) {
14921506 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([
14941509 pull.once('<h3>' + req._t('Commits') + '</h3>'),
14951510 pull(
14961511 repo.readLog(query.start || branch),
14971512 pull.take(20),
@@ -1666,66 +1681,70 @@
16661681
16671682 /* Repo commit */
16681683
16691684 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- // TODO: show diff from all parents (merge commits)
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 + // TODO: show diff from all parents (merge commits)
1717 + renderDiffStat(req, [repo, repo], [commit.parents[0], commit.id]),
1718 + pull.once('</section>')
1719 + ])))
17041720 })
1705- ]))
1721 + })
17061722 }
17071723
17081724 /* Repo tag */
17091725
17101726 function serveRepoTag(req, repo, rev) {
1711- return renderRepoPage(req, repo, 'tags', rev, readNext(function (cb) {
1727 + return readNext(function (cb) {
17121728 repo.getTagParsed(rev, function (err, tag) {
17131729 if (err) return cb(err)
1730 + var title = req._t('TagName', {
1731 + tag: escapeHTML(tag.tag)
1732 + }) + ' · %{author}/%{repo}'
17141733 var body = (tag.title + '\n\n' +
17151734 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(
17171736 '<section class="collapse">' +
17181737 '<h3>' + link([repo.id, 'tag', rev], tag.tag) + '</h3>' +
17191738 req._t('TaggedOn', {
17201739 name: escapeHTML(tag.tagger.name),
17211740 date: tag.tagger.date.toLocaleString(req._locale)
17221741 }) + '<br/>' +
17231742 link([repo.id, tag.type, tag.object]) +
17241743 linkify(pre(body)) +
1725- '</section>'))
1744 + '</section>')))
17261745 })
1727- }))
1746 + })
17281747 }
17291748
17301749
17311750 /* Diff stat */
@@ -1833,9 +1852,9 @@
18331852
18341853 /* An unknown message linking to a repo */
18351854
18361855 function serveRepoSomething(req, repo, id, msg, path) {
1837- return renderRepoPage(req, repo, null, null,
1856 + return renderRepoPage(req, repo, null, null, null,
18381857 pull.once('<section><h3>' + link([id]) + '</h3>' +
18391858 json(msg) + '</section>'))
18401859 }
18411860
@@ -1851,11 +1870,12 @@
18511870 }
18521871
18531872 function serveRepoUpdate(req, repo, id, msg, path) {
18541873 var raw = req._u.query.raw != null
1874 + var title = req._t('Update') + ' · %{author}/%{repo}'
18551875
18561876 if (raw)
1857- return renderRepoPage(req, repo, 'activity', null, pull.once(
1877 + return renderRepoPage(req, repo, 'activity', null, title, pull.once(
18581878 '<a href="?" class="raw-link header-align">' +
18591879 req._t('Info') + '</a>' +
18601880 '<h3>' + req._t('Update') + '</h3>' +
18611881 '<section class="collapse">' +
@@ -1903,9 +1923,9 @@
19031923 pull.filter()
19041924 )
19051925 ])
19061926
1907- return renderRepoPage(req, repo, 'activity', null, cat([
1927 + return renderRepoPage(req, repo, 'activity', null, title, cat([
19081928 pull.once('<a href="?raw" class="raw-link header-align">' +
19091929 req._t('Data') + '</a>' +
19101930 '<h3>' + req._t('Update') + '</h3>' +
19111931 renderRepoUpdate(req, repo, {key: id, value: msg}, true)),
@@ -1929,9 +1949,12 @@
19291949 var rawFilePath = [repo.id, 'raw', rev].concat(path)
19301950 var dirPath = path.slice(0, path.length-1)
19311951 var filename = path[path.length-1]
19321952 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([
19341957 pull.once('<section><form action="" method="get">' +
19351958 '<h3>' + req._t(type) + ': ' + rev + ' '),
19361959 revMenu(req, repo, rev),
19371960 pull.once('</h3></form>'),
@@ -2010,10 +2033,11 @@
20102033 /* Digs */
20112034
20122035 function serveRepoDigs(req, repo) {
20132036 return readNext(function (cb) {
2037 + var title = req._t('Digs') + ' · %{author}/%{repo}'
20142038 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([
20162040 pull.once('<section><h3>' + req._t('Digs') + '</h3>' +
20172041 '<div>' + req._t('Total') + ': ' + votes.upvotes + '</div>'),
20182042 pull(
20192043 pull.values(Object.keys(votes.upvoters)),
@@ -2066,9 +2090,10 @@
20662090 }
20672091
20682092 function serveRepoForks(req, repo) {
20692093 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([
20712096 pull.once('<h3>' + req._t('Forks') + '</h3>'),
20722097 pull(
20732098 getForks(repo),
20742099 pull.map(function (msg) {
@@ -2087,9 +2112,10 @@
20872112 ]))
20882113 }
20892114
20902115 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(
20922118 '<form action="" method="post" onreset="history.back()">' +
20932119 '<h3>' + req._t('ForkRepoPrompt') + '</h3>' +
20942120 '<p>' + hiddenInputs({ id: repo.id }) +
20952121 '<button class="btn open" type="submit" name="action" value="fork">' +
@@ -2106,9 +2132,10 @@
21062132 function serveRepoIssues(req, repo, isPRs) {
21072133 var count = 0
21082134 var state = req._u.query.state || 'open'
21092135 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([
21112138 pull.once(
21122139 (isPublic ? '' :
21132140 '<form class="right-bar" method="get"' +
21142141 ' action="' + encodeLink(newPath) + '">' +
@@ -2154,9 +2181,10 @@
21542181
21552182 /* New Issue */
21562183
21572184 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(
21592187 '<h3>' + req._t('issue.New') + '</h3>' +
21602188 '<section><form action="" method="post">' +
21612189 '<input type="hidden" name="action" value="new-issue">' +
21622190 '<p><input class="wide-input" name="title" placeholder="' +
@@ -2170,9 +2198,10 @@
21702198
21712199 function serveRepoIssue(req, repo, issue, path, postId) {
21722200 var isAuthor = (myId == issue.author) || (myId == repo.feed)
21732201 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([
21752204 pull.once(
21762205 renderNameForm(req, !isPublic, issue.id, issue.title, 'issue-title',
21772206 null, req._t('issue.Rename'),
21782207 '<h3>' + link([issue.id], issue.title) + '</h3>') +
@@ -2323,9 +2352,10 @@
23232352
23242353 function serveRepoPullReq(req, repo, pr, path, postId) {
23252354 var headRepo, authorLink
23262355 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([
23282358 pull.once('<div class="pull-request">' +
23292359 renderNameForm(req, !isPublic, pr.id, pr.title, 'issue-title', null,
23302360 req._t('pullRequest.Rename'),
23312361 '<h3>' + link([pr.id], pr.title) + '</h3>') +
@@ -2515,10 +2545,11 @@
25152545 function serveRepoCompare(req, repo) {
25162546 var query = req._u.query
25172547 var base
25182548 var count = 0
2549 + var title = req._t('CompareChanges') + ' · %{author}/%{repo}'
25192550
2520- return renderRepoPage(req, repo, 'pulls', null, cat([
2551 + return renderRepoPage(req, repo, 'pulls', null, title, cat([
25212552 pull.once('<h3>' + req._t('CompareChanges') + '</h3>' +
25222553 '<form action="' + encodeLink(repo.id) + '/comparing" method="get">' +
25232554 '<section>'),
25242555 pull.once(req._t('BaseBranch') + ': '),
@@ -2597,13 +2628,13 @@
25972628 var headBranch = s[1]
25982629 var baseLink = link([repo.id, 'tree', baseBranch])
25992630 var headBranchLink = link([headRepoId, 'tree', headBranch])
26002631 var backHref = encodeLink([repo.id, 'compare']) + req._u.search
2632 + var title = req._t(query.expand ? 'OpenPullRequest': 'ComparingChanges')
2633 + var pageTitle = title + ' · %{author}/%{repo}'
26012634
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>'),
26062637 readNext(function (cb) {
26072638 getRepo(headRepoId, function (err, headRepo) {
26082639 if (err) return cb(err)
26092640 getRepoFullName(about, headRepo.feed, headRepo.id,
locale/en.jsonView
@@ -30,8 +30,9 @@
3030 "Named": "%{author} named %{target} %{name}",
3131 "CommentedOn": "%{author} commented on %{target}",
3232 "Activity": "Activity",
3333 "Repos": "Repos",
34 + "UsersRepos": "%{name}'s repos",
3435 "UpdatedOnDate": "Updated %{date}",
3536 "CreatedOnDate": "Created %{date}",
3637 "Dig": "Dig",
3738 "Undig": "Undig",
@@ -77,8 +78,9 @@
7778 "deleted": "deleted",
7879 "changedMode": "changed mode from %{old} to %{new}",
7980 "changed": "changed"
8081 },
82 + "TagName": "Tag %{tag}",
8183 "View": "View",
8284 "Info": "Info",
8385 "Update": "Update",
8486 "Data": "Data",
locale/eo.jsonView
@@ -30,8 +30,9 @@
3030 "Named": "%{author} nomis %{target} %{name}",
3131 "CommentedOn": "%{author} komentis %{target}",
3232 "Activity": "Aktivaĵo",
3333 "Repos": "Deponejoj",
34 + "UsersRepos": "Deponejoj de %{name}",
3435 "UpdatedOnDate": "Ĝisdatigis je %{date}",
3536 "CreatedOnDate": "Kreis je %{date}",
3637 "Dig": "Digi",
3738 "Undig": "Maldigi",
@@ -77,8 +78,9 @@
7778 "deleted": "forviis",
7879 "changedMode": "ŝanĝis reĝimon de %{old} al %{new}",
7980 "changed": "ŝanĝis"
8081 },
82 + "TagName": "Tag %{tag}",
8183 "View": "Vidu",
8284 "Info": "Informo",
8385 "Update": "Ĝisdatigo",
8486 "Data": "Datumo",

Built with git-ssb-web