Render gathering descriptions

This commit is contained in:
Jacob Karlsson
2018-07-02 19:52:17 +02:00
parent 857dc63ce5
commit cecdc93fd3
2 changed files with 36 additions and 1 deletions
+19
View File
@@ -137,6 +137,7 @@ exports.init = function (sbot, config) {
paramap(addFollowAbout, 8), paramap(addFollowAbout, 8),
paramap(addVoteMessage, 8), paramap(addVoteMessage, 8),
paramap(addGitLinks, 8), paramap(addGitLinks, 8),
paramap(addGatheringAbout, 8),
render(), render(),
toPull(res, function (err) { toPull(res, function (err) {
if (err) console.error('[viewer]', err) if (err) console.error('[viewer]', err)
@@ -242,6 +243,7 @@ exports.init = function (sbot, config) {
paramap(addFollowAbout, 8), paramap(addFollowAbout, 8),
paramap(addVoteMessage, 8), paramap(addVoteMessage, 8),
paramap(addGitLinks, 8), paramap(addGitLinks, 8),
paramap(addGatheringAbout, 8),
pull(renderThread(feedOpts), wrapPage(name)), pull(renderThread(feedOpts), wrapPage(name)),
toPull(res, function (err) { toPull(res, function (err) {
if (err) console.error('[viewer]', err) if (err) console.error('[viewer]', err)
@@ -269,6 +271,7 @@ exports.init = function (sbot, config) {
paramap(addAuthorAbout, 8), paramap(addAuthorAbout, 8),
paramap(addBlog, 8), paramap(addBlog, 8),
paramap(addVoteMessage, 8), paramap(addVoteMessage, 8),
paramap(addGatheringAbout, 8),
pull(renderThread(defaultOpts, '', renderShowAll(showAll, req.url)), pull(renderThread(defaultOpts, '', renderShowAll(showAll, req.url)),
wrapPage('#' + channelId)), wrapPage('#' + channelId)),
toPull(res, function (err) { toPull(res, function (err) {
@@ -324,6 +327,7 @@ exports.init = function (sbot, config) {
pull.values(sort(links)), pull.values(sort(links)),
paramap(addAuthorAbout, 8), paramap(addAuthorAbout, 8),
paramap(addBlog, 8), paramap(addBlog, 8),
paramap(addGatheringAbout, 8),
format, format,
toPull(res, function (err) { toPull(res, function (err) {
if (err) console.error('[viewer]', err) if (err) console.error('[viewer]', err)
@@ -392,6 +396,21 @@ exports.init = function (sbot, config) {
}) })
} }
function addGatheringAbout(msg, cb) {
if (msg.value && msg.value.content.type === 'gathering') {
console.log('adding gathering abouts. msg:', msg)
getAbout(msg.key, (err, about) => {
if (err) { return cb(err) }
msg.value.content.about = about
console.log('about gathering', about)
cb(null, msg)
})
} else {
cb(null, msg)
}
}
function addGitLinks(msg, cb) { function addGitLinks(msg, cb) {
if (msg.value.content.type == 'git-update') if (msg.value.content.type == 'git-update')
getMsg(msg.value.content.repo, function (err, gitRepo) { getMsg(msg.value.content.repo, function (err, gitRepo) {
+16
View File
@@ -523,9 +523,25 @@ function render(opts, id, c) {
return [channel, h('h2', c.title), s]; return [channel, h('h2', c.title), s];
} }
else if (c.type === 'gathering') {
console.log('opts', opts)
console.log('c', c)
return ['id: ' + id,
h('div',
['this is a gathering boopadoop',
renderGathering(opts, id, c)]
)
]
}
else return renderDefault(c); else return renderDefault(c);
} }
function renderGathering(opts, id, c) {
console.log('gathering content:', c)
return h('div', c.about.description)
}
function renderPost(opts, id, c) { function renderPost(opts, id, c) {
opts.mentions = {}; opts.mentions = {};
if (Array.isArray(c.mentions)) { if (Array.isArray(c.mentions)) {