git ssb

30+

cel / git-ssb-web



Commit c0b3297f912bfbd496a8de48b191884b2e73f9a1

refactor u.nav to be full pull-hyperscript

mix irving committed on 11/3/2016, 9:38:32 AM
Parent: 55d2dbe265ce7a96e070134aa13efe6addfe7b2f

Files changed

lib/repos/index.jschanged
lib/util.jschanged
lib/repos/index.jsView
@@ -233,12 +233,9 @@
233233 ? once('')
234234 : h('small', {class: 'bgslash'}, req._t('ForkedFrom', {
235235 repo: `${u.link([repo.upstream.feed], upstreamAuthorName)} / ${u.link([repo.upstream.id], upstreamName)}`
236236 }))
237- //u.when(!!repo.upstream,
238- //h('small', {class: 'bgslash'}, req._t('ForkedFrom', {
239- //repo: `${u.link([repo.upstream.feed], upstreamAuthorName)} / ${u.link([repo.upstream.id], upstreamName)}`
240- //}))
237 + //TODO (mix) replace the with when. It's reporteding repo.upstream is true, then undefined attr feed is requested!
241238 ),
242239 u.nav([
243240 [[repo.id], req._t('Code'), 'code'],
244241 [[repo.id, 'activity'], req._t('Activity'), 'activity'],
lib/util.jsView
@@ -1,5 +1,6 @@
11 var pull = require('pull-stream')
2 +var h = require('pull-hyperscript')
23 var paramap = require('pull-paramap')
34 var Highlight = require('highlight.js')
45 var u = exports
56
@@ -89,17 +90,29 @@
8990 d.toLocaleString(req._locale) + '</span>'
9091 }
9192
9293 u.nav = function (links, page, after) {
93- return pull.once(['<nav>'].concat(
94- links.map(function (link) {
95- var href = typeof link[0] == 'string' ? link[0] : u.encodeLink(link[0])
96- var props = link[2] == page ? ' class="active"' : ''
97- return '<a href="' + href + '"' + props + '>' + link[1] + '</a>'
98- }), after || '', '</nav>').join('')
99- )
94 + return h('nav', [
95 + u.sourceMap(pull.values(links), link => {
96 + return h('a', {
97 + href: (typeof link[0] == 'string') ? link[0] : u.encodeLink(link[0]),
98 + class: (link[2] == page) ? 'active' : ''
99 + },
100 + link[1])
101 + }),
102 + pull.once(after || '')
103 + ])
100104 }
101105
106 + //return pull.once(['<nav>'].concat(
107 + //links.map(function (link) {
108 + //var href = typeof link[0] == 'string' ? link[0] : u.encodeLink(link[0])
109 + //var props = link[2] == page ? ' class="active"' : ''
110 + //return '<a href="' + href + '"' + props + '>' + link[1] + '</a>'
111 + //}), after || '', '</nav>').join('')
112 + //)
113 +//}
114 +
102115 u.hiddenInputs = function (values) {
103116 return Object.keys(values).map(function (key) {
104117 return '<input type="hidden"' +
105118 ' name="' + u.escape(key) + '"' +

Built with git-ssb-web