git ssb

9+

cel / ssb-viewer



Commit eb408e8545d033be2ffe5456e27eb7972717e2d4

Render name-mapped mentions

cel committed on 6/2/2017, 8:52:17 AM
Parent: a6f218a9377c5f74cbf2e54ab1d6c114a2a36434

Files changed

render.jschanged
render.jsView
@@ -28,8 +28,9 @@
2828 return this.opts.base + "channel/" + href.slice(1);
2929 case "%":
3030 return this.opts.msg_base + encodeURIComponent(href);
3131 case "@":
32 + href = this.opts.mentions[href.substr(1)] || href;
3233 return this.opts.feed_base + encodeURIComponent(href);
3334 case "&":
3435 return this.opts.blob_base + encodeURIComponent(href);
3536 }
@@ -52,13 +53,16 @@
5253 };
5354
5455 function renderEmoji(emoji) {
5556 var opts = this.renderer.opts;
56- return emoji in emojis
57 + var mentions = opts.mentions;
58 + var url = mentions[emoji]
59 + ? opts.blob_base + encodeURIComponent(mentions[emoji])
60 + : emoji in emojis && opts.emoji_base + escape(emoji) + '.png';
61 + return url
5762 ? '<img src="' +
58- opts.emoji_base +
59- escape(emoji) +
60- '.png"' +
63 + url +
64 + '"' +
6165 ' alt=":' +
6266 escape(emoji) +
6367 ':"' +
6468 ' title=":' +
@@ -454,8 +458,12 @@
454458 else return renderDefault(c);
455459 }
456460
457461 function renderPost(opts, c) {
462 + opts.mentions = {};
463 + if (Array.isArray(c.mentions)) c.mentions.forEach(function (link) {
464 + if (link && link.name && link.link) opts.mentions[link.name] = link.link;
465 + });
458466 return '<section>' + marked(String(c.text), opts.marked) + "</section>";
459467 }
460468
461469 function renderDefault(c) {

Built with git-ssb-web