Commit ea333278df31de123808813a031b904b32dab41f
Show list of repos user dug
Fix %Q/K1p5oaaZvIAMVynzpcQFUp0vIdlZT1B9baTRnOGiE=.sha256Charles Lehner committed on 4/26/2016, 8:57:28 PM
Parent: 2324d21c2b5a2390f8620efc18d98402e2474ee6
Files changed
lib/users.js | changed |
lib/util.js | changed |
locale/en.json | changed |
locale/eo.json | changed |
lib/users.js | ||
---|---|---|
@@ -21,8 +21,10 @@ | ||
21 | 21 … | case 'activity': |
22 | 22 … | return this.serveUserActivity(req, feedId) |
23 | 23 … | case 'repos': |
24 | 24 … | return this.serveUserRepos(req, feedId) |
25 … | + case 'digs': | |
26 … | + return this.serveUserDigs(req, feedId) | |
25 | 27 … | } |
26 | 28 … | } |
27 | 29 … | |
28 | 30 … | U.renderUserPage = function (req, feedId, page, titleTemplate, body) { |
@@ -37,9 +39,10 @@ | ||
37 | 39 … | pull.once('<h2>' + u.link([feedId], name) + |
38 | 40 … | '<code class="user-id">' + feedId + '</code></h2>' + |
39 | 41 … | u.nav([ |
40 | 42 … | [[feedId], req._t('Activity'), 'activity'], |
41 | - [[feedId, 'repos'], req._t('Repos'), 'repos'] | |
43 … | + [[feedId, 'repos'], req._t('Repos'), 'repos'], | |
44 … | + [[feedId, 'digs'], req._t('ReposDug'), 'digs'], | |
42 | 45 … | ], page)), |
43 | 46 … | body |
44 | 47 … | ]))) |
45 | 48 … | }) |
@@ -96,4 +99,47 @@ | ||
96 | 99 … | }) |
97 | 100 … | }, 8) |
98 | 101 … | )) |
99 | 102 … | } |
103 … | + | |
104 … | +U.serveUserDigs = function (req, feedId) { | |
105 … | + var self = this | |
106 … | + var title = req._t('UsersReposDug', {name: '%{name}'}) | |
107 … | + return self.renderUserPage(req, feedId, 'digs', title, pull( | |
108 … | + self.web.ssb.links({ | |
109 … | + source: feedId, | |
110 … | + rel: 'vote', | |
111 … | + dest: '%', | |
112 … | + reverse: true, | |
113 … | + values: true | |
114 … | + }), | |
115 … | + pull.unique('dest'), | |
116 … | + u.sortMsgs(true), | |
117 … | + paramap(function (link, cb) { | |
118 … | + self.web.getMsg(link.dest, function (err, destMsg) { | |
119 … | + if (err) return cb(err) | |
120 … | + if (destMsg.content.type != 'git-repo') return cb() | |
121 … | + var vote = link.value.content && link.value.content.vote | |
122 … | + if (!(vote && vote.value > 0)) return cb() | |
123 … | + var repoId = link.dest | |
124 … | + var repoAuthor = destMsg.author | |
125 … | + var done = multicb({ pluck: 1, spread: true }) | |
126 … | + self.web.getRepoName(repoAuthor, repoId, done()) | |
127 … | + self.web.about.getName(repoAuthor, done()) | |
128 … | + done(function (err, repoName, authorName) { | |
129 … | + var authorLink = u.link([repoAuthor], authorName) | |
130 … | + var repoLink = u.link([repoId], repoName) | |
131 … | + if (err) return cb(err) | |
132 … | + cb(null, '<section class="collapse">' + | |
133 … | + '<strong class="bgslash">' + | |
134 … | + authorLink + ' / ' + repoLink + '</strong>' + | |
135 … | + '<div class="date-info">' + | |
136 … | + req._t('DugOnDate', { | |
137 … | + date: u.timestamp(link.value.timestamp, req) | |
138 … | + }) + '</div>' + | |
139 … | + '</section>') | |
140 … | + }) | |
141 … | + }) | |
142 … | + }, 12), | |
143 … | + pull.filter() | |
144 … | + )) | |
145 … | +} |
lib/util.js | ||
---|---|---|
@@ -131,19 +131,20 @@ | ||
131 | 131 … | function compareMsgs(a, b) { |
132 | 132 … | return (a.value.timestamp - b.value.timestamp) || (a.key - b.key) |
133 | 133 … | } |
134 | 134 … | |
135 | -u.pullSort = function (comparator) { | |
135 … | +u.pullSort = function (comparator, descending) { | |
136 | 136 … | return function (read) { |
137 | 137 … | return u.readNext(function (cb) { |
138 | 138 … | pull(read, pull.collect(function (err, items) { |
139 | 139 … | if (err) return cb(err) |
140 | 140 … | items.sort(comparator) |
141 … | + if (descending) items.reverse() | |
141 | 142 … | cb(null, pull.values(items)) |
142 | 143 … | })) |
143 | 144 … | }) |
144 | 145 … | } |
145 | 146 … | } |
146 | 147 … | |
147 | -u.sortMsgs = function () { | |
148 | - return u.pullSort(compareMsgs) | |
148 … | +u.sortMsgs = function (descending) { | |
149 … | + return u.pullSort(compareMsgs, descending) | |
149 | 150 … | } |
locale/en.json | ||
---|---|---|
@@ -32,11 +32,14 @@ | ||
32 | 32 … | "Named": "%{author} named %{target} %{name}", |
33 | 33 … | "CommentedOn": "%{name} commented on %{type} %{title}", |
34 | 34 … | "Activity": "Activity", |
35 | 35 … | "Repos": "Repos", |
36 … | + "ReposDug": "Repos dug", | |
36 | 37 … | "UsersRepos": "%{name}'s repos", |
38 … | + "UsersReposDug": "Repos dug by %{name}", | |
37 | 39 … | "UpdatedOnDate": "Updated %{date}", |
38 | 40 … | "CreatedOnDate": "Created %{date}", |
41 … | + "DugOnDate": "Dug %{date}", | |
39 | 42 … | "Dig": "Dig", |
40 | 43 … | "Undig": "Undig", |
41 | 44 … | "Fork": "Fork", |
42 | 45 … | "Forks": "Forks", |
locale/eo.json | ||
---|---|---|
@@ -32,11 +32,14 @@ | ||
32 | 32 … | "Named": "%{author} nomis %{target} %{name}", |
33 | 33 … | "CommentedOn": "%{name} komentis %{type} %{title}", |
34 | 34 … | "Activity": "Aktivaĵo", |
35 | 35 … | "Repos": "Deponejoj", |
36 … | + "ReposDug": "Deponejoj dig-itaj", | |
36 | 37 … | "UsersRepos": "Deponejoj de %{name}", |
38 … | + "UsersReposDug": "Deponejoj dig-itaj de %{name}", | |
37 | 39 … | "UpdatedOnDate": "Ĝisdatigis je %{date}", |
38 | 40 … | "CreatedOnDate": "Kreis je %{date}", |
41 … | + "DugOnDate": "Dig-adi %{date}", | |
39 | 42 … | "Dig": "Digi", |
40 | 43 … | "Undig": "Maldigi", |
41 | 44 … | "Fork": "Forki", |
42 | 45 … | "Forks": "Forkoj", |
Built with git-ssb-web