Files: 7672098be439d5c9a07c4bbc2bd066d84993695f / render.js
1669 bytesRaw
1 | var u = require('yap-util') |
2 | |
3 | module.exports = function (apply, gathering, context) { |
4 | var attending = {} |
5 | gathering.value.attendee.forEach(function (attendee) { |
6 | if(attendee.link) attending[attendee.link] = true |
7 | if(attendee.remove) delete attending[attendee.link] |
8 | }) |
9 | var gth = gathering.value |
10 | var start = gth.startDateTime && gth.startDateTime//.epoch |
11 | var epoch = start && start.epoch |
12 | var tz = start && start.tz |
13 | return ['div.GatheringContent', |
14 | ['h2', {title: tz}, new Date(epoch).toString()], |
15 | u.markdown({text:gth.description, mentions: gth.mentions}), |
16 | gathering.value.image |
17 | && ['img', {href: 'http://localhost:8989/blobs/get/'+encodeURIComponent(gathering.value.image.link)}], |
18 | ['div.Attending', |
19 | 'attending:', |
20 | Object.keys(attending).map(function (id) { |
21 | return apply('avatar', id) |
22 | }) |
23 | ], |
24 | context.forms !== false && |
25 | apply('publish', { |
26 | id: context.id, |
27 | name: attending[context.id] ? "can't attend" : "attend", |
28 | content: { |
29 | type: 'about', |
30 | about: gathering.root, |
31 | root: gathering.root, |
32 | branch: gathering.branch, |
33 | attendee: { |
34 | link: context.id, |
35 | remove: attending[context.id] ? true : undefined |
36 | }, |
37 | } |
38 | }), |
39 | gathering.replies.length && |
40 | ['div.Replies', |
41 | gathering.replies.map(function (reply) { |
42 | return apply('messages/post', reply) |
43 | }), |
44 | context.forms !== false && apply('compose', { |
45 | content: { |
46 | type: 'post', |
47 | root: gathering.root, |
48 | branch: gathering.branch, |
49 | } |
50 | }) |
51 | ] |
52 | ] |
53 | } |
54 |
Built with git-ssb-web