summaryrefslogtreecommitdiff
path: root/lib/award_emoji.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-12-24 11:28:51 +0200
committerValery Sizov <vsv2711@gmail.com>2015-12-24 11:28:55 +0200
commitb6de0d28303a12c76847f1137e672aa60ae174ac (patch)
tree11ff97f14046b8d6445a6695fea00ab7c3e158e2 /lib/award_emoji.rb
parent2803b6e84e94bb3a8d85ea9e29aeade450c842a7 (diff)
downloadgitlab-ce-b6de0d28303a12c76847f1137e672aa60ae174ac.tar.gz
Emoji picker: better alias handling
Diffstat (limited to 'lib/award_emoji.rb')
-rw-r--r--lib/award_emoji.rb53
1 files changed, 17 insertions, 36 deletions
diff --git a/lib/award_emoji.rb b/lib/award_emoji.rb
index 3825f4650be..783fcfb61ad 100644
--- a/lib/award_emoji.rb
+++ b/lib/award_emoji.rb
@@ -1,35 +1,4 @@
class AwardEmoji
- ALIASES = {
- pout: "rage",
- satisfied: "laughing",
- hankey: "shit",
- poop: "shit",
- collision: "boom",
- thumbsup: "+1",
- thumbsdown: "-1",
- punch: "facepunch",
- raised_hand: "hand",
- running: "runner",
- ng_woman: "no_good",
- shoe: "mans_shoe",
- tshirt: "shirt",
- honeybee: "bee",
- flipper: "dolphin",
- paw_prints: "feet",
- waxing_gibbous_moon: "moon",
- telephone: "phone",
- knife: "hocho",
- envelope: "email",
- pencil: "memo",
- open_book: "book",
- sailboat: "boat",
- red_car: "car",
- lantern: "izakaya_lantern",
- uk: "gb",
- heavy_exclamation_mark: "exclamation",
- squirrel: "shipit"
- }.with_indifferent_access
-
CATEGORIES = {
other: "Other",
objects: "Objects",
@@ -46,17 +15,15 @@ class AwardEmoji
}.with_indifferent_access
def self.normilize_emoji_name(name)
- ALIASES[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"]
+ emojis.each do |emoji_name, data|
+ data["name"] = emoji_name
@emoji_by_category[data["category"]] ||= []
@emoji_by_category[data["category"]] << data
@@ -67,4 +34,18 @@ class AwardEmoji
@emoji_by_category
end
+
+ def self.emojis
+ @emojis ||= begin
+ json_path = File.join(Rails.root, 'fixtures', 'emojis', 'index.json' )
+ JSON.parse(File.read(json_path))
+ end
+ end
+
+ def self.aliases
+ @aliases ||= begin
+ json_path = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json' )
+ JSON.parse(File.read(json_path))
+ end
+ end
end