Skip to content

Commit

Permalink
Add ~1500 new emojis to the Javascript selector
Browse files Browse the repository at this point in the history
  • Loading branch information
edhelas committed Oct 31, 2020
1 parent 2369097 commit 5d1a053
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ v0.18.1 (trunk)
* Handle Caps in PresenceBuffer to save lots of SQL request
* Preload the MUC Presences when preparing groups of Messages in Chat
* Handle vcard-temp avatars refresh in PresenceBuffer to also save some SQL requests
* Add ~1500 new emojis to the Javascript selector

v0.18
---------------------------
Expand Down
2 changes: 1 addition & 1 deletion public/scripts/movim_emojis_list.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Movim/Console/ConfigCommand.php
Expand Up @@ -98,5 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
);
}
}

return 1;
}
}
42 changes: 36 additions & 6 deletions src/Movim/Console/EmojisToJsonCommand.php
Expand Up @@ -23,19 +23,49 @@ protected function execute(InputInterface $input, OutputInterface $output)
$emojis = (Emoji::getInstance())->getEmojis();

foreach ($emojis as $key => $value) {
if (strpos($key, '-') === false) {
$filtered[$key] = $value;
}
$value = str_replace([
'+ ',
'ZERO WIDTH JOINER ',
'EMOJI MODIFIER FITZPATRICK',
'MAN ',
'WOMAN ',
'FEMALE ',
'MALE ',
'EMOJI COMPONENT ',
' '
], [
'',
'',
'',
'',
'',
'',
'',
'',
' '
], $value);
echo $value."\n";
$filtered[$key] = $value;
}

$json = [];
foreach ($filtered as $key => $value) {
sscanf('U+'.$key, 'U+%x', $codepoint);
$json[emojiShortcut($value)] = ['e' => \IntlChar::chr($codepoint), 'c' => $key];
$emojiCode = '';
$exploded = explode('-', $key);
foreach ($exploded as $keyElement) {
$emojiCode .= '\u{'.$keyElement.'}';
}

$json[emojiShortcut($value)] = ['e' => $emojiCode, 'c' => $key];
}

\file_put_contents(PUBLIC_PATH.'scripts/movim_emojis_list.js', 'var emojis = '.\json_encode($json));
$encoded = \json_encode($json);
$encoded = str_replace('\\\\', '\\', $encoded);

\file_put_contents(PUBLIC_PATH.'scripts/movim_emojis_list.js', 'var emojis = '.$encoded);

$output->writeln('<info>'.\count($json).' emojis saved</info>');

return 1;
}
}

0 comments on commit 5d1a053

Please sign in to comment.