git ssb

16+

cel / patchfoo



Commit b90b36f54546b4bad7618a57e7f5484892e23b52

Show local name in title for links to ids

as suggested in %O4GCxFpucC3DeSTCuiR9GCha9g/NXbrQYm9iam5z1RE=.sha256
cel committed on 5/17/2017, 2:25:06 AM
Parent: 36dd4c128fa2b5b789542cb0a3f2b16231980fb4

Files changed

lib/app.jschanged
lib/render.jschanged
lib/app.jsView
@@ -190,8 +190,13 @@
190190 var id = this.reverseNameCache.get(name)
191191 return id
192192 }
193193
194 +App.prototype.getNameSync = function (name) {
195 + var about = this.aboutCache.get(name)
196 + return about && about.name
197 +}
198 +
194199 function getMsgWithValue(sbot, id, cb) {
195200 if (!id) return cb()
196201 sbot.get(id, function (err, value) {
197202 if (err) return cb(err)
lib/render.jsView
@@ -33,19 +33,36 @@
3333 title: title || undefined
3434 }).outerHTML
3535 }
3636
37-MdRenderer.prototype.link = function(href, title, text) {
38- href = this.urltransform(href)
37 +MdRenderer.prototype.link = function (ref, title, text) {
38 + var href = this.urltransform(ref)
3939 var name = href && /^\/(&|%26)/.test(href) && (title || text)
40- return h('a', {
40 + if (u.isRef(ref)) {
41 + var myName = this.render.app.getNameSync(ref)
42 + if (myName) title = title ? title + ' (' + myName + ')' : myName
43 + }
44 + var a = h('a', {
4145 class: href === false ? 'bad' : undefined,
4246 href: href !== false ? href : undefined,
4347 title: title || undefined,
4448 download: name ? encodeURIComponent(name) : undefined
45- }, text).outerHTML
46-};
49 + })
50 + // text is already html-escaped
51 + a.innerHTML = text
52 + return a.outerHTML
53 +}
4754
55 +MdRenderer.prototype.mention = function (preceding, id) {
56 + var href = this.urltransform(id)
57 + var myName = this.render.app.getNameSync(id)
58 + if (id.length > 50) id = id.slice(0, 8) + '…'
59 + return (preceding||'') + h('a', {
60 + class: href === false ? 'bad' : undefined,
61 + href: href !== false ? href : undefined,
62 + title: myName || undefined,
63 + }, id).outerHTML
64 +}
4865
4966 function lexerRenderEmoji(emoji) {
5067 var el = this.renderer.render.emoji(emoji)
5168 return el && el.outerHTML || el

Built with git-ssb-web