Compare commits

...

30 Commits

Author SHA1 Message Date
Jawira Portugal 9417315afa
Merge pull request #21 from jawira/fully-qualified-emojis
feat: Only use fully-qualified emojis
2022-11-09 22:20:58 +01:00
jawira cc467e4a2d feat: Only use fully-qualified emojis 2022-11-06 16:35:30 +01:00
Jawira Portugal a690f8075b
Merge pull request #20 from jawira/update-emoji-15
feat: Update to Emoji v15
2022-11-02 08:53:01 +01:00
jawira 74cb3040b8 feat: Update to Emoji v15 2022-11-02 08:50:54 +01:00
Jawira Portugal 7dddc44272
Merge pull request #18 from jawira/update_description
Update description
2022-02-09 00:18:39 +01:00
jawira 3de69f2bde Remove idea dir 2022-02-09 00:16:09 +01:00
jawira 715ec4619b Update description 2022-02-09 00:14:30 +01:00
Jawira Portugal aab04155e5
Merge pull request #17 from jawira/update-to-emoji-v14
Update to emoji v14
2022-02-08 23:51:52 +01:00
jawira 854eb13039 Update to emoji v14 2022-02-08 23:37:17 +01:00
jawira a194d92474 Preparing for v3.0.1 2020-10-14 09:29:44 +02:00
Jawira Portugal 6c51671e00
Merge pull request #16 from jawira/15-reduce-size
Reduce Emoji.php size
2020-10-14 09:23:44 +02:00
jawira bff303bfa6 Remove leading whitespaces #15 2020-10-13 23:58:07 +02:00
jawira b03d0252d3 Preparing for v3.0.0 2020-09-21 09:50:34 +02:00
Jawira Portugal 9599374b0c
Merge pull request #14 from jawira/13-update-emojis
Update to Emoji v13.1
2020-09-21 09:44:15 +02:00
jawira 015484b727 Clean project #13 2020-09-21 09:40:56 +02:00
jawira bab76f4256 Update to Emoji v13.1 #13 2020-09-21 09:07:01 +02:00
Jawira Portugal ae2893551f
Merge pull request #12 from jawira/9-emoji-sequences
Explain emoji sequences in readme
2020-09-18 13:35:25 +02:00
jawira 34960927dd Emoji sequences #9 2020-09-18 13:04:51 +02:00
jawira 0875da5198 Preparing for v2.0.1 2020-09-17 10:47:30 +02:00
Jawira Portugal 728e1a954b
Merge pull request #11 from jawira/8-remove-comments
Remove comments to improve op_cache performance in production environments
2020-09-17 10:45:14 +02:00
jawira 2e1c82f6cb Cleaning Emoji class removing comments #8 2020-09-17 10:38:05 +02:00
jawira 6e1b950d58 Prepare for v2.0.0 2020-03-12 19:44:01 +01:00
Jawira Portugal 5b7d1ccc29
Merge pull request #7 from jawira/6-emoji-13
Update library to emoji v13 #6
2020-02-20 21:46:22 +01:00
jawira 0f0429ca65 Update to emoji v13 #6 2020-02-20 21:08:28 +01:00
jawira b26fe6a260 Add HitCounter badge 2019-12-07 14:20:33 +01:00
jawira d34d26f465 Merge branch 'emoji-12.1' 2019-10-28 17:38:05 +01:00
jawira 8b76b11228 Updating to Emoji v12.1 2019-10-28 17:37:42 +01:00
jawira b9120b7aed Preparing for v1.1.0 2019-10-02 23:00:13 +02:00
Jawira Portugal 71c5397ec3
Merge pull request #4 from jawira/1-catalog
Add emoji catalog #1
2019-10-02 22:50:58 +02:00
jawira 9fb1d4b102 Add emoji catalog #1 2019-10-02 22:48:53 +02:00
21 changed files with 7605 additions and 21579 deletions

View File

