Merge pull request #7 from Powersource/render-gatherings
Render gatherings
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
package-lock.json
|
||||
@@ -137,6 +137,7 @@ exports.init = function (sbot, config) {
|
||||
paramap(addFollowAbout, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
paramap(addGitLinks, 8),
|
||||
paramap(addGatheringAbout, 8),
|
||||
render(),
|
||||
toPull(res, function (err) {
|
||||
if (err) console.error('[viewer]', err)
|
||||
@@ -242,6 +243,7 @@ exports.init = function (sbot, config) {
|
||||
paramap(addFollowAbout, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
paramap(addGitLinks, 8),
|
||||
paramap(addGatheringAbout, 8),
|
||||
pull(renderThread(feedOpts), wrapPage(name)),
|
||||
toPull(res, function (err) {
|
||||
if (err) console.error('[viewer]', err)
|
||||
@@ -268,7 +270,8 @@ exports.init = function (sbot, config) {
|
||||
pull.values(logs),
|
||||
paramap(addAuthorAbout, 8),
|
||||
paramap(addBlog, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
paramap(addGatheringAbout, 8),
|
||||
pull(renderThread(defaultOpts, '', renderShowAll(showAll, req.url)),
|
||||
wrapPage('#' + channelId)),
|
||||
toPull(res, function (err) {
|
||||
@@ -324,6 +327,7 @@ exports.init = function (sbot, config) {
|
||||
pull.values(sort(links)),
|
||||
paramap(addAuthorAbout, 8),
|
||||
paramap(addBlog, 8),
|
||||
paramap(addGatheringAbout, 8),
|
||||
format,
|
||||
toPull(res, function (err) {
|
||||
if (err) console.error('[viewer]', err)
|
||||
@@ -392,6 +396,40 @@ exports.init = function (sbot, config) {
|
||||
})
|
||||
}
|
||||
|
||||
function addGatheringAbout(msg, cb) {
|
||||
if (msg.value && msg.value.content.type === 'gathering') {
|
||||
getAbout(msg.key, (err, about) => {
|
||||
if (err) { cb(err) }
|
||||
|
||||
msg.value.content.about = about
|
||||
|
||||
pull(
|
||||
sbot.backlinks.read({
|
||||
query: [{ $filter: {
|
||||
dest: msg.key,
|
||||
value: { content: { type: 'about' }},
|
||||
}}],
|
||||
index: 'DTA'
|
||||
}),
|
||||
// Only grab messages about attendance
|
||||
pull.filter(o => o.value.content.attendee !== undefined),
|
||||
// Filter "can't attend"-messages
|
||||
pull.filter(o => !o.value.content.attendee.remove),
|
||||
pull.unique(o => o.value.content.attendee.link),
|
||||
pull.collect((err, arr) => {
|
||||
if (err) { cb(err) }
|
||||
|
||||
msg.value.content.numberAttending = arr.length
|
||||
|
||||
cb(null, msg)
|
||||
})
|
||||
)
|
||||
})
|
||||
} else {
|
||||
cb(null, msg)
|
||||
}
|
||||
}
|
||||
|
||||
function addGitLinks(msg, cb) {
|
||||
if (msg.value.content.type == 'git-update')
|
||||
getMsg(msg.value.content.repo, function (err, gitRepo) {
|
||||
|
||||
@@ -29,6 +29,8 @@ module.exports = function (sbot, id, cb) {
|
||||
if (typeof c.name == 'string') feedAbout.name = c.name.replace(/^@?/, '@')
|
||||
if (c.image) feedAbout.image = linkDest(c.image)
|
||||
if (c.description) feedAbout.description = c.description
|
||||
if (c.title) feedAbout.title = c.title
|
||||
if (c.startDateTime) feedAbout.startDateTime = c.startDateTime
|
||||
if (c.publicWebHosting != null && author === c.about) feedAbout.publicWebHosting = defalsify(c.publicWebHosting)
|
||||
}, function (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
@@ -296,6 +296,9 @@ var styles = `
|
||||
background-color: #748ffc;
|
||||
border-bottom: 3px solid #4c6ef5;
|
||||
}
|
||||
.attending {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
`;
|
||||
|
||||
@@ -523,9 +526,28 @@ function render(opts, id, c) {
|
||||
|
||||
return [channel, h('h2', c.title), s];
|
||||
}
|
||||
else if (c.type === 'gathering') {
|
||||
return h('div', renderGathering(opts, id, c))
|
||||
}
|
||||
else return renderDefault(c);
|
||||
}
|
||||
|
||||
function renderGathering(opts, id, c) {
|
||||
const title = h('h2', c.about.title)
|
||||
const time = h('h3', new Date(c.about.startDateTime.epoch).toUTCString())
|
||||
const image = h('p', h('img', { src: opts.img_base + c.about.image }))
|
||||
const attending = h('h3.attending', c.numberAttending + ' attending')
|
||||
const desc = h('div')
|
||||
desc.innerHTML = marked(c.about.description, opts.marked)
|
||||
return h('section',
|
||||
[title,
|
||||
time,
|
||||
image,
|
||||
attending,
|
||||
desc]
|
||||
)
|
||||
}
|
||||
|
||||
function renderPost(opts, id, c) {
|
||||
opts.mentions = {};
|
||||
if (Array.isArray(c.mentions)) {
|
||||
|
||||
Reference in New Issue
Block a user