git ssb

0+

Dominic / yap-gatherings



Tree: 98fd28641650bead5543428cdffb2bc932dbb165

Files: 98fd28641650bead5543428cdffb2bc932dbb165 / index.js

1832 bytesRaw
1var Get = require('./get')
2var paramap = require('pull-paramap')
3var pull = require('pull-stream')
4var u = require('yap-util')
5var Render = require('./render')
6
7module.exports = function (sbot) {
8 return function (use) {
9 use('event', function (opts, apply, req) {
10 var context = Object.assign({}, req.cookies, {id: sbot.id, forms: opts.embed !== true})
11// opts.id = opts.id || "%eFzw9Qca1MUppBgyGG0e2AwzlwonvwDk2GDyxM9B37c=.sha256"
12 return function (cb) {
13 Get(sbot, opts, function (err, gathering) {
14 if(err) cb(err)
15 else cb(null, Render(apply, gathering, context))
16 })
17 }
18 })
19
20 use('about', u.createRenderer(function (data, apply) {
21 console.log('RENDER ABOUT', data)
22 return ['div.Message',
23 //currently, a vote message has no need for a cache tag.
24 //unless we decide to show other peers that have liked this.
25 //u.cacheTag(toUrl('message', {id: data.key}), data.key, ),
26 ['h3', apply('avatar', {id: data.value.content.attendee.link}), data.value.content.attendee.remove ? 'is not attending' : 'is attending'],
27 ['div.EmbeddedMessage',
28 apply('gatherings/event', {id: data.value.content.about, embed: true}),
29 ]
30 ]
31 })(sbot))
32
33
34 use('all', function (opts, apply, req) {
35 console.log(opts)
36 return pull(
37 sbot.query.read(u.createQuery(Object.assign({ type: 'gathering'}, opts))),
38// sbot.messagesByType({
39// type: 'gathering',
40// limit: 10,
41// reverse: true
42// }),
43 pull.map(function (e) {
44 return apply('gatherings/event', {id: e.key, private: true})
45 })
46 )
47 })
48
49 use.map('messages', 'gathering', 'event')
50 use.map('messages', 'about', 'about')
51
52// use.list('
53 }
54}
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

Built with git-ssb-web