Compare commits

..

No commits in common. "ef32e07197e516b6d9c451ccb0ecebad8c92850f" and "93ff90472913d73a8e69a327da44c29efde45de6" have entirely different histories.

6 changed files with 80 additions and 115 deletions

View File

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

View File

@ -1,10 +1,11 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/tinyPacker/releases) [![Release](https://img.shields.io/github/v/release/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) [![Date](https://img.shields.io/github/release-date/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) [![Issues](https://img.shields.io/github/issues/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/issues)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/tinyPacker) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![License](https://img.shields.io/github/license/JcDenis/tinyPacker)](https://git.dotclear.watch/JcDenis/tinyPacker/blob/master/LICENSE) [![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://github.com/JcDenis/tinyPacker/blob/master/LICENSE)
## WHAT IS tinyPacker ? ## WHAT IS tinyPacker ?
@ -18,10 +19,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
@ -34,12 +35,12 @@ and it's pack into current blog public directory.
## MORE ## MORE
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * License : GNU GPL v2
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/tinyPacker) or [GitHub Page](https://github.com/JcDenis/tinyPacker) * Source & contribution : [GitHub Page](https://github.com/JcDenis/tinyPacker)
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/tinyPacker/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/tinyPacker) * Packages & details : [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.3', '1.2',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.27']],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/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.3</version> <version>1.2</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://git.dotclear.watch/JcDenis/tinyPacker/releases/download/v1.3/plugin-tinyPacker.zip</file> <file>https://github.com/JcDenis/tinyPacker/releases/download/v1.2/plugin-tinyPacker.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/tinyPacker/src/branch/master/README.md</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/tinyPacker</da:details>
<da:support>https://git.dotclear.watch/JcDenis/tinyPacker/issues</da:support> <da:support>https://github.com/JcDenis/tinyPacker</da:support>
</module> </module>
</modules> </modules>

View File

@ -33,9 +33,27 @@ 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(My::checkContext(My::BACKEND)); return self::status(defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin());
} }
public static function process(): bool public static function process(): bool
@ -49,18 +67,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([My::id() . '[' . Html::escapeHTML($id) . ']']))->value(__('Pack'))->render() : ''; ]) ? (new Submit([self::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[My::id()]) if (empty($_POST[self::id()])
|| !is_array($_POST[My::id()])) { || !is_array($_POST[self::id()])) {
return; return;
} }
# Repository directory # Repository directory
$dir = (string) Path::real( $dir = (string) Path::real(
dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . My::TINYPACKER_DIR, dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . self::TINYPACKER_DIR,
false false
); );
if (!empty($dir) && !is_dir($dir)) { if (!empty($dir) && !is_dir($dir)) {
@ -71,7 +89,7 @@ class Backend extends Process
} }
# Module to pack # Module to pack
$modules = array_keys($_POST[My::id()]); $modules = array_keys($_POST[self::id()]);
$id = $modules[0]; $id = $modules[0];
$module = $list->modules->getDefine($id); $module = $list->modules->getDefine($id);
@ -91,7 +109,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 (My::TINYPACKER_EXCLUDE as $e) { foreach (self::TINYPACKER_EXCLUDE as $e) {
$zip->addExclusion(sprintf( $zip->addExclusion(sprintf(
'#(^|/)(%s)(/|$)#', '#(^|/)(%s)(/|$)#',
$e $e
@ -113,4 +131,9 @@ class Backend extends Process
return true; return true;
} }
private static function id(): string
{
return basename(dirname(__DIR__));
}
} }

View File

@ -1,44 +0,0 @@
<?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();
}
}