Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.0 #49

Merged
merged 10 commits into from
Sep 10, 2021
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ Push the packaged snap to the `edge` channel on the snap store.
```bash
snapcraft push --release=edge <path to .snap>
```

### Attribution

Emoji data is sourced from https://raw.githubusercontent.com/hfg-gmuend/openmoji/master/data/openmoji.csv which is compiled by the lovely people at https://openmoji.org.
55 changes: 35 additions & 20 deletions emote/emojis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import json
import csv
from collections import defaultdict
from emote import user_data, config

Expand All @@ -9,25 +8,41 @@

emojis_by_category = defaultdict(list)
all_emojis = []
blocklisted_emoji_categories = ["component", "extras-openmoji", "extras-unicode"]


def init():
global all_emojis
global emojis_by_category

if config.is_snap:
filename = f"{config.snap_root}/static/emojis.json"
else:
filename = "static/emojis.json"

with open(filename, "r") as f:
emojis = json.load(f)

for emoji_key in emojis.keys():
emoji = emojis[emoji_key].copy()
emoji.update({"name": emoji_key})

emojis_by_category[emoji["category"]].append(emoji)
filename = (
f"{config.snap_root}/static/emojis.csv"
if config.is_snap
else "static/emojis.csv"
)

with open(filename, newline="") as csvfile:
reader = csv.DictReader(csvfile)

for row in reader:
category = row["group"]

if category in blocklisted_emoji_categories:
continue

if row["skintone"] != "":
continue

emoji = {
"keywords": row["tags"].split(", "),
tom-james-watson marked this conversation as resolved.
Show resolved Hide resolved
"char": row["emoji"],
"name": " ".join(
[part.capitalize() for part in row["annotation"].split(" ")]
),
"shortcode": row["annotation"].replace(" ", "_").replace("-", "_"),
"skintone": row["skintone_combination"] == "simple",
}
emojis_by_category[row["group"]].append(emoji)
all_emojis.append(emoji)

update_recent_category()
Expand Down Expand Up @@ -63,11 +78,11 @@ def get_category_order():
"""
return [
("recent", "Recently Used", "🕙"),
("people", "Smileys & People", "🙂"),
("animals_and_nature", "Animals & Nature", "🐯"),
("food_and_drink", "Food & Drink", "🍔"),
("activity", "Activities", "⚽"),
("travel_and_places", "Travel & Places", "✈️"),
("people-body", "Smileys & People", "🙂"),
("animals-nature", "Animals & Nature", "🐯"),
("food-drink", "Food & Drink", "🍔"),
("activities", "Activities", "⚽"),
("travel-places", "Travel & Places", "✈️"),
("objects", "Objects", "💡"),
("symbols", "Symbols", "❤️"),
("flags", "Flags", "🇺🇳"),
Expand Down
6 changes: 2 additions & 4 deletions emote/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ def init_action_bar(self):
def show_emoji_preview(self, char):
emoji = emojis.get_emoji_by_char(char)
self.previewed_emoji_label.set_text(emoji["char"])
self.previewed_emoji_shortcode_label.set_text(f':{emoji["name"]}:')
self.previewed_emoji_name_label.set_text(
" ".join([part.capitalize() for part in emoji["name"].split("_")])
)
self.previewed_emoji_shortcode_label.set_text(f':{emoji["shortcode"]}:')
self.previewed_emoji_name_label.set_text(emoji["name"])

def reset_emoji_preview(self):
if len(self.current_emojis) > 0:
Expand Down
Loading