@ -5,16 +5,16 @@ charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
[*.php]
indent_size = 4
indent_style = space
[*.{yml, yaml, neon, xml, xsl, json}]
indent_size = 2
indent_style = space
[*.{md, markdown}]
trim_trailing_whitespace = false
indent_size = 2
indent_style = space
max_line_length = 80
[.gitattributes]
indent_style = tab
tab_width = 4

21
.gitattributes vendored
View File

@ -1,8 +1,13 @@
/.gitattributes export-ignore
/.editorconfig export-ignore
/.gitignore export-ignore
/.idea export-ignore
/docs export-ignore
/resources export-ignore
/build.xml export-ignore
/build.png export-ignore
/.idea export-ignore
/docs export-ignore
/tasks export-ignore
/tests export-ignore
/resources export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/build.svg export-ignore
/build.png export-ignore
/build.xml export-ignore
/CHANGELOG.md export-ignore
/README.md export-ignore

View File

@ -1,83 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="jawira">
<words>
<w>barthelemy</w>
<w>barthélemy</w>
<w>bento</w>
<w>biohazard</w>
<w>blowfish</w>
<w>bouvet</w>
<w>buildfile</w>
<w>burkina</w>
<w>cableway</w>
<w>caicos</w>
<w>ceuta</w>
<w>clipperton</w>
<w>cunha</w>
<w>curaçao</w>
<w>czechia</w>
<w>côte</w>
<w>dango</w>
<w>dharma</w>
<w>divoire</w>
<w>diya</w>
<w>emojis</w>
<w>eswatini</w>
<w>facepalming</w>
<w>falafel</w>
<w>faroe</w>
<w>faso</w>
<w>flatbread</w>
<w>futuna</w>
<w>gbeng</w>
<w>gbsct</w>
<w>gbwls</w>
<w>gitattributes</w>
<w>gitignore</w>
<w>hong</w>
<w>ivoire</w>
<w>jawira</w>
<w>keycap</w>
<w>kitts</w>
<w>kosovo</w>
<w>lanka</w>
<w>leste</w>
<w>maarten</w>
<w>mahjong</w>
<w>marino</w>
<w>mayen</w>
<w>mayotte</w>
<w>melilla</w>
<w>mens</w>
<w>merperson</w>
<w>miquelon</w>
<w>moai</w>
<w>nazar</w>
<w>niue</w>
<w>oclock</w>
<w>oden</w>
<w>oneline</w>
<w>palau</w>
<w>papua</w>
<w>petri</w>
<w>phing</w>
<w>plantuml</w>
<w>príncipe</w>
<w>réunion</w>
<w>selfie</w>
<w>sint</w>
<w>smilies</w>
<w>spoked</w>
<w>supervillain</w>
<w>symplify</w>
<w>tanabata</w>
<w>timor</w>
<w>tokelau</w>
<w>tomé</w>
<w>womans</w>
<w>womens</w>
<w>zealand</w>
<w>åland</w>
</words>
</dictionary>
</component>

View File

