git ssb

16+

Dominic / patchbay



Commit 9d629c55b19f5dc728643731fffb36dac23c0eca

add follow messages, and "yup" button

Dominic Tarr committed on 5/16/2016, 9:32:07 AM
Parent: 00b7dc676f3599b4be16806c7ce93abbd9c724c5

Files changed

modules/like.jschanged
modules/message-link.jschanged
modules/message.jschanged
modules/follow.jsadded
modules/like.jsView
@@ -1,15 +1,27 @@
11
22 var h = require('hyperscript')
33 var u = require('../util')
44
5+exports.message_link = []
6+
57 exports.message_content = function (msg, sbot) {
68 if(msg.value.content.type !== 'vote') return
79 var link = msg.value.content.vote.link
810 return h('div', msg.value.content.vote.value > 0 ? 'yup' : 'nah',
911 u.decorate(exports.message_link, link, function (d, e, v) { return d(e, v, sbot) })
1012 )
1113 }
1214
13-exports.message_link = []
15+exports.message_action = function (msg, sbot) {
16+ if(msg.value.content.type !== 'vote')
17+ return h('a', {href: '#', onclick: function () {
18+ var yup = {
19+ type: 'vote',
20+ vote: { link: msg.key, value: 1, expression: 'yup' }
21+ }
22+ //TODO: actually publish...
1423
24+ alert(JSON.stringify(yup, null, 2))
25+ }}, 'yup')
1526
27+}
modules/message-link.jsView
@@ -1,19 +1,16 @@
11 var h = require('hyperscript')
22
33 exports.message_link = function (el, id, sbot) {
4- console.log('MESSAGE_LINK', el, id)
54 if(el) return el
65
76 var link = h('a', {href: '#'+id}, id.substring(0, 10)+'...')
87
98 sbot.get(id, function (err, value) {
109 if(err) return
11- console.log('LINKED', value)
1210 if(value.content.text)
1311 link.textContent = value.content.text.substring(0, 40)+'...'
1412 })
1513
1614 return link
1715 }
1816
19-
modules/message.jsView
@@ -6,10 +6,8 @@
66 var el = u.first(exports.message_content, function (fn) {
77 return fn(msg, sbot)
88 })
99
10- if(el) console.log(el)
11-
1210 function map (plugs, value) {
1311 return plugs.map(function (plug) {
1412 return plug(value, sbot)
1513 }).filter(Boolean)
@@ -36,9 +34,9 @@
3634 h('div.message_meta.row', map(exports.message_meta, msg))
3735 ),
3836 h('div.message_content', el),
3937 h('div.message_actions.row',
40- h('div.actions', map(exports.message_action))
38+ h('div.actions', map(exports.message_action, msg))
4139 ),
4240 backlinks
4341 )
4442 }
@@ -47,4 +45,5 @@
4745 exports.avatar = []
4846 exports.message_meta = []
4947 exports.message_action = []
5048 exports.message_link = []
49+
modules/follow.jsView
@@ -1,0 +1,23 @@
1+var h = require('hyperscript')
2+var u = require('../util')
3+exports.avatar = []
4+
5+//render a message when someone follows someone,
6+//so you see new users
7+exports.message_content = function (msg, sbot) {
8+
9+ if(msg.value.content.type == 'contact') {
10+ return h('div.contact',
11+ 'follows',
12+ u.first(exports.avatar, function (plug) {
13+ return plug(msg.value.content.contact, sbot)
14+ })
15+ )
16+ }
17+}
18+
19+
20+
21+
22+
23+

Built with git-ssb-web