Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Pico 2.0 support #8

Merged
merged 3 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions PicoContentEditor/PicoContentEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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;
Expand All @@ -37,10 +38,6 @@ class PicoContentEditor extends AbstractPicoPlugin
*/
const ENDMARK = '<!--\s*end\s+editable\s*-->';





/**
* Enable php errors reporting when the debug setting is enabled,
* look for PicoContentEditor save request and editing rights.
Expand Down Expand Up @@ -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';
Expand Down
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Copy the `PicoContentEditor` directory to the `plugins/` directory of your Pico

Some optional settings can be defined in Pico config file.

```php
$config['PicoContentEditor.debug'] = false; // enable errors reporting
$config['PicoContentEditor.lang'] = 'fr'; // language code of a supported language
$config['PicoContentEditor.ContentToolsUrl'] = 'https://cdn.jsdelivr.net/npm/ContentTools'; // custom ContentTools library location. Uses local files by default.
```yml
PicoContentEditor.debug: false # enable errors reporting
PicoContentEditor.lang: fr # language code of a supported language
PicoContentEditor.ContentToolsUrl: https://cdn.jsdelivr.net/npm/ContentTools # custom ContentTools library location. Uses local files by default.
```

The languages supported are listed in the *[translations/](https://github.com/nliautaud/pico-content-editor/tree/master/PicoContentEditor/assets/ContentTools/translations)* directory.
Expand Down Expand Up @@ -120,8 +120,8 @@ By default, files are uploaded to an `images/` directory located at the root of

You can define a custom location in the Pico config file with :

```php
$config['PicoContentEditor.uploadpath'] = 'assets';
```yml
PicoContentEditor.uploadpath: assets
```

## Authentification
Expand All @@ -136,17 +136,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
Expand Down