Commit c0b3297f912bfbd496a8de48b191884b2e73f9a1
refactor u.nav to be full pull-hyperscript
mix irving committed on 11/3/2016, 9:38:32 AMParent: 55d2dbe265ce7a96e070134aa13efe6addfe7b2f
Files changed
lib/repos/index.js | changed |
lib/util.js | changed |
lib/repos/index.js | ||
---|---|---|
@@ -233,12 +233,9 @@ | ||
233 | 233 … | ? once('') |
234 | 234 … | : h('small', {class: 'bgslash'}, req._t('ForkedFrom', { |
235 | 235 … | repo: `${u.link([repo.upstream.feed], upstreamAuthorName)} / ${u.link([repo.upstream.id], upstreamName)}` |
236 | 236 … | })) |
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! | |
241 | 238 … | ), |
242 | 239 … | u.nav([ |
243 | 240 … | [[repo.id], req._t('Code'), 'code'], |
244 | 241 … | [[repo.id, 'activity'], req._t('Activity'), 'activity'], |
lib/util.js | |||
---|---|---|---|
@@ -1,5 +1,6 @@ | |||
1 | 1 … | var pull = require('pull-stream') | |
2 … | +var h = require('pull-hyperscript') | ||
2 | 3 … | var paramap = require('pull-paramap') | |
3 | 4 … | var Highlight = require('highlight.js') | |
4 | 5 … | var u = exports | |
5 | 6 … | ||
@@ -89,17 +90,29 @@ | |||
89 | 90 … | d.toLocaleString(req._locale) + '</span>' | |
90 | 91 … | } | |
91 | 92 … | ||
92 | 93 … | 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 … | + ]) | ||
100 | 104 … | } | |
101 | 105 … | ||
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 … | + | ||
102 | 115 … | u.hiddenInputs = function (values) { | |
103 | 116 … | return Object.keys(values).map(function (key) { | |
104 | 117 … | return '<input type="hidden"' + | |
105 | 118 … | ' name="' + u.escape(key) + '"' + |
Built with git-ssb-web