diff --git a/README.md b/README.md
index e0d6845..c60bdc7 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,10 @@
-# FIND DAT EMOJI: Emoji search for Alfred
+# Alfred Emoji Picker
-Neat!
+1. Install the latest version of this extension from the Releases page.
+2. Type `emoji [thing you want to find]`
+
+## Skin tone modifier support
+
+By default, emoji that support skin tone (fitzpatrick) modifiers will default to no modifier. To pick an emoji with fitzpatrick modifier, add `-t[1-5]` to the end of your query. For emoji that accept more than one fitzpatrick modifier, you can specify multiple digits:
+
+![GIF example of Fitzpatrick modifier support](assets/fitzpatrick-preview.gif)
diff --git a/Rakefile b/Rakefile
index 8d8705d..b720ce1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -16,7 +16,7 @@ task :default do
'emoji.rb',
'icon.png',
'emoji-db/emoji-db.json',
- 'emoji-db/emoji-img/',
+ 'emoji-db/images/',
].each do |f|
dir_name = File.dirname(f)
mkdir_p(DestDir.join dir_name) if dir_name != '.'
diff --git a/assets/fitzpatrick-preview.gif b/assets/fitzpatrick-preview.gif
new file mode 100644
index 0000000..50162eb
Binary files /dev/null and b/assets/fitzpatrick-preview.gif differ
diff --git a/emoji-db b/emoji-db
index 01eb680..671eaff 160000
--- a/emoji-db
+++ b/emoji-db
@@ -1 +1 @@
-Subproject commit 01eb680858af4f96df08fec01ecf9de8cc7fdd3e
+Subproject commit 671eaffda655049559347cd39c058399e5dd49dd
diff --git a/emoji.rb b/emoji.rb
index 5fc1939..97d9775 100755
--- a/emoji.rb
+++ b/emoji.rb
@@ -14,22 +14,14 @@ def to_unicode
end
class Array
- def to_ruby
- self.map(&:to_i).int_to_hex.map {|d| "\\u{#{d}}"}.join('')
- end
-
- def int_to_hex
- self.map {|item| item.is_a?(Numeric) ? item.to_unicode : item.to_s}
- end
-
- def to_emoji
- self.map(&:to_i).pack('U*') + "\ufe0f"
+ def to_codepoint_string
+ self.map {|item| item.is_a?(Numeric) ? '0x' + item.to_unicode : item.to_s}.join(', ')
end
end
PWD = Pathname.new File.expand_path(File.dirname(__FILE__))
EMOJI_DB_PATH = PWD.join('./emoji-db/')
-MARSHAL_TMP_FILE = File.expand_path('./alfred-emoji-marshal-cache', Dir.tmpdir)
+MARSHAL_TMP_FILE = File.expand_path('./alfred-emoji-workflow-cache', Dir.tmpdir)
STDERR.puts '===='
STDERR.puts "ARGV: `#{ARGV}`"
@@ -42,8 +34,12 @@ def to_emoji
opts.summary_indent = " "
opts.summary_width = 20
- opts.on("-t", "--tone [1-5]", ['1','2','3','4','5'], "Include skin tone") do |t|
- $skin_tone = t.to_i
+ opts.on("-t", "--tone [number]", /^\d+$/, "Include skin tone") do |t|
+ if t.to_i % 11 == 0
+ $skin_tone = (t.to_i / 11).to_s
+ else
+ $skin_tone = t
+ end
end
opts.on("-d", "--debug", "Run in debug mode (no cache)") do |_o|
@@ -60,6 +56,8 @@ def reset_marshal_cache
}
fc['db'].each do |k, v|
+ puts [k, v]
+
fc['db'][k]['name'] = fc['db'][k]['name'] || ''
fc['search_strings'][k] = [
'',
@@ -77,7 +75,9 @@ def reset_marshal_cache
end
if fc['db'][k]['fitz']
- fc['db'][k]['fitz'].map! {|p| EMOJI_DB_PATH.join(p)}
+ fc['db'][k]['fitz'].each do |k, v|
+ v.merge!({ 'image' => EMOJI_DB_PATH.join(v['image']) })
+ end
end
end
f.rewind
@@ -94,7 +94,6 @@ def reset_marshal_cache
puts JSON.pretty_generate({
:items => [
{
- # :arg => unicode_txt,
:uid => '__debug__',
:title => "Debug \u{1f41b}",
:subtitle => "Emoji database has been reset",
@@ -136,68 +135,73 @@ def reset_marshal_cache
end
end
-items = (exact_matches + matches).map do |emojilib_key|
- STDERR.puts "CODEPOINT: `#{emojilib_key}`"
- emoji = EMOJI_OBJ['db'][emojilib_key]
+STDERR.puts JSON.pretty_generate(ENV.to_h)
- path = emoji['image']
- codepoints = [emoji['codepoints']]
-
- fitz = if $skin_tone && emoji['fitz']
- [
- nil,
- 0x1f3fb,
- 0x1f3fc,
- 0x1f3fd,
- 0x1f3fe,
- 0x1f3ff,
- ][$skin_tone]
+items = (exact_matches + matches).map do |emoji_key|
+ STDERR.puts "CODEPOINT: `#{emoji_key}`"
+ emoji = EMOJI_OBJ['db'][emoji_key]
+
+ if $skin_tone && emoji['fitz'] && emoji['fitz'][$skin_tone]
+ emoji = emoji['fitz'][$skin_tone]
end
- path = emoji['fitz'][$skin_tone - 1] if fitz
+ path = emoji['image']
+ codepoints = emoji['codepoints']
- STDERR.puts "KEYWORDS: `#{EMOJI_OBJ['search_strings'][emojilib_key]}`"
+ STDERR.puts "KEYWORDS: `#{EMOJI_OBJ['search_strings'][emoji_key]}`"
STDERR.puts path
- codepoints = [*emoji['codepoints'], fitz].compact
emojilib_name = emoji['emojilib_name'] ? ":#{emoji['emojilib_name']}:" : ''
- unicode_txt = codepoints.to_emoji
- ruby_txt = codepoints.to_ruby
+ unicode_txt = codepoints.pack('U*')
+ codepoint_txt = codepoints.to_codepoint_string
+
+ subtitle = "Copy #{unicode_txt} to clipboard"
+ mods = {
+ :ctrl => {
+ :valid => true,
+ :arg => emoji_key,
+ :subtitle => "Copy #{emoji_key} to clipboard",
+ :variables => {
+ :active_key => 'ctrl'
+ },
+ },
+ :shift => {
+ :valid => !!emoji['emojilib_name'],
+ :arg => emoji['emojilib_name'],
+ :subtitle => emoji['emojilib_name'] ? "Copy #{emojilib_name} to clipboard" : "No emojilib name :..(",
+ :variables => {
+ :active_key => 'shift'
+ },
+ },
+ :alt => {
+ :valid => true,
+ :arg => codepoint_txt,
+ :subtitle => "Copy '#{codepoint_txt}' to clipboard",
+ },
+ :cmd => {
+ :valid => true,
+ :arg => path,
+ :subtitle => "Reveal image for #{unicode_txt} in Finder",
+ :variables => {
+ :active_key => 'cmd'
+ },
+ },
+ }
{
:arg => unicode_txt,
- :uid => emojilib_key,
+ :uid => emoji_key,
+ :variables => {},
:icon => {
:path => path,
},
# :type => 'file:skipcheck',
:title => emoji['name'],
:quicklookurl => path,
- :subtitle => "Copy #{unicode_txt} to clipboard",
- :mods => {
- :alt => {
- :valid => true,
- :arg => ruby_txt,
- :subtitle => "Copy #{ruby_txt} to clipboard"
- },
- :ctrl => {
- :valid => true,
- :arg => emojilib_key,
- :subtitle => "Copy #{emojilib_key} to clipboard"
- },
- :shift => {
- :valid => !!emoji['emojilib_name'],
- :arg => emoji['emojilib_name'],
- :subtitle => emoji['emojilib_name'] ? "Copy #{emojilib_name} to clipboard" : "No emojilib name :..("
- },
- :cmd => {
- :valid => true,
- :arg => path,
- :subtitle => "Reveal image for #{unicode_txt} in Finder"
- }
- }
+ :subtitle => subtitle,
+ :mods => mods,
}
end
diff --git a/info.plist b/info.plist
index d660dde..8625bf6 100644
--- a/info.plist
+++ b/info.plist
@@ -119,11 +119,32 @@
version
1
+
+ config
+
+ autopaste
+
+ clipboardtext
+ {query}
+ transient
+
+
+ type
+ alfred.workflow.output.clipboard
+ uid
+ 2404AE08-D4CF-4265-B7BB-44043DD356DD
+ version
+ 2
+
config
alfredfiltersresults
+ alfredfiltersresultsmatchmode
+ 0
+ argumenttrimmode
+ 0
argumenttype
1
escaping
@@ -162,23 +183,6 @@
version
2
-
- config
-
- autopaste
-
- clipboardtext
- {query}
- transient
-
-
- type
- alfred.workflow.output.clipboard
- uid
- 2404AE08-D4CF-4265-B7BB-44043DD356DD
- version
- 2
-
type
alfred.workflow.utility.junction