git ssb

0+

Dominic / yap-gatherings



Commit 7672098be439d5c9a07c4bbc2bd066d84993695f

rewrite to use messageLayout

Dominic Tarr committed on 7/5/2019, 2:10:17 PM
Parent: 98fd28641650bead5543428cdffb2bc932dbb165

Files changed

get.jschanged
index.jschanged
render.jschanged
get.jsView
@@ -12,9 +12,8 @@
1212 if(msg.content.type !== 'gathering')
1313 return cb(new Error('not a gathering, was:'+msg.content.type))
1414 var root = {key:id, value: msg}
1515 seen[id] = true
16- console.log('gathering', opts)
1716 pull(
1817 sbot.links({
1918 dest: id, values: true,
2019 rel: opts.replies ? undefined : 'about'
@@ -40,8 +39,4 @@
4039 })
4140 )
4241 })
4342 }
44-
45-
46-
47-
index.jsView
@@ -6,20 +6,27 @@
66
77 module.exports = function (sbot) {
88 return function (use) {
99 use('event', function (opts, apply, req) {
10 + if(!opts.id) opts.id = opts.key
1011 var context = Object.assign({}, req.cookies, {id: sbot.id, forms: opts.embed !== true})
11-// opts.id = opts.id || "%eFzw9Qca1MUppBgyGG0e2AwzlwonvwDk2GDyxM9B37c=.sha256"
1212 return function (cb) {
1313 Get(sbot, opts, function (err, gathering) {
1414 if(err) cb(err)
15- else cb(null, Render(apply, gathering, context))
15 + else cb(null, apply('messageLayout', {
16 + id: gathering.root,
17 + author: gathering.creator,
18 + ts: gathering.created,
19 + content: Render(apply, gathering, context),
20 + meta: !opts.embed ?
21 + ['a', {href: u.toUrl('gatherings/event', {id: gathering.root})}, 'Event']
22 + : []
23 + }))
1624 })
1725 }
1826 })
1927
2028 use('about', u.createRenderer(function (data, apply) {
21- console.log('RENDER ABOUT', data)
2229 return ['div.Message',
2330 //currently, a vote message has no need for a cache tag.
2431 //unless we decide to show other peers that have liked this.
2532 //u.cacheTag(toUrl('message', {id: data.key}), data.key, ),
@@ -31,38 +38,20 @@
3138 })(sbot))
3239
3340
3441 use('all', function (opts, apply, req) {
35- console.log(opts)
3642 return pull(
3743 sbot.query.read(u.createQuery(Object.assign({ type: 'gathering'}, opts))),
38-// sbot.messagesByType({
39-// type: 'gathering',
40-// limit: 10,
41-// reverse: true
42-// }),
4344 pull.map(function (e) {
4445 return apply('gatherings/event', {id: e.key, private: true})
4546 })
4647 )
4748 })
4849
4950 use.map('messages', 'gathering', 'event')
5051 use.map('messages', 'about', 'about')
51-
52-// use.list('
52 + use('menu', function (opts, apply, req) {
53 + return ['a', {href: '/gatherings/all'}, 'Gatherings']
54 + })
55 + use.list('menu', 'menu')
5356 }
5457 }
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
render.jsView
@@ -9,67 +9,45 @@
99 var gth = gathering.value
1010 var start = gth.startDateTime && gth.startDateTime//.epoch
1111 var epoch = start && start.epoch
1212 var tz = start && start.tz
13-// console.log("START", gth.startDateTime)
14- return ['div.Gathering',
15- apply('avatar', {id: gathering.creator, name: true, image: true}),' ',
16- ['h1',
17- ['a',
18- {href: apply.toUrl('gatherings/event', {id:gathering.root, replies: true})},
19- gth.title
20- ],
21- tz && '(tz: '+tz+')'
22- ],
13 + return ['div.GatheringContent',
2314 ['h2', {title: tz}, new Date(epoch).toString()],
2415 u.markdown({text:gth.description, mentions: gth.mentions}),
2516 gathering.value.image
26- ? ['img', {href: 'http://localhost:8989/blobs/get/'+encodeURIComponent(gathering.value.image.link)}]
27- : '',
17 + && ['img', {href: 'http://localhost:8989/blobs/get/'+encodeURIComponent(gathering.value.image.link)}],
2818 ['div.Attending',
2919 'attending:',
3020 Object.keys(attending).map(function (id) {
3121 return apply('avatar', id)
3222 })
3323 ],
3424 context.forms !== false &&
35- apply('publish', {
36- id: context.id,
37- name: attending[context.id] ? "can't attend" : "attend",
38- content: {
39- type: 'about',
40- about: gathering.root,
41- root: gathering.root,
42- branch: gathering.branch,
43- attendee: {
44- link: context.id,
45- remove: attending[context.id] ? true : undefined
46- },
47- }
48- }),
49- gathering.replies.length &&
50- ['div.Replies',
51- gathering.replies.map(function (reply) {
52- return apply('messages/post', reply)
53- }),
54- context.forms !== false && apply('compose', {
25 + apply('publish', {
26 + id: context.id,
27 + name: attending[context.id] ? "can't attend" : "attend",
5528 content: {
56- type: 'post',
29 + type: 'about',
30 + about: gathering.root,
5731 root: gathering.root,
58-// recps: recps,
5932 branch: gathering.branch,
60- //channel: ary[0].value.content.channel
33 + attendee: {
34 + link: context.id,
35 + remove: attending[context.id] ? true : undefined
36 + },
6137 }
62- })
63-
64- ]
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 + ]
6552 ]
6653 }
67-
68-
69-
70-
71-
72-
73-
74-
75-

Built with git-ssb-web