Compare commits

...

2 Commits

Author SHA1 Message Date
Jean-Christian Paul Denis ef32e07197
release 1.3 2023-08-13 22:00:34 +02:00
Jean-Christian Paul Denis 956da8a211
use My class 2023-08-13 21:59:23 +02:00
6 changed files with 115 additions and 80 deletions

View File

@ -1,34 +1,49 @@
1.2 - 2023.07.30 tinyPacker 1.3 - 2023.08.13
- require Dotclear 2.26 ===========================================================
- require PHP 7.4+ * Require Dotclear 2.27
- update to Dotclear 2.27-dev * Require PHP 7.4
* Move third party repository
* Use Dotclear style for CHANGELOG
1.1.1 - 2023..04.23 tinyPacker 1.2 - 2023.07.30
- require Dotclear 2.26 ===========================================================
- use latest dotclear namespace * require Dotclear 2.26
- fix nullsafe warnings * require PHP 7.4+
* update to Dotclear 2.27-dev
1.1 - 2023.03.21 tinyPacker 1.1.1 - 2023..04.23
- require Dotclear 2.26 ===========================================================
- use dcNsProcess * require Dotclear 2.26
- use new Zip Helper * use latest dotclear namespace
- use new Behaviors methods * fix nullsafe warnings
- add translation
1.0 - 2022.12.23 tinyPacker 1.1 - 2023.03.21
- use anonymous functions ===========================================================
- use namesapce * require Dotclear 2.26
- use abstract plugin id * use dcNsProcess
* use new Zip Helper
* use new Behaviors methods
* add translation
0.5 - 2022.11.20 tinyPacker 1.0 - 2022.12.23
- fix compatibility with Dotclear 2.24 (required) ===========================================================
* use anonymous functions
* use namesapce
* use abstract plugin id
0.4 - 2021.09.02 tinyPacker 0.5 - 2022.11.20
- clean up code ===========================================================
- add dcstore.xml * fix compatibility with Dotclear 2.24 (required)
0.3 - 2021.08.18 tinyPacker 0.4 - 2021.09.02
- cleaned code and adopt PSR2 ===========================================================
* clean up code
* add dcstore.xml
0.1 - 2010.10.22 tinyPacker 0.3 - 2021.08.18
- first version ===========================================================
* cleaned code and adopt PSR2
tinyPacker 0.1 - 2010.10.22
===========================================================
* first version

View File

@ -1,11 +1,10 @@
# README # README
[![Release](https://img.shields.io/github/v/release/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases) [![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/tinyPacker/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases) [![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/tinyPacker/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/issues) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/tinyPacker)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/tinyPacker) [![License](https://img.shields.io/github/license/JcDenis/tinyPacker)](https://git.dotclear.watch/JcDenis/tinyPacker/blob/master/LICENSE)
[![License](https://img.shields.io/github/license/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/blob/master/LICENSE)
## WHAT IS tinyPacker ? ## WHAT IS tinyPacker ?
@ -19,10 +18,10 @@ direct from Dotclear blog manager.
_tinyPacker_ requires: _tinyPacker_ requires:
* Super administrator permissions * Super administrator permissions
* A writable public directory. * A writable public directory.
* Dotclear 2.27 * Dotclear 2.27
* PHP 7.4+ * PHP 7.4+
## USAGE ## USAGE
@ -35,12 +34,12 @@ and it's pack into current blog public directory.
## MORE ## MORE
* License : GNU GPL v2 * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [GitHub Page](https://github.com/JcDenis/tinyPacker) * Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/tinyPacker) or [GitHub Page](https://github.com/JcDenis/tinyPacker)
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/tinyPacker) * Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/tinyPacker/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/tinyPacker)
## CONTRIBUTORS ## CONTRIBUTORS
* Jean-Christian Denis * Jean-Christian Denis
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -18,13 +18,13 @@ $this->registerModule(
'Tiny packer', 'Tiny packer',
'Quick pack theme or plugin into public dir', 'Quick pack theme or plugin into public dir',
'Jean-Christian Denis', 'Jean-Christian Denis',
'1.2', '1.3',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.27']],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__), 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__), 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml', 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
] ]
); );

View File

