Commit ac38f3bf0c59103522861df8b3a1f1f545247977
Merge branch 'master' of ssb://%q5d5Du+9WkaSdjc8aJPZm+jMrqgo0tmfR+RcX5ZZ6H4=.sha256 into repo-index-hyperscript
mix irving committed on 11/3/2016, 8:31:28 AMParent: 0b95005d33b39339c34360a02ee6a8f696c7ec92
Parent: a9fe03daf5d840abc9878f2330aaec4a12666857
Files changed
lib/repos/index.js | changed |
lib/util.js | changed |
lib/repos/index.js | |||
---|---|---|---|
@@ -38,18 +38,8 @@ | |||
38 | 38 … | u.readObjectString(obj, cb) | |
39 | 39 … | }) | |
40 | 40 … | } | |
41 | 41 … | ||
42 | -function ul(props) { | ||
43 | - return function (read) { | ||
44 | - return cat([ | ||
45 | - pull.once('<ul' + (props ? ' ' + props : '') + '>'), | ||
46 | - pull(read, pull.map(function (li) { return '<li>' + li + '</li>' })), | ||
47 | - pull.once('</ul>') | ||
48 | - ]) | ||
49 | - } | ||
50 | -} | ||
51 | - | ||
52 | 42 … | /* Repo */ | |
53 | 43 … | ||
54 | 44 … | R.serveRepoPage = function (req, repo, path) { | |
55 | 45 … | var self = this | |
@@ -503,9 +493,9 @@ | |||
503 | 493 … | ': ' + linkPath([repo.id, 'tree'], [rev].concat(path)) | |
504 | 494 … | ||
505 | 495 … | var location = once('') | |
506 | 496 … | if (path.length !== 0) { | |
507 | - var link = linkPath([repo.id, 'tree'], [rev].concat(path)) | ||
497 … | + var link = linkPath([repo.id, 'tree'], [rev].concat(path)) | ||
508 | 498 … | location = h('div', {class: 'fileLocation'}, `${req._t('Files')}: ${link}`) | |
509 | 499 … | } | |
510 | 500 … | ||
511 | 501 … | return cat([ | |
@@ -913,28 +903,24 @@ | |||
913 | 903 … | } | |
914 | 904 … | ||
915 | 905 … | /* Digs */ | |
916 | 906 … | ||
917 | -R.serveRepoDigs = function (req, repo) { | ||
907 … | +R.serveRepoDigs = function serveRepoDigs (req, repo) { | ||
918 | 908 … | var self = this | |
919 | - return u.readNext(function (cb) { | ||
920 | - var title = req._t('Digs') + ' · %{author}/%{repo}' | ||
921 | - self.web.getVotes(repo.id, function (err, votes) { | ||
922 | - cb(null, self.renderRepoPage(req, repo, null, null, title, cat([ | ||
923 | - pull.once('<section><h3>' + req._t('Digs') + '</h3>' + | ||
924 | - '<div>' + req._t('Total') + ': ' + votes.upvotes + '</div>'), | ||
925 | - pull( | ||
926 | - pull.values(Object.keys(votes.upvoters)), | ||
927 | - paramap(function (feedId, cb) { | ||
928 | - self.web.about.getName(feedId, function (err, name) { | ||
929 | - if (err) return cb(err) | ||
930 | - cb(null, u.link([feedId], name)) | ||
909 … | + return u.readNext(cb => { | ||
910 … | + var title = req._t('Digs') + ' · %{author}/%{repo}' | ||
911 … | + self.web.getVotes(repo.id, (err, votes) => { | ||
912 … | + cb(null, self.renderRepoPage(req, repo, null, null, title, | ||
913 … | + h('section', [ | ||
914 … | + h('h3', req._t('Digs')), | ||
915 … | + h('div', `${req._t('Total')}: ${votes.upvotes}`), | ||
916 … | + h('ul', u.paraSourceMap(Object.keys(votes.upvoters), (feedId, cb) => { | ||
917 … | + self.web.about.getName(feedId, (err, name) => { | ||
918 … | + cb(null, h('li', u.link([feedId], name))) | ||
931 | 919 … | }) | |
932 | - }, 8), | ||
933 | - ul() | ||
934 | - ), | ||
935 | - pull.once('</section>') | ||
936 | - ]))) | ||
920 … | + })) | ||
921 … | + ]) | ||
922 … | + )) | ||
937 | 923 … | }) | |
938 | 924 … | }) | |
939 | 925 … | } | |
940 | 926 … |
lib/util.js | ||
---|---|---|
@@ -53,8 +53,16 @@ | ||
53 | 53 … | pull.map(fn) |
54 | 54 … | ) |
55 | 55 … | } |
56 | 56 … | |
57 … | +u.paraSourceMap = function paraSourceMap (source, fn) { | |
58 … | + return pull( | |
59 … | + pull.values(source), | |
60 … | + paramap(fn, 8), | |
61 … | + pull.flatten() | |
62 … | + ) | |
63 … | +} | |
64 … | + | |
57 | 65 … | u.escape = function (str) { |
58 | 66 … | return String(str) |
59 | 67 … | .replace(/&/g, '&') |
60 | 68 … | .replace(/</g, '<') |
Built with git-ssb-web