From a4d6170fa8955ba25c566516ad0e1cb395b21e3b Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 17 Feb 2020 13:32:09 +0300 Subject: [PATCH] feat(icon-plugin): add Icon Plugin for Font Awesome icons collection #371 --- site/plugins/icon/LICENSE.txt | 21 ++++++++++ site/plugins/icon/README.md | 8 ++++ .../icon/app/Controllers/IconController.php | 36 +++++++++++++++++ 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 | 1 + .../shortcodes/IconShortcodeExtension.php | 17 ++++++++ site/plugins/icon/twig/IconTwigExtension.php | 36 +++++++++++++++++ 14 files changed, 262 insertions(+) create mode 100755 site/plugins/icon/LICENSE.txt create mode 100755 site/plugins/icon/README.md create mode 100644 site/plugins/icon/app/Controllers/IconController.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..f0fe6af3 --- /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 for Flextype. + +## LICENSE +[The MIT License (MIT)](https://github.com/flextype/flextype/blob/master/LICENSE.txt) +Copyright (c) 2018-2020 [Sergey Romanenko](https://github.com/Awilum) diff --git a/site/plugins/icon/app/Controllers/IconController.php b/site/plugins/icon/app/Controllers/IconController.php new file mode 100644 index 00000000..d6935e30 --- /dev/null +++ b/site/plugins/icon/app/Controllers/IconController.php @@ -0,0 +1,36 @@ +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 dependencies + */ +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..ef52dc23 --- /dev/null +++ b/site/plugins/icon/composer.json @@ -0,0 +1,34 @@ +{ + "name": "flextype-plugins/icon", + "type": "project", + "description": "Icon plugin 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..1ddbc65d --- /dev/null +++ b/site/plugins/icon/lang/en_US.yaml @@ -0,0 +1,2 @@ +icon: "Icon" +icon_description: "Icon plugin 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..1ddbc65d --- /dev/null +++ b/site/plugins/icon/lang/ru_RU.yaml @@ -0,0 +1,2 @@ +icon: "Icon" +icon_description: "Icon plugin for Flextype" diff --git a/site/plugins/icon/package.json b/site/plugins/icon/package.json new file mode 100644 index 00000000..7780ca59 --- /dev/null +++ b/site/plugins/icon/package.json @@ -0,0 +1,23 @@ +{ + "name": "Icon", + "version": "0.9.7", + "description": "Icon plugin for Flextype", + "homepage": "http://flextype.org", + "author": "Sergey Romanenko", + "license": "MIT", + "keywords": [ + "flextype", + "cms", + "flat cms", + "flatfile cms", + "css", + "html" + ], + "bugs": { + "url": "https://github.com/flextype/flextype/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..c0fd35ff --- /dev/null +++ b/site/plugins/icon/plugin.yaml @@ -0,0 +1,11 @@ +name: Icon +version: 0.9.7 +description: Icon plugin for Flextype +icon: fas fa-check-circle +author: + name: Sergey Romanenko + email: hello@romanenko.digital + url: http://flextype.org +homepage: https://github.com/flextype +bugs: https://github.com/flextype/issues +license: MIT diff --git a/site/plugins/icon/settings.yaml b/site/plugins/icon/settings.yaml new file mode 100644 index 00000000..d4ca9418 --- /dev/null +++ b/site/plugins/icon/settings.yaml @@ -0,0 +1 @@ +enabled: true diff --git a/site/plugins/icon/shortcodes/IconShortcodeExtension.php b/site/plugins/icon/shortcodes/IconShortcodeExtension.php new file mode 100644 index 00000000..10af1c52 --- /dev/null +++ b/site/plugins/icon/shortcodes/IconShortcodeExtension.php @@ -0,0 +1,17 @@ +addHandler('icon', static function (ShortcodeInterface $s) { + return IconController::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..4ace8955 --- /dev/null +++ b/site/plugins/icon/twig/IconTwigExtension.php @@ -0,0 +1,36 @@ + ['html']]) + ]; + } + + /** + * Get Icon + */ + public function icon(string $value) : string + { + return IconController::icon($value); + } +}