git ssb

16+

Dominic / patchbay



Commit 2d0ca7a523a5241557291110fc1537f1f6cca471

implement avatar images

Dominic Tarr committed on 5/29/2016, 3:08:48 AM
Parent: 98dc93ff833ad078b62215c5a044dedbbceb1887

Files changed

modules/avatar.jschanged
modules/avatar-image.jsadded
package.jsonchanged
modules/avatar.jsView
@@ -1,14 +1,15 @@
11
22 var h = require('hyperscript')
33 var u = require('../util')
44
5+exports.avatar_name = []
6+exports.avatar_image = []
7+
58 exports.avatar = function (author, sbot) {
6- return h('a',
9+ return h('a.avatar',
710 {href:'#'+author},
11+ u.firstPlug(exports.avatar_image, author, sbot),
812 u.firstPlug(exports.avatar_name, author, sbot)
913 )
1014 }
1115
12-exports.avatar_name = []
13-
14-
modules/avatar-image.jsView
@@ -1,0 +1,16 @@
1+
2+var getAvatar = require('ssb-avatar')
3+var h = require('hyperscript')
4+var ref = require('ssb-ref')
5+
6+exports.avatar_image = function (author, sbot) {
7+ var img = h('img', {src: 'http://localhost:7777/img/fallback.png'})
8+ sbot.whoami(function (err, me) {
9+ getAvatar(sbot, me.id, author, function (err, avatar) {
10+ if(ref.isBlob(avatar.image))
11+ img.src = 'http://localhost:7777/'+encodeURIComponent(avatar.image)
12+ })
13+ })
14+ return img
15+}
16+
package.jsonView
@@ -16,8 +16,9 @@
1616 "pull-next": "0.0.0",
1717 "pull-paramap": "^1.1.6",
1818 "pull-scroll": "^0.1.0",
1919 "pull-stream": "^3.3.2",
20+ "ssb-avatar": "0.0.0",
2021 "ssb-client": "^3.0.1",
2122 "ssb-keys": "^5.0.2",
2223 "ssb-markdown": "^3.0.0",
2324 "ssb-mentions": "^0.1.0",

Built with git-ssb-web