Create EmojiCatalog

This commit is contained in:
jawira 2019-08-30 21:22:51 +02:00
commit 1a7bc6fb85
17 changed files with 3572 additions and 0 deletions

20
.editorconfig Normal file
View File

@ -0,0 +1,20 @@
root = true
[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
[*.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

8
.gitattributes vendored Normal file
View File

@ -0,0 +1,8 @@
/.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

21
.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
/.makerc
/.idea/
/bin/behat
/bin/cc-test-reporter
/bin/composer
/bin/phing
/bin/phpcs
/bin/phpdoc
/bin/phpDocumentor
/bin/phploc
/bin/phpstan
/bin/phpunit
/bin/phpunit.phar
/composer-setup.php
/coverage/codeclimate.json
/site/
/vendor/
/resources/unicode/
/composer.lock
/resources/deleteme.txt
/resources/output/

View File

@ -0,0 +1,15 @@
<component name="ProjectDictionaryState">
<dictionary name="jawira">
<words>
<w>buildfile</w>
<w>emojis</w>
<w>gitattributes</w>
<w>gitignore</w>
<w>jawira</w>
<w>oneline</w>
<w>phing</w>
<w>plantuml</w>
<w>symplify</w>
</words>
</dictionary>
</component>

43
CHANGELOG.md Normal file
View File

@ -0,0 +1,43 @@
Changelog
=========
All notable changes to this project will be documented in this file.
<!--
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
-->
Unreleased
----------
### Added
- Added a change
<!---
Guiding Principles
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each versions is displayed.
Mention whether you follow Semantic Versioning.
Types of changes
### Added for new features.
### Changed for changes in existing functionality.
### Deprecated for soon-to-be removed features.
### Removed for now removed features.
### Fixed for any bug fixes.
### Security in case of vulnerabilities.
-->

51
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,51 @@
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/

25
LICENSE.md Normal file
View File

@ -0,0 +1,25 @@
The MIT License (MIT)
=====================
Copyright © `2019` `Jawira Portugal`
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

87
README.md Normal file
View File

@ -0,0 +1,87 @@
Emoji catalog 📔
==============
Get access to +3000 emojis as class constants.
Features:
- 🍼 Really easy to use
- 🔓 Zero dependencies
- 💪 A lot of emojis
[![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)
Usage
-----
You have access to emojis as `\Jawira\EmojiCatalog\Emoji` constants:
```php
<?php
use Jawira\EmojiCatalog\Emoji;
echo Emoji::GRINNING_FACE; // 😀
echo Emoji::SOCCER_BALL; // ⚽
echo Emoji::HOURGLASS_DONE; // ⌛
echo Emoji::EJECT_BUTTON; // ⏏
```
Your favorite IDE should give you autocomplete since you are calling class
constants:
![Autocomplete](docs/images/autocomplete.png)
How to install
--------------
```
$ composer require jawira/emoji-catalog
```
Contributing
------------
If you liked this project, ⭐ star it on [GitHub].
License
-------
This library is licensed under the [MIT license](LICENSE.md).
[GitHub]: https://github.com/jawira/emoji-catalog
***
My other packages
-----------------
<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/phing-visualizer">jawira/phing-visualizer</a> (library)</dt>
<dd>Graphical representation of Phing's buildfile.</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>
</dl>

BIN
build.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

99
build.xml Normal file
View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" ?>
<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}"/>
<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="composer:validate" description="Validate composer.json">
<composer command="validate">
<arg value="--no-interaction"/>
<arg value="--profile"/>
<arg value="--strict"/>
</composer>
</target>
<target name="phing:visualizer">
<visualizer/>
</target>
<target name="composer:install" description="Install for dev">
<composer command="install">
<arg value="--no-suggest"/>
<arg value="--no-interaction"/>
<arg value="--profile"/>
<arg value="--prefer-dist"/>
</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"/>
</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>
<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>
<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>
<target name="php:lint" description="Check PHP syntax">
<phplint deprecatedAsError="true">
<fileset dir="src">
<include name="**/*.php"/>
</fileset>
</phplint>
</target>
</project>

26
composer.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "jawira/emoji-catalog",
"type": "library",
"description": "Get access to +3000 emojis as class constants",
"license": "MIT",
"authors": [
{
"name": "Jawira Portugal",
"email": "dev@tugal.be"
}
],
"require": {
"php": ">=5.6"
},
"require-dev": {
},
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"autoload": {
"psr-4": {
"Jawira\\EmojiCatalog\\": "src"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -0,0 +1,32 @@
<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 @@
}

View File

@ -0,0 +1,14 @@
<?php
/**
* Class Emoji
*
* Get access to all emojis as class constants.
*
* @package Jawira\EmojiCatalog
* @author Jawira Portugal <dev@tugal.be>
*/
namespace Jawira\EmojiCatalog;
class Emoji
{

96
resources/xslt/emoji.xsl Normal file
View File

@ -0,0 +1,96 @@
<?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> const </xsl:text>
<xsl:call-template name="get-name"/>
<xsl:text> = "</xsl:text>
<xsl:call-template name="get-alt"/>
<xsl:text>";&#10;</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template name="get-alt">
<xsl:value-of select="./td[3]/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: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>

3034
src/Emoji.php Normal file

File diff suppressed because it is too large Load Diff