update license and minor fix

master
Jean-Christian Paul Denis 2021-08-19 23:33:19 +02:00
parent 9ebc2c4f8f
commit e9274e5b43
6 changed files with 141 additions and 101 deletions

5
CHANGELOG.md 100644
View File

@ -0,0 +1,5 @@
simplyFavicon 2021.08.18
* update license
simplyFavicon 2011.04.08
* first version

31
README.md 100644
View File

@ -0,0 +1,31 @@
# README
## WHAT IS simplyFavicon ?
simplyFavicon is a plugin for the open-source
web publishing software called Dotclear.
.
## REQUIREMENTS
simplyFavicon requires:
* Administrator permissions
* Dotclear 2.18
* A readable public directory.
## USAGE
First install simplyFavicon, manualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this)
Add un file called ''favicon.xxx'' where xxx could be ico, jpg, png,
on your blog public root directory and
simplyFavicon add required code to public page to show favicon on browser.
## MORE
* License : GNU GPL v2
* Source & contribution : [GitHub Page](https://github.com/JcDenis/simplyFavicon)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/simplyFavicon)

View File

@ -1,17 +1,18 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of simplyFavicon, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2011 JC Denis and contributors
# jcdenis@gdwd.com
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return;
return;
}
$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
@ -19,21 +20,21 @@ $core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'admi
class adminSimplyFavicon
{
public static function adminBlogPreferencesForm($core, $blog_settings)
{
echo
'<div class="fieldset"><h4 id="simply_favicon_params">Favicon</h4>' .
'<p><label class="classic">' .
form::checkbox('simply_favicon', '1', (boolean) $blog_settings->system->simply_favicon) .
__('Enable "Simply favicon" extension') . '</label></p>' .
'<p class="form-note">' .
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") .
'</p>' .
'</div>';
}
public static function adminBeforeBlogSettingsUpdate($blog_settings)
{
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon']));
}
}
public static function adminBlogPreferencesForm($core, $blog_settings)
{
echo
'<div class="fieldset"><h4 id="simply_favicon_params">Favicon</h4>' .
'<p><label class="classic">' .
form::checkbox('simply_favicon', '1', (boolean) $blog_settings->system->simply_favicon) .
__('Enable "Simply favicon" extension') . '</label></p>' .
'<p class="form-note">' .
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") .
'</p>' .
'</div>';
}
public static function adminBeforeBlogSettingsUpdate($blog_settings)
{
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon']));
}
}

View File

@ -1,23 +1,24 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of simplyFavicon, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2011 JC Denis and contributors
# jcdenis@gdwd.com
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){
return;
return;
}
$this->registerModule(
/* Name */ "Simply favicon",
/* Description*/ "Multi-agents favicon",
/* Author */ "JC Denis",
/* Version */ '2021.08.16',
/* Permissions */ 'admin'
);
"Simply favicon",
"Multi-agents favicon",
"Jean-Christian Denis",
'2021.08.18',
'admin'
);

View File

@ -1,19 +1,20 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of simplyFavicon, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2011 JC Denis and contributors
# jcdenis@gdwd.com
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){
return;
return;
}
$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php';
$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']);
$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']);

View File

@ -1,84 +1,85 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of simplyFavicon, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2011 JC Denis and contributors
# jcdenis@gdwd.com
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){
return;
return;
}
$core->addBehavior('publicHeadContent', ['publicSimplyFavicon','publicHeadContent']);
$core->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']);
class publicSimplyFavicon extends dcUrlHandlers
{
public static $mimetypes = array(
'ico' => 'image/x-icon',
'png' => 'image/png',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'mng' => 'video/x-mng'
);
public static function simplyFaviconUrl($arg)
{
global $core;
$mimetypes = self::$mimetypes;
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
public static $mimetypes = array(
'ico' => 'image/x-icon',
'png' => 'image/png',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'mng' => 'video/x-mng'
);
public static function simplyFaviconUrl($arg)
{
global $core;
$mimetypes = self::$mimetypes;
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
if (!$core->blog->settings->system->simply_favicon
|| empty($arg)
|| !array_key_exists($arg, $mimetypes)
|| file_exists($public_path . 'favicon' . $arg)
) {
throw new Exception ("Page not found", 404);
}
else {
header('Content-Type: ' . $mimetypes[$arg] . ';');
readfile($public_path . $arg);
exit;
}
}
public static function publicHeadContent($core)
{
if (!$core->blog->settings->system->simply_favicon){
return;
}
$mimetypes = self::$mimetypes;
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
$public_url = $core->blog->url.$core->url->getBase('simplyFavicon') . '.';
// ico : IE6
if (file_exists($public_path . 'ico') && '?' != substr($core->blog->url, -1)) {
echo
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
}
// png: apple and others
if (file_exists($public_path . 'png')) {
echo
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
}
// all others
else {
foreach($mimetypes as $ext => $mime)
{
if (file_exists($public_path . $ext)) {
echo
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
break;
}
}
}
}
}
if (!$core->blog->settings->system->simply_favicon
|| empty($arg)
|| !array_key_exists($arg, $mimetypes)
|| file_exists($public_path . 'favicon' . $arg)
) {
throw new Exception ("Page not found", 404);
}
else {
header('Content-Type: ' . $mimetypes[$arg] . ';');
readfile($public_path . $arg);
exit;
}
}
public static function publicHeadContent($core)
{
if (!$core->blog->settings->system->simply_favicon){
return;
}
$mimetypes = self::$mimetypes;
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
$public_url = $core->blog->url.$core->url->getBase('simplyFavicon') . '.';
// ico : IE6
if (file_exists($public_path . 'ico') && '?' != substr($core->blog->url, -1)) {
echo
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
}
// png: apple and others
if (file_exists($public_path . 'png')) {
echo
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
}
// all others
else {
foreach($mimetypes as $ext => $mime)
{
if (file_exists($public_path . $ext)) {
echo
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
break;
}
}
}
}
}