@ -1,34 +0,0 @@
# Changelog
<!--
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
-->
## Unreleased
## [v1.0.0] - 2019-10-01
### Added
- [#2] Added docblock with _name_ and _code point_ to all constants.
### Changed
- [#2] Constant `Emoji::LAPTOP_COMPUTER` was changed to `Emoji::LAPTOP`.
- [#2] Constant `Emoji::FLAG_ENGLAND` was changed to `Emoji::FLAG_GBENG`.
- [#2] Constant `Emoji::FLAG_SCOTLAND` was changed to `Emoji::FLAG_GBSCT`.
- [#2] Constant `Emoji::FLAG_WALES` was changed to `Emoji::FLAG_GBWLS`.
## [v0.0.0] - 2019-08-30
### Added
- First working version.
[#2]: https://github.com/jawira/emoji-catalo/pull/2
[v1.0.0]: https://github.com/jawira/emoji-catalo/compare/v0.0.0...v1.0.0

View File

@ -1,51 +0,0 @@
Contributing
============
Contributions in the form of **✍Issues** and **🛠Pull requests** are welcomed
and encouraged.
How to contribute
-----------------
In order to contribute to this project:
1. **Fork** this repository
2. Create a **new branch** and commit your feature or bugfix
3. Once you have finished, create a **Pull Request** to merge your changes into
remote's develop branch
Do not forget to add your name at the end of this file.
Recommendations
---------------
This project adheres to:
* [Contributor Covenant]: A Code of Conduct for Open Source Projects
* [Keep a Changelog]: Good practices for changelog file
* [pds/skeleton]: Standard PHP package skeleton
* [Vincent Driessen's branching model]: A branching model for Git
* [Semantic Versioning]: Simple rules for version numbers
It's encouraged to use:
* [The seven rules of a great Git commit message]: How to Write a good Git
Commit Message
* [git-flow]: Git extensions to provide high-level repository operations for
Vincent Driessen's branching model
Contributors
------------
The following individuals have contributed to this project:
- (add your name here)
[Contributor Covenant]: https://www.contributor-covenant.org/
[git-flow]: https://danielkummer.github.io/git-flow-cheatsheet/
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/
[pds/skeleton]: https://github.com/php-pds/skeleton
[Semantic Versioning]: http://semver.org/
[The seven rules of a great Git commit message]: https://chris.beams.io/posts/git-commit/#seven-rules
[Vincent Driessen's branching model]: http://nvie.com/posts/a-successful-git-branching-model/

View File

@ -1,7 +1,6 @@
Emoji catalog 📔
==============
# Emoji catalog 📔
Get access to +3000 emojis as class constants.
Get access to +3600 emojis as class constants.
Features:
@ -9,16 +8,12 @@ Features:
- 🤩 A lot of emojis
- 🔓 Zero dependencies
[![Latest Stable Version](https://poser.pugx.org/jawira/emoji-catalog/v/stable)](https://packagist.org/packages/jawira/emoji-catalog)
![Emoji](https://img.shields.io/badge/Emoji-v12.0-%235354FE)
[![Total Downloads](https://poser.pugx.org/jawira/emoji-catalog/downloads)](https://packagist.org/packages/jawira/emoji-catalog)
[![License](https://poser.pugx.org/jawira/emoji-catalog/license)](https://packagist.org/packages/jawira/emoji-catalog)
[![composer.lock](https://poser.pugx.org/jawira/emoji-catalog/composerlock)](https://packagist.org/packages/jawira/emoji-catalog)
[![PDS Skeleton](https://img.shields.io/badge/pds-skeleton-blue.svg)](https://github.com/php-pds/skeleton)
[![Issues](https://img.shields.io/github/issues/jawira/emoji-catalog.svg?label=HuBoard&color=694DC2)](https://huboard.com/jawira/emoji-catalog)
You can see the [full emoji list].
Usage
-----
[![Latest Stable Version](https://poser.pugx.org/jawira/emoji-catalog/v/stable)](https://packagist.org/packages/jawira/emoji-catalog)
[![License](https://poser.pugx.org/jawira/emoji-catalog/license)](https://packagist.org/packages/jawira/emoji-catalog)
## Usage
You have access to emojis as `\Jawira\EmojiCatalog\Emoji` constants:
@ -32,57 +27,71 @@ echo Emoji::HOURGLASS_DONE; // ⌛
echo Emoji::EJECT_BUTTON; // ⏏
```
Your favorite IDE should give you autocomplete since you are simply calling
Your favorite IDE should give you autocomplete since you are simply calling
class constants:
![Autocomplete](docs/images/autocomplete.png)
How to install
--------------
## How to install
```
$ composer require jawira/emoji-catalog
```
Contributing
------------
## Emoji sequences
If you liked this project, ⭐ star it on [GitHub].
An _emoji sequence_ is an emoji composed of other emojis. For example the
character "👨‍👩‍👧" is composed of five characters: _U+1F468 U+200D U+1F469
U+200D U+1F467_.
License
-------
You don't need to compose your emojis, _jawira/emoji-catalog_ comes with all
possible sequences as class constants:
```php
echo Emoji::FAMILY_MAN_WOMAN_GIRL; // 👨‍👩‍👧
```
## Contributing
- If you liked this project, ⭐ star it on [GitHub]
. [![GitHub Repo stars](https://img.shields.io/github/stars/jawira/emoji-catalog?style=social)][GitHub]
- Or follow me on
Twitter. [![Twitter Follow](https://img.shields.io/twitter/follow/jawira?style=social)](https://twitter.com/jawira)
## License
This library is licensed under the [MIT license](LICENSE.md).
[GitHub]: https://github.com/jawira/emoji-catalog
[full emoji list]: https://github.com/jawira/emoji-catalog/blob/master/docs/catalog.md
***
My other packages
-----------------
## Packages from jawira
<dl>
<dt><a href="https://packagist.org/packages/jawira/case-converter">jawira/case-converter</a> (library)</dt>
<dd>Convert strings between 13 naming conventions: Snake case, Camel case,
Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case,
Upper case, Lower case, Sentence case, Title case and Dot notation.
</dd>
<dt>
<a href="https://packagist.org/packages/jawira/plantuml">jawira/plantuml
<img alt="GitHub stars" src="https://badgen.net/github/stars/jawira/plantuml?icon=github"/></a>
</dt>
<dd>Provides PlantUML executable and plantuml.jar</dd>
<dt><a href="https://packagist.org/packages/jawira/phing-visualizer">jawira/phing-visualizer</a> (library)</dt>
<dd>Graphical representation of Phing's buildfile.</dd>
<dt>
<a href="https://packagist.org/packages/jawira/plantuml-encoding"> jawira/plantuml-encoding
<img alt="GitHub stars" src="https://badgen.net/github/stars/jawira/plantuml-encoding?icon=github"/></a>
</dt>
<dd>PlantUML encoding functions.</dd>
<dt><a href="https://packagist.org/packages/jawira/phing-open-task">jawira/phing-open-task</a> (library)</dt>
<dd>Phing task to open files, directories, and URLs with your favorite software.</dd>
<dt><a href="https://packagist.org/packages/jawira/plantuml">jawira/plantuml</a> (library)</dt>
<dd>Provides PlantUML integration: plantuml executable and plantuml.jar</dd>
<dt><a href="https://packagist.org/packages/jawira/plantuml-encoding">jawira/plantuml-encoding</a> (library)</dt>
<dd>PlantUML encoding functions.</dd>
<dt><a href="https://packagist.org/packages/jawira/process-maker">jawira/process-maker</a> (project)</dt>
<dd>Easily install and try ProcessMaker using Docker Compose.</dd>
<dt>
<a href="https://packagist.org/packages/jawira/case-converter">jawira/case-converter
<img alt="GitHub stars" src="https://badgen.net/github/stars/jawira/case-converter?icon=github"/></a>
</dt>
<dd>Convert strings between 13 naming conventions: Snake case, Camel case,
Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case,
Upper case, Lower case, Sentence case, Title case and Dot notation.
</dd>
<dt><a href="https://packagist.org/packages/jawira/">More...</a></dt>
</dl>

BIN
build.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 44 KiB

121
build.xml
View File

@ -1,34 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8"?>
<project name="jawira/emoji-catalog" default="help" phingVersion="3">
<project name="Emoji catalog" default="diagnostics">
<defaultexcludes default="true"/><!--Initializing default excludes-->
<defaultexcludes add="**/.idea"/>
<defaultexcludes add="**/.idea/**"/>
<property name="phing.http.proxy" value="${env.http_proxy}"/>
<property name="emoji.source" value="https://unicode.org/Public/emoji/15.0/emoji-test.txt"/>
<target name="diagnostics">
<diagnostics/>
</target>
<target name="setup" description="Prepare project for dev" depends="diagnostics, composer:install, phing:visualizer"/>
<target name="qa" description="Quality assurance" depends="composer:validate, php:lint"/>
<target name="update" description="Update Emoji.php" depends="emoji:download, emoji:parse, emoji:build"/>
<target name="setup" description="Prepare project for dev" depends="composer:install"/>
<target name="qa" description="Quality assurance"
depends="composer:normalize,composer:validate,php:lint,emoji:tests"/>
<target name="update" description="Update class and catalog"
depends="emoji:download-source,emoji:update,doc:update,emoji:count"/>
<target name="composer:validate" description="Validate composer.json">
<composer command="validate">
<arg value="--no-interaction"/>
<arg value="--profile"/>
<arg value="--strict"/>
<arg value="--quiet"/>
</composer>
</target>
<target name="phing:visualizer">
<visualizer/>
</target>
<target name="composer:install" description="Install for dev">
<composer command="install">
<arg value="--quiet"/>
<arg value="--no-suggest"/>
<arg value="--no-interaction"/>
<arg value="--profile"/>
@ -36,64 +31,70 @@
</composer>
</target>
<target name="git:tag-listing" description="List all git tags">
<!--https://stackoverflow.com/a/34239190/4345061-->
<exec executable="git" passthru="true">
<arg value="log"/>
<arg line="--graph --all --decorate --oneline --simplify-by-decoration"/>
</exec>
</target>
<target name="changelog:links" description="Update links in composer.json">
<composer command="require">
<arg value="symplify/changelog-linker"/>
</composer>
<exec executable="vendor/bin/changelog-linker">
<arg value="link"/>
</exec>
<composer command="remove">
<arg value="symplify/changelog-linker"/>
<target name="composer:normalize" description="Normalize composer.json">
<composer command="normalize">
<arg value="--ansi"/>
<arg value="--no-interaction"/>
<arg value="--diff"/>
<arg value="--indent-size=2"/>
<arg value="--indent-style=space"/>
</composer>
</target>
<target name="emoji:download">
<mkdir dir="resources/unicode/"/>
<httpget dir="resources/unicode/" url="https://unicode.org/emoji/charts/full-emoji-list.html"/>
<httpget dir="resources/unicode/" url="https://unicode.org/emoji/charts/full-emoji-modifiers.html"/>
<target name="emoji:download-source">
<mkdir dir="resources/unicode"/>
<httpget dir="resources/unicode" url="${emoji.source}"/>
</target>
<target name="emoji:parse">
<mkdir dir="resources/output"/>
<delete file="resources/output/full-emoji-list.txt"/>
<xslt file="resources/unicode/full-emoji-list.html"
tofile="resources/output/full-emoji-list.txt"
style="resources/xslt/emoji.xsl"
haltonerror="false"
overwrite="true"
html="true"/>
<delete file="resources/output/full-emoji-modifiers.txt"/>
<xslt file="resources/unicode/full-emoji-modifiers.html"
tofile="resources/output/full-emoji-modifiers.txt"
style="resources/xslt/emoji.xsl"
haltonerror="false"
overwrite="true"
html="true"/>
<target name="emoji:update" description="Generate Emoji class">
<autoloader autoloaderpath="vendor/autoload.php"/>
<taskdef name="emoji-update" classname="\Jawira\EmojiTask\EmojiUpdateTask"/>
<emoji-update/>
</target>
<target name="emoji:build">
<append file="resources/templates/header.php.dist" destFile="src/Emoji.php" append="false" overwrite="true"/>
<append file="resources/output/full-emoji-list.txt" destFile="src/Emoji.php"/>
<append file="resources/output/full-emoji-modifiers.txt" destFile="src/Emoji.php"/>
<append file="resources/templates/footer.php.dist" destFile="src/Emoji.php"/>
<target name="doc:update">
<autoloader autoloaderpath="vendor/autoload.php"/>
<taskdef name="catalog-update" classname="\Jawira\EmojiTask\CatalogUpdateTask"/>
<catalog-update/>
</target>
<target name="php:lint" description="Check PHP syntax">
<phplint deprecatedAsError="true">
<phplint deprecatedAsError="true" haltonfailure="true">
<fileset dir="src">
<include name="**/*.php"/>
</fileset>
</phplint>
</target>
<target name="emoji:tests" description="Test some fully-qualified emojis">
<autoloader autoloaderpath="vendor/autoload.php"/>
<php function="vanilla"/>
</target>
<target name="emoji:count" description="Count constants in Emoji class">
<autoloader autoloaderpath="vendor/autoload.php"/>
<adhoc-task name="emoji-count">
class EmojiCountTask extends \Phing\Task {
function main() {
$emojiReflection = new ReflectionClass(\Jawira\EmojiCatalog\Emoji::class);
$constants = $emojiReflection-&gt;getConstants();
$count = count($constants);
$this-&gt;log("Emoji count: $count");
$this-&gt;project-&gt;setProperty('emoji-count', $count);
}
}
</adhoc-task>
<emoji-count/>
</target>
<target name="help">
<uptodate property="uptodate.visualizer" srcfile="build.xml" targetfile="build.png"/>
<runtarget target="visualizer"/>
<open path="build.png"/>
</target>
<target name="visualizer" unless="uptodate.visualizer" description="Create buildfile map">
<visualizer/>
</target>
</project>

View File

@ -1,7 +1,8 @@
{
"name": "jawira/emoji-catalog",
"description": "Get access to +3600 emojis as class constants",
"license": "MIT",
"type": "library",
"description": "Get access to +3000 emojis as class constants",
"keywords": [
"emoji",
"emojis",
@ -11,24 +12,39 @@
"unicode",
"catalog"
],
"license": "MIT",
"authors": [
{
"name": "Jawira Portugal",
"email": "dev@tugal.be"
}
],
"require": {
"php": ">=5.6"
},
"require-dev": {},
"config": {
"preferred-install": "dist",
"sort-packages": true
"require-dev": {
"php": "^7.3 || ^8.0",
"ext-intl": "*",
"ext-mbstring": "*",
"ergebnis/composer-normalize": "^2.28",
"jawira/skeleton": "^2.16",
"phing/phing": "^2.17 || ^3"
},
"autoload": {
"psr-4": {
"Jawira\\EmojiCatalog\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Jawira\\EmojiTask\\": "tasks"
},
"files": [
"tests/vanilla.php"
]
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"platform-check": true,
"preferred-install": "dist",
"sort-packages": true
}
}

3661
docs/catalog.md Normal file

File diff suppressed because it is too large Load Diff

21
docs/dev.md Normal file
View File

@ -0,0 +1,21 @@
Dev notes
=========
Update emoji class
------------------
1. Run `$ phing setup update qa` and see if you had new emojis (you can also use
`$ phing emoji:count` before and after update)
2. Be aware that emojis can change its name without reason (ex: DIRECT_HIT →
BULLSEYE). This forces me to publish a major version 👎.
3. Update Readme: badges, emoji count, ...
4. Update CHANGELOG.md
Cleaning Emoji.php
------------------
Emoji.php is generated with descriptive comments for each constant.
The comments are striped later to [avoid impacting OP_CACHE in production
environments][issue-8].
[issue-8]: https://github.com/jawira/emoji-catalog/issues/8

View File

@ -1,32 +0,0 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="end" select="14"/>
<xsl:variable name="increment" select="1"/>
<xsl:template match="/">
<table>
<xsl:for-each select="//record">
<tr>
<xsl:variable name="start" select="1"/>
<xsl:call-template name="loop">
<xsl:with-param name="counter" select="$start"/>
</xsl:call-template>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="loop">
<xsl:param name="counter"/>
<xsl:if test="$counter &lt;= $end">
<td>
<xsl:value-of select="Merkmale/Product/Merkmal[@ColNo=$counter]/@Farbe"/>
</td>
<xsl:call-template name="loop">
<xsl:with-param name="counter" select="$counter + $increment"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,6 @@
# Emoji Catalog
This list contains all the _emojis_ from `\Jawira\EmojiCatalog\Emoji`.
| Name | Emoji | Code point(s) | `\Jawira\EmojiCatalog\Emoji::` |
| --------- | --------- | ------------- | ------------------------------- |

View File

@ -3,11 +3,8 @@
namespace Jawira\EmojiCatalog;
/**
* Class Emoji
*
* Get access to all emojis as class constants.
*
* @package Jawira\EmojiCatalog
* @author Jawira Portugal <dev@tugal.be>
*/
class Emoji

View File

@ -1,116 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="2.0" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:for-each select="//table//tr[./td//img]">
<xsl:text> /**&#10;</xsl:text>
<xsl:text> * </xsl:text>
<xsl:call-template name="get-name"/>
<xsl:text>&#10;</xsl:text>
<xsl:text> *&#10;</xsl:text>
<xsl:text> * Code point(s): </xsl:text>
<xsl:call-template name="get-code"/>
<xsl:text>&#10;</xsl:text>
<xsl:text> */&#10;</xsl:text>
<xsl:text> const </xsl:text>
<xsl:call-template name="get-constant-name"/>
<xsl:text> = "</xsl:text>
<xsl:call-template name="get-alt"/>
<xsl:text>";&#10;&#10;</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template name="get-code">
<xsl:value-of select="./td[2]//a/text()"/>
</xsl:template>
<xsl:template name="get-name">
<xsl:variable name="short-name" select="./td[last()]/text()"/>
<xsl:variable name="removable" select="'⊛⊖'"/>
<xsl:variable name="cleaned" select="translate($short-name, $removable, '')"/>
<xsl:value-of select="normalize-space($cleaned)"/>
</xsl:template>
<xsl:template name="get-alt">
<xsl:value-of select="./td[3]/text()"/>
</xsl:template>
<xsl:template name="get-constant-name">
<xsl:variable name="short-name" select="./td[last()]/text()"/>
<xsl:variable name="removable" select="':;.,⊛’!“”()⊖'"/>
<xsl:variable name="cleaned" select="translate($short-name, $removable, '')"/>
<xsl:variable name="lowercase" select="'Åãabcçdeéfghíijklmnoôpqrstuvwxyz-&amp;'"/>
<xsl:variable name="uppercase" select="'AAABCCDEEFGHIIJKLMNOOPQRSTUVWXYZ N'"/>
<xsl:variable name="no-accents" select="translate($cleaned, $lowercase, $uppercase)"/>
<xsl:variable name="normalized" select="normalize-space($no-accents)"/>
<xsl:variable name="no-spaces" select="translate($normalized, ' ', '_')"/>
<xsl:variable name="no-1st">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$no-spaces"/>
<xsl:with-param name="replace" select="'1ST'"/>
<xsl:with-param name="by" select="'FIRST'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="no-2nd">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$no-1st"/>
<xsl:with-param name="replace" select="'2ND'"/>
<xsl:with-param name="by" select="'SECOND'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="no-3rd">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$no-2nd"/>
<xsl:with-param name="replace" select="'3RD'"/>
<xsl:with-param name="by" select="'THIRD'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="no-number">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$no-3rd"/>
<xsl:with-param name="replace" select="'#'"/>
<xsl:with-param name="by" select="'NUMBER'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="no-asterisk">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$no-number"/>
<xsl:with-param name="replace" select="'*'"/>
<xsl:with-param name="by" select="'ASTERISK'"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$no-asterisk"/>
</xsl:template>
<!-- http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx -->
<xsl:template name="string-replace-all">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="by"/>
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$by"/>
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="by" select="$by"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
<?php declare(strict_types=1);
namespace Jawira\EmojiTask;
abstract class AbstractEmojiTask extends \Phing\Task
{
function codepointsToEmoji(string $codepoints): string
{
$codepointsArray = array_filter(explode(' ', $codepoints));
$reducer = function (string $carry, string $codepoint) {
return $carry . mb_chr(hexdec($codepoint), 'UTF-8');
};
return array_reduce($codepointsArray, $reducer, '');
}
function extractParts(string $line): ?array
{
preg_match('@^(?<CODEPOINTS>[0-9A-H\s]+); fully-qualified\s+#\s\S+\sE\d*\.\d*\s(?<NAME>.+)@', $line, $matches);
return empty($matches) ? null : $matches;
}
function normalizeEmojiName(string $emojiName): string
{
$rules = "'*' > asterisk ; '#' > number ; :: Any-Latin; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC; :: [^-[:^Punctuation:]] Remove; :: Upper(); [:^L:] { [-] > ; [-] } [:^L:] > ; [-[:Separator:]]+ > '_'; 1ST > FIRST ; 2ND > SECOND ; 3RD > THIRD ; ";
return \Transliterator::createFromRules($rules)->transliterate($emojiName);
}
}

View File

@ -0,0 +1,23 @@
<?php declare(strict_types=1);
namespace Jawira\EmojiTask;
use SplFileObject;
class CatalogUpdateTask extends AbstractEmojiTask
{
function main()
{
$file = new SplFileObject('docs/catalog.md', 'w+');
$file->fwrite(file_get_contents('resources/templates/catalog-header.md.dist'));
foreach (file('resources/unicode/emoji-test.txt') as $line) {
$matches = $this->extractParts($line);
if (!is_array($matches)) {
continue;
}
$emoji = $this->codepointsToEmoji($matches['CODEPOINTS']);
$constantName = $this->normalizeEmojiName($matches['NAME']);
$file->fwrite(sprintf("| %s | %s | %s | %s |%s", $matches['NAME'], $emoji, trim($matches['CODEPOINTS']), $constantName, PHP_EOL));
}
}
}

25
tasks/EmojiUpdateTask.php Normal file
View File

@ -0,0 +1,25 @@
<?php declare(strict_types=1);
namespace Jawira\EmojiTask;
use SplFileObject;
class EmojiUpdateTask extends AbstractEmojiTask
{
function main()
{
$file = new SplFileObject('src/Emoji.php', 'w+');
$file->fwrite(file_get_contents('resources/templates/emoji-header.php.dist'));
foreach (file('resources/unicode/emoji-test.txt') as $line) {
$matches = $this->extractParts($line);
if (!is_array($matches)) {
continue;
}
$emoji = $this->codepointsToEmoji($matches['CODEPOINTS']);
$constantName = $this->normalizeEmojiName($matches['NAME']);
$file->fwrite("const $constantName = '$emoji';" . PHP_EOL);
}
$file->fwrite(file_get_contents('resources/templates/emoji-footer.php.dist'));
}
}

32
tests/vanilla.php Normal file
View File

@ -0,0 +1,32 @@
<?php declare(strict_types=1);
use Jawira\EmojiCatalog\Emoji;
/**
* Simply test if some Emojis are respected.
*
* Since Emojis can have different names between versions, update tests accordingly.
*/
function vanilla()
{
$provider = [
'E0.6' => [Emoji::VICTORY_HAND, "\u{270C}\u{FE0F}"],
'E0.7' => [Emoji::MOUNTAIN, "\u{26F0}\u{FE0F}"],
'E1.0' => [Emoji::GRINNING_FACE, "\u{1F600}"],
'E2.0' => [Emoji::FLAG_EUROPEAN_UNION, "\u{1F1EA}\u{1F1FA}"],
'E3.0' => [Emoji::CALL_ME_HAND, "\u{1F919}"],
'E4.0' => [Emoji::FLAG_UNITED_NATIONS, "\u{1F1FA}\u{1F1F3}"],
'E13.1' => [Emoji::HEART_ON_FIRE, "\u{2764}\u{FE0F}\u{200D}\u{1F525}"],
'E15.0' => [Emoji::PINK_HEART, "\u{1FA77}"],
];
foreach ($provider as $key => $testCase) {
if ($testCase[0] !== $testCase[1]) {
throw new Exception("Test '$key' failed!");
}
echo $testCase[0];
}
$count = count($provider);
echo PHP_EOL, "All $count tests ok!", PHP_EOL;
}