git ssb

0+

dangerousbeans / patchbay-bootstrap



Commit 53cf077425b3a9a22877b44e927c7bcc36fb08e8

Merge branch 'avatar-sizes'

Dominic Tarr committed on 7/25/2016, 5:07:30 AM
Parent: 52daeae1fcff1fca37ecf65e1ff73d7a80bea2cf
Parent: a3e5002b4bcd5008621def698c4febc157444093

Files changed

modules/about.jschanged
modules/avatar-edit.jschanged
modules/avatar-image.jschanged
modules/avatar-profile.jschanged
modules/avatar.jschanged
modules/follow.jschanged
modules/message.jschanged
style.csschanged
modules/about.jsView
@@ -26,9 +26,9 @@
2626 ' as ',
2727 h('a', {href:"#"+about.about},
2828 about.name || null,
2929 about.image
30- ? h('img', {src: blob_url(about.image)})
30+ ? h('img.avatar--fullsize', {src: blob_url(about.image)})
3131 : null
3232 )
3333 )
3434
modules/avatar-edit.jsView
@@ -36,13 +36,13 @@
3636 }
3737
3838 exports.avatar_edit = function (id) {
3939
40- var img = h('img', {src: blob_url(default_avatar)})
40+ var img = h('img.avatar--large', {src: blob_url(default_avatar)})
4141 var lb = hyperlightbox()
4242 var name_input = h('input', {placeholder: 'rename'})
4343 var name = avatar_name(id)
44- var selected = null
44+ var selected = null, selected_data = null
4545
4646 getAvatar({links: sbot_links}, self_id, id, function (err, avatar) {
4747 if (err) return console.error(err)
4848 //don't show user has already selected an avatar.
@@ -50,8 +50,33 @@
5050 if(ref.isBlob(avatar.image))
5151 img.src = blob_url(avatar.image)
5252 })
5353
54+ var also_pictured = h('div.profile__alsopicturedas.wrap')
55+
56+ pull(
57+ sbot_links({dest: id, rel: 'about', values: true}),
58+ pull.map(function (e) {
59+ return e.value.content.image
60+ }),
61+ pull.filter(function (e) {
62+ return e && 'string' == typeof e.link
63+ }),
64+ pull.unique('link'),
65+ pull.drain(function (image) {
66+ also_pictured.appendChild(
67+ h('a', {href:'#', onclick: function (ev) {
68+ ev.stopPropagation()
69+ ev.preventDefault()
70+ selected = image
71+ img.src = blob_url(image.link || image)
72+ }},
73+ h('img.avatar--thumbnail', {src: blob_url(image)})
74+ )
75+ )
76+ })
77+ )
78+
5479 return h('div.row.profile',
5580 lb,
5681 img,
5782 h('div.column.profile__info',
@@ -61,9 +86,25 @@
6186 hyperfile.asDataURL(function (data) {
6287 var el = crop(data, function (err, data) {
6388 if(data) {
6489 img.src = data
65- selected = dataurl.parse(data)
90+ pull(
91+ pull.once(dataurl.parse(data)),
92+ sbot_blobs_add(function (err, hash) {
93+ //TODO. Alerts are EVIL.
94+ //I use them only in a moment of weakness.
95+
96+ if(err) return alert(err.stack)
97+ selected = {
98+ link: hash,
99+ size: selected.data.length,
100+ type: selected.mimetype,
101+ width: 512,
102+ height: 512
103+ }
104+
105+ })
106+ )
66107 }
67108 lb.close()
68109 })
69110 lb.show(el)
@@ -71,30 +112,15 @@
71112 h('button', 'update', {onclick: function () {
72113 if(name_input.value)
73114 name.textContent = name_input.value
74115
75- if(selected) {
76- pull(
77- pull.once(selected.data),
78- sbot_blobs_add(function (err, hash) {
79- //TODO. Alerts are EVIL.
80- //I use them only in a moment of weakness.
81- if(err) return alert(err.stack)
82- confirm({
83- type: 'about',
84- about: id,
85- name: name_input.value || undefined,
86- image: {
87- link: hash,
88- size: selected.data.length,
89- type: selected.mimetype,
90- width: 512,
91- height: 512
92- }
93- })
94- })
95- )
96- }
116+ if(selected)
117+ confirm({
118+ type: 'about',
119+ about: id,
120+ name: name_input.value || undefined,
121+ image: selected
122+ })
97123 else if(input.value) //name only
98124 confirm({
99125 type: 'about',
100126 about: id,
@@ -102,9 +128,20 @@
102128 })
103129 else
104130 //another moment of weakness
105131 alert('must select a name or image')
106- }})
132+ }}),
133+ also_pictured
107134 )
108135 )
109136 }
110137
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
modules/avatar-image.jsView
@@ -10,10 +10,13 @@
1010 var id = require('../keys').id
1111
1212 var default_avatar = '&qjeAs8+uMXLlyovT4JnEpMwTNDx/QXHfOl2nv2u0VCM=.sha256'
1313
14-exports.avatar_image = function (author) {
15- var img = h('img', {src: blob_url(default_avatar)})
14+exports.avatar_image = function (author, classes) {
15+ classes = classes || ''
16+ if(classes && 'string' === typeof classes) classes = '.avatar--'+classes
17+
18+ var img = h('img'+classes, {src: blob_url(default_avatar)})
1619 getAvatar({links: sbot_links}, id, author, function (err, avatar) {
1720 if (err) return console.error(err)
1821 if(ref.isBlob(avatar.image))
1922 img.src = blob_url(avatar.image)
modules/avatar-profile.jsView
@@ -12,18 +12,17 @@
1212
1313 function streamToList(stream, el) {
1414 pull(
1515 stream,
16-// pull.unique(function (e) { return e }),
1716 pull.drain(function (item) {
1817 if(item) el.appendChild(item)
1918 })
2019 )
2120 return el
2221 }
2322
2423 function image_link (id) {
25- return h('a', {href:'#'+id}, avatar_image(id))
24+ return h('a', {href:'#'+id}, avatar_image(id, 'thumbnail'))
2625 }
2726
2827 exports.avatar_profile = function (id) {
2928 return h('div.column.profile',
@@ -48,12 +47,4 @@
4847 )
4948 )
5049 }
5150
52-
53-
54-
55-
56-
57-
58-
59-
modules/avatar.jsView
@@ -5,12 +5,12 @@
55 var plugs = require('../plugs')
66 var avatar_name = plugs.first(exports.avatar_name = [])
77 var avatar_image = plugs.first(exports.avatar_image = [])
88
9-exports.avatar = function (author) {
9+exports.avatar = function (author, classes) {
1010 return h('a.avatar',
1111 {href:'#'+author},
12- avatar_image(author),
12+ avatar_image(author, classes),
1313 avatar_name(author)
1414 )
1515 }
1616
modules/follow.jsView
@@ -10,9 +10,9 @@
1010
1111 if(msg.value.content.type == 'contact' && msg.value.content.contact) {
1212 return h('div.contact',
1313 'follows',
14- avatar(msg.value.content.contact)
14+ avatar(msg.value.content.contact, 'thumbnail')
1515 )
1616 }
1717 }
1818
modules/message.jsView
@@ -32,9 +32,9 @@
3232 )
3333
3434 var msg = h('div.message',
3535 h('div.title.row',
36- h('div.avatar', avatar(msg.value.author)),
36+ h('div.avatar', avatar(msg.value.author, 'thumbnail')),
3737 h('div.message_meta.row', message_meta(msg))
3838 ),
3939 h('div.message_content', el),
4040 h('div.message_actions.row',
style.cssView
@@ -52,9 +52,9 @@
5252 overflow-x: hidden;
5353 }
5454
5555
56-img {
56+.message img {
5757 max-width: 100%;
5858 display: block;
5959 }
6060
@@ -211,27 +211,32 @@
211211 .avatar {
212212 display: flex;
213213 flex-direction: row;
214214 }
215-.avatar img {
215+
216+.avatar--large {
217+ width: 256px;
218+ height: 256px;
219+ border: 1px solid #eee;
220+}
221+
222+.avatar--thumbnail {
216223 width: 40px;
217224 height: 40px;
218225 margin-right: 3px;
219226 border: 1px solid #ccc;
220227 }
221228
229+.avatar--fullsize {
230+ width: 100%;
231+}
232+
222233 .profile {
223234 background: #fff;
224235 padding: .5em;
225236 border: 1px solid #eee;
226237 }
227238
228-.profile img {
229- width: 256px;
230- height: 256px;
231- border: 1px solid #eee;
232-}
233-
234239 .profile__info {
235240 margin-left: .5em;
236241 }
237242
@@ -280,14 +285,8 @@
280285 .hypercrop__canvas {
281286 width: 100%;
282287 }
283288
284-.profile__follows img, .profile__followers img {
285- width: 40px;
286- height: 40px;
287- margin-right: 3px;
288- border: 1px solid #ccc;
289-}
290289
291290
292291 .git-table-wrapper {
293292 max-height: 12em;

Built with git-ssb-web