Changeset View
Changeset View
Standalone View
Standalone View
scripts/celerity/generate_emoji.php
Show All 15 Lines | $args->parse( | ||||
array( | array( | ||||
array( | array( | ||||
'name' => 'force', | 'name' => 'force', | ||||
'help' => pht('Force regeneration even if sources have not changed.'), | 'help' => pht('Force regeneration even if sources have not changed.'), | ||||
), | ), | ||||
)); | )); | ||||
$root = dirname(phutil_get_library_root('phabricator')); | $root = dirname(phutil_get_library_root('phabricator')); | ||||
$path = $root.'/webroot/rsrc/externals/emojione/emoji_strategy.json'; | // move this to an argument? | ||||
$export_path = $root.'/webroot/rsrc/emoji/manifest.json'; | $path = $root.'/emoji_strategy.json'; | ||||
$export_path = $root.'/resources/emoji/manifest.json'; | |||||
if (Filesystem::pathExists($path)) { | if (Filesystem::pathExists($path)) { | ||||
$json = Filesystem::readFile($path); | $json = Filesystem::readFile($path); | ||||
$emojis = phutil_json_decode($json); | $emojis = phutil_json_decode($json); | ||||
$data = array(); | $data = array(); | ||||
foreach ($emojis as $shortname => $emoji) { | foreach ($emojis as $shortname => $emoji) { | ||||
$unicode = $emoji['unicode']; | $unicode = $emoji['unicode']; | ||||
$codes = explode('-', $unicode); | $codes = explode('-', $unicode); | ||||
$hex = ''; | $hex = ''; | ||||
foreach ($codes as $code) { | foreach ($codes as $code) { | ||||
$hex .= phutil_utf8_encode_codepoint(hexdec($code)); | $hex .= phutil_utf8_encode_codepoint(hexdec($code)); | ||||
} | } | ||||
$data[$shortname] = $hex; | $data[$shortname] = $hex; | ||||
} | } | ||||
ksort($data); | |||||
epriestley: I believe this won't impact the display order in the UI, but it will make future `manifest. | |||||
$json = new PhutilJSON(); | $json = new PhutilJSON(); | ||||
$data = $json->encodeFormatted($data); | $data = $json->encodeFormatted($data); | ||||
Filesystem::writeFile($export_path, $data); | Filesystem::writeFile($export_path, $data); | ||||
echo pht('Done.')."\n"; | echo pht('Done.')."\n"; | ||||
} else { | } else { | ||||
echo pht('Path %s not exist.', $path)."\n"; | echo pht('Path %s not exist.', $path)."\n"; | ||||
} | } |
I believe this won't impact the display order in the UI, but it will make future manifest.json diffs smaller so it's probably good anyway.