diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-05-29 06:38:49 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-05-30 09:58:53 -1000 |
commit | 35a3dedeb8b9670721bd363031083cc2c90fa085 (patch) | |
tree | 96fca1e6767d22556f096ab8bb535aa2cfbe2265 /lib/render.js | |
parent | 9e859f9fe19da67e9688bd4310bd2bae75b3d5c1 (diff) | |
download | patchfoo-35a3dedeb8b9670721bd363031083cc2c90fa085.tar.gz patchfoo-35a3dedeb8b9670721bd363031083cc2c90fa085.zip |
Implement custom emoji rendering and uploading
Diffstat (limited to 'lib/render.js')
-rw-r--r-- | lib/render.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/render.js b/lib/render.js index 2c2278c..0135205 100644 --- a/lib/render.js +++ b/lib/render.js @@ -88,13 +88,26 @@ function Render(app, opts) { Render.prototype.emoji = function (emoji) { var name = ':' + emoji + ':' - return emoji in emojis ? - h('img.ssb-emoji', { + if (emoji in emojis) { + return h('img.ssb-emoji', { src: this.opts.emoji_base + emoji + '.png', alt: name, height: 17, title: name, - }) : name + }) + } + var link = this._mentions[name] + if (link && link.link) { + this.app.reverseEmojiNameCache.set(emoji, link.link) + return h('img.ssb-emoji', { + src: this.opts.img_base + link.link, + alt: name + + (link.size != null ? ' (' + this.formatSize(link.size) + ')' : ''), + height: 17, + title: name, + }) + } + return name } /* disabled until it can be done safely without breaking html @@ -113,6 +126,8 @@ Render.prototype.markdown = function (text, mentions) { var mentionsByLink = this._mentionsByLink = {} if (Array.isArray(mentions)) mentions.forEach(function (link) { if (!link) return + else if (link.emoji) + mentionsObj[':' + link.name + ':'] = link else if (link.name) mentionsObj['@' + link.name] = link.link else if (link.host === 'http://localhost:7777') |