Skip to content

Commit

Permalink
Merge branch 'wintercms:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
damsfx authored Nov 16, 2024
2 parents 26b4fc5 + ec86098 commit cd971ba
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

![Blocks Plugin](https://github.com/wintercms/wn-blocks-plugin/blob/main/.github/banner.png?raw=true)

[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wintercms/wn-blocks-plugin/blob/main/LICENSE)

Provides a "block based" content management experience in Winter CMS

>**NOTE:** This plugin is still in development and is likely to undergo changes. Do not use in production environments without using a version constraint in your composer.json file and carefully monitoring for breaking changes.
>**NOTE:** This plugin requires Winter CMS v1.2.2 or above.

## Installation

This plugin is available for installation via [Composer](http://getcomposer.org/).
Expand All @@ -17,8 +16,13 @@ This plugin is available for installation via [Composer](http://getcomposer.org/
composer require winter/wn-blocks-plugin
```

In order to have the `actions` support function correctly, you need to load `/plugins/winter/blocks/assets/dist/js/blocks.js` after the Snowboard framework has been loaded.
After installing the plugin you will need to run the migrations and (if you are using a [public folder](https://wintercms.com/docs/develop/docs/setup/configuration#using-a-public-folder)) [republish your public directory](https://wintercms.com/docs/develop/docs/console/setup-maintenance#mirror-public-files).

```bash
php artisan migrate
```

>**NOTE:** In order to have the `actions` support function correctly, you need to load `/plugins/winter/blocks/assets/dist/js/blocks.js` after the Snowboard framework has been loaded.
## Core Concepts

Expand Down
16 changes: 16 additions & 0 deletions classes/BlockManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,20 @@ public function isBlock(string $type): bool
{
return !!$this->getConfig($type);
}

/**
* Remove a block by key
*/
public function removeBlock(string|array $key): void
{
if (is_array($key)) {
foreach ($key as $k) {
$this->removeBlock($k);
}

return;
}

unset($this->blocks[$key]);
}
}
9 changes: 8 additions & 1 deletion classes/BlocksDatasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ class BlocksDatasource extends Datasource
public function __construct()
{
$this->processor = new BlockProcessor();
$this->blocks = BlockManager::instance()->getRegisteredBlocks();
$this->blocks = array_merge(
// Get blocks registered via plugins
BlockManager::instance()->getRegisteredBlocks(),
// Get blocks existing in the autodatasource
BlockManager::instance()->getBlocks()->map(function ($block) {
return ['name' => $block->id, 'path' => $block->getFilePath()];
})->pluck('path', 'name')->toArray()
);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lang/fr/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'description' => 'Ouvrez l\'URL fournie',
'href' => 'URL',
'target' => 'Ouvrir l\'URL dans',
'target_self' => 'Même onget',
'target_self' => 'Même onglet',
'target_blank' => 'Nouvel onglet',
],
'open_media' => [
Expand Down Expand Up @@ -115,9 +115,9 @@
'default' => 'Défaut',
'alignment_x' => [
'label' => 'Alignement horizontal',
'left' => 'A gauche',
'center' => 'Au entre',
'right' => 'A droite',
'left' => 'À gauche',
'center' => 'Centré',
'right' => 'À droite',
],
],
];

0 comments on commit cd971ba

Please sign in to comment.