summaryrefslogtreecommitdiff
path: root/lib/award_emoji.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-12-17 14:29:55 +0200
committerValery Sizov <vsv2711@gmail.com>2015-12-22 23:12:23 +0200
commita48dd40a926fdeddfdd76cea5db468a82096c7f4 (patch)
tree523151bfaa5c0f8f554b0029ae8dd5ae3a7ddc86 /lib/award_emoji.rb
parent3b61dc47ec377b857b66f9b2a81a183276163f4e (diff)
downloadgitlab-ce-a48dd40a926fdeddfdd76cea5db468a82096c7f4.tar.gz
base implementation of emoji picker [ci skip]
Diffstat (limited to 'lib/award_emoji.rb')
-rw-r--r--lib/award_emoji.rb49
1 files changed, 40 insertions, 9 deletions
diff --git a/lib/award_emoji.rb b/lib/award_emoji.rb
index 4d99164bc33..d3f98d2d7f0 100644
--- a/lib/award_emoji.rb
+++ b/lib/award_emoji.rb
@@ -1,11 +1,4 @@
class AwardEmoji
- EMOJI_LIST = [
- "+1", "-1", "100", "blush", "heart", "smile", "rage",
- "beers", "disappointed", "ok_hand",
- "helicopter", "shit", "airplane", "alarm_clock",
- "ambulance", "anguished", "two_hearts", "wink"
- ]
-
ALIASES = {
pout: "rage",
satisfied: "laughing",
@@ -37,11 +30,49 @@ class AwardEmoji
squirrel: "shipit"
}.with_indifferent_access
- def self.path_to_emoji_image(name)
- "emoji/#{Emoji.emoji_filename(name)}.png"
+ CATEGORIES = {
+ other: "Other",
+ objects: "Objects",
+ places: "Places",
+ travel_places: "Travel",
+ emoticons: "Emoticons",
+ objects_symbols: "Symbols",
+ nature: "Nature",
+ celebration: "Celebration",
+ people: "People",
+ activity: "Activity",
+ flags: "Flags",
+ food_drink: "Food"
+ }.with_indifferent_access
+
+ def self.positions_by_name(name)
+ emoji = emojis_json.find do |emoji|
+ emoji["short_names"].include?(name)
+ end
+
+ [emoji["sheet_x"], emoji["sheet_y"]]
end
def self.normilize_emoji_name(name)
ALIASES[name] || name
end
+
+ def self.emoji_by_category
+ unless @emoji_by_category
+ @emoji_by_category = {}
+ emojis_added = []
+
+ Emoji.emojis.each do |emoji_name, data|
+ next if emojis_added.include?(data["name"])
+ emojis_added << data["name"]
+
+ @emoji_by_category[data["category"]] ||= []
+ @emoji_by_category[data["category"]] << data
+ end
+
+ @emoji_by_category = @emoji_by_category.sort.to_h
+ end
+
+ @emoji_by_category
+ end
end