Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from pghk/feature/icons
Browse files Browse the repository at this point in the history
✨ Replace item icons with EmojiOne PNGs
  • Loading branch information
leolabs authored Feb 24, 2019
2 parents 2a5ad12 + b7ef202 commit d6244fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions gitmoji.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
#!/usr/bin/python
# encoding: utf-8

import sys
import sys, os

from workflow import Workflow3, web

gitmoji_db = 'https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json'

emojione_assets = 'https://raw.githubusercontent.com/emojione/emojione-assets/master/png/128'

def get_gitmoji_db():
return web.get(gitmoji_db).json()

def determine_icon_name(emoji):
esc_seqs = ['\\U000', '\\u']
ascii_char = emoji.encode('unicode-escape')
codes = ascii_char
for x in esc_seqs:
codes = codes.replace(x, " ")
return codes.split()[0] + ".png"

def fetch_icon(wf, emoji):
filename = determine_icon_name(emoji)
icon = wf.datafile(filename)
if not os.path.isfile(icon):
request = web.get(emojione_assets + '/' + filename)
request.save_to_path(icon)
return icon

def main(wf):
data = wf.cached_data('gitmoji_db', get_gitmoji_db, max_age=86400)
Expand All @@ -20,7 +35,7 @@ def main(wf):
title=emoji['emoji'] + ' ' + emoji['code'],
subtitle=emoji['description'],
valid=True,
icon='9B7FE8AC-6582-4825-917E-92D0E0291CC1.png',
icon=fetch_icon(wf, emoji['emoji']),
match=emoji['name'] + ' ' + emoji['description'],
arg=emoji['code'],
copytext=emoji['code'],
Expand Down
2 changes: 1 addition & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<string>getting icons...</string>
<key>script</key>
<string>chmod +x jq &amp;&amp; cat gitmojis.json | ./jq --raw-output '{items: [.gitmojis | .[] | {emoji: .emoji, code: .code, title: (.emoji + " " + .code), subtitle: .description, match: (.description + " " + .name), arg: .code, text: {copy: .code, largetype: .code}}]}'</string>
<key>scriptargtype</key>
Expand Down

0 comments on commit d6244fe

Please sign in to comment.