From 7badfea64f6b333b553cefdabdfec6ec9a584bcf Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Wed, 6 Sep 2017 07:11:32 +0000 Subject: [PATCH] Twemoji parsing --- webapp/titanembeds/static/js/embed.js | 13 +++++++++++++ webapp/titanembeds/templates/embed.html.j2 | 1 + 2 files changed, 14 insertions(+) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index f25b8ba..44d5a31 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -9,6 +9,7 @@ /* global cheet */ /* global location */ /* global io */ +/* global twemoji */ (function () { const theme_options = ["DiscordDark", "BetterTitan"]; // All the avaliable theming names @@ -672,6 +673,18 @@ } var rendered = Mustache.render(template, {"id": "$2", "name": "$1"}).trim(); message.content = message.content.replace(/<:(.*?):(.*?)>/g, rendered); + message.content = twemoji.parse(message.content, { + className: "message_emoji", + callback: function(icon, options, variant) { // exclude special characters + switch (icon) { + case 'a9': // © copyright + case 'ae': // ® registered trademark + case '2122': // ™ trademark + return false; + } + return ''.concat(options.base, options.size, '/', icon, options.ext); + } + }); return message; } diff --git a/webapp/titanembeds/templates/embed.html.j2 b/webapp/titanembeds/templates/embed.html.j2 index 2fdd76c..4f8944e 100644 --- a/webapp/titanembeds/templates/embed.html.j2 +++ b/webapp/titanembeds/templates/embed.html.j2 @@ -189,6 +189,7 @@ + {% raw %}