release 2023.10.13
This commit is contained in:
parent
d32c8525e7
commit
742692f9db
@ -1,3 +1,9 @@
|
||||
simplyFavicon 2023.10.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
simplyFavicon 2023.08.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
30
README.md
30
README.md
@ -1,26 +1,23 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-2023.10.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.13-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/simplyFavicon)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/simplyFavicon)](https://git.dotclear.watch/JcDenis/simplyFavicon/blob/master/LICENSE)
|
||||
|
||||
## WHAT IS simplyFavicon ?
|
||||
## ABOUT
|
||||
|
||||
_simplyFavicon_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_pacKman_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
It adds a favicon to your blog.
|
||||
> Add a favicon to your blog.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_simplyFavicon_ requires:
|
||||
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* A readable public directory
|
||||
* Administrator permissions
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
* A readable public directory.
|
||||
|
||||
## USAGE
|
||||
|
||||
@ -33,12 +30,13 @@ simplyFavicon add required code to public page to show favicon on browser.
|
||||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/simplyFavicon) or [GitHub Page](https://github.com/JcDenis/simplyFavicon)
|
||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/simplyFavicon)
|
||||
* [License](https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/simplyFavicon))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/simplyFavicon) (or on [GitHub](https://github.com/JcDenis/simplyFavicon))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/simplyFavicon/issues) (or on [GitHub](https://github.com/JcDenis/simplyFavicon/issues))
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (author)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
24
_define.php
24
_define.php
@ -10,9 +10,19 @@
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* @file
|
||||
* @brief The simplyFavicon pacKman definition
|
||||
* @ingroup simplyFavicon
|
||||
*
|
||||
* @defgroup simplyFavicon Plugin simplyFavicon.
|
||||
*
|
||||
* Multi-agents favicon.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'Simply favicon',
|
||||
@ -20,11 +30,9 @@ $this->registerModule(
|
||||
'Jean-Christian Denis',
|
||||
'2023.08.13',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'settings' => [
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'settings' => [
|
||||
'blog' => '#params.' . basename(__DIR__) . '_params',
|
||||
],
|
||||
'type' => 'plugin',
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="simplyFavicon">
|
||||
<name>Simply favicon</name>
|
||||
<version>2023.08.13</version>
|
||||
<version>2023.10.13</version>
|
||||
<author>Jean-Christian Denis</author>
|
||||
<desc>Multi-agents favicon</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.08.13/plugin-simplyFavicon.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.13/plugin-simplyFavicon.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/simplyFavicon/issues</da:support>
|
||||
</module>
|
||||
|
@ -1,21 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\simplyFavicon;
|
||||
|
||||
use dcCore;
|
||||
use dcSettings;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\BlogSettings;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
@ -26,6 +16,13 @@ use Dotclear\Helper\Html\Form\{
|
||||
Para
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief simplyFavicon backend class.
|
||||
* @ingroup simplyFavicon
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -39,18 +36,17 @@ class Backend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void {
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
App::behavior()->addBehaviors([
|
||||
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$exists = [];
|
||||
$path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), DC_ROOT);
|
||||
$path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), App::config()->dotclearRoot());
|
||||
foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) {
|
||||
if (file_exists($path . '/favicon.' . $ext)) {
|
||||
$url = dcCore::app()->blog->url . dcCore::app()->url->getURLFor('simplyFavicon', $ext);
|
||||
$url = App::blog()->url() . App::url()->getURLFor('simplyFavicon', $ext);
|
||||
$exists[] = '<li><a href="' . $url . '">' . $url . '</a></li>';
|
||||
}
|
||||
}
|
||||
@ -82,7 +78,7 @@ class Backend extends Process
|
||||
) .
|
||||
'</div></div><br class="clear" /></div>';
|
||||
},
|
||||
'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void {
|
||||
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
|
||||
$blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon']));
|
||||
},
|
||||
]);
|
||||
|
@ -1,23 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\simplyFavicon;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\File\Path;
|
||||
|
||||
/**
|
||||
* @brief simplyFavicon frontend class.
|
||||
* @ingroup simplyFavicon
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -31,16 +28,16 @@ class Frontend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('publicHeadContent', function (): void {
|
||||
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get('system')->get('simply_favicon')) {
|
||||
App::behavior()->addBehavior('publicHeadContent', function (): void {
|
||||
if (!App::blog()->isDefined() || !App::blog()->settings()->get('system')->get('simply_favicon')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT) . '/favicon.';
|
||||
$public_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('simplyFavicon') . '.';
|
||||
$public_path = Path::fullFromRoot(App::blog()->settings()->get('system')->get('public_path'), App::config()->dotclearRoot()) . '/favicon.';
|
||||
$public_url = App::blog()->url() . App::url()->getBase('simplyFavicon') . '.';
|
||||
|
||||
// ico : IE6
|
||||
if (file_exists($public_path . 'ico') && '?' != substr(dcCore::app()->blog->url, -1)) {
|
||||
if (file_exists($public_path . 'ico') && '?' != substr(App::blog()->url(), -1)) {
|
||||
echo
|
||||
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
|
||||
}
|
||||
@ -49,7 +46,7 @@ class Frontend extends Process
|
||||
echo
|
||||
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
|
||||
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
|
||||
// all others
|
||||
// all others
|
||||
} else {
|
||||
foreach (UrlHandler::$mimetypes as $ext => $mime) {
|
||||
if (in_array($ext, ['ico', 'png'])) {
|
||||
|
33
src/My.php
33
src/My.php
@ -1,21 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\simplyFavicon;
|
||||
|
||||
use Dotclear\App;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief simplyFavicon My helper.
|
||||
* @ingroup simplyFavicon
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
protected static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return match ($context) {
|
||||
// Limit BACKEND to admin
|
||||
self::BACKEND => App::task()->checkContext('BACKEND')
|
||||
&& App::blog()->isDefined()
|
||||
&& App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_ADMIN,
|
||||
]), App::blog()->id()),
|
||||
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\simplyFavicon;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief simplyFavicon prepend class.
|
||||
* @ingroup simplyFavicon
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -30,11 +27,11 @@ class Prepend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->url->register(
|
||||
App::url()->register(
|
||||
'simplyFavicon',
|
||||
'favicon',
|
||||
'^favicon.(.*?)$',
|
||||
[UrlHandler::class, 'simplyFaviconUrl']
|
||||
UrlHandler::simplyFaviconUrl(...)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
@ -1,25 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\simplyFavicon;
|
||||
|
||||
use dcCore;
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Url;
|
||||
use Dotclear\Helper\File\Path;
|
||||
|
||||
class UrlHandler extends dcUrlHandlers
|
||||
/**
|
||||
* @brief simplyFavicon frontend URL handler.
|
||||
* @ingroup simplyFavicon
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class UrlHandler extends Url
|
||||
{
|
||||
/**
|
||||
* Mime types.
|
||||
*
|
||||
* @var array<string,string> $mimetypes
|
||||
*/
|
||||
public static array $mimetypes = [
|
||||
'ico' => 'image/x-icon',
|
||||
'png' => 'image/png',
|
||||
@ -31,14 +33,13 @@ class UrlHandler extends dcUrlHandlers
|
||||
|
||||
public static function simplyFaviconUrl(string $arg): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT);
|
||||
$public_path = Path::fullFromRoot(App::blog()->settings()->get('system')->get('public_path'), App::config()->dotclearRoot());
|
||||
|
||||
if (dcCore::app()->blog->settings->get('system')->get('simply_favicon')
|
||||
if (App::blog()->settings()->get('system')->get('simply_favicon')
|
||||
&& !empty($arg)
|
||||
&& array_key_exists($arg, self::$mimetypes)
|
||||
&& file_exists($public_path . '/favicon.' . $arg)
|
||||
|
Loading…
Reference in New Issue
Block a user