git ssb

9+

cel / ssb-viewer



Commit 728dd36ef62070f884bb5a7854652d466aaf5fe2

whitespace

cel committed on 4/16/2018, 6:41:44 AM
Parent: 08321fdd28495d2cb08d4f7256ed2f6aab925315

Files changed

index.jschanged
index.jsView
@@ -152,36 +152,36 @@
152152 var channelSubscriptions = []
153153
154154 getAbout(feedId, function (err, about) {
155155 pull(
156- sbot.createUserStream({ id: feedId }),
157- pull.filter((msg) => {
158- return !msg.value ||
159- msg.value.content.type == 'contact' ||
160- (msg.value.content.type == 'channel' &&
161- typeof msg.value.content.subscribed != 'undefined')
162- }),
163- pull.collect(function (err, msgs) {
164- msgs.forEach((msg) => {
165- if (msg.value.content.type == 'contact')
166- {
167- if (msg.value.content.following)
168- following[msg.value.content.contact] = 1
169- else
170- delete following[msg.value.content.contact]
171- }
172- else // channel subscription
173- {
174- if (msg.value.content.subscribed)
175- channelSubscriptions[msg.value.content.channel] = 1
176- else
177- delete channelSubscriptions[msg.value.content.channel]
178- }
179- })
180-
181- serveFeeds(req, res, following, channelSubscriptions, feedId,
156 + sbot.createUserStream({ id: feedId }),
157 + pull.filter((msg) => {
158 + return !msg.value ||
159 + msg.value.content.type == 'contact' ||
160 + (msg.value.content.type == 'channel' &&
161 + typeof msg.value.content.subscribed != 'undefined')
162 + }),
163 + pull.collect(function (err, msgs) {
164 + msgs.forEach((msg) => {
165 + if (msg.value.content.type == 'contact')
166 + {
167 + if (msg.value.content.following)
168 + following[msg.value.content.contact] = 1
169 + else
170 + delete following[msg.value.content.contact]
171 + }
172 + else // channel subscription
173 + {
174 + if (msg.value.content.subscribed)
175 + channelSubscriptions[msg.value.content.channel] = 1
176 + else
177 + delete channelSubscriptions[msg.value.content.channel]
178 + }
179 + })
180 +
181 + serveFeeds(req, res, following, channelSubscriptions, feedId,
182182 'user feed ' + (about ? about.name : ""))
183- })
183 + })
184184 )
185185 })
186186 }
187187
@@ -194,29 +194,29 @@
194194
195195 pull(
196196 sbot.createLogStream({ reverse: true, limit: 5000 }),
197197 pull.filter((msg) => {
198- return !msg.value ||
199- (msg.value.author in following ||
200- msg.value.content.channel in channelSubscriptions)
198 + return !msg.value ||
199 + (msg.value.author in following ||
200 + msg.value.content.channel in channelSubscriptions)
201201 }),
202202 pull.take(150),
203203 pull.collect(function (err, logs) {
204- if (err) return respond(res, 500, err.stack || err)
205- res.writeHead(200, {
206- 'Content-Type': ctype("html")
207- })
208- pull(
209- pull.values(logs),
210- paramap(addAuthorAbout, 8),
211- paramap(addFollowAbout, 8),
212- paramap(addVoteMessage, 8),
213- paramap(addGitLinks, 8),
214- pull(renderThread(feedOpts), wrapPage(name)),
215- toPull(res, function (err) {
216- if (err) console.error('[viewer]', err)
217- })
218- )
204 + if (err) return respond(res, 500, err.stack || err)
205 + res.writeHead(200, {
206 + 'Content-Type': ctype("html")
207 + })
208 + pull(
209 + pull.values(logs),
210 + paramap(addAuthorAbout, 8),
211 + paramap(addFollowAbout, 8),
212 + paramap(addVoteMessage, 8),
213 + paramap(addGitLinks, 8),
214 + pull(renderThread(feedOpts), wrapPage(name)),
215 + toPull(res, function (err) {
216 + if (err) console.error('[viewer]', err)
217 + })
218 + )
219219 })
220220 )
221221 }
222222
@@ -228,23 +228,23 @@
228228
229229 pull(
230230 sbot.query.read({ limit: showAll ? 300 : 10, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
231231 pull.collect(function (err, logs) {
232- if (err) return respond(res, 500, err.stack || err)
233- res.writeHead(200, {
234- 'Content-Type': ctype("html")
235- })
236- pull(
237- pull.values(logs),
238- paramap(addAuthorAbout, 8),
239- paramap(addVoteMessage, 8),
240- pull(renderThread(defaultOpts, '',
241- renderShowAll(showAll, req.url)),
242- wrapPage('#' + channelId)),
243- toPull(res, function (err) {
244- if (err) console.error('[viewer]', err)
245- })
246- )
232 + if (err) return respond(res, 500, err.stack || err)
233 + res.writeHead(200, {
234 + 'Content-Type': ctype("html")
235 + })
236 + pull(
237 + pull.values(logs),
238 + paramap(addAuthorAbout, 8),
239 + paramap(addVoteMessage, 8),
240 + pull(renderThread(defaultOpts, '',
241 + renderShowAll(showAll, req.url)),
242 + wrapPage('#' + channelId)),
243 + toPull(res, function (err) {
244 + if (err) console.error('[viewer]', err)
245 + })
246 + )
247247 })
248248 )
249249 }
250250
@@ -317,22 +317,22 @@
317317
318318 function addFollowAbout(msg, cb) {
319319 if (msg.value.content.contact)
320320 getAbout(msg.value.content.contact, function (err, about) {
321- if (err) return cb(err)
322- msg.value.content.contactAbout = about
323- cb(null, msg)
321 + if (err) return cb(err)
322 + msg.value.content.contactAbout = about
323 + cb(null, msg)
324324 })
325325 else
326326 cb(null, msg)
327327 }
328328
329329 function addVoteMessage(msg, cb) {
330330 if (msg.value.content.type == 'vote' && msg.value.content.vote.link[0] == '%')
331331 getMsg(msg.value.content.vote.link, function (err, linkedMsg) {
332- if (linkedMsg)
333- msg.value.content.vote.linkedText = linkedMsg.value.content.text
334- cb(null, msg)
332 + if (linkedMsg)
333 + msg.value.content.vote.linkedText = linkedMsg.value.content.text
334 + cb(null, msg)
335335 })
336336 else
337337 cb(null, msg)
338338 }
@@ -347,17 +347,17 @@
347347
348348 function addGitLinks(msg, cb) {
349349 if (msg.value.content.type == 'git-update')
350350 getMsg(msg.value.content.repo, function (err, gitRepo) {
351- if (gitRepo)
352- msg.value.content.repoName = gitRepo.value.content.name
353- cb(null, msg)
351 + if (gitRepo)
352 + msg.value.content.repoName = gitRepo.value.content.name
353 + cb(null, msg)
354354 })
355355 else if (msg.value.content.type == 'issue')
356356 getMsg(msg.value.content.project, function (err, gitRepo) {
357- if (gitRepo)
358- msg.value.content.repoName = gitRepo.value.content.name
359- cb(null, msg)
357 + if (gitRepo)
358 + msg.value.content.repoName = gitRepo.value.content.name
359 + cb(null, msg)
360360 })
361361 else
362362 cb(null, msg)
363363 }
@@ -443,25 +443,21 @@
443443 fs.createReadStream(file).pipe(res)
444444 })
445445 }
446446
447-//function prepend(fn, arg) {
448-// return function (read) {
449-// return function (abort, cb) {
450-// if (fn && !abort) {
451-// var _fn = fn
452-// fn = null
453-// return _fn(arg, function (err, value) {
454-// if (err) return read(err, function (err) {
455-// cb(err || true)
456-// })
457-// cb(null, value)
458-// })
459-// }
460-// read(abort, cb)
461-// }
462-// }
463-//}
464-
465-
466-
467-
447 +function prepend(fn, arg) {
448 + return function (read) {
449 + return function (abort, cb) {
450 + if (fn && !abort) {
451 + var _fn = fn
452 + fn = null
453 + return _fn(arg, function (err, value) {
454 + if (err) return read(err, function (err) {
455 + cb(err || true)
456 + })
457 + cb(null, value)
458 + })
459 + }
460 + read(abort, cb)
461 + }
462 + }
463 +}

Built with git-ssb-web