Commit 1102f8d1089ec8200edbda914e81221149bb8bfb
use blob_url plugin, instead of hardcoding
Dominic Tarr committed on 7/21/2016, 4:53:28 AMParent: 1e96fe40426d528418966ef69c30886b19bbaa61
Files changed
modules/about.js | changed |
modules/avatar-image.js | changed |
modules/about.js | ||
---|---|---|
@@ -4,9 +4,15 @@ | ||
4 | 4 | function idLink (id) { |
5 | 5 | return h('a', {href:'#'+id}, id) |
6 | 6 | } |
7 | 7 | |
8 | -exports.message_content = function (msg, sbot) { | |
8 | +function asLink (ln) { | |
9 | + return 'string' === typeof ln ? ln : ln.link | |
10 | +} | |
11 | + | |
12 | +var blob_url = require('../plugs').first(exports.blob_url = []) | |
13 | + | |
14 | +exports.message_content = function (msg) { | |
9 | 15 | if(msg.value.content.type !== 'about') return |
10 | 16 | |
11 | 17 | if(!msg.value.content.image && !msg.value.content.name) |
12 | 18 | return |
@@ -20,9 +26,9 @@ | ||
20 | 26 | ' as ', |
21 | 27 | h('a', {href:"#"+about.about}, |
22 | 28 | about.name || null, |
23 | 29 | about.image |
24 | - ? h('img', {src:'http://localhost:7777/'+ encodeURIComponent(about.image.link)}) | |
30 | + ? h('img', {src: blob_url(about.image)}) | |
25 | 31 | : null |
26 | 32 | ) |
27 | 33 | ) |
28 | 34 | |
@@ -30,4 +36,5 @@ | ||
30 | 36 | |
31 | 37 | |
32 | 38 | |
33 | 39 | |
40 | + |
modules/avatar-image.js | ||
---|---|---|
@@ -3,21 +3,28 @@ | ||
3 | 3 | var h = require('hyperscript') |
4 | 4 | var ref = require('ssb-ref') |
5 | 5 | |
6 | 6 | var plugs = require('../plugs') |
7 | -var sbot_whoami = plugs.first(exports.sbot_whoami = []) | |
8 | 7 | var sbot_links = plugs.first(exports.sbot_links = []) |
8 | +var blob_url = require('../plugs').first(exports.blob_url = []) | |
9 | 9 | |
10 | +var id = require('../keys').id | |
11 | + | |
12 | +var default_avatar = '&qjeAs8+uMXLlyovT4JnEpMwTNDx/QXHfOl2nv2u0VCM=.sha256' | |
13 | + | |
10 | 14 | exports.avatar_image = function (author) { |
11 | - var img = h('img', {src: 'http://localhost:7777/img/fallback.png'}) | |
12 | - sbot_whoami(function (err, me) { | |
15 | + var img = h('img', {src: blob_url(default_avatar)}) | |
16 | + getAvatar({links: sbot_links}, id, author, function (err, avatar) { | |
13 | 17 | if (err) return console.error(err) |
14 | - getAvatar({links: sbot_links}, me.id, author, function (err, avatar) { | |
15 | - if (err) return console.error(err) | |
16 | - if(ref.isBlob(avatar.image)) | |
17 | - img.src = 'http://localhost:7777/'+encodeURIComponent(avatar.image) | |
18 | - }) | |
18 | + if(ref.isBlob(avatar.image)) | |
19 | + img.src = blob_url(avatar.image) | |
19 | 20 | }) |
20 | 21 | return img |
21 | 22 | } |
22 | 23 | |
23 | 24 | |
25 | + | |
26 | + | |
27 | + | |
28 | + | |
29 | + | |
30 | + |
Built with git-ssb-web