git ssb

16+

Dominic / patchbay



Commit 72eb82ee5e74b99fd8e844dbf026d5f50df1ba4c

markdown css tweak, start of message.html.like

mix irving committed on 12/4/2017, 11:35:51 AM
Parent: 4450ad44216486af61ce817b3d9a7b0bbc6de991

Files changed

app/styles/mcss/markdown.mcsschanged
message/html/like.jsadded
app/styles/mcss/markdown.mcssView
@@ -19,25 +19,24 @@
1919 clear: both
2020 margin-bottom: .9em
2121 }
2222
23- (pre) {
23 + pre {
2424 background-color: #f5f5f5
2525 color: #c121dc
2626 padding: .3rem
2727 white-space: pre-wrap
2828 word-wrap: break-word
29 +
2930 code {
31 + $code
3032 border: none
31- padding: none
3233 }
3334 }
34- (code) {
35- background-color: #f5f5f5
36- color: #c121dc
35 +
36 + p code {
37 + $code
3738 padding: 0.1rem .2rem
38- border: 1px solid #e6e6e6
39- border-radius: 2px
4039 }
4140
4241 blockquote {
4342 color: #666
@@ -90,4 +89,10 @@
9089 h5 { font-size: 1.1rem }
9190 h6 { font-size: 1rem }
9291 }
9392
93 +$code {
94 + background-color: #f5f5f5
95 + color: #c121dc
96 + border: 1px solid #e6e6e6
97 + border-radius: 2px
98 +}
message/html/like.jsView
@@ -1,0 +1,51 @@
1 +var { h, computed, when } = require('mutant')
2 +var nest = require('depnest')
3 +
4 +exports.needs = nest({
5 + 'keys.sync.id': 'first',
6 + 'message.obs.likes': 'first',
7 + 'sbot.async.publish': 'first'
8 +})
9 +
10 +exports.gives = nest('message.html.like')
11 +
12 +exports.create = (api) => {
13 + return nest('message.html.like', function like (msg) {
14 + var id = api.keys.sync.id()
15 + var liked = computed([api.message.obs.likes(msg.key), id], doesLike)
16 + return when(liked,
17 + h('a.unlike', {
18 + href: '#',
19 + 'ev-click': () => publishLike(msg, false)
20 + }, 'Unlike'),
21 + h('a.like', {
22 + href: '#',
23 + 'ev-click': () => publishLike(msg, true)
24 + }, 'Like')
25 + )
26 + })
27 +
28 + function publishLike (msg, status = true) {
29 + var like = status ? {
30 + type: 'vote',
31 + channel: msg.value.content.channel,
32 + vote: { link: msg.key, value: 1, expression: 'Like' }
33 + } : {
34 + type: 'vote',
35 + channel: msg.value.content.channel,
36 + vote: { link: msg.key, value: 0, expression: 'Unlike' }
37 + }
38 + if (msg.value.content.recps) {
39 + like.recps = msg.value.content.recps.map(function (e) {
40 + return e && typeof e !== 'string' ? e.link : e
41 + })
42 + like.private = true
43 + }
44 + api.sbot.async.publish(like)
45 + }
46 +}
47 +
48 +function doesLike (likes, userId) {
49 + return likes.includes(userId)
50 +}
51 +

Built with git-ssb-web