From 428155f25b5a60aacd7ea5ded6f866b2958e7c42 Mon Sep 17 00:00:00 2001 From: nliautaud Date: Mon, 6 Nov 2017 15:29:30 +0100 Subject: [PATCH 1/2] update config documentation for Pico 2.0 YML --- README.md | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9ed9525..339b336 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ Copy the `PicoContentEditor` directory to the `plugins/` directory of your Pico The settings are stored in Pico config file. -```php -$config['PicoContentEditor.debug'] = false; // if true, outputs the requests to the console -$config['PicoContentEditor.lang'] = 'fr'; // language code of a supported language +```yml +PicoContentEditor.debug: false # if true, outputs the requests to the console +PicoContentEditor.lang: fr # language code of a supported language ``` The languages supported are listed in the *[translations/](https://github.com/nliautaud/pico-content-editor/tree/master/PicoContentEditor/assets/ContentTools/translations)* directory. @@ -119,8 +119,8 @@ Files are uploaded to `images/` by default. You can define a custom location in the Pico config file with : -```php -$config['PicoContentEditor.uploadpath'] = 'assets'; +```yml +PicoContentEditor.uploadpath: assets ``` ## Authentification @@ -135,17 +135,14 @@ If the [PicoUsers] plugin is installed and detected, actions are automatically r Configuration example of [PicoUsers] : -```php -$config['users'] = array( - 'admin' => '$2y$10$Ym/XYzM9GsCzv3xFTiCea..8.F3xY/BpQISqW6/q3H41SmIK1reZe', - 'editors' => array( - 'bill' => '$2y$10$INwdOkshW6dhyVJbZYVm1..PxKc1CQTRG5jF.UaynOPDC6aukfkaa' - ) -); -$config['rights'] = array( - 'PicoContentEditor' => 'admin', - 'PicoContentEditor/save' => 'editors', -); +```yml +users: + admin: $2y$10$Ym/XYzM9GsCzv3xFTiCea..8.F3xY/BpQISqW6/q3H41SmIK1reZe + editors: + bill: $2y$10$INwdOkshW6dhyVJbZYVm1..PxKc1CQTRG5jF.UaynOPDC6aukfkaa +rights: + PicoContentEditor: admin + PicoContentEditor/save: editors ``` [ContentTools]: http://getcontenttools.com From 8d2a1635866148b1409df672125473e0b14432e5 Mon Sep 17 00:00:00 2001 From: nliautaud Date: Tue, 5 Jun 2018 12:28:30 +0200 Subject: [PATCH 2/2] Pico plugin api 2 support --- PicoContentEditor/PicoContentEditor.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/PicoContentEditor/PicoContentEditor.php b/PicoContentEditor/PicoContentEditor.php index 5f5cd05..676aa81 100644 --- a/PicoContentEditor/PicoContentEditor.php +++ b/PicoContentEditor/PicoContentEditor.php @@ -2,7 +2,7 @@ require_once 'vendor/pixel418/markdownify/src/Converter.php'; require_once 'vendor/pixel418/markdownify/src/ConverterExtra.php'; /** - * A content editor plugin for Pico, using ContentTools. + * A content editor plugin for Pico 2, using ContentTools. * * Supports PicoUsers plugin for authentification * {@link https://github.com/nliautaud/pico-users} @@ -11,10 +11,11 @@ * @link https://github.com/nliautaud/pico-content-editor * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License - * @version 0.2.3 */ class PicoContentEditor extends AbstractPicoPlugin { + const API_VERSION = 2; + private $edits = null; private $upload = null; private $canSave = true; @@ -37,10 +38,6 @@ class PicoContentEditor extends AbstractPicoPlugin */ const ENDMARK = ''; - - - - /** * Enable php errors reporting when the debug setting is enabled, * look for PicoContentEditor save request and editing rights. @@ -108,14 +105,12 @@ public function onContentLoaded(&$rawContent) * * Triggered before Pico renders the page * - * @see Pico::getTwig() - * @see DummyPlugin::onPageRendered() - * @param Twig_Environment &$twig twig template engine - * @param array &$twigVariables template variables - * @param string &$templateName file name of the template + * @see DummyPlugin::onPageRendered() + * @param string &$templateName file name of the template + * @param array &$twigVariables template variables * @return void */ - public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName) + public function onPageRendering(&$templateName, array &$twigVariables) { if (!$this->canSave) return; $pluginUrl = $this->getBaseUrl() . basename($this->getPluginsDir()) . '/PicoContentEditor';