Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a39782a46 | ||
|
|
c6a9db29bd | ||
|
|
3ec375d299 | ||
|
|
34cd8356bb | ||
|
|
58f2f068c1 | ||
|
|
c5ee5ebb29 | ||
|
|
2b26bb9b0d | ||
|
|
be4946fbbe | ||
|
|
3b65ee2f15 | ||
|
|
0bea2df7ba | ||
|
|
e9480a983b | ||
|
|
3935375ca8 | ||
|
|
77ff183d85 | ||
|
|
06c5d0993b | ||
|
|
f73921aacd | ||
|
|
e2ae300270 | ||
|
|
bbfae32663 | ||
|
|
65031cfcd2 | ||
|
|
7477247802 | ||
|
|
ef06de5305 | ||
|
|
097fbafcb7 | ||
|
|
608ddd58fd | ||
|
|
72aecc9105 | ||
|
|
6a781b6474 | ||
|
|
cb55354db9 | ||
|
|
490b07b49e | ||
|
|
1a7a23fd46 | ||
|
|
d7b020fd16 | ||
|
|
a9112090fa | ||
|
|
01394ed139 | ||
|
|
2530b24121 | ||
|
|
5d2401222a | ||
|
|
70db910026 | ||
|
|
0845c3898a | ||
|
|
07e15fde99 | ||
|
|
2fad57ed49 | ||
|
|
c8c9805bfc | ||
|
|
f1d0bfedaf | ||
|
|
204ace76da | ||
|
|
824a0ee189 | ||
|
|
4536894c48 | ||
|
|
28983a9ea9 | ||
|
|
11c08bdd2f | ||
|
|
c77cd152ba | ||
|
|
73f48e4b57 | ||
|
|
633bd4ff33 | ||
|
|
8c96cb878f | ||
|
|
dc06bc9a6b | ||
|
|
7755a8a181 | ||
|
|
69f625f36c | ||
|
|
13bcea9b4a | ||
|
|
19ddee2bdc | ||
|
|
9cd56f6e3d | ||
|
|
56da9a86e3 | ||
|
|
c180447c5b | ||
|
|
150c509735 | ||
|
|
8e098547ad | ||
|
|
968373beae | ||
|
|
cb85b7b105 | ||
|
|
bfbc8c5e98 | ||
|
|
2d799338d9 | ||
|
|
8b45468c6e | ||
|
|
d7f9549261 | ||
|
|
17946e381b | ||
|
|
f9f0527fbe | ||
|
|
a844c2c1f7 | ||
|
|
ece49a0f11 | ||
|
|
27e6ef7bc0 | ||
|
|
b67f98a130 | ||
|
|
282ae85ea0 | ||
|
|
baa55a8eda | ||
|
|
4db892b66b | ||
|
|
8db84353e4 | ||
|
|
7f9b0eaca9 | ||
|
|
3e9c7cc8fb | ||
|
|
808cb099de | ||
|
|
8441803d17 | ||
|
|
8781d47ddb | ||
|
|
88fce2aa9e | ||
|
|
b9fa07e0e2 | ||
|
|
6723776d77 | ||
|
|
5179cd8159 | ||
|
|
198d829f42 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.ruby-version
|
||||
db/NamesList.txt
|
||||
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.1.2
|
||||
notifications:
|
||||
email: false
|
||||
6
Gemfile
Normal file
6
Gemfile
Normal file
@@ -0,0 +1,6 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rake"
|
||||
gem "minitest"
|
||||
|
||||
gemspec
|
||||
18
Gemfile.lock
Normal file
18
Gemfile.lock
Normal file
@@ -0,0 +1,18 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
gemoji (2.0.1)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
minitest (5.3.5)
|
||||
rake (10.3.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
gemoji!
|
||||
minitest
|
||||
rake
|
||||
37
LICENSE
37
LICENSE
@@ -1,14 +1,39 @@
|
||||
octocat, squirrel, shipit
|
||||
Copyright (c) 2012 GitHub Inc. All rights reserved.
|
||||
Copyright (c) 2013 GitHub Inc. All rights reserved.
|
||||
|
||||
bowtie, neckbeard
|
||||
Copyright (c) 2012 37signals, LLC. All rights reserved.
|
||||
bowtie, neckbeard, fu
|
||||
Copyright (c) 2013 37signals, LLC. All rights reserved.
|
||||
|
||||
feelsgood, finnadie, goberserk, godmode, hurtrealbad, rage 1-4, suspect
|
||||
Copyright (c) 2012 id Software. All rights reserved.
|
||||
Copyright (c) 2013 id Software. All rights reserved.
|
||||
|
||||
trollface
|
||||
Copyright (c) 2012 whynne@deviantart. All rights reserved.
|
||||
Copyright (c) 2013 whynne@deviantart. All rights reserved.
|
||||
|
||||
All other images
|
||||
Copyright (c) 2012 Apple Inc. All rights reserved.
|
||||
Copyright (c) 2013 Apple Inc. All rights reserved.
|
||||
|
||||
Source code:
|
||||
|
||||
Copyright (c) 2013 GitHub, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
83
README.md
83
README.md
@@ -7,7 +7,7 @@ Emoji images and names. See the LICENSE for copyright information.
|
||||
Installation
|
||||
------------
|
||||
|
||||
Add `gemoji` to you Gemfile.
|
||||
Add `gemoji` to your Gemfile.
|
||||
|
||||
``` ruby
|
||||
gem 'gemoji'
|
||||
@@ -15,7 +15,16 @@ gem 'gemoji'
|
||||
|
||||
**Sync images**
|
||||
|
||||
Images can be copied to your public directory with `rake emoji` in your Rails app. This is the recommended approach since the images will be available at a consistent location. This works best with cached formatted user content generated by tools like [html-pipeline](https://github.com/jch/html-pipeline).
|
||||
Images can be copied to your public directory with `rake emoji` in your app. This is the recommended approach since the images will be available at a consistent location. This works best with cached formatted user content generated by tools like [html-pipeline](https://github.com/jch/html-pipeline).
|
||||
|
||||
``` ruby
|
||||
# Rakefile
|
||||
load 'tasks/emoji.rake'
|
||||
```
|
||||
|
||||
```
|
||||
$ rake emoji
|
||||
```
|
||||
|
||||
**Assets Precompiling**
|
||||
|
||||
@@ -30,25 +39,25 @@ Then have them compiled to public on deploy.
|
||||
|
||||
``` ruby
|
||||
# config/application.rb
|
||||
config.assets.precompile << "emoji/*.png"
|
||||
config.assets.precompile << "emoji/**/*.png"
|
||||
```
|
||||
|
||||
**WARNING** Since there are a ton of images, just adding the path may slow down other lookups if you aren't using it. Compiling all the emojis on deploy will add overhead to your deploy if even the images haven't changed. Theres just so many more superfluous files to iterate over. Also, the urls will be fingerprinted which many not be ideal for referencing from cached content.
|
||||
**WARNING** Since there are a ton of images, just adding the path may slow down other lookups if you aren't using it. Compiling all the emojis on deploy will add overhead to your deploy if even the images haven't changed. Theres just so many more superfluous files to iterate over. Also, the urls will be fingerprinted which may not be ideal for referencing from cached content.
|
||||
|
||||
|
||||
Example Rails Helper
|
||||
--------------------
|
||||
|
||||
This would allow emojifying content such as: `it's raining :cats: and :dogs:!`
|
||||
This would allow emojifying content such as: `it's raining :cat:s and :dog:s!`
|
||||
|
||||
See the [Emoji cheat sheet](http://www.emoji-cheat-sheet.com) for more examples.
|
||||
|
||||
```ruby
|
||||
module EmojiHelper
|
||||
def emojify(content)
|
||||
h(content).to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match|
|
||||
if Emoji.names.include?($1)
|
||||
'<img alt="' + $1 + '" height="20" src="' + asset_path("emoji/#{$1}.png") + '" style="vertical-align:middle" width="20" />'
|
||||
def emojify(content)
|
||||
h(content).to_str.gsub(/:([\w+-]+):/) do |match|
|
||||
if emoji = Emoji.find_by_alias($1) { nil }
|
||||
%(<img alt="#$1" src="#{asset_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
|
||||
else
|
||||
match
|
||||
end
|
||||
@@ -56,3 +65,59 @@ module EmojiHelper
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Unicode mapping
|
||||
---------------
|
||||
|
||||
Translate emoji names to unicode and vice versa.
|
||||
|
||||
```ruby
|
||||
>> Emoji.find_by_alias("cat").raw
|
||||
=> "🐱" # Don't see a cat? That's U+1F431.
|
||||
|
||||
>> Emoji.find_by_unicode("\u{1f431}").name
|
||||
=> "cat"
|
||||
```
|
||||
|
||||
Adding new emoji
|
||||
----------------
|
||||
|
||||
You can add new emoji characters to the `Emoji.all` list:
|
||||
|
||||
```ruby
|
||||
emoji = Emoji.create("music") do |char|
|
||||
char.add_alias "song"
|
||||
char.add_unicode_alias "\u{266b}"
|
||||
char.add_tag "notes"
|
||||
end
|
||||
|
||||
emoji.name #=> "music"
|
||||
emoji.raw #=> "♫"
|
||||
emoji.image_filename #=> "unicode/266b.png"
|
||||
|
||||
# Creating custom emoji (no Unicode aliases):
|
||||
emoji = Emoji.create("music") do |char|
|
||||
char.add_tag "notes"
|
||||
end
|
||||
|
||||
emoji.custom? #=> true
|
||||
emoji.image_filename #=> "music.png"
|
||||
```
|
||||
|
||||
As you create new emoji, you must ensure that you also create and put the images
|
||||
they reference by their `image_filename` to your assets directory.
|
||||
|
||||
For existing emojis, you can edit the list of aliases or add new tags in an edit block:
|
||||
|
||||
```ruby
|
||||
emoji = Emoji.find_by_alias "musical_note"
|
||||
|
||||
Emoji.edit_emoji(emoji) do |char|
|
||||
char.add_alias "music"
|
||||
char.add_unicode_alias "\u{266b}"
|
||||
char.add_tag "notes"
|
||||
end
|
||||
|
||||
Emoji.find_by_alias "music" #=> emoji
|
||||
Emoji.find_by_unicode "\u{266b}" #=> emoji
|
||||
```
|
||||
|
||||
34
Rakefile
34
Rakefile
@@ -1,7 +1,29 @@
|
||||
desc "Checks for missing aliases to unicode sources"
|
||||
task :unnamed do
|
||||
unicodes = Dir["./images/emoji/unicode/*.png"].map { |fn| File.basename(fn) }
|
||||
aliases = Dir["./images/emoji/*.png"].select { |fn| File.symlink?(fn) }.map { |fn| File.basename(fn) }
|
||||
used_unicodes = aliases.map { |name| File.basename(File.readlink("./images/emoji/#{name}")) }.uniq
|
||||
puts unicodes - used_unicodes
|
||||
require 'rake/testtask'
|
||||
|
||||
task :default => :test
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.libs << "test"
|
||||
t.test_files = FileList["test/*_test.rb"]
|
||||
end
|
||||
|
||||
namespace :db do
|
||||
desc %(Generate Emoji data files needed for development)
|
||||
task :generate => ['db/Category-Emoji.json', 'db/NamesList.txt']
|
||||
|
||||
desc %(Dump a list of supported Emoji with Unicode descriptions and aliases)
|
||||
task :dump => :generate do
|
||||
system 'ruby', '-Ilib', 'db/dump.rb'
|
||||
end
|
||||
end
|
||||
|
||||
emoji_plist = '/System/Library/Input Methods/CharacterPalette.app/Contents/Resources/Category-Emoji.plist'
|
||||
nameslist_url = 'http://www.unicode.org/Public/6.3.0/ucd/NamesList.txt'
|
||||
|
||||
task 'db/Category-Emoji.json' do |t|
|
||||
system "plutil -convert json -r '#{emoji_plist}' -o '#{t.name}'"
|
||||
end
|
||||
|
||||
file 'db/NamesList.txt' do |t|
|
||||
system "curl -fsSL '#{nameslist_url}' -o '#{t.name}'"
|
||||
end
|
||||
|
||||
47
db/Category-Emoji.json
Normal file
47
db/Category-Emoji.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"EmojiDataArray" : [
|
||||
{
|
||||
"CVDataTitle" : "EmojiCategory-People",
|
||||
"CVCategoryImage" : "Emoji-HumanImage",
|
||||
"CVCategoryData" : {
|
||||
"CVSkipNullGlyphs" : true,
|
||||
"Data" : "😄,😃,😀,😊,☺️,😉,😍,😘,😚,😗,😙,😜,😝,😛,😳,😁,😔,😌,😒,😞,😣,😢,😂,😭,😪,😥,😰,😅,😓,😩,😫,😨,😱,😠,😡,😤,😖,😆,😋,😷,😎,😴,😵,😲,😟,😦,😧,😈,👿,😮,😬,😐,😕,😯,😶,😇,😏,😑,👲,👳,👮,👷,💂,👶,👦,👧,👨,👩,👴,👵,👱,👼,👸,😺,😸,😻,😽,😼,🙀,😿,😹,😾,👹,👺,🙈,🙉,🙊,💀,👽,💩,🔥,✨,🌟,💫,💥,💢,💦,💧,💤,💨,👂,👀,👃,👅,👄,👍,👎,👌,👊,✊,✌️,👋,✋,👐,👆,👇,👉,👈,🙌,🙏,☝️,👏,💪,🚶,🏃,💃,👫,👪,👬,👭,💏,💑,👯,🙆,🙅,💁,🙋,💆,💇,💅,👰,🙎,🙍,🙇,🎩,👑,👒,👟,👞,👡,👠,👢,👕,👔,👚,👗,🎽,👖,👘,👙,💼,👜,👝,👛,👓,🎀,🌂,💄,💛,💙,💜,💚,❤️,💔,💗,💓,💕,💖,💞,💘,💌,💋,💍,💎,👤,👥,💬,👣,💭"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CVDataTitle" : "EmojiCategory-Nature",
|
||||
"CVCategoryImage" : "Emoji-NatureImage",
|
||||
"CVCategoryData" : {
|
||||
"CVSkipNullGlyphs" : true,
|
||||
"Data" : "🐶,🐺,🐱,🐭,🐹,🐰,🐸,🐯,🐨,🐻,🐷,🐽,🐮,🐗,🐵,🐒,🐴,🐑,🐘,🐼,🐧,🐦,🐤,🐥,🐣,🐔,🐍,🐢,🐛,🐝,🐜,🐞,🐌,🐙,🐚,🐠,🐟,🐬,🐳,🐋,🐄,🐏,🐀,🐃,🐅,🐇,🐉,🐎,🐐,🐓,🐕,🐖,🐁,🐂,🐲,🐡,🐊,🐫,🐪,🐆,🐈,🐩,🐾,💐,🌸,🌷,🍀,🌹,🌻,🌺,🍁,🍃,🍂,🌿,🌾,🍄,🌵,🌴,🌲,🌳,🌰,🌱,🌼,🌐,🌞,🌝,🌚,🌑,🌒,🌓,🌔,🌕,🌖,🌗,🌘,🌜,🌛,🌙,🌍,🌎,🌏,🌋,🌌,🌠,⭐️,☀️,⛅️,☁️,⚡️,☔️,❄️,⛄️,🌀,🌁,🌈,🌊"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CVDataTitle" : "EmojiCategory-Objects",
|
||||
"CVCategoryImage" : "Emoji-ObjectsImage",
|
||||
"CVCategoryData" : {
|
||||
"CVSkipNullGlyphs" : true,
|
||||
"Data" : "🎍,💝,🎎,🎒,🎓,🎏,🎆,🎇,🎐,🎑,🎃,👻,🎅,🎄,🎁,🎋,🎉,🎊,🎈,🎌,🔮,🎥,📷,📹,📼,💿,📀,💽,💾,💻,📱,☎️,📞,📟,📠,📡,📺,📻,🔊,🔉,🔈,🔇,🔔,🔕,📢,📣,⏳,⌛️,⏰,⌚️,🔓,🔒,🔏,🔐,🔑,🔎,💡,🔦,🔆,🔅,🔌,🔋,🔍,🛁,🛀,🚿,🚽,🔧,🔩,🔨,🚪,🚬,💣,🔫,🔪,💊,💉,💰,💴,💵,💷,💶,💳,💸,📲,📧,📥,📤,✉️,📩,📨,📯,📫,📪,📬,📭,📮,📦,📝,📄,📃,📑,📊,📈,📉,📜,📋,📅,📆,📇,📁,📂,✂️,📌,📎,✒️,✏️,📏,📐,📕,📗,📘,📙,📓,📔,📒,📚,📖,🔖,📛,🔬,🔭,📰,🎨,🎬,🎤,🎧,🎼,🎵,🎶,🎹,🎻,🎺,🎷,🎸,👾,🎮,🃏,🎴,🀄️,🎲,🎯,🏈,🏀,⚽️,⚾️,🎾,🎱,🏉,🎳,⛳️,🚵,🚴,🏁,🏇,🏆,🎿,🏂,🏊,🏄,🎣,☕️,🍵,🍶,🍼,🍺,🍻,🍸,🍹,🍷,🍴,🍕,🍔,🍟,🍗,🍖,🍝,🍛,🍤,🍱,🍣,🍥,🍙,🍘,🍚,🍜,🍲,🍢,🍡,🍳,🍞,🍩,🍮,🍦,🍨,🍧,🎂,🍰,🍪,🍫,🍬,🍭,🍯,🍎,🍏,🍊,🍋,🍒,🍇,🍉,🍓,🍑,🍈,🍌,🍐,🍍,🍠,🍆,🍅,🌽"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CVDataTitle" : "EmojiCategory-Places",
|
||||
"CVCategoryImage" : "Emoji-PlacesImage",
|
||||
"CVCategoryData" : {
|
||||
"CVSkipNullGlyphs" : true,
|
||||
"Data" : "🏠,🏡,🏫,🏢,🏣,🏥,🏦,🏪,🏩,🏨,💒,⛪️,🏬,🏤,🌇,🌆,🏯,🏰,⛺️,🏭,🗼,🗾,🗻,🌄,🌅,🌃,🗽,🌉,🎠,🎡,⛲️,🎢,🚢,⛵️,🚤,🚣,⚓️,🚀,✈️,💺,🚁,🚂,🚊,🚉,🚞,🚆,🚄,🚅,🚈,🚇,🚝,🚋,🚃,🚎,🚌,🚍,🚙,🚘,🚗,🚕,🚖,🚛,🚚,🚨,🚓,🚔,🚒,🚑,🚐,🚲,🚡,🚟,🚠,🚜,💈,🚏,🎫,🚦,🚥,⚠️,🚧,🔰,⛽️,🏮,🎰,♨️,🗿,🎪,🎭,📍,🚩,🇯🇵,🇰🇷,🇩🇪,🇨🇳,🇺🇸,🇫🇷,🇪🇸,🇮🇹,🇷🇺,🇬🇧"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CVDataTitle" : "EmojiCategory-Symbols",
|
||||
"CVCategoryImage" : "Emoji-SymbolImage",
|
||||
"CVCategoryData" : {
|
||||
"CVSkipNullGlyphs" : true,
|
||||
"Data" : "1️⃣,2️⃣,3️⃣,4️⃣,5️⃣,6️⃣,7️⃣,8️⃣,9️⃣,0️⃣,🔟,🔢,#️⃣,🔣,⬆️,⬇️,⬅️,➡️,🔠,🔡,🔤,↗️,↖️,↘️,↙️,↔️,↕️,🔄,◀️,▶️,🔼,🔽,↩️,↪️,ℹ️,⏪,⏩,⏫,⏬,⤵️,⤴️,🆗,🔀,🔁,🔂,🆕,🆙,🆒,🆓,🆖,📶,🎦,🈁,🈯️,🈳,🈵,🈴,🈲,🉐,🈹,🈺,🈶,🈚️,🚻,🚹,🚺,🚼,🚾,🚰,🚮,🅿️,♿️,🚭,🈷,🈸,🈂,Ⓜ️,🛂,🛄,🛅,🛃,🉑,㊙️,㊗️,🆑,🆘,🆔,🚫,🔞,📵,🚯,🚱,🚳,🚷,🚸,⛔️,✳️,❇️,❎,✅,✴️,💟,🆚,📳,📴,🅰,🅱,🆎,🅾,💠,➿,♻️,♈️,♉️,♊️,♋️,♌️,♍️,♎️,♏️,♐️,♑️,♒️,♓️,⛎,🔯,🏧,💹,💲,💱,©,®,™,❌,‼️,⁉️,❗️,❓,❕,❔,⭕️,🔝,🔚,🔙,🔛,🔜,🔃,🕛,🕧,🕐,🕜,🕑,🕝,🕒,🕞,🕓,🕟,🕔,🕠,🕕,🕖,🕗,🕘,🕙,🕚,🕡,🕢,🕣,🕤,🕥,🕦,✖️,➕,➖,➗,♠️,♥️,♣️,♦️,💮,💯,✔️,☑️,🔘,🔗,➰,〰,〽️,🔱,◼️,◻️,◾️,◽️,▪️,▫️,🔺,🔲,🔳,⚫️,⚪️,🔴,🔵,🔻,⬜️,⬛️,🔶,🔷,🔸,🔹"
|
||||
}
|
||||
}
|
||||
],
|
||||
"CVViewFontList" : [
|
||||
"AppleColorEmoji"
|
||||
]
|
||||
}
|
||||
87
db/aliases.html
Normal file
87
db/aliases.html
Normal file
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<title>Emoji alias detection</title>
|
||||
<style>
|
||||
textarea {
|
||||
font-family: monospace;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>Save the following as <tt>emoji.json</tt>:</p>
|
||||
|
||||
<textarea id="output" rows="50" cols="80"></textarea>
|
||||
|
||||
<script>
|
||||
const VARIATION_SELECTOR_15 = String.fromCharCode(0xfe0e);
|
||||
const VARIATION_SELECTOR_16 = String.fromCharCode(0xfe0f);
|
||||
|
||||
function detectAliases(db) {
|
||||
for (var i = 0; i < db.length; ++i) {
|
||||
var emoji = db[i];
|
||||
var raw = emoji.emoji;
|
||||
if (!raw) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var candidates = [];
|
||||
|
||||
if (raw.length === 1) {
|
||||
candidates.push(raw + VARIATION_SELECTOR_15);
|
||||
candidates.push(raw + VARIATION_SELECTOR_16);
|
||||
} else if (raw[raw.length - 1] === VARIATION_SELECTOR_16) {
|
||||
var base = raw.substr(0, raw.length - 1);
|
||||
candidates.push(base);
|
||||
candidates.push(base + VARIATION_SELECTOR_15);
|
||||
}
|
||||
|
||||
var aliases = candidates.filter(isColorEmoji);
|
||||
if (aliases.length) {
|
||||
emoji.unicodes = aliases;
|
||||
} else {
|
||||
delete emoji.unicodes;
|
||||
}
|
||||
}
|
||||
|
||||
dump(db);
|
||||
}
|
||||
|
||||
function isColorEmoji(candidate) {
|
||||
// Draw the emoji twice using a different color each time. If the emoji
|
||||
// draws as the same color regardless of what color we set, it's a color
|
||||
// emoji.
|
||||
return color(candidate, "#f00") === color(candidate, "#0f0");
|
||||
}
|
||||
|
||||
var canvas = document.createElement("canvas");
|
||||
function color(emoji, rgb) {
|
||||
var context = canvas.getContext("2d");
|
||||
context.clearRect(0, 0, 32, 32);
|
||||
context.fillStyle = rgb;
|
||||
context.textBaseline = "top";
|
||||
context.font = "32px Arial";
|
||||
context.fillText(emoji, 0, 0);
|
||||
var data = context.getImageData(0, 0, 32, 32).data;
|
||||
for (var i = 0; i < data.length; i += 4) {
|
||||
if (data[i] === 0 && data[i + 1] === 0 && data[i + 2] === 0) {
|
||||
continue;
|
||||
}
|
||||
return data[i].toString(16)
|
||||
+ data[i + 1].toString(16)
|
||||
+ data[i + 2].toString(16);
|
||||
}
|
||||
return "no colored pixel found";
|
||||
}
|
||||
|
||||
function dump(db) {
|
||||
var json = JSON.stringify(db, null, " ")
|
||||
.replace(/^( +)(.+)\[\](,?)$/mg, "$1$2[\n$1]$3")
|
||||
.replace(/,\n( *) /g, "\n$1, ");
|
||||
document.getElementById("output").value = json + "\n";
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.onload = function() {
|
||||
detectAliases(JSON.parse(this.responseText));
|
||||
};
|
||||
xhr.open("GET", "emoji.json", false);
|
||||
xhr.send(null);
|
||||
</script>
|
||||
79
db/dump.rb
Normal file
79
db/dump.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
require 'emoji'
|
||||
require 'json'
|
||||
|
||||
names_list = File.expand_path('../NamesList.txt', __FILE__)
|
||||
|
||||
class UnicodeCharacter
|
||||
attr_reader :code, :description, :aliases
|
||||
|
||||
@index = {}
|
||||
class << self
|
||||
attr_reader :index
|
||||
|
||||
def fetch(code, *args, &block)
|
||||
code = code.to_s(16).rjust(4, '0') if code.is_a?(Integer)
|
||||
index.fetch(code, *args, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(code, description)
|
||||
@code = code.downcase
|
||||
@description = description.downcase
|
||||
@aliases = []
|
||||
@references = []
|
||||
|
||||
self.class.index[@code] = self
|
||||
end
|
||||
|
||||
def add_alias(string)
|
||||
@aliases.concat string.split(/\s*,\s*/)
|
||||
end
|
||||
|
||||
def add_reference(code)
|
||||
@references << code.downcase
|
||||
end
|
||||
end
|
||||
|
||||
char = nil
|
||||
|
||||
File.foreach(names_list) do |line|
|
||||
case line
|
||||
when /^[A-F0-9]{4,5}\t/
|
||||
code, desc = line.chomp.split("\t", 2)
|
||||
codepoint = code.hex
|
||||
char = UnicodeCharacter.new(code, desc)
|
||||
when /^\t= /
|
||||
char.add_alias($')
|
||||
when /^\tx .+ - ([A-F0-9]{4,5})\)$/
|
||||
char.add_reference($1)
|
||||
end
|
||||
end
|
||||
|
||||
trap(:PIPE) { abort }
|
||||
|
||||
items = []
|
||||
variation = "\u{fe0f}".freeze
|
||||
|
||||
|
||||
for emoji in Emoji.all
|
||||
unicodes = emoji.unicode_aliases.dup
|
||||
|
||||
item = {}
|
||||
|
||||
unless emoji.custom?
|
||||
variation_codepoint = variation.codepoints[0]
|
||||
chars = emoji.raw.codepoints.map { |code| UnicodeCharacter.fetch(code) unless code == variation_codepoint }.compact
|
||||
item[:emoji] = unicodes.shift
|
||||
item[:unicodes] = unicodes if unicodes.any?
|
||||
item[:description] = chars.map(&:description).join(' + ')
|
||||
end
|
||||
|
||||
item[:aliases] = emoji.aliases
|
||||
item[:tags] = emoji.tags
|
||||
|
||||
items << item
|
||||
end
|
||||
|
||||
puts JSON.pretty_generate(items)
|
||||
.gsub("\n\n", "\n")
|
||||
.gsub(/,\n( +)/) { "\n%s, " % $1[2..-1] }
|
||||
8474
db/emoji.json
Normal file
8474
db/emoji.json
Normal file
File diff suppressed because it is too large
Load Diff
113
db/index.html
Normal file
113
db/index.html
Normal file
@@ -0,0 +1,113 @@
|
||||
<!doctype html>
|
||||
<title>Emoji preview</title>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font: 14px/18px Verdana, Arial, sans-serif;
|
||||
padding: 2em;
|
||||
}
|
||||
ol {
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
li {
|
||||
margin-left: 0;
|
||||
margin-top: 5px;
|
||||
clear: left;
|
||||
}
|
||||
li:first-child { display: none; }
|
||||
li > span {
|
||||
display: block;
|
||||
}
|
||||
.emoji {
|
||||
font-size: 50px;
|
||||
line-height: 50px;
|
||||
float: left;
|
||||
margin-right: 20px;
|
||||
}
|
||||
.description {
|
||||
font-style: italic;
|
||||
color: gray;
|
||||
}
|
||||
.aliases span:before, .aliases span:after {
|
||||
content: ":";
|
||||
color: gray;
|
||||
}
|
||||
.tags {
|
||||
font-size: 11px;
|
||||
}
|
||||
.tags span {
|
||||
display: inline-block;
|
||||
padding: 1px 5px 2px;
|
||||
border-radius: 3px;
|
||||
background: #dadada;
|
||||
line-height: 11px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p><input type=search placeholder="Search..."></p>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<span class="emoji"></span>
|
||||
<span class="description"></span>
|
||||
<span class="aliases"></span>
|
||||
<span class="tags"></span>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<script>
|
||||
function renderEmoji(emojis) {
|
||||
var item, els, template = document.querySelector('li')
|
||||
for (var emoji, i=0; i < emojis.length; i++) {
|
||||
emoji = emojis[i]
|
||||
item = template.cloneNode(true)
|
||||
els = item.querySelectorAll('span')
|
||||
if (emoji.emoji) els[0].textContent = emoji.emoji
|
||||
else {
|
||||
var img = document.createElement('img')
|
||||
img.src = "../images/emoji/" + emoji.aliases[0] + ".png"
|
||||
els[0].appendChild(img)
|
||||
}
|
||||
els[1].textContent = emoji.description || ''
|
||||
els[2].innerHTML = emoji.aliases.map(function(n){ return '<span>'+n+'</span>' }).join(' ')
|
||||
els[3].innerHTML = emoji.tags.map(function(n){ return '<span>'+n+'</span>' }).join(' ')
|
||||
template.parentNode.appendChild(item)
|
||||
|
||||
item._emojiText = (els[2].textContent + ' ' + els[3].textContent).replace(/_/g, '-')
|
||||
}
|
||||
}
|
||||
|
||||
xhr = new XMLHttpRequest
|
||||
xhr.onreadystatechange = function() {
|
||||
if (this.readyState == 4) {
|
||||
json = JSON.parse(this.responseText)
|
||||
renderEmoji(json)
|
||||
}
|
||||
}
|
||||
xhr.open('GET', 'emoji.json', false)
|
||||
xhr.send(null)
|
||||
|
||||
function searchEmoji(query) {
|
||||
var el,
|
||||
re = new RegExp('\\b' + query),
|
||||
els = document.querySelectorAll('li')
|
||||
|
||||
for (var i=1; i < els.length; i++) {
|
||||
el = els[i]
|
||||
if ( !query || re.test(el._emojiText) ) {
|
||||
el.style.display = 'list-item'
|
||||
} else {
|
||||
el.style.display = 'none'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var timeout, search = document.querySelector('input[type=search]')
|
||||
search.addEventListener('input', function() {
|
||||
var $this = this
|
||||
if (timeout) clearTimeout(timeout)
|
||||
timeout = setTimeout(function(){ searchEmoji($this.value) }, 200)
|
||||
}, false)
|
||||
search.focus()
|
||||
</script>
|
||||
@@ -1,12 +1,21 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "gemoji"
|
||||
s.version = "1.3.0"
|
||||
s.summary = "Emoji Assets"
|
||||
s.description = "Emoji assets"
|
||||
s.version = "2.0.1"
|
||||
s.summary = "Emoji conversion and image assets"
|
||||
s.description = "Image assets and character information for emoji."
|
||||
|
||||
s.required_ruby_version = '> 1.9'
|
||||
|
||||
s.authors = ["GitHub"]
|
||||
s.email = "support@github.com"
|
||||
s.homepage = "https://github.com/github/gemoji"
|
||||
s.licenses = ["MIT"]
|
||||
|
||||
s.files = Dir["README.md", "images/**/*.png", "lib/**/*.rb", "lib/tasks/*.rake"]
|
||||
s.files = Dir[
|
||||
"README.md",
|
||||
"images/**/*.png",
|
||||
"db/emoji.json",
|
||||
"lib/**/*.rb",
|
||||
"lib/tasks/*.rake"
|
||||
]
|
||||
end
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f44d.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f44e.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f4af.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f522.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f3b1.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f170.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f18e.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f524.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f521.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f251.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6a1.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2708.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/23f0.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f47d.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f691.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2693.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f47c.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f4a2.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f620.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f627.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f41c.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f34e.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2652.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2648.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/25c0.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/23ec.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/23eb.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2b07.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f53d.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/25b6.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2935.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2934.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2b05.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2199.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2198.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/27a1.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/21aa.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2b06.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2195.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f53c.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2196.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2197.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f503.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f504.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f3a8.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f69b.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f632.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f45f.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f3e7.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f171.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f476.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f37c.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f424.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6bc.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f519.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6c4.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f388.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2611.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f38d.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f34c.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/203c.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f3e6.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f4ca.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f488.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/26be.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f3c0.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6c0.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6c1.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f50b.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f43b.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f41d.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f37a.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f37b.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f41e.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f530.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f514.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f371.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6b4.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f6b2.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f459.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f426.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f382.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/26ab.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/1f0cf.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/2b1b.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/25fe.png
|
||||
@@ -1 +0,0 @@
|
||||
unicode/25fc.png
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user