Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alex second contribution #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
58 changes: 58 additions & 0 deletions Classes/Eel/Helper/PackageManagerHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
namespace Breadlesscode\NodeTypes\Folder\Eel\Helper;

use Neos\Flow\Annotations as Flow;
use Neos\Eel\ProtectedContextAwareInterface;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
use Neos\Flow\Package\Exception\UnknownPackageException;
use Neos\Flow\Package\PackageManager;

class PackageManagerHelper implements ProtectedContextAwareInterface
{
/**
* @Flow\Inject
* @var ObjectManagerInterface
*/
protected $objectManager;

/**
* @return string
*/
public function getNeosUiMajorVersion(): string
{
return preg_replace('#^v?(\d+)\.(\d+)\.(\d+)$#', '$1', $this->getNeosUiVersion());
}

/**
* @return string
*/
public function getNeosUiMinorVersion(): string
{
return preg_replace('#^v?(\d+)\.(\d+)\.(\d+)$#', '$1.$2', $this->getNeosUiVersion());
}

/**
* @return string
*/
public function getNeosUiVersion(): string
{
try {
$packageManager = $this->objectManager->get(PackageManager::class);
$neosUiPackage = $packageManager->getPackage('Neos.Neos.Ui');
return $neosUiPackage->getInstalledVersion();
} catch (UnknownPackageException $e) {
return '0.0.0';
}
}

/**
* All methods are considered safe
*
* @param string $methodName
* @return boolean
*/
public function allowsCallOfMethod($methodName): bool
{
return true;
}
}
3 changes: 3 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Neos:
Fusion:
defaultContext:
'Breadlesscode.NodeTypes.Folder.PackageManager': 'Breadlesscode\NodeTypes\Folder\Eel\Helper\PackageManagerHelper'
Neos:
userInterface:
translation:
Expand Down
14 changes: 10 additions & 4 deletions Resources/Private/Fusion/Document/Folder.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ prototype(Breadlesscode.NodeTypes.Folder:Document.Folder) < prototype(Neos.Fusio
}
body {
templatePath = 'resource://Breadlesscode.NodeTypes.Folder/Private/Templates/Folder.html'
title = ${q(node).property('title')}
title = ${q(documentNode).property('title')}
version = ${Breadlesscode.NodeTypes.Folder.PackageManager.getNeosUiMajorVersion()}
}
}
}

default {
condition = true
renderer = Neos.Neos:Page {
body = Neos.Neos:Shortcut {
targetMode = 'parentNode'
renderer = Neos.Fusion:Http.Message {
httpResponseHead {
statusCode = 301
headers {
Location = Neos.Neos:NodeUri {
node = ${q(documentNode).parent().get(0)}
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Templates/Folder.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="breadlesscode-node-types-folder">
<div id="breadlesscode-node-types-folder" class="btnf-neos-version-{version}">
<div class="bntf-inner">
<div class="bntf-icon"><i class="fas fa-folder"></i></div>
<div class="bntf-title">{title}</div>
Expand Down
17 changes: 10 additions & 7 deletions Resources/Public/Styles/Folder.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
height: 100%;
background-color: #222222;
z-index: 9999;
/*
The Neos 7 backend normally uses the "Noto Sans" font,
which is no longer available as of 14 January 2023 in
the Neos.Neos package due to an incorrect file path in
Neos.css.
*/
font-family: sans-serif;
font-family: "Noto Sans", sans-serif;
-webkit-font-smoothing: antialiased;
}

/*
The Neos backend normally uses the "Noto Sans" font,
which is not available in Neos 5 due to an incorrect
file path in Neos.css.
*/
#breadlesscode-node-types-folder.btnf-neos-version-5 {
font-family: sans-serif;
}

#breadlesscode-node-types-folder > div.bntf-inner {
position: relative;
width: 260px;
Expand Down