mirror of https://github.com/zulip/zulip.git
build_emoji: Remove old code in favor of `generate_sprite_css_files()`.
This commit is contained in:
parent
beab00a5e1
commit
eed7d4b8d7
|
@ -220,8 +220,8 @@ def generate_sprite_css_files(cache_path, emoji_map, emoji_data):
|
||||||
})
|
})
|
||||||
sprite_css_file.close()
|
sprite_css_file.close()
|
||||||
|
|
||||||
def setup_emoji_farm(cache_path):
|
def setup_emoji_farm(cache_path, emoji_map, emoji_data):
|
||||||
# type: (Text) -> None
|
# type: (Text, Dict[Text, Text], List[Dict[Text, Any]]) -> None
|
||||||
# Copy individual emoji images from npm package.
|
# Copy individual emoji images from npm package.
|
||||||
src_emoji_farm = os.path.join(NODE_MODULES_PATH, 'emoji-datasource-google', 'img', 'google', '64', '*')
|
src_emoji_farm = os.path.join(NODE_MODULES_PATH, 'emoji-datasource-google', 'img', 'google', '64', '*')
|
||||||
target_emoji_farm = os.path.join(cache_path, 'images-google-64')
|
target_emoji_farm = os.path.join(cache_path, 'images-google-64')
|
||||||
|
@ -232,6 +232,14 @@ def setup_emoji_farm(cache_path):
|
||||||
zulip_image = "{}/static/assets/zulip-emoji/*".format(ZULIP_PATH)
|
zulip_image = "{}/static/assets/zulip-emoji/*".format(ZULIP_PATH)
|
||||||
run(['cp', '-RPp', zulip_image, target_emoji_farm], shell=True)
|
run(['cp', '-RPp', zulip_image, target_emoji_farm], shell=True)
|
||||||
|
|
||||||
|
# Copy spritesheets.
|
||||||
|
for emojiset in EMOJISETS:
|
||||||
|
input_sprite_sheet = os.path.join(EMOJI_DATA_PATH, 'img', emojiset, 'sheets', '32.png')
|
||||||
|
output_sprite_sheet = os.path.join(cache_path, 'sheet_%s_32.png' % (emojiset,))
|
||||||
|
run(['cp', input_sprite_sheet, output_sprite_sheet])
|
||||||
|
|
||||||
|
generate_sprite_css_files(cache_path, emoji_map, emoji_data)
|
||||||
|
|
||||||
def dump_emojis(cache_path):
|
def dump_emojis(cache_path):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True)
|
subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True)
|
||||||
|
@ -303,37 +311,7 @@ def dump_emojis(cache_path):
|
||||||
os.path.join(cache_emoji, fn)
|
os.path.join(cache_emoji, fn)
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_emoji_farm(cache_path)
|
setup_emoji_farm(cache_path, emoji_map, emoji_data)
|
||||||
|
|
||||||
# Spritesheet CSS generation code.
|
|
||||||
emoji_positions = ""
|
|
||||||
for emoji in emoji_data:
|
|
||||||
if emoji["has_img_google"]:
|
|
||||||
emoji_positions += EMOJI_POS_INFO_TEMPLATE % {
|
|
||||||
'codepoint': emoji['unified'].lower(),
|
|
||||||
'pos_x': (emoji["sheet_x"] * 100) / 48,
|
|
||||||
'pos_y': (emoji["sheet_y"] * 100) / 48,
|
|
||||||
}
|
|
||||||
# Remove the code below once the migration to iamcal's dataset is complete.
|
|
||||||
emoji_name = emoji['short_name']
|
|
||||||
codepoint = emoji['unified'].lower()
|
|
||||||
if emoji_name in emoji_map and codepoint != emoji_map[emoji_name]:
|
|
||||||
emoji_positions += EMOJI_POS_INFO_TEMPLATE % {
|
|
||||||
'codepoint': emoji_map[emoji_name],
|
|
||||||
'pos_x': (emoji["sheet_x"] * 100) / 48,
|
|
||||||
'pos_y': (emoji["sheet_y"] * 100) / 48,
|
|
||||||
}
|
|
||||||
|
|
||||||
for emojiset in EMOJISETS:
|
|
||||||
input_sprite_sheet = os.path.join(EMOJI_DATA_PATH, 'img', emojiset, 'sheets', '32.png')
|
|
||||||
output_sprite_sheet = os.path.join(cache_path, 'sheet_%s_32.png' % (emojiset,))
|
|
||||||
run(['cp', input_sprite_sheet, output_sprite_sheet], shell=True)
|
|
||||||
SPRITE_CSS_PATH = os.path.join(cache_path, '%s_sprite.css' % (emojiset,))
|
|
||||||
sprite_css_file = open(SPRITE_CSS_PATH, 'w')
|
|
||||||
sprite_css_file.write(SPRITE_CSS_FILE_TEMPLATE % {'emojiset': emojiset,
|
|
||||||
'emoji_positions': emoji_positions,
|
|
||||||
})
|
|
||||||
sprite_css_file.close()
|
|
||||||
|
|
||||||
EMOJI_CODES_PATH = os.path.join(cache_path, 'emoji_codes.js')
|
EMOJI_CODES_PATH = os.path.join(cache_path, 'emoji_codes.js')
|
||||||
emoji_codes_file = open(EMOJI_CODES_PATH, 'w')
|
emoji_codes_file = open(EMOJI_CODES_PATH, 'w')
|
||||||
|
|
Loading…
Reference in New Issue