@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 50 lines 1.3 kB view raw
1#!/usr/bin/env php 2<?php 3 4require_once dirname(dirname(__FILE__)).'/__init_script__.php'; 5 6$args = new PhutilArgumentParser($argv); 7$args->setTagline(pht('regenerate Emoji data sheets')); 8$args->setSynopsis(pht(<<<EOHELP 9**emoji** 10 Rebuild Emoji data sheets. 11 12EOHELP 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 28if (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}