@ -2,12 +2,12 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="tinyPacker"> <module id="tinyPacker">
<name>Tiny packer</name> <name>Tiny packer</name>
<version>1.2</version> <version>1.3</version>
<author>Jean-Christian Denis</author> <author>Jean-Christian Denis</author>
<desc>Quick pack theme or plugin into public dir</desc> <desc>Quick pack theme or plugin into public dir</desc>
<file>https://github.com/JcDenis/tinyPacker/releases/download/v1.2/plugin-tinyPacker.zip</file> <file>https://git.dotclear.watch/JcDenis/tinyPacker/releases/download/v1.3/plugin-tinyPacker.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/tinyPacker</da:details> <da:details>https://git.dotclear.watch/JcDenis/tinyPacker/src/branch/master/README.md</da:details>
<da:support>https://github.com/JcDenis/tinyPacker</da:support> <da:support>https://git.dotclear.watch/JcDenis/tinyPacker/issues</da:support>
</module> </module>
</modules> </modules>

View File

@ -33,27 +33,9 @@ use Exception;
*/ */
class Backend extends Process class Backend extends Process
{ {
/** @var string Public packages folder */
public const TINYPACKER_DIR = 'packages';
/** @var array Excluded files and dirs */
public const TINYPACKER_EXCLUDE = [
'\.',
'\.\.',
'__MACOSX',
'\.svn',
'\.hg.*?',
'\.git.*?',
'CVS',
'\.directory',
'\.DS_Store',
'Thumbs\.db',
'_disabled',
];
public static function init(): bool public static function init(): bool
{ {
return self::status(defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin()); return self::status(My::checkContext(My::BACKEND));
} }
public static function process(): bool public static function process(): bool
@ -67,18 +49,18 @@ class Backend extends Process
return in_array($list->getList(), [ return in_array($list->getList(), [
'plugin-activate', 'plugin-activate',
'theme-activate', 'theme-activate',
]) ? (new Submit([self::id() . '[' . Html::escapeHTML($id) . ']']))->value(__('Pack'))->render() : ''; ]) ? (new Submit([My::id() . '[' . Html::escapeHTML($id) . ']']))->value(__('Pack'))->render() : '';
}, },
'adminModulesListDoActions' => function (ModulesList $list, array $modules, string $type): void { 'adminModulesListDoActions' => function (ModulesList $list, array $modules, string $type): void {
# Pack action # Pack action
if (empty($_POST[self::id()]) if (empty($_POST[My::id()])
|| !is_array($_POST[self::id()])) { || !is_array($_POST[My::id()])) {
return; return;
} }
# Repository directory # Repository directory
$dir = (string) Path::real( $dir = (string) Path::real(
dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . self::TINYPACKER_DIR, dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . My::TINYPACKER_DIR,
false false
); );
if (!empty($dir) && !is_dir($dir)) { if (!empty($dir) && !is_dir($dir)) {
@ -89,7 +71,7 @@ class Backend extends Process
} }
# Module to pack # Module to pack
$modules = array_keys($_POST[self::id()]); $modules = array_keys($_POST[My::id()]);
$id = $modules[0]; $id = $modules[0];
$module = $list->modules->getDefine($id); $module = $list->modules->getDefine($id);
@ -109,7 +91,7 @@ class Backend extends Process
$fp = fopen($dir . DIRECTORY_SEPARATOR . $file, 'wb'); $fp = fopen($dir . DIRECTORY_SEPARATOR . $file, 'wb');
$zip = new Zip($fp); $zip = new Zip($fp);
foreach (self::TINYPACKER_EXCLUDE as $e) { foreach (My::TINYPACKER_EXCLUDE as $e) {
$zip->addExclusion(sprintf( $zip->addExclusion(sprintf(
'#(^|/)(%s)(/|$)#', '#(^|/)(%s)(/|$)#',
$e $e
@ -131,9 +113,4 @@ class Backend extends Process
return true; return true;
} }
private static function id(): string
{
return basename(dirname(__DIR__));
}
} }

44
src/My.php 100644
View File

@ -0,0 +1,44 @@
<?php
/**
* @brief tinyPacker, 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\tinyPacker;
use dcCore;
use Dotclear\Module\MyPlugin;
class My extends MyPlugin
{
/** @var string Public packages folder */
public const TINYPACKER_DIR = 'packages';
/** @var array Excluded files and dirs */
public const TINYPACKER_EXCLUDE = [
'\.',
'\.\.',
'__MACOSX',
'\.svn',
'\.hg.*?',
'\.git.*?',
'CVS',
'\.directory',
'\.DS_Store',
'Thumbs\.db',
'_disabled',
];
public static function checkCustomContext(int $context): ?bool
{
return defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
}
}