Compare commits

..

No commits in common. "master" and "v2023.08.13" have entirely different histories.

9 changed files with 122 additions and 117 deletions

View File

@ -1,16 +1,3 @@
simplyFavicon 2023.10.20
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix use of interface
* Use default permissions
simplyFavicon 2023.10.14
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
simplyFavicon 2023.08.13 simplyFavicon 2023.08.13
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View File

@ -1,23 +1,26 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.10.20-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) [![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.10.20-c44d58.svg) [![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.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/simplyFavicon) [![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) [![License](https://img.shields.io/github/license/JcDenis/simplyFavicon)](https://git.dotclear.watch/JcDenis/simplyFavicon/blob/master/LICENSE)
## ABOUT ## WHAT IS simplyFavicon ?
_simplyFavicon_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). _simplyFavicon_ is a plugin for the open-source
web publishing software called Dotclear.
> Add a favicon to your blog. It adds a favicon to your blog.
## REQUIREMENTS ## REQUIREMENTS
* Dotclear 2.28 _simplyFavicon_ requires:
* PHP 8.1+
* A readable public directory * Administrator permissions
* Dotclear admin permissions * Dotclear 2.27
* PHP 7.4+
* A readable public directory.
## USAGE ## USAGE
@ -30,13 +33,12 @@ simplyFavicon add required code to public page to show favicon on browser.
## LINKS ## LINKS
* [License](https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/LICENSE) * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* [Packages & details](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/simplyFavicon)) * Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/simplyFavicon) or [GitHub Page](https://github.com/JcDenis/simplyFavicon)
* [Sources & contributions](https://git.dotclear.watch/JcDenis/simplyFavicon) (or on [GitHub](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)
* [Issues & security](https://git.dotclear.watch/JcDenis/simplyFavicon/issues) (or on [GitHub](https://github.com/JcDenis/simplyFavicon/issues))
## CONTRIBUTORS ## CONTRIBUTORS
* Jean-Christian Denis (author) * Jean-Christian Denis
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -1,27 +1,32 @@
<?php <?php
/** /**
* @file * @brief simplyFavicon, a plugin for Dotclear 2
* @brief The simplyFavicon pacKman definition
* @ingroup simplyFavicon
* *
* @defgroup simplyFavicon Plugin simplyFavicon. * @package Dotclear
* * @subpackage Plugin
* Multi-agents favicon.
* *
* @author Jean-Christian Denis * @author Jean-Christian Denis
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
declare(strict_types=1); if (!defined('DC_RC_PATH')) {
return;
}
$this->registerModule( $this->registerModule(
'Simply favicon', 'Simply favicon',
'Multi-agents favicon', 'Multi-agents favicon',
'Jean-Christian Denis', 'Jean-Christian Denis',
'2023.10.20', '2023.08.13',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.27']],
'permissions' => 'My', 'permissions' => dcCore::app()->auth->makePermissions([
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'], dcCore::app()->auth::PERMISSION_ADMIN,
]),
'settings' => [
'blog' => '#params.' . basename(__DIR__) . '_params',
],
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="simplyFavicon"> <module id="simplyFavicon">
<name>Simply favicon</name> <name>Simply favicon</name>
<version>2023.10.20</version> <version>2023.08.13</version>
<author>Jean-Christian Denis</author> <author>Jean-Christian Denis</author>
<desc>Multi-agents favicon</desc> <desc>Multi-agents favicon</desc>
<file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.20/plugin-simplyFavicon.zip</file> <file>https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.08.13/plugin-simplyFavicon.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/README.md</da:details> <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> <da:support>https://git.dotclear.watch/JcDenis/simplyFavicon/issues</da:support>
</module> </module>

View File

@ -1,10 +1,21 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App; use dcCore;
use dcSettings;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\File\Path; use Dotclear\Helper\File\Path;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
@ -14,15 +25,7 @@ use Dotclear\Helper\Html\Form\{
Note, Note,
Para Para
}; };
use Dotclear\Interface\Core\BlogSettingsInterface;
/**
* @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 class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -36,17 +39,18 @@ class Backend extends Process
return false; return false;
} }
App::behavior()->addBehaviors([ dcCore::app()->addBehaviors([
'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void { 'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void {
if (!App::blog()->isDefined()) { // nullsafe
if (is_null(dcCore::app()->blog)) {
return; return;
} }
$exists = []; $exists = [];
$path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), App::config()->dotclearRoot()); $path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), DC_ROOT);
foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) { foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) {
if (file_exists($path . '/favicon.' . $ext)) { if (file_exists($path . '/favicon.' . $ext)) {
$url = App::blog()->url() . App::url()->getURLFor('simplyFavicon', $ext); $url = dcCore::app()->blog->url . dcCore::app()->url->getURLFor('simplyFavicon', $ext);
$exists[] = '<li><a href="' . $url . '">' . $url . '</a></li>'; $exists[] = '<li><a href="' . $url . '">' . $url . '</a></li>';
} }
} }
@ -78,7 +82,7 @@ class Backend extends Process
) . ) .
'</div></div><br class="clear" /></div>'; '</div></div><br class="clear" /></div>';
}, },
'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void { 'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void {
$blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon'])); $blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon']));
}, },
]); ]);

View File

@ -1,20 +1,23 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\File\Path; 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 class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -28,16 +31,16 @@ class Frontend extends Process
return false; return false;
} }
App::behavior()->addBehavior('publicHeadContent', function (): void { dcCore::app()->addBehavior('publicHeadContent', function (): void {
if (!App::blog()->isDefined() || !App::blog()->settings()->get('system')->get('simply_favicon')) { if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get('system')->get('simply_favicon')) {
return; return;
} }
$public_path = Path::fullFromRoot(App::blog()->settings()->get('system')->get('public_path'), App::config()->dotclearRoot()) . '/favicon.'; $public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT) . '/favicon.';
$public_url = App::blog()->url() . App::url()->getBase('simplyFavicon') . '.'; $public_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('simplyFavicon') . '.';
// ico : IE6 // ico : IE6
if (file_exists($public_path . 'ico') && '?' != substr(App::blog()->url(), -1)) { if (file_exists($public_path . 'ico') && '?' != substr(dcCore::app()->blog->url, -1)) {
echo echo
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n"; '<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
} }

View File

@ -1,19 +1,21 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\Module\MyPlugin; 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 class My extends MyPlugin
{ {
// Use default permissions
} }

View File

@ -1,19 +1,22 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; 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 class Prepend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -27,11 +30,11 @@ class Prepend extends Process
return false; return false;
} }
App::url()->register( dcCore::app()->url->register(
'simplyFavicon', 'simplyFavicon',
'favicon', 'favicon',
'^favicon.(.*?)$', '^favicon.(.*?)$',
UrlHandler::simplyFaviconUrl(...) [UrlHandler::class, 'simplyFaviconUrl']
); );
return true; return true;

View File

@ -1,27 +1,25 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\simplyFavicon; namespace Dotclear\Plugin\simplyFavicon;
use Dotclear\App; use dcCore;
use Dotclear\Core\Frontend\Url; use dcUrlHandlers;
use Dotclear\Helper\File\Path; 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 = [ public static array $mimetypes = [
'ico' => 'image/x-icon', 'ico' => 'image/x-icon',
'png' => 'image/png', 'png' => 'image/png',
@ -33,13 +31,14 @@ class UrlHandler extends Url
public static function simplyFaviconUrl(string $arg): void public static function simplyFaviconUrl(string $arg): void
{ {
if (!App::blog()->isDefined()) { // nullsafe
if (is_null(dcCore::app()->blog)) {
return; return;
} }
$public_path = Path::fullFromRoot(App::blog()->settings()->get('system')->get('public_path'), App::config()->dotclearRoot()); $public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT);
if (App::blog()->settings()->get('system')->get('simply_favicon') if (dcCore::app()->blog->settings->get('system')->get('simply_favicon')
&& !empty($arg) && !empty($arg)
&& array_key_exists($arg, self::$mimetypes) && array_key_exists($arg, self::$mimetypes)
&& file_exists($public_path . '/favicon.' . $arg) && file_exists($public_path . '/favicon.' . $arg)