git ssb

9+

cel / ssb-viewer



Commit e525414d1f2edc4363b7e94b7b4da1252e853026

Render blog posts

Anders Rune Jensen committed on 4/25/2018, 1:57:30 PM
Parent: 1eb1be440d662e83405d844c8ae88402c56c92a6

Files changed

index.jschanged
render.jschanged
index.jsView
@@ -132,8 +132,9 @@
132132 })
133133 pull(
134134 pull.values(logs),
135135 paramap(addAuthorAbout, 8),
136 + paramap(addBlog, 8),
136137 paramap(addFollowAbout, 8),
137138 paramap(addVoteMessage, 8),
138139 paramap(addGitLinks, 8),
139140 render(),
@@ -231,8 +232,9 @@
231232 })
232233 pull(
233234 pull.values(logs),
234235 paramap(addAuthorAbout, 8),
236 + paramap(addBlog, 8),
235237 paramap(addFollowAbout, 8),
236238 paramap(addVoteMessage, 8),
237239 paramap(addGitLinks, 8),
238240 pull(renderThread(feedOpts), wrapPage(name)),
@@ -259,11 +261,11 @@
259261 })
260262 pull(
261263 pull.values(logs),
262264 paramap(addAuthorAbout, 8),
265 + paramap(addBlog, 8),
263266 paramap(addVoteMessage, 8),
264- pull(renderThread(defaultOpts, '',
265- renderShowAll(showAll, req.url)),
267 + pull(renderThread(defaultOpts, '', renderShowAll(showAll, req.url)),
266268 wrapPage('#' + channelId)),
267269 toPull(res, function (err) {
268270 if (err) console.error('[viewer]', err)
269271 })
@@ -315,8 +317,9 @@
315317 })
316318 pull(
317319 pull.values(sort(links)),
318320 paramap(addAuthorAbout, 8),
321 + paramap(addBlog, 8),
319322 format,
320323 toPull(res, function (err) {
321324 if (err) console.error('[viewer]', err)
322325 })
@@ -362,8 +365,21 @@
362365 else
363366 cb(null, msg)
364367 }
365368
369 + function addBlog(msg, cb) {
370 + if (msg.value && msg.value.content.type == "blog") {
371 + pull(
372 + sbot.blobs.get(msg.value.content.blog),
373 + pull.collect(function(err, blob) {
374 + msg.value.content.blogContent = blob
375 + cb(null, msg)
376 + })
377 + )
378 + } else
379 + cb(null, msg)
380 + }
381 +
366382 function addAuthorAbout(msg, cb) {
367383 getAbout(msg.value.author, function (err, about) {
368384 if (err) return cb(err)
369385 msg.author = about
render.jsView
@@ -503,8 +503,22 @@
503503 'Unsubscribed from channel ',
504504 h('a',
505505 { href: base + 'channel/' + c.channel },
506506 '#' + c.channel))
507 + else if (c.type == "blog") {
508 + //%RTXvyZ2fZWwTyWdlk0lYGk5sKw5Irj+Wk4QwxyOVG5g=.sha256
509 + var channel = c.channel
510 + ? h('div.top-right',
511 + h('a',
512 + { href: base + 'channel/' + c.channel },
513 + '#' + c.channel))
514 + : "";
515 +
516 + var s = h('section');
517 + s.innerHTML = marked(String(c.blogContent), opts.marked)
518 +
519 + return [channel, h('h2', c.title), s];
520 + }
507521 else return renderDefault(c);
508522 }
509523
510524 function renderPost(opts, id, c) {

Built with git-ssb-web