Commit 2d0ca7a523a5241557291110fc1537f1f6cca471
implement avatar images
Dominic Tarr committed on 5/29/2016, 3:08:48 AMParent: 98dc93ff833ad078b62215c5a044dedbbceb1887
Files changed
modules/avatar.js | changed |
modules/avatar-image.js | added |
package.json | changed |
modules/avatar.js | ||
---|---|---|
@@ -1,14 +1,15 @@ | ||
1 | 1 | |
2 | 2 | var h = require('hyperscript') |
3 | 3 | var u = require('../util') |
4 | 4 | |
5 | +exports.avatar_name = [] | |
6 | +exports.avatar_image = [] | |
7 | + | |
5 | 8 | exports.avatar = function (author, sbot) { |
6 | - return h('a', | |
9 | + return h('a.avatar', | |
7 | 10 | {href:'#'+author}, |
11 | + u.firstPlug(exports.avatar_image, author, sbot), | |
8 | 12 | u.firstPlug(exports.avatar_name, author, sbot) |
9 | 13 | ) |
10 | 14 | } |
11 | 15 | |
12 | -exports.avatar_name = [] | |
13 | - | |
14 | - |
modules/avatar-image.js | ||
---|---|---|
@@ -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 | + |
Built with git-ssb-web