emoji: Move EMOTICON_CONVERSIONS mapping to build_emoji infra.

This commit closes a long pending issue which involved moving the
`EMOTICON_CONVERSION` mapping to build_emoji infrastructure so
that there is only one source of truth. This was pending from the
time when this feature was implemented.
This commit is contained in:
Harshit Bansal
2018-07-20 09:37:39 +00:00
committed by Tim Abbott
parent 565fd75661
commit c0b0fb7cce
6 changed files with 39 additions and 38 deletions

View File

@@ -18,18 +18,6 @@ var zulip_emoji = {
deactivated: false,
};
// Emoticons, and which emoji they should become (without colons). Duplicate
// emoji are allowed. Changes here should be mimicked in `zerver/lib/emoji.py`
// and `templates/zerver/help/enable-emoticon-translations.md`.
exports.EMOTICON_CONVERSIONS = {
':)': 'smiley',
'(:': 'smiley',
':(': 'slight_frown',
'<3': 'heart',
':|': 'expressionless',
':/': 'confused',
};
exports.update_emojis = function update_emojis(realm_emojis) {
// exports.all_realm_emojis is emptied before adding the realm-specific emoji
// to it. This makes sure that in case of deletion, the deleted realm_emojis
@@ -148,9 +136,9 @@ exports.translate_emoticons_to_names = function translate_emoticons_to_names(tex
return match;
};
for (var emoticon in exports.EMOTICON_CONVERSIONS) {
if (exports.EMOTICON_CONVERSIONS.hasOwnProperty(emoticon)) {
replacement_text = ':' + exports.EMOTICON_CONVERSIONS[emoticon] + ':';
for (var emoticon in emoji_codes.emoticon_conversions) {
if (emoji_codes.emoticon_conversions.hasOwnProperty(emoticon)) {
replacement_text = emoji_codes.emoticon_conversions[emoticon];
var emoticon_regex = new RegExp('(' + util.escape_regexp(emoticon) + ')', 'g');
translated = translated.replace(emoticon_regex, emoticon_replacer);
}