git ssb

1+

Daan Patchwork / patchwork



Commit 7f4a4d5b90c62d06c0bfcd39e29051e47d4f4fef

Add super-short bio summary to mouseover popup.

This addresses #780 (Mouseover of profiles should include some of the
user bio) in a relatively hap-hazard way.
Daan Wynen committed on 4/28/2020, 11:56:31 AM
Parent: e5dcb55e879c8b04584b7aa08bf803220ff08d42

Files changed

lib/depject/profile/html/preview.jschanged
package-lock.jsonchanged
package.jsonchanged
lib/depject/profile/html/preview.jsView
@@ -3,11 +3,13 @@
33 const map = require('mutant/map')
44 const when = require('mutant/when')
55 const computed = require('mutant/computed')
66 const send = require('mutant/send')
7 +const removeMd = require('remove-markdown')
78
89 exports.needs = nest({
910 'about.obs.name': 'first',
11 + 'about.obs.description': 'first',
1012 'about.html.image': 'first',
1113 'keys.sync.id': 'first',
1214 'sheet.display': 'first',
1315 'app.navigate': 'first',
@@ -24,10 +26,12 @@
2426 const i18n = api.intl.sync.i18n
2527 const plural = api.intl.sync.i18n_n
2628
2729 return nest('profile.html.preview', function (id) {
30 + const idLen = id.length
2831 const name = api.about.obs.name(id)
2932 const contact = api.profile.obs.contact(id)
33 + const description = api.about.obs.description(id)
3034
3135 return h('ProfilePreview', [
3236 h('header', [
3337 h('div.image', api.about.html.image(id)),
@@ -41,9 +45,17 @@
4145 ])
4246 ]),
4347 h('section -publicKey', [
4448 h('pre', { title: i18n('Public key for this profile') }, id)
45- ])
49 + ]),
50 + h(
51 + 'section -profile', [
52 + computed(description, (description) => {
53 + const txt = removeMd(description)
54 + const summary = shortenDescription(txt, idLen)
55 + return summary
56 + })]
57 + )
4658 ])
4759 ]),
4860
4961 when(contact.isYou, h('section -you', [
@@ -94,8 +106,33 @@
94106 ])
95107 ])
96108 })
97109
110 + function shortenDescription (txt, len) {
111 + if (txt == null) {
112 + return ''
113 + }
114 + const line1 = txt.trim().split('\n', 1)[0]
115 + if (line1.length <= len) {
116 + return line1
117 + }
118 + const words = line1.split(' ')
119 + let result = words.shift()
120 + if (result.length > len) {
121 + return result.splice(0, len - 1) + ' …'
122 + }
123 + for (let i = 0; i < len; i++) {
124 + const currentWord = words.shift()
125 + // + 1 for the joining space, and +2 for the final ellipsis
126 + if (result.length + 1 + currentWord.length + 2 <= len) {
127 + result += ` ${currentWord}`
128 + } else {
129 + break
130 + }
131 + }
132 + return result + ' …'
133 + }
134 +
98135 function displayMutualFriends (profiles) {
99136 api.sheet.profiles(profiles, i18n('Mutual Friends'))
100137 }
101138
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 370667 bytes
New file size: 370913 bytes
package.jsonView
@@ -57,8 +57,9 @@
5757 "pull-pause": "~0.0.2",
5858 "pull-pushable": "^2.2.0",
5959 "pull-reconnect": "0.0.3",
6060 "pull-stream": "^3.6.14",
61 + "remove-markdown": "^0.3.0",
6162 "require-style": "^1.1.0",
6263 "run-parallel": "^1.1.9",
6364 "scuttle-blog": "^1.0.1",
6465 "scuttle-tag": "^0.4.0",

Built with git-ssb-web