git ssb

30+

cel / git-ssb-web



Commit ce171726150b63b15a82a7416797bb7926742a25

Work with multi-feed ssb-git-repo

Charles Lehner committed on 9/27/2016, 8:42:42 PM
Parent: 3b463efb1d84d837baadd660454a865beb148b56

Files changed

lib/forms.jschanged
lib/repos/index.jschanged
lib/repos/issues.jschanged
lib/repos/pulls.jschanged
lib/forms.jsView
@@ -67,9 +67,9 @@
6767 : btn.getAttribute('data-value-nocomment'))
6868 }
6969 }.toString() + ')()'
7070
71-forms.issueComment = function (req, issue, repo, branch, isAuthor, type) {
71 +forms.issueComment = function (req, issue, repo, branch, type) {
7272 return '<section><form action="" method="post">' +
7373 '<input type="hidden" name="action" value="comment">' +
7474 '<input type="hidden" name="id" value="' + issue.id + '">' +
7575 '<input type="hidden" name="issue" value="' + issue.id + '">' +
@@ -77,20 +77,18 @@
7777 '<input type="hidden" name="branch" value="' + branch + '">' +
7878 forms.post(req, repo) +
7979 '<input type="submit" class="btn open" value="' +
8080 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>' +
9593 '</form></section>'
9694 }
lib/repos/index.jsView
@@ -157,10 +157,10 @@
157157 'onclick="this.select()"/>'
158158 var digsPath = [repo.id, 'digs']
159159
160160 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())
163163 self.web.getVotes(repo.id, done())
164164
165165 if (repo.upstream) {
166166 self.web.getRepoName(repo.upstream.feed, repo.upstream.id, done())
@@ -200,9 +200,9 @@
200200 req._t('Forks') + '"') +
201201 '</form>' +
202202 forms.name(req, !isPublic, repo.id, repoName, 'repo-name',
203203 null, req._t('repo.Rename'),
204- '<h2 class="bgslash">' + u.link([repo.feed], authorName) + ' / ' +
204 + '<h2 class="bgslash">' + u.link([repo.creator], authorName) + ' / ' +
205205 u.link([repo.id], repoName) + '</h2>') +
206206 '</div>' +
207207 (repo.upstream ? '<small class="bgslash">' + req._t('ForkedFrom', {
208208 repo: u.link([repo.upstream.feed], upstreamAuthorName) + '/' +
@@ -221,9 +221,9 @@
221221 })
222222 }
223223
224224 R.serveEmptyRepo = function (req, repo) {
225- if (repo.feed != this.web.myId)
225 + if (repo.creator != this.web.myId)
226226 return this.renderRepoPage(req, repo, 'code', null, null, pull.once(
227227 '<section>' +
228228 '<h3>' + req._t('EmptyRepo') + '</h3>' +
229229 '</section>'))
@@ -245,9 +245,8 @@
245245 '</section>'))
246246 }
247247
248248 R.serveRepoTree = function (req, repo, rev, path) {
249- if (!rev) return this.serveEmptyRepo(req, repo)
250249 var type = repo.isCommitHash(rev) ? 'Tree' : 'Branch'
251250 var title = (path.length ? path.join('/') + ' · ' : '') +
252251 '%{author}/%{repo}' +
253252 (repo.head == 'refs/heads/' + rev ? '' : '@' + rev)
@@ -256,12 +255,15 @@
256255 '<h3>' + req._t(type) + ': ' + rev + ' '),
257256 this.revMenu(req, repo, rev),
258257 pull.once('</h3></form>'),
259258 type == 'Branch' && renderRepoLatest(req, repo, rev),
260- pull.once('</section><section>'),
261- renderRepoTree(req, repo, rev, path),
262259 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)
264266 ]))
265267 }
266268
267269 /* Repo activity */
@@ -282,9 +284,9 @@
282284 pull.map(renderRepoUpdate.bind(self, req, repo))
283285 ),
284286 u.readOnce(function (cb) {
285287 var done = multicb({ pluck: 1, spread: true })
286- self.web.about.getName(repo.feed, done())
288 + self.web.about.getName(repo.creator, done())
287289 self.web.getMsg(repo.id, done())
288290 done(function (err, authorName, msg) {
289291 if (err) return cb(err)
290292 self.web.renderFeedItem(req, {
@@ -415,8 +417,9 @@
415417
416418 /* Repo tree */
417419
418420 function renderRepoLatest(req, repo, rev) {
421 + if (!rev) return pull.empty()
419422 return u.readOnce(function (cb) {
420423 repo.getCommitParsed(rev, function (err, commit) {
421424 if (err) return cb(err)
422425 var commitPath = [repo.id, 'commit', commit.id]
lib/repos/issues.jsView
@@ -97,10 +97,8 @@
9797 /* Issue */
9898
9999 I.serveRepoIssue = function (req, repo, issue, path, postId) {
100100 var self = this
101- var isAuthor = (self.web.myId == issue.author)
102- || (self.web.myId == repo.feed)
103101 var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}}
104102 var title = u.escape(issue.title) + ' · %{author}/%{repo}'
105103 return self.repo.renderRepoPage(req, repo, 'issues', null, title, cat([
106104 pull.once(
@@ -142,9 +140,9 @@
142140 req._t('issue.'), postId))
143141 ),
144142 self.web.isPublic ? pull.empty() : u.readOnce(function (cb) {
145143 cb(null, forms.issueComment(req, issue, repo,
146- newestMsg.key, isAuthor, req._t('issue.')))
144 + newestMsg.key, req._t('issue.')))
147145 })
148146 ]))
149147 }
150148
lib/repos/pulls.jsView
@@ -126,9 +126,8 @@
126126 var self = this
127127 var msgTimeLink = u.link([pr.id],
128128 new Date(pr.created_at).toLocaleString(req._locale))
129129 var newestMsg = {key: pr.id, value: {timestamp: pr.created_at}}
130- var isAuthor = (self.web.myId == pr.author) || (self.web.myId == repo.feed)
131130 return cat([
132131 u.readOnce(function (cb) {
133132 cb(null,
134133 '<section class="collapse">' +
@@ -176,9 +175,9 @@
176175 return self.repo.issues.renderIssueActivityMsg(req, repo, pr,
177176 req._t('pull request'), postId, item)
178177 })
179178 ),
180- !self.web.isPublic && isAuthor && pr.open && pull.once(
179 + !self.web.isPublic && pr.open && pull.once(
181180 '<section class="merge-instructions">' +
182181 '<input type="checkbox" class="toggle" id="merge-instructions"/>' +
183182 '<h4><label for="merge-instructions" class="toggle-link"><a>' +
184183 req._t('mergeInstructions.MergeViaCmdLine') +
@@ -198,9 +197,9 @@
198197 '</pre>' +
199198 '</div></section>'),
200199 !self.web.isPublic && u.readOnce(function (cb) {
201200 cb(null, forms.issueComment(req, pr, repo, newestMsg.key,
202- isAuthor, req._t('pull request')))
201 + req._t('pull request')))
203202 })
204203 ])
205204 }
206205

Built with git-ssb-web