git ssb

16+

Dominic / patchbay



Commit 1102f8d1089ec8200edbda914e81221149bb8bfb

use blob_url plugin, instead of hardcoding

Dominic Tarr committed on 7/21/2016, 4:53:28 AM
Parent: 1e96fe40426d528418966ef69c30886b19bbaa61

Files changed

modules/about.jschanged
modules/avatar-image.jschanged
modules/about.jsView
@@ -4,9 +4,15 @@
44 function idLink (id) {
55 return h('a', {href:'#'+id}, id)
66 }
77
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) {
915 if(msg.value.content.type !== 'about') return
1016
1117 if(!msg.value.content.image && !msg.value.content.name)
1218 return
@@ -20,9 +26,9 @@
2026 ' as ',
2127 h('a', {href:"#"+about.about},
2228 about.name || null,
2329 about.image
24- ? h('img', {src:'http://localhost:7777/'+ encodeURIComponent(about.image.link)})
30+ ? h('img', {src: blob_url(about.image)})
2531 : null
2632 )
2733 )
2834
@@ -30,4 +36,5 @@
3036
3137
3238
3339
40+
modules/avatar-image.jsView
@@ -3,21 +3,28 @@
33 var h = require('hyperscript')
44 var ref = require('ssb-ref')
55
66 var plugs = require('../plugs')
7-var sbot_whoami = plugs.first(exports.sbot_whoami = [])
87 var sbot_links = plugs.first(exports.sbot_links = [])
8+var blob_url = require('../plugs').first(exports.blob_url = [])
99
10+var id = require('../keys').id
11+
12+var default_avatar = '&qjeAs8+uMXLlyovT4JnEpMwTNDx/QXHfOl2nv2u0VCM=.sha256'
13+
1014 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) {
1317 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)
1920 })
2021 return img
2122 }
2223
2324
25+
26+
27+
28+
29+
30+

Built with git-ssb-web