git ssb

30+

cel / git-ssb-web



Commit 0b95005d33b39339c34360a02ee6a8f696c7ec92

introduce when helper, introduce clearer tachyon-style

mix irving committed on 11/3/2016, 8:31:12 AM
Parent: dcaef795f59bc5e84215b51bc26bbaf77972e711

Files changed

lib/repos/index.jschanged
lib/util.jschanged
package.jsonchanged
static/styles.csschanged
lib/repos/index.jsView
@@ -208,38 +208,35 @@
208208 .replace(/%\{repo\}/g, repoName)
209209 .replace(/%\{author\}/g, authorName)
210210 : authorName + '/' + repoName
211211 var isPublic = self.web.isPublic
212- var isPrivate = !isPublic //TODO use this with u.when(isPrivate, h())
212 + var isLocal = !isPublic
213213 cb(null, self.web.serveTemplate(req, title)(cat([
214214 h('div', {class: 'repo-title'}, [
215215 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'})
216 + h('strong', {class: 'ml2 mr1'}, u.link(digsPath, votes.upvotes)),
217 + h('button',
218 + extend(
219 + {class: 'btn', name: 'action', value: 'vote'},
220 + isPublic ? {disabled: 'disabled'} : {type: 'submit'}
219221 ), [
220- h('i', '✌'),
221- h('span', req._t(!isPublic && upvoted ? 'Undig' : 'Dig'))
222 + h('i', '✌ '),
223 + h('span', req._t(isLocal && upvoted ? 'Undig' : 'Dig'))
222224 ]
223225 ),
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)}, [])
226 + u.when(isLocal, 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 + h('a', {href: u.encodeLink([repo.id, 'forks']), title: req._t('Forks'), class: 'ml2 mr1'}, '+'),
231 + u.when(isLocal,
232 + h('button', {class: 'btn', type: 'submit', name: 'action', value: 'fork-prompt'}, [
233 + h('i', '⑂ '),
234 + once(req._t('Fork'))
229235 ])
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')}, '+')
236 + )
240237 ]),
241- forms.name(req, !isPublic, repo.id, repoName, 'repo-name', null, req._t('repo.Rename'),
238 + forms.name(req, isLocal, repo.id, repoName, 'repo-name', null, req._t('repo.Rename'),
242239 h('h2', {class: 'bgslash'}, `${u.link([repo.feed], authorName)} / ${u.link([repo.id], repoName)}`)
243240 ),
244241 ]),
245242 (!repo.upstream
@@ -471,9 +468,9 @@
471468 var commitPath = [repo.id, 'commit', commit.id]
472469 var actor = commit.separateAuthor ? 'author' : 'committer'
473470 var actionKey = actor.slice(0,1).toUpperCase() + actor.slice(1) + 'ReleasedCommit'
474471 cb(null,
475- '<div class="mt1">' +
472 + '<div class="mt2">' +
476473 '<span>' +
477474 req._t(actionKey, {
478475 name: u.escape(commit[actor].name),
479476 commitName: u.link(commitPath, commit.title)
lib/util.jsView
@@ -39,14 +39,19 @@
3939 })
4040 }
4141 }
4242
43-u.sourceMap = function sourceMap (source, fn) {
43 +u.when = function (bool, el) {
44 + return bool
45 + ? el
46 + : pull.once('')
47 +}
48 +
49 +u.sourceMap = function (source, fn) {
4450 return pull(
4551 source,
4652 pull.filter(Boolean),
47- pull.map(fn),
48- pull.flatten()
53 + pull.map(fn)
4954 )
5055 }
5156
5257 u.escape = function (str) {
package.jsonView
@@ -13,9 +13,9 @@
1313 "node-polyglot": "^1.0.0",
1414 "pull-cat": "^1.1.8",
1515 "pull-git-pack": "^0.2.0",
1616 "pull-git-repo": "^0.6.1",
17- "pull-hyperscript": "^0.0.4",
17 + "pull-hyperscript": "^0.2.1",
1818 "pull-identify-filetype": "^1.1.0",
1919 "pull-many": "^1.0.6",
2020 "pull-paramap": "^1.1.6",
2121 "pull-stream": "^3.1.0",
static/styles.cssView
@@ -508,12 +508,20 @@
508508 .dib { display: inline-block; }
509509
510510 .w-100 { width: 100%; }
511511
512-.ml2 { margin-left: 2rem; }
512 +.ml4 { margin-left: 2rem; }
513 +.ml3 { margin-left: 1rem; }
514 +.ml2 { margin-left: 0.5rem; }
515 +.ml1 { margin-left: 0.25rem; }
513516
514-.mt1 { margin-top: 0.5rem; }
517 +.mr4 { margin-right: 2rem; }
518 +.mr3 { margin-right: 1rem; }
519 +.mr2 { margin-right: 0.5rem; }
520 +.mr1 { margin-right: 0.25rem; }
515521
522 +.mt2 { margin-top: 0.5rem; }
523 +
516524 .float-right { float: right; }
517525
518526 .light-grey { color: #909090; }
519527

Built with git-ssb-web