Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/scripts/celerity/generate_emoji.php
12241 views
1
#!/usr/bin/env php
2
<?php
3
4
require_once dirname(dirname(__FILE__)).'/__init_script__.php';
5
6
$args = new PhutilArgumentParser($argv);
7
$args->setTagline(pht('regenerate Emoji data sheets'));
8
$args->setSynopsis(<<<EOHELP
9
**emoji**
10
Rebuild Emoji data sheets.
11
12
EOHELP
13
);
14
$args->parseStandardArguments();
15
$args->parse(
16
array(
17
array(
18
'name' => 'force',
19
'help' => pht('Force regeneration even if sources have not changed.'),
20
),
21
));
22
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';
27
28
if (Filesystem::pathExists($path)) {
29
$json = Filesystem::readFile($path);
30
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));
39
}
40
$data[$shortname] = $hex;
41
}
42
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";
50
}
51
52