94 lines
2.9 KiB
PHP
94 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
* Copyright 2026, Dreytac <dreytac@hobbyhome.net>
|
|
*
|
|
* This file is part of Kirby Font Awesome.
|
|
*
|
|
* Kirby Font Awesome is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
*
|
|
* Kirby Font Awesome is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License along with Kirby Font Awesome. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
Kirby::plugin(
|
|
name: "hobbyhome/fontawesome",
|
|
extends: [
|
|
"options" => [
|
|
"defaultFamily" => "classic",
|
|
"defaultStyle" => "solid",
|
|
"assets" => [
|
|
"css" => [
|
|
150 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/fontawesome/css/fontawesome" . r(!option("debug"), ".min") . ".css", true),
|
|
151 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/fontawesome/css/regular" . r(!option("debug"), ".min") . ".css", true),
|
|
152 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/fontawesome/css/solid" . r(!option("debug"), ".min") . ".css", true),
|
|
153 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/fontawesome/css/brands" . r(!option("debug"), ".min") . ".css", true),
|
|
],
|
|
],
|
|
],
|
|
"hooks" => [
|
|
/**
|
|
* To add this hook to a plugin, change the option() call to use the plugins name.
|
|
*
|
|
* @version 1.0
|
|
*/
|
|
"hobbyhome.getAssets" => function ($files = [], $type = "css") {
|
|
foreach (option("hobbyhome.fontawesome.assets.{$type}", []) as $order => $file) {
|
|
# Make sure no other file exists with the current sort order index.
|
|
while (isset($files[$order])) {
|
|
$order++;
|
|
}
|
|
|
|
$files[$order] = $file;
|
|
}
|
|
|
|
return $files;
|
|
},
|
|
],
|
|
"tags" => [
|
|
"fa" => [
|
|
"attr" => [
|
|
"style",
|
|
"class",
|
|
"family",
|
|
"fastyle",
|
|
"title",
|
|
],
|
|
"html" => function ($tag) {
|
|
$html = "";
|
|
|
|
if ($tag->style) {
|
|
$html .= "<span style=\"{$tag->style}\">";
|
|
}
|
|
|
|
$html .= "<i" .
|
|
" class=\"" .
|
|
r($tag->class, $tag->class . " ") .
|
|
"fa-" . r($tag->family, $tag->family, option("hobbyhome.fontawesome.defaultFamily")) . " " .
|
|
"fa-" . r($tag->fastyle, $tag->fastyle, option("hobbyhome.fontawesome.defaultStyle")) . " " .
|
|
"fa-" . $tag->value .
|
|
"\"" .
|
|
r($tag->title, " title=\"{$tag->title}\"") .
|
|
"></i>";
|
|
|
|
if ($tag->style) {
|
|
$html .= "</span>";
|
|
}
|
|
|
|
return $html;
|
|
},
|
|
],
|
|
],
|
|
],
|
|
info: [
|
|
"authors" => [[
|
|
"name" => "Dreytac",
|
|
"email" => "dreytac@hobbyhome.net",
|
|
"homepage" => "https://hobbyhome.net",
|
|
]],
|
|
"license" => "AGPL-3.0-only",
|
|
"version" => "0.0.0",
|
|
# "bootstrap" => "7.2.0",
|
|
],
|
|
);
|