Commit 1b057d84aa726cdc9404a6340cb96c8825329242
More refactor
Anders Rune Jensen committed on 5/11/2017, 7:49:44 PMParent: 4f7d162bf1625d6dc4e8e518f55ee5d842d12bc2
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -91,10 +91,8 @@ | ||
91 | 91 … | |
92 | 92 … | function serveFeed(req, res, feedId) { |
93 | 93 … | console.log("serving feed: " + feedId) |
94 | 94 … | |
95 | - var opts = defaultOpts | |
96 | - | |
97 | 95 … | getAbout(feedId, function (err, about) { |
98 | 96 … | if (err) return cb(err) |
99 | 97 … | |
100 | 98 … | pull( |
@@ -108,9 +106,9 @@ | ||
108 | 106 … | pull.values(logs), |
109 | 107 … | paramap(addAuthorAbout, 8), |
110 | 108 … | paramap(addFollowAbout, 8), |
111 | 109 … | paramap(addVoteMessage, 8), |
112 | - pull(renderThread(opts), wrapPage(about.name)), | |
110 … | + pull(renderThread(defaultOpts), wrapPage(about.name)), | |
113 | 111 … | toPull(res, function (err) { |
114 | 112 … | if (err) console.error('[viewer]', err) |
115 | 113 … | }) |
116 | 114 … | ) |
@@ -159,10 +157,8 @@ | ||
159 | 157 … | }) |
160 | 158 … | } |
161 | 159 … | |
162 | 160 … | function serveFeeds(req, res, following, channelSubscriptions, feedId, name) { |
163 | - var opts = defaultOpts | |
164 | - | |
165 | 161 … | pull( |
166 | 162 … | sbot.createLogStream({ reverse: true, limit: 2500 }), |
167 | 163 … | pull.filter((msg) => { |
168 | 164 … | return !msg.value || |
@@ -179,9 +175,9 @@ | ||
179 | 175 … | pull.values(logs), |
180 | 176 … | paramap(addAuthorAbout, 8), |
181 | 177 … | paramap(addFollowAbout, 8), |
182 | 178 … | paramap(addVoteMessage, 8), |
183 | - pull(renderThread(opts), wrapPage(name)), | |
179 … | + pull(renderThread(defaultOpts), wrapPage(name)), | |
184 | 180 … | toPull(res, function (err) { |
185 | 181 … | if (err) console.error('[viewer]', err) |
186 | 182 … | }) |
187 | 183 … | ) |
@@ -191,10 +187,8 @@ | ||
191 | 187 … | |
192 | 188 … | function serveChannel(req, res, url) { |
193 | 189 … | var channelId = url.substring(url.lastIndexOf('channel/')+8, 100) |
194 | 190 … | console.log("serving channel: " + channelId) |
195 | - | |
196 | - var opts = defaultOpts | |
197 | 191 … | |
198 | 192 … | pull( |
199 | 193 … | sbot.query.read({ limit: 500, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}), |
200 | 194 … | pull.collect(function (err, logs) { |
@@ -205,39 +199,17 @@ | ||
205 | 199 … | pull( |
206 | 200 … | pull.values(logs), |
207 | 201 … | paramap(addAuthorAbout, 8), |
208 | 202 … | paramap(addVoteMessage, 8), |
209 | - pull(renderThread(opts), wrapPage('#' + channelId)), | |
203 … | + pull(renderThread(defaultOpts), wrapPage('#' + channelId)), | |
210 | 204 … | toPull(res, function (err) { |
211 | 205 … | if (err) console.error('[viewer]', err) |
212 | 206 … | }) |
213 | 207 … | ) |
214 | 208 … | }) |
215 | 209 … | ) |
216 | 210 … | } |
217 | 211 … | |
218 | - function addFollowAbout(msg, cb) { | |
219 | - if (msg.value.content.contact) | |
220 | - getAbout(msg.value.content.contact, function (err, about) { | |
221 | - if (err) return cb(err) | |
222 | - msg.value.content.contactAbout = about | |
223 | - cb(null, msg) | |
224 | - }) | |
225 | - else | |
226 | - cb(null, msg) | |
227 | - } | |
228 | - | |
229 | - function addVoteMessage(msg, cb) { | |
230 | - if (msg.value.content.type == 'vote' && msg.value.content.vote.link[0] == '%') | |
231 | - getMsg(msg.value.content.vote.link, function (err, linkedMsg) { | |
232 | - if (linkedMsg) | |
233 | - msg.value.content.vote.linkedText = linkedMsg.value.content.text | |
234 | - cb(null, msg) | |
235 | - }) | |
236 | - else | |
237 | - cb(null, msg) | |
238 | - } | |
239 | - | |
240 | 212 … | function serveId(req, res, id, ext, query) { |
241 | 213 … | var q = query ? qs.parse(query) : {} |
242 | 214 … | var includeRoot = !('noroot' in q) |
243 | 215 … | var base = q.base || conf.base |
@@ -294,8 +266,30 @@ | ||
294 | 266 … | }) |
295 | 267 … | ) |
296 | 268 … | } |
297 | 269 … | |
270 … | + function addFollowAbout(msg, cb) { | |
271 … | + if (msg.value.content.contact) | |
272 … | + getAbout(msg.value.content.contact, function (err, about) { | |
273 … | + if (err) return cb(err) | |
274 … | + msg.value.content.contactAbout = about | |
275 … | + cb(null, msg) | |
276 … | + }) | |
277 … | + else | |
278 … | + cb(null, msg) | |
279 … | + } | |
280 … | + | |
281 … | + function addVoteMessage(msg, cb) { | |
282 … | + if (msg.value.content.type == 'vote' && msg.value.content.vote.link[0] == '%') | |
283 … | + getMsg(msg.value.content.vote.link, function (err, linkedMsg) { | |
284 … | + if (linkedMsg) | |
285 … | + msg.value.content.vote.linkedText = linkedMsg.value.content.text | |
286 … | + cb(null, msg) | |
287 … | + }) | |
288 … | + else | |
289 … | + cb(null, msg) | |
290 … | + } | |
291 … | + | |
298 | 292 … | function addAuthorAbout(msg, cb) { |
299 | 293 … | getAbout(msg.value.author, function (err, about) { |
300 | 294 … | if (err) return cb(err) |
301 | 295 … | msg.author = about |
Built with git-ssb-web