git ssb

16+

Dominic / patchbay



Commit ac953328a93f9bf165c04473766270dd2360fc91

show generated avatars, instead of fallback image

Dominic Tarr committed on 9/17/2016, 2:47:52 AM
Parent: 18587bcb2aa7e5dd708e8a2dfef6e56ef56ca83e

Files changed

modules/avatar-edit.jschanged
modules/avatar-image.jschanged
package.jsonchanged
modules/avatar-edit.jsView
@@ -6,11 +6,10 @@
66 var pull = require('pull-stream')
77 var getAvatar = require('ssb-avatar')
88 var plugs = require('../plugs')
99 var ref = require('ssb-ref')
10-
10 +var visualize = require('visualize-buffer')
1111 var self_id = require('../keys').id
12-var default_avatar = '&qjeAs8+uMXLlyovT4JnEpMwTNDx/QXHfOl2nv2u0VCM=.sha256'
1312
1413 var confirm = plugs.first(exports.message_confirm = [])
1514 var sbot_blobs_add = plugs.first(exports.sbot_blobs_add = [])
1615 var blob_url = plugs.first(exports.blob_url = [])
@@ -36,9 +35,11 @@
3635 }
3736
3837 exports.avatar_edit = function (id) {
3938
40- var img = h('img.avatar--large', {src: blob_url(default_avatar)})
39 + var img = visualize(new Buffer(id.substring(1), 'base64'), 256)
40 + img.classList.add('avatar--large')
41 +
4142 var lb = hyperlightbox()
4243 var name_input = h('input', {placeholder: 'rename'})
4344 var name = avatar_name(id)
4445 var selected = null, selected_data = null
@@ -135,4 +136,6 @@
135136 )
136137 )
137138 }
138139
140 +
141 +
modules/avatar-image.jsView
@@ -2,8 +2,9 @@
22 var getAvatar = require('ssb-avatar')
33 var h = require('hyperscript')
44 var ref = require('ssb-ref')
55 var path = require('path')
6 +var visualize = require('visualize-buffer')
67
78 var plugs = require('../plugs')
89 var sbot_query = plugs.first(exports.sbot_query = [])
910 var blob_url = require('../plugs').first(exports.blob_url = [])
@@ -11,10 +12,8 @@
1112 var pull = require('pull-stream')
1213
1314 var id = require('../keys').id
1415
15-var default_avatar = path.join(__dirname, 'avatar_fallback.png')
16-
1716 var avatars = AVATARS = {}
1817
1918 function isFunction (f) {
2019 return 'function' === typeof f
@@ -78,14 +77,12 @@
7877 exports.avatar_image = function (author, classes) {
7978 classes = classes || ''
8079 if(classes && 'string' === typeof classes) classes = '.avatar--'+classes
8180
82- var img = h('img'+classes, {src: default_avatar})
83-// getAvatar({links: sbot_links}, id, author, function (err, avatar) {
84-// if (err) return console.error(err)
85-// if(ref.isBlob(avatar.image))
86-// img.src = blob_url(avatar.image)
87-// })
81 + var img = visualize(new Buffer(author.substring(1), 'base64'), 256)
82 + ;(classes || '').split('.').filter(Boolean).forEach(function (c) {
83 + img.classList.add(c)
84 + })
8885
8986 function go () {
9087 if(avatars[author]) img.src = blob_url(avatars[author].image)
9188 }
@@ -103,4 +100,9 @@
103100
104101
105102
106103
104 +
105 +
106 +
107 +
108 +
package.jsonView
@@ -43,9 +43,10 @@
4343 "ssb-markdown": "^3.0.0",
4444 "ssb-mentions": "^0.1.0",
4545 "ssb-sort": "^1.0.0",
4646 "suggest-box": "^2.2.1",
47- "text-node-searcher": "^1.1.0"
47 + "text-node-searcher": "^1.1.0",
48 + "visualize-buffer": "0.0.0"
4849 },
4950 "devDependencies": {
5051 "browselectrify": "^1.0.1"
5152 },

Built with git-ssb-web