lib/repos/index.jsView |
---|
14 | 14 … | var ssbRef = require('ssb-ref') |
15 | 15 … | var zlib = require('zlib') |
16 | 16 … | var toPull = require('stream-to-pull-stream') |
17 | 17 … | var h = require('pull-hyperscript') |
| 18 … | +var extend = require('xtend') |
18 | 19 … | |
19 | 20 … | module.exports = function (web) { |
20 | 21 … | return new RepoRoutes(web) |
21 | 22 … | } |
197 | 198 … | self.web.about.getName(repo.upstream.feed, done()) |
198 | 199 … | } |
199 | 200 … | |
200 | 201 … | return u.readNext(function (cb) { |
201 | | - done(function (err, repoName, authorName, votes, |
202 | | - upstreamName, upstreamAuthorName) { |
| 202 … | + done(function (err, repoName, authorName, votes, upstreamName, upstreamAuthorName) { |
203 | 203 … | if (err) return cb(null, self.web.serveError(req, err)) |
204 | 204 … | var upvoted = votes.upvoters[self.web.myId] > 0 |
205 | 205 … | var upstreamLink = !repo.upstream ? '' : |
206 | 206 … | u.link([repo.upstream]) |
208 | 208 … | .replace(/%\{repo\}/g, repoName) |
209 | 209 … | .replace(/%\{author\}/g, authorName) |
210 | 210 … | : authorName + '/' + repoName |
211 | 211 … | var isPublic = self.web.isPublic |
| 212 … | + var isPrivate = !isPublic |
212 | 213 … | cb(null, self.web.serveTemplate(req, title)(cat([ |
213 | | - pull.once( |
214 | | - '<div class="repo-title">' + |
215 | | - '<form class="right-bar" action="" method="post">' + |
216 | | - '<button class="btn" name="action" value="vote" ' + |
217 | | - (isPublic ? 'disabled="disabled"' : ' type="submit"') + '>' + |
218 | | - '<i>✌</i> ' + req._t(!isPublic && upvoted ? 'Undig' : 'Dig') + |
219 | | - '</button>' + |
220 | | - (isPublic ? '' : '<input type="hidden" name="value" value="' + |
221 | | - (upvoted ? '0' : '1') + '">' + |
222 | | - '<input type="hidden" name="id" value="' + |
223 | | - u.escape(repo.id) + '">') + ' ' + |
224 | | - '<strong>' + u.link(digsPath, votes.upvotes) + '</strong> ' + |
225 | | - (isPublic ? '' : '<button class="btn" type="submit" ' + |
226 | | - ' name="action" value="fork-prompt">' + |
227 | | - '<i>⑂</i> ' + req._t('Fork') + |
228 | | - '</button>') + ' ' + |
229 | | - u.link([repo.id, 'forks'], '+', false, ' title="' + |
230 | | - req._t('Forks') + '"') + |
231 | | - '</form>' + |
232 | | - forms.name(req, !isPublic, repo.id, repoName, 'repo-name', |
233 | | - null, req._t('repo.Rename'), |
234 | | - '<h2 class="bgslash">' + u.link([repo.feed], authorName) + ' / ' + |
235 | | - u.link([repo.id], repoName) + '</h2>') + |
236 | | - '</div>' + |
237 | | - (repo.upstream ? '<small class="bgslash">' + req._t('ForkedFrom', { |
238 | | - repo: u.link([repo.upstream.feed], upstreamAuthorName) + '/' + |
239 | | - u.link([repo.upstream.id], upstreamName) |
240 | | - }) + '</small>' : '') + |
241 | | - u.nav([ |
242 | | - [[repo.id], req._t('Code'), 'code'], |
243 | | - [[repo.id, 'activity'], req._t('Activity'), 'activity'], |
244 | | - [[repo.id, 'commits', branch||''], req._t('Commits'), 'commits'], |
245 | | - [[repo.id, 'issues'], req._t('Issues'), 'issues'], |
246 | | - [[repo.id, 'pulls'], req._t('PullRequests'), 'pulls'] |
247 | | - ], page, cloneUrls)), |
| 214 … | + h('div', {class: 'repo-title'}, [ |
| 215 … | + h('form', {class: 'right-bar', action: '', method: 'post'}, [ |
| 216 … | + h('button', |
| 217 … | + extend({class: 'btn', name: 'action', value: 'vote'}, |
| 218 … | + (isPublic ? {disabled: 'disabled'} : {type: 'submit'}) |
| 219 … | + ), [ |
| 220 … | + h('i', '✌'), |
| 221 … | + h('span', req._t(!isPublic && upvoted ? 'Undig' : 'Dig')) |
| 222 … | + ] |
| 223 … | + ), |
| 224 … | + (isPublic |
|
| 225 … | + ? once('') |
| 226 … | + : cat([ |
| 227 … | + h('input', {type: 'hidden', name: 'value', value: (upvoted ? '0' : '1')}, []), |
| 228 … | + h('input', {type: 'hidden', name: 'id', value: u.escape(repo.id)}, []) |
| 229 … | + ]) |
| 230 … | + ), |
| 231 … | + h('strong', u.link(digsPath, votes.upvotes)), |
| 232 … | + (isPublic |
| 233 … | + ? once('') |
| 234 … | + : h('button', {class: 'btn', type: 'submit', name: 'action', value: 'fork-prompt'}, [ |
| 235 … | + h('i', '⑂'), |
| 236 … | + once(req._t('Fork')) |
| 237 … | + ]) |
| 238 … | + ), |
| 239 … | + h('a', {href: u.encodeLink([repo.id, 'forks']), title: req._t('Forks')}, '+') |
| 240 … | + ]), |
| 241 … | + forms.name(req, !isPublic, repo.id, repoName, 'repo-name', null, req._t('repo.Rename'), |
| 242 … | + h('h2', {class: 'bgslash'}, `${u.link([repo.feed], authorName)} / ${u.link([repo.id], repoName)}`) |
| 243 … | + ), |
| 244 … | + ]), |
| 245 … | + (!repo.upstream |
| 246 … | + ? once('') |
| 247 … | + : h('small', {class: 'bgslash'}, req._t('ForkedFrom', { |
| 248 … | + repo: `${u.link([repo.upstream.feed], upstreamAuthorName)} / ${u.link([repo.upstream.id], upstreamName)}` |
| 249 … | + })) |
| 250 … | + ), |
| 251 … | + u.nav([ |
| 252 … | + [[repo.id], req._t('Code'), 'code'], |
| 253 … | + [[repo.id, 'activity'], req._t('Activity'), 'activity'], |
| 254 … | + [[repo.id, 'commits', branch||''], req._t('Commits'), 'commits'], |
| 255 … | + [[repo.id, 'issues'], req._t('Issues'), 'issues'], |
| 256 … | + [[repo.id, 'pulls'], req._t('PullRequests'), 'pulls'] |
| 257 … | + ], page, cloneUrls), |
248 | 258 … | body |
249 | | - ]))) |
| 259 … | + ]) |
| 260 … | + )) |
250 | 261 … | }) |
251 | 262 … | }) |
252 | 263 … | } |
253 | 264 … | |