git ssb

30+

cel / git-ssb-web



Commit 47ebea298eda55724bb6e637ea900aada10c5eab

re-write ul to use pull-hyperscript

mix irving committed on 10/27/2016, 8:20:27 AM
Parent: 5da7f6c737d6456f6e702d4a2fa0bee6b9217a5c

Files changed

lib/repos/index.jschanged
lib/util.jschanged
lib/repos/index.jsView
@@ -37,18 +37,8 @@
3737 u.readObjectString(obj, cb)
3838 })
3939 }
4040
41-function ul(props) {
42- return function (read) {
43- return cat([
44- pull.once('<ul' + (props ? ' ' + props : '') + '>'),
45- pull(read, pull.map(function (li) { return '<li>' + li + '</li>' })),
46- pull.once('</ul>')
47- ])
48- }
49-}
50-
5141 /* Repo */
5242
5343 R.serveRepoPage = function (req, repo, path) {
5444 var self = this
@@ -495,9 +485,9 @@
495485 ': ' + linkPath([repo.id, 'tree'], [rev].concat(path))
496486
497487 var location = once('')
498488 if (path.length !== 0) {
499- var link = linkPath([repo.id, 'tree'], [rev].concat(path))
489 + var link = linkPath([repo.id, 'tree'], [rev].concat(path))
500490 location = h('div', {class: 'fileLocation'}, `${req._t('Files')}: ${link}`)
501491 }
502492
503493 return cat([
@@ -905,28 +895,24 @@
905895 }
906896
907897 /* Digs */
908898
909-R.serveRepoDigs = function (req, repo) {
899 +R.serveRepoDigs = function serveRepoDigs (req, repo) {
910900 var self = this
911- return u.readNext(function (cb) {
912- var title = req._t('Digs') + ' · %{author}/%{repo}'
913- self.web.getVotes(repo.id, function (err, votes) {
914- cb(null, self.renderRepoPage(req, repo, null, null, title, cat([
915- pull.once('<section><h3>' + req._t('Digs') + '</h3>' +
916- '<div>' + req._t('Total') + ': ' + votes.upvotes + '</div>'),
917- pull(
918- pull.values(Object.keys(votes.upvoters)),
919- paramap(function (feedId, cb) {
920- self.web.about.getName(feedId, function (err, name) {
921- if (err) return cb(err)
922- cb(null, u.link([feedId], name))
901 + return u.readNext(cb => {
902 + var title = req._t('Digs') + ' · %{author}/%{repo}'
903 + self.web.getVotes(repo.id, (err, votes) => {
904 + cb(null, self.renderRepoPage(req, repo, null, null, title,
905 + h('section', [
906 + h('h3', req._t('Digs')),
907 + h('div', `${req._t('Total')}: ${votes.upvotes}`),
908 + h('ul', u.paraSourceMap(Object.keys(votes.upvoters), (feedId, cb) => {
909 + self.web.about.getName(feedId, (err, name) => {
910 + cb(null, h('li', u.link([feedId], name)))
923911 })
924- }, 8),
925- ul()
926- ),
927- pull.once('</section>')
928- ])))
912 + }))
913 + ])
914 + ))
929915 })
930916 })
931917 }
932918
lib/util.jsView
@@ -48,8 +48,16 @@
4848 pull.flatten()
4949 )
5050 }
5151
52 +u.paraSourceMap = function paraSourceMap (source, fn) {
53 + return pull(
54 + pull.values(source),
55 + paramap(fn),
56 + pull.flatten()
57 + )
58 +}
59 +
5260 u.escape = function (str) {
5361 return String(str)
5462 .replace(/&/g, '&amp;')
5563 .replace(/</g, '&lt;')

Built with git-ssb-web