Render blog posts
This commit is contained in:
@@ -133,6 +133,7 @@ exports.init = function (sbot, config) {
|
|||||||
pull(
|
pull(
|
||||||
pull.values(logs),
|
pull.values(logs),
|
||||||
paramap(addAuthorAbout, 8),
|
paramap(addAuthorAbout, 8),
|
||||||
|
paramap(addBlog, 8),
|
||||||
paramap(addFollowAbout, 8),
|
paramap(addFollowAbout, 8),
|
||||||
paramap(addVoteMessage, 8),
|
paramap(addVoteMessage, 8),
|
||||||
paramap(addGitLinks, 8),
|
paramap(addGitLinks, 8),
|
||||||
@@ -232,6 +233,7 @@ exports.init = function (sbot, config) {
|
|||||||
pull(
|
pull(
|
||||||
pull.values(logs),
|
pull.values(logs),
|
||||||
paramap(addAuthorAbout, 8),
|
paramap(addAuthorAbout, 8),
|
||||||
|
paramap(addBlog, 8),
|
||||||
paramap(addFollowAbout, 8),
|
paramap(addFollowAbout, 8),
|
||||||
paramap(addVoteMessage, 8),
|
paramap(addVoteMessage, 8),
|
||||||
paramap(addGitLinks, 8),
|
paramap(addGitLinks, 8),
|
||||||
@@ -260,9 +262,9 @@ exports.init = function (sbot, config) {
|
|||||||
pull(
|
pull(
|
||||||
pull.values(logs),
|
pull.values(logs),
|
||||||
paramap(addAuthorAbout, 8),
|
paramap(addAuthorAbout, 8),
|
||||||
|
paramap(addBlog, 8),
|
||||||
paramap(addVoteMessage, 8),
|
paramap(addVoteMessage, 8),
|
||||||
pull(renderThread(defaultOpts, '',
|
pull(renderThread(defaultOpts, '', renderShowAll(showAll, req.url)),
|
||||||
renderShowAll(showAll, req.url)),
|
|
||||||
wrapPage('#' + channelId)),
|
wrapPage('#' + channelId)),
|
||||||
toPull(res, function (err) {
|
toPull(res, function (err) {
|
||||||
if (err) console.error('[viewer]', err)
|
if (err) console.error('[viewer]', err)
|
||||||
@@ -316,6 +318,7 @@ exports.init = function (sbot, config) {
|
|||||||
pull(
|
pull(
|
||||||
pull.values(sort(links)),
|
pull.values(sort(links)),
|
||||||
paramap(addAuthorAbout, 8),
|
paramap(addAuthorAbout, 8),
|
||||||
|
paramap(addBlog, 8),
|
||||||
format,
|
format,
|
||||||
toPull(res, function (err) {
|
toPull(res, function (err) {
|
||||||
if (err) console.error('[viewer]', err)
|
if (err) console.error('[viewer]', err)
|
||||||
@@ -363,6 +366,19 @@ exports.init = function (sbot, config) {
|
|||||||
cb(null, msg)
|
cb(null, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addBlog(msg, cb) {
|
||||||
|
if (msg.value && msg.value.content.type == "blog") {
|
||||||
|
pull(
|
||||||
|
sbot.blobs.get(msg.value.content.blog),
|
||||||
|
pull.collect(function(err, blob) {
|
||||||
|
msg.value.content.blogContent = blob
|
||||||
|
cb(null, msg)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
} else
|
||||||
|
cb(null, msg)
|
||||||
|
}
|
||||||
|
|
||||||
function addAuthorAbout(msg, cb) {
|
function addAuthorAbout(msg, cb) {
|
||||||
getAbout(msg.value.author, function (err, about) {
|
getAbout(msg.value.author, function (err, about) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|||||||
@@ -504,6 +504,20 @@ function render(opts, id, c) {
|
|||||||
h('a',
|
h('a',
|
||||||
{ href: base + 'channel/' + c.channel },
|
{ href: base + 'channel/' + c.channel },
|
||||||
'#' + c.channel))
|
'#' + c.channel))
|
||||||
|
else if (c.type == "blog") {
|
||||||
|
//%RTXvyZ2fZWwTyWdlk0lYGk5sKw5Irj+Wk4QwxyOVG5g=.sha256
|
||||||
|
var channel = c.channel
|
||||||
|
? h('div.top-right',
|
||||||
|
h('a',
|
||||||
|
{ href: base + 'channel/' + c.channel },
|
||||||
|
'#' + c.channel))
|
||||||
|
: "";
|
||||||
|
|
||||||
|
var s = h('section');
|
||||||
|
s.innerHTML = marked(String(c.blogContent), opts.marked)
|
||||||
|
|
||||||
|
return [channel, h('h2', c.title), s];
|
||||||
|
}
|
||||||
else return renderDefault(c);
|
else return renderDefault(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user