git ssb

16+

Dominic / patchbay



Commit d9f1971c3d17925ef02061745ea977da4be146c5

Make likes and follows be small

Charles Lehner authored on 10/11/2016, 9:01:52 PM
cel committed on 10/17/2016, 9:05:51 PM
Parent: a4c97b2c28b8bb16232a873162d6d9992353cedc

Files changed

modules/follow.jschanged
modules/like.jschanged
modules/message.jschanged
modules/raw.jschanged
modules/follow.jsView
@@ -1,7 +1,10 @@
11 var h = require('hyperscript')
22 var u = require('../util')
3-var avatar = require('../plugs').first(exports.avatar = [])
3 +var plugs = require('../plugs')
4 +var avatar = plugs.first(exports.avatar = [])
5 +var avatar_name = plugs.first(exports.avatar_name = [])
6 +var avatar_link = plugs.first(exports.avatar_link = [])
47 var pull = require('pull-stream')
58 var plugs = require('../plugs')
69
710 //render a message when someone follows someone,
@@ -9,8 +12,20 @@
912 function isRelated(value, name) {
1013 return value ? name : value === false ? 'un'+name : ''
1114 }
1215
16 +exports.message_content_mini = function (msg) {
17 + var content = msg.value.content
18 + if(content.type == 'contact' && content.contact) {
19 + var relation = isRelated(content.following, 'follows')
20 + if(content.blocking) relation = 'blocks'
21 + return [
22 + relation, ' ',
23 + avatar_link(content.contact, avatar_name(content.contact), '')
24 + ]
25 + }
26 +}
27 +
1328 exports.message_content = function (msg) {
1429
1530 var content = msg.value.content
1631 if(content.type == 'contact' && content.contact) {
modules/like.jsView
@@ -8,15 +8,15 @@
88 var message_confirm = plugs.first(exports.message_confirm = [])
99 var message_link = plugs.first(exports.message_link = [])
1010 var sbot_links = plugs.first(exports.sbot_links = [])
1111
12-exports.message_content = function (msg, sbot) {
12 +exports.message_content_mini = function (msg, sbot) {
1313 if(msg.value.content.type !== 'vote') return
1414 var link = msg.value.content.vote.link
15- return h('div',
15 + return [
1616 msg.value.content.vote.value > 0 ? 'Dug' : 'Undug',
1717 ' ', message_link(link)
18- )
18 + ]
1919 }
2020
2121 exports.message_meta = function (msg, sbot) {
2222 var digs = h('a')
modules/message.jsView
@@ -5,16 +5,33 @@
55
66
77 var plugs = require('../plugs')
88 var message_content = plugs.first(exports.message_content = [])
9 +var message_content_mini = plugs.first(exports.message_content_mini = [])
910 var avatar = plugs.first(exports.avatar = [])
11 +var avatar_name = plugs.first(exports.avatar_name = [])
12 +var avatar_link = plugs.first(exports.avatar_link = [])
1013 var message_meta = plugs.map(exports.message_meta = [])
1114 var message_action = plugs.map(exports.message_action = [])
1215 var message_link = plugs.first(exports.message_link = [])
1316
1417 var sbot_links = plugs.first(exports.sbot_links = [])
1518
1619 exports.message_render = function (msg, sbot) {
20 + var elMini = message_content_mini(msg)
21 + if (elMini) {
22 + var div = h('div.message',
23 + h('div.message_content.row',
24 + h('div',
25 + avatar_link(msg.value.author, avatar_name(msg.value.author), ''),
26 + ' ', elMini),
27 + h('div.message_meta.row', message_meta(msg))
28 + )
29 + )
30 + div.setAttribute('tabindex', '0')
31 + return div
32 + }
33 +
1734 var el = message_content(msg)
1835 if(!el) return
1936
2037 var links = []
modules/raw.jsView
@@ -9,9 +9,9 @@
99
1010 // from ssb-ref
1111 var refRegex = /((?:@|%|&)[A-Za-z0-9\/+]{43}=\.[\w\d]+)/g
1212
13-function linkify(text) {
13 +exports.linkify = function (text) {
1414 var arr = text.split(refRegex)
1515 for (var i = 1; i < arr.length; i += 2) {
1616 arr[i] = h('a', {href: '#' + arr[i]}, arr[i])
1717 }
@@ -32,9 +32,9 @@
3232 // move away the content
3333 while (el = msgContentEl.firstChild)
3434 tmp.appendChild(el)
3535 // show the raw stuff
36- if (!pre) pre = h('pre', linkify(JSON.stringify({
36 + if (!pre) pre = h('pre', exports.linkify(JSON.stringify({
3737 key: msg.key,
3838 value: msg.value
3939 }, 0, 2)))
4040 msgContentEl.appendChild(pre)

Built with git-ssb-web