Fix broken emojis.

This commit is contained in:
Guo Xiang Tan 2017-01-24 16:11:20 +08:00
parent f49c9f6c43
commit d4ca8ea617
24 changed files with 15 additions and 7 deletions

View File

@ -40,7 +40,10 @@ task "emoji:update" => :environment do
code = cells[1].at_css("a")["name"] code = cells[1].at_css("a")["name"]
next unless emojis[code] unless emojis[code]
code = code.gsub(/_fe0f/, "")
next unless emojis[code]
end
apple = cell_to_image(cells[4]) apple = cell_to_image(cells[4])
google = cell_to_image(cells[5]) google = cell_to_image(cells[5])
@ -50,7 +53,7 @@ task "emoji:update" => :environment do
if WINDOWS_FLAGS.include?(code) if WINDOWS_FLAGS.include?(code)
windows = custom_windows_flag(code) windows = custom_windows_flag(code)
else else
windows = cell_to_image(cells[9]) windows = cell_to_image(cells[11])
end end
if apple.blank? || google.blank? || twitter.blank? || one.blank? || windows.blank? if apple.blank? || google.blank? || twitter.blank? || one.blank? || windows.blank?
@ -94,13 +97,16 @@ def custom_windows_flag(code)
end end
def write_emojis(emojis, aliases, style, folder) def write_emojis(emojis, aliases, style, folder)
path = "public/images/emoji/#{folder}/" path = "public/images/emoji/#{folder}"
FileUtils.rm_f Dir.glob("#{path}/*") # Uncomment to recreate all emojis
# FileUtils.rm_f Dir.glob("#{path}/*")
puts folder puts folder
emojis.values.each do |emoji| emojis.values.each do |emoji|
next if emoji[style].nil?
write_emoji("#{path}/#{emoji[:name]}.png", emoji[style]) write_emoji("#{path}/#{emoji[:name]}.png", emoji[style])
if aliases[emoji[:name]] if aliases[emoji[:name]]
aliases[emoji[:name]].each do |new_name| aliases[emoji[:name]].each do |new_name|
@ -113,7 +119,9 @@ def write_emojis(emojis, aliases, style, folder)
end end
def write_emoji(path, emoji) def write_emoji(path, emoji)
open(path, "wb") { |f| f << emoji } open(path, "wb") { |f| f << emoji }
`pngout #{path}` `pngout #{path}`
putc "." putc "."
ensure
raise "Failed to write emoji: #{path}" if File.exists?(path) && !File.size?(path)
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 B

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 458 B