git ssb

9+

cel / ssb-viewer



Commit 77471357a47c8057251ef438e025a95428a78eb8

Render blog posts and minor fix to vote messages

Anders Rune Jensen committed on 2/20/2018, 9:27:36 PM
Parent: 4370a22cdd69c8e422d8f56bd0673ffca8de29ba

Files changed

index.jschanged
render.jschanged
index.jsView
@@ -115,8 +115,9 @@
115115 })
116116 pull(
117117 pull.values(logs),
118118 paramap(addAuthorAbout, 8),
119 + paramap(addBlog, 8),
119120 paramap(addFollowAbout, 8),
120121 paramap(addVoteMessage, 8),
121122 paramap(addGitLinks, 8),
122123 render(),
@@ -200,8 +201,9 @@
200201 })
201202 pull(
202203 pull.values(logs),
203204 paramap(addAuthorAbout, 8),
205 + paramap(addBlog, 8),
204206 paramap(addFollowAbout, 8),
205207 paramap(addVoteMessage, 8),
206208 paramap(addGitLinks, 8),
207209 pull(renderThread(feedOpts), wrapPage(name)),
@@ -230,8 +232,9 @@
230232 })
231233 pull(
232234 pull.values(logs),
233235 paramap(addAuthorAbout, 8),
236 + paramap(addBlog, 8),
234237 paramap(addVoteMessage, 8),
235238 pull(renderThread(defaultOpts, '', renderShowAll(req.url)),
236239 wrapPage('#' + channelId)),
237240 toPull(res, function (err) {
@@ -293,8 +296,9 @@
293296 })
294297 pull(
295298 pull.values(sort(links)),
296299 paramap(addAuthorAbout, 8),
300 + paramap(addBlog, 8),
297301 format,
298302 toPull(res, function (err) {
299303 if (err) console.error('[viewer]', err)
300304 })
@@ -315,9 +319,9 @@
315319 cb(null, msg)
316320 }
317321
318322 function addVoteMessage(msg, cb) {
319- if (msg.value.content.type == 'vote' && msg.value.content.vote.link[0] == '%')
323 + if (msg.value.content.type == 'vote' && msg.value.content.vote && msg.value.content.vote.link[0] == '%')
320324 getMsg(msg.value.content.vote.link, function (err, linkedMsg) {
321325 if (linkedMsg)
322326 msg.value.content.vote.linkedText = linkedMsg.value.content.text
323327 cb(null, msg)
@@ -325,8 +329,21 @@
325329 else
326330 cb(null, msg)
327331 }
328332
333 + function addBlog(msg, cb) {
334 + if (msg.value && msg.value.content.type == "blog") {
335 + pull(
336 + sbot.blobs.get(msg.value.content.blog),
337 + pull.collect(function(err, blob) {
338 + msg.value.content.blogContent = blob
339 + cb(null, msg)
340 + })
341 + )
342 + } else
343 + cb(null, msg)
344 + }
345 +
329346 function addAuthorAbout(msg, cb) {
330347 getAbout(msg.value.author, function (err, about) {
331348 if (err) return cb(err)
332349 msg.author = about
render.jsView
@@ -508,8 +508,22 @@
508508 'Unsubscribed from channel ',
509509 h('a',
510510 { href: base + 'channel/' + c.channel },
511511 '#' + c.channel))
512 + else if (c.type == "blog") {
513 + //%RTXvyZ2fZWwTyWdlk0lYGk5sKw5Irj+Wk4QwxyOVG5g=.sha256
514 + var channel = c.channel
515 + ? h('div.top-right',
516 + h('a',
517 + { href: base + 'channel/' + c.channel },
518 + '#' + c.channel))
519 + : "";
520 +
521 + var s = h('section');
522 + s.innerHTML = marked(String(c.blogContent), opts.marked)
523 +
524 + return [channel, h('h2', c.title), s];
525 + }
512526 else return renderDefault(c);
513527 }
514528
515529 function renderPost(opts, id, c) {

Built with git-ssb-web