From 3bd095c66fb1504dcedd25ddebd889d4a6383681 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 14 Mar 2020 20:34:21 +0300 Subject: [PATCH] refactor(core): revert back icon plugin from flextype core #414 --- site/plugins/icon/LICENSE.txt | 21 +++++++++ site/plugins/icon/README.md | 8 ++++ site/plugins/icon/app/Models/Icon.php | 45 +++++++++++++++++++ site/plugins/icon/bootstrap.php | 40 +++++++++++++++++ site/plugins/icon/composer.json | 34 ++++++++++++++ site/plugins/icon/dependencies.php | 15 +++++++ site/plugins/icon/gulpfile.js | 16 +++++++ site/plugins/icon/lang/en_US.yaml | 2 + site/plugins/icon/lang/ru_RU.yaml | 2 + site/plugins/icon/package.json | 23 ++++++++++ site/plugins/icon/plugin.yaml | 11 +++++ site/plugins/icon/settings.yaml | 2 + .../shortcodes/IconShortcodeExtension.php | 17 +++++++ site/plugins/icon/twig/IconTwigExtension.php | 36 +++++++++++++++ 14 files changed, 272 insertions(+) create mode 100755 site/plugins/icon/LICENSE.txt create mode 100755 site/plugins/icon/README.md create mode 100644 site/plugins/icon/app/Models/Icon.php create mode 100644 site/plugins/icon/bootstrap.php create mode 100644 site/plugins/icon/composer.json create mode 100644 site/plugins/icon/dependencies.php create mode 100755 site/plugins/icon/gulpfile.js create mode 100755 site/plugins/icon/lang/en_US.yaml create mode 100755 site/plugins/icon/lang/ru_RU.yaml create mode 100644 site/plugins/icon/package.json create mode 100755 site/plugins/icon/plugin.yaml create mode 100644 site/plugins/icon/settings.yaml create mode 100644 site/plugins/icon/shortcodes/IconShortcodeExtension.php create mode 100644 site/plugins/icon/twig/IconTwigExtension.php diff --git a/site/plugins/icon/LICENSE.txt b/site/plugins/icon/LICENSE.txt new file mode 100755 index 00000000..f628cc1e --- /dev/null +++ b/site/plugins/icon/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018-2020 Sergey Romanenko + +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. diff --git a/site/plugins/icon/README.md b/site/plugins/icon/README.md new file mode 100755 index 00000000..e98087c1 --- /dev/null +++ b/site/plugins/icon/README.md @@ -0,0 +1,8 @@ +# Icon Plugin for [Flextype](http://flextype.org/) +![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square) + +Icon plugin to present Font Awesome icons set for Flextype. + +## LICENSE +[The MIT License (MIT)](https://github.com/flextype-plugins/icon/blob/master/LICENSE.txt) +Copyright (c) 2018-2020 [Sergey Romanenko](https://github.com/Awilum) diff --git a/site/plugins/icon/app/Models/Icon.php b/site/plugins/icon/app/Models/Icon.php new file mode 100644 index 00000000..44e0504d --- /dev/null +++ b/site/plugins/icon/app/Models/Icon.php @@ -0,0 +1,45 @@ +composer install for icon plugin'); + +/** + * Register The Auto Loader + * + * Composer provides a convenient, automatically generated class loader for + * our application. We just need to utilize it! We'll simply require it + * into the script here so that we don't have to worry about manual + * loading any of our classes later on. It feels nice to relax. + * Register The Auto Loader + */ +$form_loader = require_once $form_autoload; + +/** + * Include shortcodes + */ +include_once 'shortcodes/IconShortcodeExtension.php'; + +/** + * Include dependencies + */ +include_once 'dependencies.php'; diff --git a/site/plugins/icon/composer.json b/site/plugins/icon/composer.json new file mode 100644 index 00000000..a87eaa6a --- /dev/null +++ b/site/plugins/icon/composer.json @@ -0,0 +1,34 @@ +{ + "name": "flextype-plugins/icon", + "type": "project", + "description": "Icon plugin to present Font Awesome icons set for Flextype.", + "keywords": ["icon", "plugin", "flextype", "php", "html"], + "homepage": "https://github.com/flextype", + "license": "MIT", + "authors": [ + { + "name": "Sergey Romanenko", + "email": "hello@romanenko.digital", + "homepage": "http://digital.flextype.org" + } + ], + "support": { + "issues": "https://github.com/flextype/issues" + }, + "require": { + "php": ">=7.2.0" + }, + "config": { + "apcu-autoloader": true, + "optimize-autoloader": true, + "platform": { + "php": "7.2.0" + } + }, + "autoload": { + "classmap": [ + "app", + "twig" + ] + } +} diff --git a/site/plugins/icon/dependencies.php b/site/plugins/icon/dependencies.php new file mode 100644 index 00000000..bb0adc8e --- /dev/null +++ b/site/plugins/icon/dependencies.php @@ -0,0 +1,15 @@ +view->addExtension(new IconTwigExtension($flextype)); diff --git a/site/plugins/icon/gulpfile.js b/site/plugins/icon/gulpfile.js new file mode 100755 index 00000000..4c1f2aeb --- /dev/null +++ b/site/plugins/icon/gulpfile.js @@ -0,0 +1,16 @@ +const gulp = require('gulp'); + +/** + * Task: gulp fontawesome-icons + */ +gulp.task('fontawesome-icons', function(){ + return gulp.src(['node_modules/@fortawesome/fontawesome-free/svgs/**/*']) + .pipe(gulp.dest('assets/dist/fontawesome/svgs')); +}); + +/** + * Task: gulp default + */ +gulp.task('default', gulp.series( + 'fontawesome-icons' +)); diff --git a/site/plugins/icon/lang/en_US.yaml b/site/plugins/icon/lang/en_US.yaml new file mode 100755 index 00000000..71277702 --- /dev/null +++ b/site/plugins/icon/lang/en_US.yaml @@ -0,0 +1,2 @@ +icon: "Icon" +icon_description: "Icon plugin to present Font Awesome icons set for Flextype." diff --git a/site/plugins/icon/lang/ru_RU.yaml b/site/plugins/icon/lang/ru_RU.yaml new file mode 100755 index 00000000..71277702 --- /dev/null +++ b/site/plugins/icon/lang/ru_RU.yaml @@ -0,0 +1,2 @@ +icon: "Icon" +icon_description: "Icon plugin to present Font Awesome icons set for Flextype." diff --git a/site/plugins/icon/package.json b/site/plugins/icon/package.json new file mode 100644 index 00000000..f201ba4d --- /dev/null +++ b/site/plugins/icon/package.json @@ -0,0 +1,23 @@ +{ + "name": "Icon", + "version": "1.0.0", + "description": "Icon plugin to present Font Awesome icons set for Flextype.", + "homepage": "http://flextype.org", + "author": "Sergey Romanenko", + "license": "MIT", + "keywords": [ + "flextype", + "cms", + "flat cms", + "flatfile cms", + "plugin", + "icon" + ], + "bugs": { + "url": "https://github.com/flextype-plugins/icon/issues" + }, + "dependencies": { + "@fortawesome/fontawesome-free": "5.12.1", + "gulp": "4.0.2" + } +} diff --git a/site/plugins/icon/plugin.yaml b/site/plugins/icon/plugin.yaml new file mode 100755 index 00000000..df911180 --- /dev/null +++ b/site/plugins/icon/plugin.yaml @@ -0,0 +1,11 @@ +name: Icon +version: 1.0.0 +description: Icon plugin to present Font Awesome icons set for Flextype. +icon: fab fa-font-awesome-flag +author: + name: Sergey Romanenko + email: support@flextype.org + url: http://flextype.org +homepage: https://github.com/flextype-plugins/icon +bugs: https://github.com/flextype-plugins/icon/issues +license: MIT diff --git a/site/plugins/icon/settings.yaml b/site/plugins/icon/settings.yaml new file mode 100644 index 00000000..93f33599 --- /dev/null +++ b/site/plugins/icon/settings.yaml @@ -0,0 +1,2 @@ +# enabled: true or false to disable the plugin +enabled: true diff --git a/site/plugins/icon/shortcodes/IconShortcodeExtension.php b/site/plugins/icon/shortcodes/IconShortcodeExtension.php new file mode 100644 index 00000000..5408a720 --- /dev/null +++ b/site/plugins/icon/shortcodes/IconShortcodeExtension.php @@ -0,0 +1,17 @@ +addHandler('icon', static function (ShortcodeInterface $s) { + return Icon::icon($s->getParameter('value')); +}); diff --git a/site/plugins/icon/twig/IconTwigExtension.php b/site/plugins/icon/twig/IconTwigExtension.php new file mode 100644 index 00000000..9a3a63a1 --- /dev/null +++ b/site/plugins/icon/twig/IconTwigExtension.php @@ -0,0 +1,36 @@ + ['html']]) + ]; + } + + /** + * Get Icon + */ + public function icon(string $value) : string + { + return Icon::icon($value); + } +}