From 99dee8450f27c4391a2b2fdb83806cfa6bf89225 Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Wed, 25 Jan 2023 16:41:59 +0100 Subject: [PATCH 1/4] TASK: Handle missing Noto Sans font in Neos 5 LTS Starting with Neos 5, the font Noto Sans was missing in Neos.css. This has been fixed for Neos > 5 with https://github.com/neos/neos-development-collection/issues/4005. So avoid using the Noto Sans font specifically for Neos 5. --- Classes/Eel/Helper/PackageManagerHelper.php | 58 +++++++++++++++++++ Configuration/Settings.yaml | 3 + .../Private/Fusion/Document/Folder.fusion | 1 + Resources/Private/Templates/Folder.html | 2 +- Resources/Public/Styles/Folder.css | 17 +++--- 5 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 Classes/Eel/Helper/PackageManagerHelper.php diff --git a/Classes/Eel/Helper/PackageManagerHelper.php b/Classes/Eel/Helper/PackageManagerHelper.php new file mode 100644 index 0000000..09685a2 --- /dev/null +++ b/Classes/Eel/Helper/PackageManagerHelper.php @@ -0,0 +1,58 @@ +getNeosUiVersion()); + } + + /** + * @return string + */ + public function getNeosUiMinorVersion() + { + return preg_replace('#^v?(\d+)\.(\d+)\.(\d+)$#', '$1.$2', $this->getNeosUiVersion()); + } + + /** + * @return string + */ + public function getNeosUiVersion() + { + 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) + { + return true; + } +} diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 7b930a9..d5ccdc7 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -1,4 +1,7 @@ Neos: + Fusion: + defaultContext: + 'Breadlesscode.NodeTypes.Folder.PackageManager': 'Breadlesscode\NodeTypes\Folder\Eel\Helper\PackageManagerHelper' Neos: userInterface: translation: diff --git a/Resources/Private/Fusion/Document/Folder.fusion b/Resources/Private/Fusion/Document/Folder.fusion index 74d41de..d1351c9 100644 --- a/Resources/Private/Fusion/Document/Folder.fusion +++ b/Resources/Private/Fusion/Document/Folder.fusion @@ -27,6 +27,7 @@ prototype(Breadlesscode.NodeTypes.Folder:Document.Folder) < prototype(Neos.Fusio body { templatePath = 'resource://Breadlesscode.NodeTypes.Folder/Private/Templates/Folder.html' title = ${q(node).property('title')} + version = ${Breadlesscode.NodeTypes.Folder.PackageManager.getNeosUiMajorVersion()} } } } diff --git a/Resources/Private/Templates/Folder.html b/Resources/Private/Templates/Folder.html index 915e026..abee294 100644 --- a/Resources/Private/Templates/Folder.html +++ b/Resources/Private/Templates/Folder.html @@ -1,4 +1,4 @@ -
+
{title}
diff --git a/Resources/Public/Styles/Folder.css b/Resources/Public/Styles/Folder.css index 7ff4c3d..c87aa64 100644 --- a/Resources/Public/Styles/Folder.css +++ b/Resources/Public/Styles/Folder.css @@ -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; From 878f49891df86981698755ff416a918a7f67062e Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Wed, 25 Jan 2023 17:18:57 +0100 Subject: [PATCH 2/4] TASK: Add method return types Method return type declarations are supported since PHP 7.0 and this package is compatible with down to Neos 4.3, which requires PHP 7.1+. --- Classes/Eel/Helper/PackageManagerHelper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/Eel/Helper/PackageManagerHelper.php b/Classes/Eel/Helper/PackageManagerHelper.php index 09685a2..7f8ffea 100644 --- a/Classes/Eel/Helper/PackageManagerHelper.php +++ b/Classes/Eel/Helper/PackageManagerHelper.php @@ -18,7 +18,7 @@ class PackageManagerHelper implements ProtectedContextAwareInterface /** * @return string */ - public function getNeosUiMajorVersion() + public function getNeosUiMajorVersion(): string { return preg_replace('#^v?(\d+)\.(\d+)\.(\d+)$#', '$1', $this->getNeosUiVersion()); } @@ -26,7 +26,7 @@ public function getNeosUiMajorVersion() /** * @return string */ - public function getNeosUiMinorVersion() + public function getNeosUiMinorVersion(): string { return preg_replace('#^v?(\d+)\.(\d+)\.(\d+)$#', '$1.$2', $this->getNeosUiVersion()); } @@ -34,7 +34,7 @@ public function getNeosUiMinorVersion() /** * @return string */ - public function getNeosUiVersion() + public function getNeosUiVersion(): string { try { $packageManager = $this->objectManager->get(PackageManager::class); @@ -51,7 +51,7 @@ public function getNeosUiVersion() * @param string $methodName * @return boolean */ - public function allowsCallOfMethod($methodName) + public function allowsCallOfMethod($methodName): bool { return true; } From c6d64857b349c20d7a91333d8d58bd1ff9effa84 Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Wed, 25 Jan 2023 18:22:08 +0100 Subject: [PATCH 3/4] TASK: Automatic redirection to parent page of folder in frontend --- Resources/Private/Fusion/Document/Folder.fusion | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Resources/Private/Fusion/Document/Folder.fusion b/Resources/Private/Fusion/Document/Folder.fusion index d1351c9..b9006af 100644 --- a/Resources/Private/Fusion/Document/Folder.fusion +++ b/Resources/Private/Fusion/Document/Folder.fusion @@ -34,9 +34,14 @@ prototype(Breadlesscode.NodeTypes.Folder:Document.Folder) < prototype(Neos.Fusio 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()} + } + } } } } From 728e76acd12b0c409abe8a264f611836c732f90d Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Thu, 26 Jan 2023 13:49:28 +0100 Subject: [PATCH 4/4] BUGFIX: Create correct URI of parent document node .. and use documentNode instead of node consistently, as stated by Sebobo: "documentNode and node are sometimes the same thing, but documentNode makes it easier to read the code". --- Resources/Private/Fusion/Document/Folder.fusion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/Private/Fusion/Document/Folder.fusion b/Resources/Private/Fusion/Document/Folder.fusion index b9006af..a31a163 100644 --- a/Resources/Private/Fusion/Document/Folder.fusion +++ b/Resources/Private/Fusion/Document/Folder.fusion @@ -26,7 +26,7 @@ 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()} } } @@ -39,7 +39,7 @@ prototype(Breadlesscode.NodeTypes.Folder:Document.Folder) < prototype(Neos.Fusio statusCode = 301 headers { Location = Neos.Neos:NodeUri { - node = ${q(documentNode).parent()} + node = ${q(documentNode).parent().get(0)} } } }