Path: blob/master/scripts/celerity/generate_emoji.php
12241 views
#!/usr/bin/env php1<?php23require_once dirname(dirname(__FILE__)).'/__init_script__.php';45$args = new PhutilArgumentParser($argv);6$args->setTagline(pht('regenerate Emoji data sheets'));7$args->setSynopsis(<<<EOHELP8**emoji**9Rebuild Emoji data sheets.1011EOHELP12);13$args->parseStandardArguments();14$args->parse(15array(16array(17'name' => 'force',18'help' => pht('Force regeneration even if sources have not changed.'),19),20));2122$root = dirname(phutil_get_library_root('phabricator'));23// move this to an argument?24$path = $root.'/emoji_strategy.json';25$export_path = $root.'/resources/emoji/manifest.json';2627if (Filesystem::pathExists($path)) {28$json = Filesystem::readFile($path);2930$emojis = phutil_json_decode($json);31$data = array();32foreach ($emojis as $shortname => $emoji) {33$unicode = $emoji['unicode'];34$codes = explode('-', $unicode);35$hex = '';36foreach ($codes as $code) {37$hex .= phutil_utf8_encode_codepoint(hexdec($code));38}39$data[$shortname] = $hex;40}4142ksort($data);43$json = new PhutilJSON();44$data = $json->encodeFormatted($data);45Filesystem::writeFile($export_path, $data);46echo pht('Done.')."\n";47} else {48echo pht('Path %s not exist.', $path)."\n";49}505152