Commit ce171726150b63b15a82a7416797bb7926742a25
Work with multi-feed ssb-git-repo
Charles Lehner committed on 9/27/2016, 8:42:42 PMParent: 3b463efb1d84d837baadd660454a865beb148b56
Files changed
lib/forms.js | changed |
lib/repos/index.js | changed |
lib/repos/issues.js | changed |
lib/repos/pulls.js | changed |
lib/forms.js | ||
---|---|---|
@@ -67,9 +67,9 @@ | ||
67 | 67 … | : btn.getAttribute('data-value-nocomment')) |
68 | 68 … | } |
69 | 69 … | }.toString() + ')()' |
70 | 70 … | |
71 | -forms.issueComment = function (req, issue, repo, branch, isAuthor, type) { | |
71 … | +forms.issueComment = function (req, issue, repo, branch, type) { | |
72 | 72 … | return '<section><form action="" method="post">' + |
73 | 73 … | '<input type="hidden" name="action" value="comment">' + |
74 | 74 … | '<input type="hidden" name="id" value="' + issue.id + '">' + |
75 | 75 … | '<input type="hidden" name="issue" value="' + issue.id + '">' + |
@@ -77,20 +77,18 @@ | ||
77 | 77 … | '<input type="hidden" name="branch" value="' + branch + '">' + |
78 | 78 … | forms.post(req, repo) + |
79 | 79 … | '<input type="submit" class="btn open" value="' + |
80 | 80 … | req._t('issue.Comment') + '" />' + |
81 | - (isAuthor ? | |
82 | - '<input id="comment-close-btn" type="submit" class="btn"' + | |
83 | - ' name="' + (issue.open ? 'close' : 'open') + '"' + | |
84 | - ' value="' + req._t(issue.open ? 'issue.Close' : 'issue.Reopen', | |
85 | - {type: type}) + '"' + | |
86 | - ' data-value-nocomment="' + req._t(issue.open ? | |
87 | - 'issue.Close' : 'issue.Reopen', | |
88 | - {type: type}) + '"' + | |
89 | - ' data-value-withcomment="' + req._t(issue.open ? | |
90 | - 'issue.CommentAndClose' : 'issue.CommentAndReopen', | |
91 | - {type: type}) + '"' + | |
92 | - '/>' + | |
93 | - '<script>' + issueCommentButtonScript + '</script>' | |
94 | - : '') + | |
81 … | + '<input id="comment-close-btn" type="submit" class="btn"' + | |
82 … | + ' name="' + (issue.open ? 'close' : 'open') + '"' + | |
83 … | + ' value="' + req._t(issue.open ? 'issue.Close' : 'issue.Reopen', | |
84 … | + {type: type}) + '"' + | |
85 … | + ' data-value-nocomment="' + req._t(issue.open ? | |
86 … | + 'issue.Close' : 'issue.Reopen', | |
87 … | + {type: type}) + '"' + | |
88 … | + ' data-value-withcomment="' + req._t(issue.open ? | |
89 … | + 'issue.CommentAndClose' : 'issue.CommentAndReopen', | |
90 … | + {type: type}) + '"' + | |
91 … | + '/>' + | |
92 … | + '<script>' + issueCommentButtonScript + '</script>' + | |
95 | 93 … | '</form></section>' |
96 | 94 … | } |
lib/repos/index.js | ||
---|---|---|
@@ -157,10 +157,10 @@ | ||
157 | 157 … | 'onclick="this.select()"/>' |
158 | 158 … | var digsPath = [repo.id, 'digs'] |
159 | 159 … | |
160 | 160 … | var done = multicb({ pluck: 1, spread: true }) |
161 | - self.web.getRepoName(repo.feed, repo.id, done()) | |
162 | - self.web.about.getName(repo.feed, done()) | |
161 … | + self.web.getRepoName(repo.creator, repo.id, done()) | |
162 … | + self.web.about.getName(repo.creator, done()) | |
163 | 163 … | self.web.getVotes(repo.id, done()) |
164 | 164 … | |
165 | 165 … | if (repo.upstream) { |
166 | 166 … | self.web.getRepoName(repo.upstream.feed, repo.upstream.id, done()) |
@@ -200,9 +200,9 @@ | ||
200 | 200 … | req._t('Forks') + '"') + |
201 | 201 … | '</form>' + |
202 | 202 … | forms.name(req, !isPublic, repo.id, repoName, 'repo-name', |
203 | 203 … | null, req._t('repo.Rename'), |
204 | - '<h2 class="bgslash">' + u.link([repo.feed], authorName) + ' / ' + | |
204 … | + '<h2 class="bgslash">' + u.link([repo.creator], authorName) + ' / ' + | |
205 | 205 … | u.link([repo.id], repoName) + '</h2>') + |
206 | 206 … | '</div>' + |
207 | 207 … | (repo.upstream ? '<small class="bgslash">' + req._t('ForkedFrom', { |
208 | 208 … | repo: u.link([repo.upstream.feed], upstreamAuthorName) + '/' + |
@@ -221,9 +221,9 @@ | ||
221 | 221 … | }) |
222 | 222 … | } |
223 | 223 … | |
224 | 224 … | R.serveEmptyRepo = function (req, repo) { |
225 | - if (repo.feed != this.web.myId) | |
225 … | + if (repo.creator != this.web.myId) | |
226 | 226 … | return this.renderRepoPage(req, repo, 'code', null, null, pull.once( |
227 | 227 … | '<section>' + |
228 | 228 … | '<h3>' + req._t('EmptyRepo') + '</h3>' + |
229 | 229 … | '</section>')) |
@@ -245,9 +245,8 @@ | ||
245 | 245 … | '</section>')) |
246 | 246 … | } |
247 | 247 … | |
248 | 248 … | R.serveRepoTree = function (req, repo, rev, path) { |
249 | - if (!rev) return this.serveEmptyRepo(req, repo) | |
250 | 249 … | var type = repo.isCommitHash(rev) ? 'Tree' : 'Branch' |
251 | 250 … | var title = (path.length ? path.join('/') + ' · ' : '') + |
252 | 251 … | '%{author}/%{repo}' + |
253 | 252 … | (repo.head == 'refs/heads/' + rev ? '' : '@' + rev) |
@@ -256,12 +255,15 @@ | ||
256 | 255 … | '<h3>' + req._t(type) + ': ' + rev + ' '), |
257 | 256 … | this.revMenu(req, repo, rev), |
258 | 257 … | pull.once('</h3></form>'), |
259 | 258 … | type == 'Branch' && renderRepoLatest(req, repo, rev), |
260 | - pull.once('</section><section>'), | |
261 | - renderRepoTree(req, repo, rev, path), | |
262 | 259 … | pull.once('</section>'), |
263 | - this.renderRepoReadme(req, repo, rev, path) | |
260 … | + rev ? cat([ | |
261 … | + pull.once('<section>'), | |
262 … | + renderRepoTree(req, repo, rev, path), | |
263 … | + pull.once('</section>'), | |
264 … | + this.renderRepoReadme(req, repo, rev, path) | |
265 … | + ]) : this.serveEmptyRepo(req, repo) | |
264 | 266 … | ])) |
265 | 267 … | } |
266 | 268 … | |
267 | 269 … | /* Repo activity */ |
@@ -282,9 +284,9 @@ | ||
282 | 284 … | pull.map(renderRepoUpdate.bind(self, req, repo)) |
283 | 285 … | ), |
284 | 286 … | u.readOnce(function (cb) { |
285 | 287 … | var done = multicb({ pluck: 1, spread: true }) |
286 | - self.web.about.getName(repo.feed, done()) | |
288 … | + self.web.about.getName(repo.creator, done()) | |
287 | 289 … | self.web.getMsg(repo.id, done()) |
288 | 290 … | done(function (err, authorName, msg) { |
289 | 291 … | if (err) return cb(err) |
290 | 292 … | self.web.renderFeedItem(req, { |
@@ -415,8 +417,9 @@ | ||
415 | 417 … | |
416 | 418 … | /* Repo tree */ |
417 | 419 … | |
418 | 420 … | function renderRepoLatest(req, repo, rev) { |
421 … | + if (!rev) return pull.empty() | |
419 | 422 … | return u.readOnce(function (cb) { |
420 | 423 … | repo.getCommitParsed(rev, function (err, commit) { |
421 | 424 … | if (err) return cb(err) |
422 | 425 … | var commitPath = [repo.id, 'commit', commit.id] |
lib/repos/issues.js | ||
---|---|---|
@@ -97,10 +97,8 @@ | ||
97 | 97 … | /* Issue */ |
98 | 98 … | |
99 | 99 … | I.serveRepoIssue = function (req, repo, issue, path, postId) { |
100 | 100 … | var self = this |
101 | - var isAuthor = (self.web.myId == issue.author) | |
102 | - || (self.web.myId == repo.feed) | |
103 | 101 … | var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}} |
104 | 102 … | var title = u.escape(issue.title) + ' · %{author}/%{repo}' |
105 | 103 … | return self.repo.renderRepoPage(req, repo, 'issues', null, title, cat([ |
106 | 104 … | pull.once( |
@@ -142,9 +140,9 @@ | ||
142 | 140 … | req._t('issue.'), postId)) |
143 | 141 … | ), |
144 | 142 … | self.web.isPublic ? pull.empty() : u.readOnce(function (cb) { |
145 | 143 … | cb(null, forms.issueComment(req, issue, repo, |
146 | - newestMsg.key, isAuthor, req._t('issue.'))) | |
144 … | + newestMsg.key, req._t('issue.'))) | |
147 | 145 … | }) |
148 | 146 … | ])) |
149 | 147 … | } |
150 | 148 … |
lib/repos/pulls.js | |||
---|---|---|---|
@@ -126,9 +126,8 @@ | |||
126 | 126 … | var self = this | |
127 | 127 … | var msgTimeLink = u.link([pr.id], | |
128 | 128 … | new Date(pr.created_at).toLocaleString(req._locale)) | |
129 | 129 … | var newestMsg = {key: pr.id, value: {timestamp: pr.created_at}} | |
130 | - var isAuthor = (self.web.myId == pr.author) || (self.web.myId == repo.feed) | ||
131 | 130 … | return cat([ | |
132 | 131 … | u.readOnce(function (cb) { | |
133 | 132 … | cb(null, | |
134 | 133 … | '<section class="collapse">' + | |
@@ -176,9 +175,9 @@ | |||
176 | 175 … | return self.repo.issues.renderIssueActivityMsg(req, repo, pr, | |
177 | 176 … | req._t('pull request'), postId, item) | |
178 | 177 … | }) | |
179 | 178 … | ), | |
180 | - !self.web.isPublic && isAuthor && pr.open && pull.once( | ||
179 … | + !self.web.isPublic && pr.open && pull.once( | ||
181 | 180 … | '<section class="merge-instructions">' + | |
182 | 181 … | '<input type="checkbox" class="toggle" id="merge-instructions"/>' + | |
183 | 182 … | '<h4><label for="merge-instructions" class="toggle-link"><a>' + | |
184 | 183 … | req._t('mergeInstructions.MergeViaCmdLine') + | |
@@ -198,9 +197,9 @@ | |||
198 | 197 … | '</pre>' + | |
199 | 198 … | '</div></section>'), | |
200 | 199 … | !self.web.isPublic && u.readOnce(function (cb) { | |
201 | 200 … | cb(null, forms.issueComment(req, pr, repo, newestMsg.key, | |
202 | - isAuthor, req._t('pull request'))) | ||
201 … | + req._t('pull request'))) | ||
203 | 202 … | }) | |
204 | 203 … | ]) | |
205 | 204 … | } | |
206 | 205 … |
Built with git-ssb-web