Add more server side unicode replacements for emoji

This commit is contained in:
Robin Ward 2015-12-30 14:46:52 -05:00
parent b17e5c99cc
commit 74780c1688
2 changed files with 14 additions and 1 deletions

View File

@ -119,7 +119,16 @@ class Emoji
end
def self.unicode_replacements
@unicode_replacements ||= Hash[db.map {|e| [e['emoji'], e['aliases'][0]] }]
return @unicode_replacements if @unicode_replacements
@unicode_replacements = Hash[db.map {|e| [e['emoji'], e['aliases'][0]] }]
@unicode_replacements["\u{2639}"] = 'frowning'
@unicode_replacements["\u{263A}"] = 'slightly_smiling'
@unicode_replacements["\u{263B}"] = 'slightly_smiling'
@unicode_replacements["\u{2661}"] = 'heart'
@unicode_replacements["\u{2665}"] = 'heart'
@unicode_replacements
end
def self.unicode_regexp

View File

@ -385,6 +385,10 @@ HTML
expect(PrettyText.cook("💣")).to match(/\:bomb\:/)
end
it "replaces some glyphs that are not in the emoji range" do
expect(PrettyText.cook("")).to match(/\:slightly_smiling\:/)
end
it "doesn't replace unicode emoji if emoji is disabled" do
SiteSetting.enable_emoji = false
expect(PrettyText.cook("💣")).not_to match(/\:bomb\:/)