discourse-emojis 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/discourse_emojis/codepoints_emoji_processor.rb +1 -1
- data/lib/discourse_emojis/constants.rb +0 -2
- data/lib/discourse_emojis/emoji_alias_creator.rb +2 -2
- data/lib/discourse_emojis/emoji_synchronizer.rb +1 -1
- data/lib/discourse_emojis/fluentui_emoji_processor.rb +7 -7
- data/lib/discourse_emojis/unicode_emoji_extractor.rb +10 -10
- data/lib/discourse_emojis/version.rb +1 -1
- data/lib/discourse_emojis.rb +0 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93129574be47db8ef174e6651bffa0e7738b2d2b183eaecc860d50b8c1cef7a7
|
4
|
+
data.tar.gz: 5ca53f21cf04a2e106eb79f69fe79e6e71c6492eade52b265c7a83285100bc1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df5a01ec357a9d2e5dd4bca84a8b87df0641dd5893dd8b1083679825c16d3cc47918c587f05e44aa91eb4eba3859efde5ab8a872b6bea3560cbcba9bc5d03ea
|
7
|
+
data.tar.gz: 1c7edc68c776e35a470643fd0288f310bd99584e1f55f4291192b5694d315247f7dc39dddd0a3b71c9c49a95c7885ee8df1dd8b2b475611dbb1da841f0ef80d5
|
@@ -82,7 +82,7 @@ module DiscourseEmojis
|
|
82
82
|
emoji = convert_to_emoji(base_codepoints)
|
83
83
|
emoji_name = supported_emojis[emoji]
|
84
84
|
|
85
|
-
return
|
85
|
+
return if !emoji_name
|
86
86
|
return if fitzpatrick_level && !tonable_emojis.include?(emoji_name)
|
87
87
|
|
88
88
|
save_emoji_image(file, output_dir, emoji_name, fitzpatrick_level)
|
@@ -22,7 +22,7 @@ module DiscourseEmojis
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def emoji_dirs
|
25
|
-
Dir.glob("#{
|
25
|
+
Dir.glob("#{DiscourseEmojis.path_for_emojis}/*").select { |d| File.directory?(d) }
|
26
26
|
end
|
27
27
|
|
28
28
|
def create_aliases_for_directory(dir)
|
@@ -45,7 +45,7 @@ module DiscourseEmojis
|
|
45
45
|
FileUtils.cp(source_file, target_file)
|
46
46
|
|
47
47
|
variations_dir = File.join(dir, original_name)
|
48
|
-
return
|
48
|
+
return if !File.directory?(variations_dir)
|
49
49
|
|
50
50
|
create_tone_variations(dir, variations_dir, alias_name)
|
51
51
|
end
|
@@ -54,7 +54,7 @@ module DiscourseEmojis
|
|
54
54
|
base_name = File.basename(unicode_file, ".png")
|
55
55
|
unicode_variations_dir = File.join(UNICODE_DIR, base_name)
|
56
56
|
|
57
|
-
return
|
57
|
+
return if !File.directory?(unicode_variations_dir)
|
58
58
|
|
59
59
|
target_variations_dir = File.join(target_dir, base_name)
|
60
60
|
FileUtils.mkdir_p(target_variations_dir)
|
@@ -52,7 +52,7 @@ module DiscourseEmojis
|
|
52
52
|
metadata = load_metadata(emoji_dir)
|
53
53
|
emoji_name = valid_metadata?(metadata)
|
54
54
|
|
55
|
-
return
|
55
|
+
return if !emoji_name
|
56
56
|
|
57
57
|
if supports_skin_tones?(emoji_dir)
|
58
58
|
process_skin_tone_emoji(emoji_dir, emoji_name)
|
@@ -63,7 +63,7 @@ module DiscourseEmojis
|
|
63
63
|
|
64
64
|
def load_metadata(emoji_dir)
|
65
65
|
metadata_path = File.join(emoji_dir, "metadata.json")
|
66
|
-
return
|
66
|
+
return if !File.exist?(metadata_path)
|
67
67
|
|
68
68
|
JSON.parse(File.read(metadata_path))
|
69
69
|
rescue JSON::ParserError
|
@@ -72,7 +72,7 @@ module DiscourseEmojis
|
|
72
72
|
|
73
73
|
def valid_metadata?(metadata)
|
74
74
|
return false if metadata.nil?
|
75
|
-
return false
|
75
|
+
return false if !metadata["glyph"]
|
76
76
|
@supported_emojis[DiscourseEmojis::Utils.force_emoji_presentation(metadata["glyph"])]
|
77
77
|
end
|
78
78
|
|
@@ -94,7 +94,7 @@ module DiscourseEmojis
|
|
94
94
|
|
95
95
|
SKIN_TONE_LEVELS.each do |tone, level|
|
96
96
|
svg_path = Dir.glob(File.join(emoji_dir, tone, "Color", "*.svg")).first
|
97
|
-
next
|
97
|
+
next if !File.exist?(svg_path)
|
98
98
|
|
99
99
|
output_path = File.join(base_output_dir, "#{level}.png")
|
100
100
|
convert_svg_to_png(svg_path, output_path)
|
@@ -103,7 +103,7 @@ module DiscourseEmojis
|
|
103
103
|
|
104
104
|
def process_regular_emoji(emoji_dir, emoji_name)
|
105
105
|
svg_path = Dir.glob(File.join(emoji_dir, "Color", "*.svg")).first
|
106
|
-
return
|
106
|
+
return if !File.exist?(svg_path)
|
107
107
|
|
108
108
|
output_path = File.join(OUTPUT_DIR, "#{emoji_name}.png")
|
109
109
|
FileUtils.mkdir_p(File.dirname(output_path))
|
@@ -124,14 +124,14 @@ module DiscourseEmojis
|
|
124
124
|
svg_path,
|
125
125
|
)
|
126
126
|
|
127
|
-
|
127
|
+
if !step1_result
|
128
128
|
status = $?.nil? ? "unknown" : $?.exitstatus
|
129
129
|
puts "Conversion step 1 failed with status: #{status}"
|
130
130
|
return
|
131
131
|
end
|
132
132
|
|
133
133
|
step2_result = system("magick", intermediate_png, "-resize", "72x72", output_png)
|
134
|
-
|
134
|
+
if !step2_result
|
135
135
|
status = $?.nil? ? "unknown" : $?.exitstatus
|
136
136
|
puts "Conversion step 2 (resize) failed with status: #{status}"
|
137
137
|
return
|
@@ -39,13 +39,13 @@ module DiscourseEmojis
|
|
39
39
|
|
40
40
|
process_file(EMOJI_LIST_FILE) do |row|
|
41
41
|
codepoint = extract_codepoint(row)
|
42
|
-
next
|
42
|
+
next if !codepoint
|
43
43
|
|
44
44
|
emoji_char = extract_emoji_char(row)
|
45
|
-
next
|
45
|
+
next if !emoji_char
|
46
46
|
|
47
47
|
image_data = extract_image_data(row)
|
48
|
-
next
|
48
|
+
next if !image_data
|
49
49
|
|
50
50
|
base_emojis[codepoint] = { char: emoji_char, image: image_data }
|
51
51
|
end
|
@@ -58,14 +58,14 @@ module DiscourseEmojis
|
|
58
58
|
|
59
59
|
process_file(EMOJI_MODIFIER_FILE) do |row|
|
60
60
|
full_codepoint = extract_codepoint(row)
|
61
|
-
next
|
61
|
+
next if !full_codepoint&.include?("_")
|
62
62
|
|
63
63
|
parts = full_codepoint.split("_")
|
64
64
|
modifier = parts.find { |part| DiscourseEmojis::FITZPATRICK_SCALE.key?(part) }
|
65
65
|
base = parts.reject { |part| part == modifier }.join("_")
|
66
66
|
|
67
67
|
image_data = extract_image_data(row)
|
68
|
-
next
|
68
|
+
next if !image_data
|
69
69
|
|
70
70
|
variations << { base:, modifier:, image: image_data }
|
71
71
|
end
|
@@ -84,7 +84,7 @@ module DiscourseEmojis
|
|
84
84
|
|
85
85
|
def extract_codepoint(row)
|
86
86
|
code_td = row.xpath("./td[2]").first
|
87
|
-
return
|
87
|
+
return if !code_td
|
88
88
|
|
89
89
|
link = code_td.at_xpath(".//a")
|
90
90
|
link&.[]("name")
|
@@ -97,13 +97,13 @@ module DiscourseEmojis
|
|
97
97
|
|
98
98
|
def extract_image_data(row)
|
99
99
|
img_td = row.xpath("./td[4]").first
|
100
|
-
return
|
100
|
+
return if !img_td
|
101
101
|
|
102
102
|
img = img_td.at_xpath(".//img")
|
103
|
-
return
|
103
|
+
return if !img
|
104
104
|
|
105
105
|
src = img["src"]
|
106
|
-
return
|
106
|
+
return if !src&.start_with?("data:image/png;base64,")
|
107
107
|
|
108
108
|
Base64.decode64(src.split(",").last)
|
109
109
|
end
|
@@ -112,7 +112,7 @@ module DiscourseEmojis
|
|
112
112
|
base_emojis.each do |codepoint, data|
|
113
113
|
emoji_char = data[:char]
|
114
114
|
emoji_name = @supported_emojis[DiscourseEmojis::Utils.force_emoji_presentation(emoji_char)]
|
115
|
-
next
|
115
|
+
next if !emoji_name
|
116
116
|
|
117
117
|
save_base_emoji(emoji_name, data[:image])
|
118
118
|
save_variations(emoji_name, codepoint, variations)
|
data/lib/discourse_emojis.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse-emojis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joffrey Jaffeux
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rake
|