Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,41 @@

namespace Neos\NeosIo\ContentRepository\Transformations;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Factory\NodeFactory;
use Neos\ContentRepository\Domain\Model\NodeData;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Migration\Transformations\AbstractTransformation;
use Neos\Neos\Controller\CreateContentContextTrait;
use Neos\Flow\Annotations as Flow;

/**
* Move content of elements with a single content collection to the parent to cleanup the content tree
*/
class FlattenCollectionsTransformation extends AbstractTransformation
{
use CreateContentContextTrait;
/**
* @Flow\Inject
* @var NodeFactory
*/
protected $nodeFactory;

public function isTransformable(NodeData $node): bool
{
$numberOfChildNodes = $node->getNumberOfChildNodes('Neos.Neos:ContentCollection', $node->getWorkspace(), $node->getDimensions());
$numberOfChildNodes = $node->getNumberOfChildNodes(
'Neos.Neos:ContentCollection',
$node->getWorkspace(),
$node->getDimensionValues()
);
return ($numberOfChildNodes === 1);
}

public function execute(NodeData $node): void
{
$contentContext = $this->createContentContext($node->getWorkspace()->getName(), $node->getDimensionValues());
$parentNode = $contentContext->getNodeByIdentifier($node->getIdentifier());
$parentNode = $this->nodeFactory->createFromNodeData($node, $this->nodeFactory->createContextMatchingNodeData($node));
if (!$parentNode) {
return;
}

$contentCollections = $parentNode->getChildNodes('Neos.Neos:ContentCollection');

foreach ($contentCollections as $contentCollection) {
if ($contentCollection->hasChildNodes() && $contentCollection->getNodeType()->getName() === 'Neos.Neos:ContentCollection') {
$this->moveChildNodesToParent($contentCollection->getChildNodes(), $parentNode);
Expand All @@ -45,7 +52,17 @@ protected function moveChildNodesToParent(array $children, NodeInterface $parent
{
foreach ($children as $childNode) {
if ($childNode instanceof NodeInterface) {
$childNode->moveInto($parentNode);
try {
$childNode->moveInto($parentNode);
} catch (\Exception $exception) {
\Neos\Flow\var_dump([
'contextPath' => $parentNode->getContextPath(),
'workspace' => $parentNode->getWorkspace()->getName(),
'dimensions' => json_encode($parentNode->getDimensions()),
'nodetype' => $parentNode->getNodeType()->getName(),
'exception' => $exception->getMessage(),
], 'Could not move node ' . $parentNode->getIdentifier());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,51 @@

namespace Neos\NeosIo\ContentRepository\Transformations;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Factory\NodeFactory;
use Neos\ContentRepository\Domain\Model\NodeData;
use Neos\ContentRepository\Migration\Transformations\AbstractTransformation;
use Neos\Neos\Controller\CreateContentContextTrait;
use Neos\Flow\Annotations as Flow;

/**
* Remove empty content collections that are leftover after the FlattenCollectionsTransformation
*/
class RemoveEmptyCollectionsTransformation extends AbstractTransformation
{
use CreateContentContextTrait;
/**
* @Flow\Inject
* @var NodeFactory
*/
protected $nodeFactory;

public function isTransformable(NodeData $node): bool
{
$numberOfChildNodes = $node->getNumberOfChildNodes('Neos.Neos:ContentCollection', $node->getWorkspace(), $node->getDimensions());
return ($numberOfChildNodes > 0);
$numberOfChildCollections = $node->getNumberOfChildNodes(
'Neos.Neos:ContentCollection',
$node->getWorkspace(),
$node->getDimensionValues()
);
return ($numberOfChildCollections > 0);
}

public function execute(NodeData $node): void
{
$contentContext = $this->createContentContext($node->getWorkspace()->getName(), $node->getDimensionValues());
$parentNode = $contentContext->getNodeByIdentifier($node->getIdentifier());
$parentNode = $this->nodeFactory->createFromNodeData($node, $this->nodeFactory->createContextMatchingNodeData($node));
if (!$parentNode) {
return;
}
$contentCollections = $parentNode->getChildNodes('Neos.Neos:ContentCollection');

foreach ($contentCollections as $contentCollection) {
if ($contentCollection->hasChildNodes() === false) {
$contentCollection->remove();
if ($contentCollection->hasChildNodes() === false && $contentCollection->getNodeType()->getName() === 'Neos.Neos:ContentCollection') {
try {
$contentCollection->remove();
} catch (\Exception $exception) {
\Neos\Flow\var_dump([
'dimensions' => json_encode($parentNode->getDimensions()),
'nodetype' => $parentNode->getNodeType()->getName(),
'exception' => $exception->getMessage(),
], 'Could not remove node at ' . $parentNode->getContextPath());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ up:
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.NeosIo:Stage'
nodeType: 'Neos.NeosIo:Box'
transformations:
- type: 'Neos\NeosIo\ContentRepository\Transformations\FlattenCollectionsTransformation'
- type: 'Neos\NeosIo\ContentRepository\Transformations\RemoveEmptyCollectionsTransformation'
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.NeosIo:BadgeGrid'
transformations:
- type: 'Neos\NeosIo\ContentRepository\Transformations\FlattenCollectionsTransformation'
- type: 'Neos\NeosIo\ContentRepository\Transformations\RemoveEmptyCollectionsTransformation'
Expand All @@ -18,7 +25,7 @@ up:
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.NeosIo:Box'
nodeType: 'Neos.NeosIo:Stage'
transformations:
- type: 'Neos\NeosIo\ContentRepository\Transformations\FlattenCollectionsTransformation'
- type: 'Neos\NeosIo\ContentRepository\Transformations\RemoveEmptyCollectionsTransformation'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
'Neos.NeosIo:BadgeGrid':
superTypes:
'Neos.Neos:Content': true
childNodes:
badges:
type: 'Neos.Neos:ContentCollection'
constraints:
nodeTypes:
'*': false
'Neos.NeosIo:Badge': true
'Neos.Neos:ContentCollection': true
constraints:
nodeTypes:
'*': false
'Neos.NeosIo:Badge': true
ui:
label: 'Badge grid'
icon: 'th-large'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
prototype(Neos.NeosIo:BadgeGrid) < prototype(Neos.Neos:Content) {
templatePath = 'resource://Neos.NeosIo/Private/Templates/NodeTypes/BadgeGrid.html'

attributes.class = 'g'

badges = Neos.Neos:ContentCollection {
nodePath = 'badges'
}
prototype(Neos.NeosIo:BadgeGrid) < prototype(Neos.Neos:ContentComponent) {
renderer = afx`
<div class="badge-grid g">
<Neos.Neos:ContentCollection />
</div>
`
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ prototype(Neos.NeosIo:SemanticSection) < prototype(Neos.Neos:ContentComponent) {
isLast = ${iterator.isLast}

renderer = afx`
<section>
<section class="semantic-section">
<Neos.Neos:ContentCollection />
<hr @if={!props.isLast} />
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) {
}

image = ${q(node).property('image')}
imageClassName = Neos.Fusion:DataStructure {
className = Neos.Fusion:DataStructure {
main = 'neos-nodetypes-image'

alignment = ${'neos-alignment-' + q(node).property('alignment')}
alignment.@if.isSet = ${q(node).property('alignment')}

Expand Down Expand Up @@ -54,22 +56,38 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) {
renderer.@context.image = Neos.Fusion:Case {
default {
condition = ${props.image}
renderer = Neos.Neos:ImageTag {
asset = ${props.image}
title = ${props.title}
maximumHeight = ${props.maximumHeight}
maximumWidth = ${props.maximumWidth}
allowUpScaling = ${props.allowUpScaling}
allowCropping = ${props.allowCropping}
width = ${props.width}
height = ${props.height}
async = true
attributes.alt = ${props.alternativeText}
attributes.loading = ${props.loading}
attributes.style = Neos.Fusion:Join {
maxHeight = ${'max-height: ' + props.maximumHeight + 'px;'}
maxHeight.@if.set = ${props.maximumHeight}
renderer = Neos.Fusion:Component {
@apply.props = ${props}

thumbnail = ${Neos.Seo.Image.createThumbnail(
props.image,
null,
props.width,
props.maximumWidth,
props.height,
props.maximumHeight,
props.allowCropping,
props.allowUpScaling,
true
)}

renderer.@process.debug = Neos.Fusion:Debug.Console {
value = ${props}
}

renderer = afx`
<img
title={props.title}
alt={props.alternativeText}
style={'max-height: ' + props.maximumHeight + 'px;'}
style.@if={props.maximumHeight}
width={props.thumbnail.width || props.width}
height={props.thumbnail.height || props.height}
loading={props.loading}
>
<Neos.Fusion:ResourceUri resource={props.thumbnail.resource} @path='attributes.src'/>
</img>
`
}
}
fallback {
Expand All @@ -87,8 +105,8 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) {
}

renderer = afx`
<div class="neos-nodetypes-image">
<figure class={props.imageClassName}>
<div class={props.className}>
<figure>
<a
href={props.link}
href.@if.live={!node.context.inBackend}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ prototype(Neos.NodeTypes:TextWithImage) < prototype(Neos.NodeTypes:Image) {
property = 'text'
}

className.main = 'neos-nodetypes-textwithimage'

renderer {
attributes.class = 'neos-nodetypes-textwithimage'
content.@process.appendText = ${value + props.text}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
*/

p {
margin: 0 0 rs($basic-spacing);
margin: 0;

& + * {
margin-top: rs($basic-spacing);
}
}

b,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
@import "Molecules/_EventList";
@import "Molecules/_VidoeEmbed";
@import "Molecules/_FormBuilder";
@import "Molecules/_SemanticSection";

// Organisms
@import "Organisms/_SiteHeader";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
.neos-nodetypes-textwithimage,
.neos-nodetypes-image {
@include u-cf();
display: flex;
gap: rs($half-spacing, $unit: rem) rs($basic-spacing, $unit: rem);
flex-direction: column;
align-items: start;

figure {
--background-color: none;
--color: currentColor;
background-color: var(--background-color);
color: var(--color);
display: flex;
flex-direction: column;

& + * {
margin-top: 1em;
img {
display: block;
}

figcaption {
Expand Down Expand Up @@ -76,17 +81,17 @@
}

.neos-alignment-left {
text-align: left;
flex-direction: row;
}

.neos-alignment-center {
text-align: center;
align-items: center;
}

.neos-alignment-right {
text-align: right;
}
flex-direction: row-reverse;

.neos-nodetypes-image {
margin-bottom: rs($basic-spacing, $unit: rem);
figure {
justify-content: end;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.semantic-section {
> .neos-contentcollection {
display: flex;
flex-direction: column;
gap: rs($basic-spacing, $unit: rem);
}
}

This file was deleted.