Copy file attachment edges to new storage
[phabricator.git] / scripts / celerity / generate_emoji.php
blobd5337529328963d4865aa8235a668e538bc42f6f
1 #!/usr/bin/env php
2 <?php
4 require_once dirname(dirname(__FILE__)).'/__init_script__.php';
6 $args = new PhutilArgumentParser($argv);
7 $args->setTagline(pht('regenerate Emoji data sheets'));
8 $args->setSynopsis(<<<EOHELP
9 **emoji**
10 Rebuild Emoji data sheets.
12 EOHELP
14 $args->parseStandardArguments();
15 $args->parse(
16 array(
17 array(
18 'name' => 'force',
19 'help' => pht('Force regeneration even if sources have not changed.'),
21 ));
23 $root = dirname(phutil_get_library_root('phabricator'));
24 // move this to an argument?
25 $path = $root.'/emoji_strategy.json';
26 $export_path = $root.'/resources/emoji/manifest.json';
28 if (Filesystem::pathExists($path)) {
29 $json = Filesystem::readFile($path);
31 $emojis = phutil_json_decode($json);
32 $data = array();
33 foreach ($emojis as $shortname => $emoji) {
34 $unicode = $emoji['unicode'];
35 $codes = explode('-', $unicode);
36 $hex = '';
37 foreach ($codes as $code) {
38 $hex .= phutil_utf8_encode_codepoint(hexdec($code));
40 $data[$shortname] = $hex;
43 ksort($data);
44 $json = new PhutilJSON();
45 $data = $json->encodeFormatted($data);
46 Filesystem::writeFile($export_path, $data);
47 echo pht('Done.')."\n";
48 } else {
49 echo pht('Path %s not exist.', $path)."\n";