git ssb

9+

cel / ssb-viewer



Commit 1b057d84aa726cdc9404a6340cb96c8825329242

More refactor

Anders Rune Jensen committed on 5/11/2017, 7:49:44 PM
Parent: 4f7d162bf1625d6dc4e8e518f55ee5d842d12bc2

Files changed

index.jschanged
index.jsView
@@ -91,10 +91,8 @@
9191
9292 function serveFeed(req, res, feedId) {
9393 console.log("serving feed: " + feedId)
9494
95- var opts = defaultOpts
96-
9795 getAbout(feedId, function (err, about) {
9896 if (err) return cb(err)
9997
10098 pull(
@@ -108,9 +106,9 @@
108106 pull.values(logs),
109107 paramap(addAuthorAbout, 8),
110108 paramap(addFollowAbout, 8),
111109 paramap(addVoteMessage, 8),
112- pull(renderThread(opts), wrapPage(about.name)),
110 + pull(renderThread(defaultOpts), wrapPage(about.name)),
113111 toPull(res, function (err) {
114112 if (err) console.error('[viewer]', err)
115113 })
116114 )
@@ -159,10 +157,8 @@
159157 })
160158 }
161159
162160 function serveFeeds(req, res, following, channelSubscriptions, feedId, name) {
163- var opts = defaultOpts
164-
165161 pull(
166162 sbot.createLogStream({ reverse: true, limit: 2500 }),
167163 pull.filter((msg) => {
168164 return !msg.value ||
@@ -179,9 +175,9 @@
179175 pull.values(logs),
180176 paramap(addAuthorAbout, 8),
181177 paramap(addFollowAbout, 8),
182178 paramap(addVoteMessage, 8),
183- pull(renderThread(opts), wrapPage(name)),
179 + pull(renderThread(defaultOpts), wrapPage(name)),
184180 toPull(res, function (err) {
185181 if (err) console.error('[viewer]', err)
186182 })
187183 )
@@ -191,10 +187,8 @@
191187
192188 function serveChannel(req, res, url) {
193189 var channelId = url.substring(url.lastIndexOf('channel/')+8, 100)
194190 console.log("serving channel: " + channelId)
195-
196- var opts = defaultOpts
197191
198192 pull(
199193 sbot.query.read({ limit: 500, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
200194 pull.collect(function (err, logs) {
@@ -205,39 +199,17 @@
205199 pull(
206200 pull.values(logs),
207201 paramap(addAuthorAbout, 8),
208202 paramap(addVoteMessage, 8),
209- pull(renderThread(opts), wrapPage('#' + channelId)),
203 + pull(renderThread(defaultOpts), wrapPage('#' + channelId)),
210204 toPull(res, function (err) {
211205 if (err) console.error('[viewer]', err)
212206 })
213207 )
214208 })
215209 )
216210 }
217211
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-
240212 function serveId(req, res, id, ext, query) {
241213 var q = query ? qs.parse(query) : {}
242214 var includeRoot = !('noroot' in q)
243215 var base = q.base || conf.base
@@ -294,8 +266,30 @@
294266 })
295267 )
296268 }
297269
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 +
298292 function addAuthorAbout(msg, cb) {
299293 getAbout(msg.value.author, function (err, about) {
300294 if (err) return cb(err)
301295 msg.author = about

Built with git-ssb-web