var u = require('yap-util') module.exports = function (apply, gathering, context) { var attending = {} gathering.value.attendee.forEach(function (attendee) { if(attendee.link) attending[attendee.link] = true if(attendee.remove) delete attending[attendee.link] }) var gth = gathering.value var start = gth.startDateTime && gth.startDateTime//.epoch var epoch = start && start.epoch var tz = start && start.tz // console.log("START", gth.startDateTime) return ['div.Gathering', apply('avatar', {id: gathering.creator, name: true, image: true}),' ', ['h1', ['a', {href: apply.toUrl('gatherings/event', {id:gathering.root, replies: true})}, gth.title ], tz && '(tz: '+tz+')' ], ['h2', {title: tz}, new Date(epoch).toString()], u.markdown({text:gth.description, mentions: gth.mentions}), gathering.value.image ? ['img', {href: 'http://localhost:8989/blobs/get/'+encodeURIComponent(gathering.value.image.link)}] : '', ['div.Attending', 'attending:', Object.keys(attending).map(function (id) { return apply('avatar', id) }) ], context.forms !== false && apply('publish', { id: context.id, name: attending[context.id] ? "can't attend" : "attend", content: { type: 'about', about: gathering.root, root: gathering.root, branch: gathering.branch, attendee: { link: context.id, remove: attending[context.id] ? true : undefined }, } }), gathering.replies.length && ['div.Replies', gathering.replies.map(function (reply) { return apply('messages/post', reply) }), context.forms !== false && apply('compose', { content: { type: 'post', root: gathering.root, // recps: recps, branch: gathering.branch, //channel: ary[0].value.content.channel } }) ] ] }