1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-15 01:24:25 +02:00

refactor(core): remove icon plugin from flextype core #414

This commit is contained in:
Awilum
2020-03-13 17:06:13 +03:00
parent a84d29f55c
commit 3397929176
14 changed files with 0 additions and 272 deletions

View File

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

View File

@@ -1,8 +0,0 @@
# 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)

View File

@@ -1,45 +0,0 @@
<?php
declare(strict_types=1);
/**
* @link http://digital.flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Flextype\Component\Filesystem\Filesystem;
class IconController extends Controller
{
public static function icon($value)
{
$icon_parts = explode(" ", $value);
if ($icon_parts[0] == 'fas') {
$icon_category = 'solid';
} elseif ($icon_parts[0] == 'fab') {
$icon_category = 'brands';
} elseif ($icon_parts[0] == 'far') {
$icon_category = 'regular';
} else {
$icon_category = 'regular';
}
$icon_name = str_replace("fa-", "", $icon_parts[1]);
$icon_file_path = PATH['plugins'] . '/icon/assets/dist/fontawesome/svgs/' . $icon_category . '/' . $icon_name . '.svg';
$icon_fallback_file_path = PATH['plugins'] . '/icon/assets/dist/fontawesome/svgs/regular/file-alt.svg';
if (Filesystem::has($icon_file_path)) {
$icon = Filesystem::read($icon_file_path);
} else {
$icon = Filesystem::read($icon_fallback_file_path);
}
return $icon;
}
}

View File

@@ -1,40 +0,0 @@
<?php
declare(strict_types=1);
/**
* @link http://digital.flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use function is_file;
/**
* Ensure vendor libraries exist
*/
! is_file($form_autoload = __DIR__ . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> 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';

View File

@@ -1,34 +0,0 @@
{
"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"
]
}
}

View File

@@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
/**
* @link http://digital.flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
// Add Icon Twig Extension
$flextype->view->addExtension(new IconTwigExtension($flextype));

View File

@@ -1,16 +0,0 @@
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'
));

View File

@@ -1,2 +0,0 @@
icon: "Icon"
icon_description: "Icon plugin for Flextype"

View File

@@ -1,2 +0,0 @@
icon: "Icon"
icon_description: "Icon plugin for Flextype"

View File

@@ -1,23 +0,0 @@
{
"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"
}
}

View File

@@ -1,11 +0,0 @@
name: Icon
version: 0.9.7
description: Icon plugin for Flextype
icon: fab fa-font-awesome-flag
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

View File

@@ -1,2 +0,0 @@
# enabled: true or false to disable the plugin
enabled: true

View File

@@ -1,17 +0,0 @@
<?php
declare(strict_types=1);
/**
* Flextype (http://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [icon value="fab fa-apple"]
$flextype['shortcodes']->addHandler('icon', static function (ShortcodeInterface $s) {
return IconController::icon($s->getParameter('value'));
});

View File

@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
/**
* Flextype (http://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype;
use Twig_Extension;
use Twig_SimpleFunction;
class IconTwigExtension extends Twig_Extension
{
/**
* Callback for twig.
*
* @return array
*/
public function getFunctions() : array
{
return [
new Twig_SimpleFunction('icon', [$this, 'icon'], ['is_safe' => ['html']])
];
}
/**
* Get Icon
*/
public function icon(string $value) : string
{
return IconController::icon($value);
}
}