lib/repos/index.jsView |
---|
159 | 159 … | '<pre>' + u.escape(err.stack) + '</pre>' |
160 | 160 … | ])) |
161 | 161 … | } |
162 | 162 … | |
163 | | -R.renderRepoPage = function (req, repo, page, branch, titleTemplate, body) { |
| 163 … | +R.serveRepoTemplate = function (req, repo, page, branch, titleTemplate, body) { |
164 | 164 … | var self = this |
165 | 165 … | var gitUrl = 'ssb://' + repo.id |
166 | 166 … | var host = req.headers.host || '127.0.0.1:7718' |
167 | 167 … | var path = '/' + encodeURIComponent(repo.id) |
291 | 291 … | (path.length ? `${path.join('/')} · ` : '') + |
292 | 292 … | '%{author}/%{repo}' + |
293 | 293 … | (repo.head == `refs/heads/${rev}` ? '' : `@${rev}`) |
294 | 294 … | |
295 | | - return this.renderRepoPage(req, repo, 'code', rev, title, |
| 295 … | + return this.serveRepoTemplate(req, repo, 'code', rev, title, |
296 | 296 … | u.readNext((cb) => { |
297 | 297 … | repo.getLatestAvailableRev(rev, 10e3, (err, revGot, numSkipped) => { |
298 | 298 … | if (err) return cb(err) |
299 | 299 … | cb(null, cat([ |
324 | 324 … | |
325 | 325 … | R.serveRepoActivity = function (req, repo, branch) { |
326 | 326 … | var self = this |
327 | 327 … | var title = req._t('Activity') + ' · %{author}/%{repo}' |
328 | | - return self.renderRepoPage(req, repo, 'activity', branch, title, cat([ |
| 328 … | + return self.serveRepoTemplate(req, repo, 'activity', branch, title, cat([ |
329 | 329 … | h('h3', req._t('Activity')), |
330 | 330 … | pull( |
331 | 331 … | self.web.ssb.links({ |
332 | 332 … | dest: repo.id, |
401 | 401 … | |
402 | 402 … | R.serveRepoCommits = function (req, repo, branch) { |
403 | 403 … | var query = req._u.query |
404 | 404 … | var title = req._t('Commits') + ' · %{author}/%{repo}' |
405 | | - return this.renderRepoPage(req, repo, 'commits', branch, title, cat([ |
| 405 … | + return this.serveRepoTemplate(req, repo, 'commits', branch, title, cat([ |
406 | 406 … | pull.once('<h3>' + req._t('Commits') + '</h3>'), |
407 | 407 … | pull( |
408 | 408 … | repo.readLog(query.start || branch), |
409 | 409 … | pull.take(20), |
589 | 589 … | var self = this |
590 | 590 … | return u.readNext(function (cb) { |
591 | 591 … | repo.getCommitParsed(rev, function (err, commit) { |
592 | 592 … | if (err) return cb(null, |
593 | | - self.renderRepoPage(req, repo, null, rev, `%{author}/%{repo}@${rev}`, |
| 593 … | + self.serveRepoTemplate(req, repo, null, rev, `%{author}/%{repo}@${rev}`, |
594 | 594 … | pull.once(self.web.renderError(err)))) |
595 | 595 … | var commitPath = [repo.id, 'commit', commit.id] |
596 | 596 … | var treePath = [repo.id, 'tree', commit.id] |
597 | 597 … | var title = u.escape(commit.title) + ' · ' + |
598 | 598 … | '%{author}/%{repo}@' + commit.id.substr(0, 8) |
599 | | - cb(null, self.renderRepoPage(req, repo, null, rev, title, cat([ |
| 599 … | + cb(null, self.serveRepoTemplate(req, repo, null, rev, title, cat([ |
600 | 600 … | pull.once( |
601 | 601 … | '<h3>' + u.link(commitPath, |
602 | 602 … | req._t('CommitRev', {rev: rev})) + '</h3>' + |
603 | 603 … | '<section class="collapse">' + |
647 | 647 … | }) + ' · %{author}/%{repo}' |
648 | 648 … | var body = (tag.title + '\n\n' + |
649 | 649 … | tag.body.replace(/-----BEGIN PGP SIGNATURE-----\n[^.]*?\n-----END PGP SIGNATURE-----\s*$/, '')).trim() |
650 | 650 … | var date = tag.tagger.date |
651 | | - cb(null, self.renderRepoPage(req, repo, 'tags', tag.object, title, |
| 651 … | + cb(null, self.serveRepoTemplate(req, repo, 'tags', tag.object, title, |
652 | 652 … | pull.once( |
653 | 653 … | '<section class="collapse">' + |
654 | 654 … | '<h3>' + u.link([repo.id, 'tag', rev], tag.tag) + '</h3>' + |
655 | 655 … | req._t('TaggedOn', { |
787 | 787 … | |
788 | 788 … | |
789 | 789 … | |
790 | 790 … | R.serveRepoSomething = function (req, repo, id, msg, path) { |
791 | | - return this.renderRepoPage(req, repo, null, null, null, |
| 791 … | + return this.serveRepoTemplate(req, repo, null, null, null, |
792 | 792 … | pull.once('<section><h3>' + u.link([id]) + '</h3>' + |
793 | 793 … | u.json(msg) + '</section>')) |
794 | 794 … | } |
795 | 795 … | |
809 | 809 … | var raw = req._u.query.raw != null |
810 | 810 … | var title = req._t('Update') + ' · %{author}/%{repo}' |
811 | 811 … | |
812 | 812 … | if (raw) |
813 | | - return self.renderRepoPage(req, repo, 'activity', null, title, pull.once( |
| 813 … | + return self.serveRepoTemplate(req, repo, 'activity', null, title, pull.once( |
814 | 814 … | '<a href="?" class="raw-link header-align">' + |
815 | 815 … | req._t('Info') + '</a>' + |
816 | 816 … | '<h3>' + req._t('Update') + '</h3>' + |
817 | 817 … | '<section class="collapse">' + |
859 | 859 … | pull.filter() |
860 | 860 … | ) |
861 | 861 … | ]) |
862 | 862 … | |
863 | | - return self.renderRepoPage(req, repo, 'activity', null, title, cat([ |
| 863 … | + return self.serveRepoTemplate(req, repo, 'activity', null, title, cat([ |
864 | 864 … | pull.once('<a href="?raw" class="raw-link header-align">' + |
865 | 865 … | req._t('Data') + '</a>' + |
866 | 866 … | '<h3>' + req._t('Update') + '</h3>'), |
867 | 867 … | pull( |
892 | 892 … | var extension = u.getExtension(filename) |
893 | 893 … | var title = (path.length ? path.join('/') + ' · ' : '') + |
894 | 894 … | '%{author}/%{repo}' + |
895 | 895 … | (repo.head == 'refs/heads/' + rev ? '' : '@' + rev) |
896 | | - cb(null, self.renderRepoPage(req, repo, 'code', rev, title, cat([ |
| 896 … | + cb(null, self.serveRepoTemplate(req, repo, 'code', rev, title, cat([ |
897 | 897 … | pull.once('<section><form action="" method="get">' + |
898 | 898 … | '<h3>' + req._t(type) + ': ' + rev + ' '), |
899 | 899 … | self.revMenu(req, repo, rev), |
900 | 900 … | pull.once('</h3></form>'), |
937 | 937 … | var self = this |
938 | 938 … | return u.readNext(cb => { |
939 | 939 … | var title = req._t('Digs') + ' · %{author}/%{repo}' |
940 | 940 … | self.web.getVotes(repo.id, (err, votes) => { |
941 | | - cb(null, self.renderRepoPage(req, repo, null, null, title, |
| 941 … | + cb(null, self.serveRepoTemplate(req, repo, null, null, title, |
942 | 942 … | h('section', [ |
943 | 943 … | h('h3', req._t('Digs')), |
944 | 944 … | h('div', `${req._t('Total')}: ${votes.upvotes}`), |
945 | 945 … | h('ul', u.paraSourceMap(Object.keys(votes.upvoters), (feedId, cb) => { |
1010 | 1010 … | |
1011 | 1011 … | R.serveRepoForks = function (req, repo) { |
1012 | 1012 … | var hasForks |
1013 | 1013 … | var title = req._t('Forks') + ' · %{author}/%{repo}' |
1014 | | - return this.renderRepoPage(req, repo, null, null, title, cat([ |
| 1014 … | + return this.serveRepoTemplate(req, repo, null, null, title, cat([ |
1015 | 1015 … | pull.once('<h3>' + req._t('Forks') + '</h3>'), |
1016 | 1016 … | pull( |
1017 | 1017 … | this.getForks(repo), |
1018 | 1018 … | pull.map(function (msg) { |
1032 | 1032 … | } |
1033 | 1033 … | |
1034 | 1034 … | R.serveRepoForkPrompt = function (req, repo) { |
1035 | 1035 … | var title = req._t('Fork') + ' · %{author}/%{repo}' |
1036 | | - return this.renderRepoPage(req, repo, null, null, title, pull.once( |
| 1036 … | + return this.serveRepoTemplate(req, repo, null, null, title, pull.once( |
1037 | 1037 … | '<form action="" method="post" onreset="history.back()">' + |
1038 | 1038 … | '<h3>' + req._t('ForkRepoPrompt') + '</h3>' + |
1039 | 1039 … | '<p>' + u.hiddenInputs({ id: repo.id }) + |
1040 | 1040 … | '<button class="btn open" type="submit" name="action" value="fork">' + |