From e24eccf72b9c4d509ef0a1b5100066c214fb3082 Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Thu, 2 Nov 2017 11:14:06 +0100 Subject: [PATCH] :hammer: Include Carbon.FileContent --- Classes/Fusion/FileContentImplementation.php | 61 ------------------- README.md | 6 -- Resources/Private/Fusion/External/File.fusion | 2 +- .../Fusion/External/FileContent.fusion | 5 -- .../Private/Fusion/External/HashOfFile.fusion | 16 ----- .../Fusion/Internal/VersionOfAsset.fusion | 2 +- composer.json | 3 +- 7 files changed, 4 insertions(+), 91 deletions(-) delete mode 100644 Classes/Fusion/FileContentImplementation.php delete mode 100644 Resources/Private/Fusion/External/FileContent.fusion delete mode 100644 Resources/Private/Fusion/External/HashOfFile.fusion diff --git a/Classes/Fusion/FileContentImplementation.php b/Classes/Fusion/FileContentImplementation.php deleted file mode 100644 index 54f27a2..0000000 --- a/Classes/Fusion/FileContentImplementation.php +++ /dev/null @@ -1,61 +0,0 @@ -fusionValue('path'); - } - - /** - * If specified, this resource object is used instead of the path and package information - * - * @return Resource - */ - public function getResource() - { - return $this->fusionValue('resource'); - } - - /** - * Returns the file content of a resource. Fails silent - * - * @return string | boolean - */ - public function evaluate() - { - $resource = $this->getResource(); - - if ($resource) { - return stream_get_contents($resource->getStream()); - } - - $path = $this->getPath(); - if ($path) { - return Files::getFileContents($path); - } - - return false; - } -} diff --git a/README.md b/README.md index 5913108..190529d 100755 --- a/README.md +++ b/README.md @@ -73,15 +73,9 @@ This prototype generate your `script` and `style` tags from the certain setting ### [Carbon.IncludeAssets:File](Resources/Private/Fusion/External/File.fusion) The heart of this package. This prototype generates a `script` or `style` tag. You can pass a `file` (without the path) or the complete `path`. Be aware that you can also pass the attributes like described on top. To force a type you can write `(js)` or `(css)` at the end of `path` or `file`. -### [Carbon.IncludeAssets:FileContent](Resources/Private/Fusion/External/FileContent.fusion) -This prototype read a file from a `path` or `resource`. Used for including the files inline. - ### [Carbon.IncludeAssets:GoogleFonts](Resources/Private/Fusion/External/GoogleFonts.fusion) You can set the property `fonts` e.g. `Lato|Open+Sans:400,700` and the `script` tag get generated. Per default, this prototype read the [Settings.yaml](Configuration/Settings.yaml). -### [Carbon.IncludeAssets:HashOfFile](Resources/Private/Fusion/External/HashOfFile.fusion) -This prototype read a file from a `path` or `resource` and return a md5 based string. - Installation ------------ Most of the time you have to make small adjustments to a package (e.g., the configuration in `Settings.yaml`). Because of that, it is important to add the corresponding package to the composer from your theme package. Mostly this is the site packages located under `Packages/Sites/`. To install it correctly go to your theme package (e.g.`Packages/Sites/Foo.Bar`) and run following command: diff --git a/Resources/Private/Fusion/External/File.fusion b/Resources/Private/Fusion/External/File.fusion index 46f8b45..f339533 100644 --- a/Resources/Private/Fusion/External/File.fusion +++ b/Resources/Private/Fusion/External/File.fusion @@ -25,7 +25,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Case) { isInternal { condition = ${attributes == 'inline' ? true : false} - renderer = Carbon.IncludeAssets:FileContent { + renderer = Carbon.FileContent:FileContent { path = ${path} @process.wrapWithTag = Carbon.IncludeAssets:TypeCase { isCSS.renderer = ${''} diff --git a/Resources/Private/Fusion/External/FileContent.fusion b/Resources/Private/Fusion/External/FileContent.fusion deleted file mode 100644 index efe0c5a..0000000 --- a/Resources/Private/Fusion/External/FileContent.fusion +++ /dev/null @@ -1,5 +0,0 @@ -prototype(Carbon.IncludeAssets:FileContent) < prototype(Neos.Fusion:Value) { - @class = 'Carbon\\IncludeAssets\\Fusion\\FileContentImplementation' - path = null - resource = null -} diff --git a/Resources/Private/Fusion/External/HashOfFile.fusion b/Resources/Private/Fusion/External/HashOfFile.fusion deleted file mode 100644 index 9400552..0000000 --- a/Resources/Private/Fusion/External/HashOfFile.fusion +++ /dev/null @@ -1,16 +0,0 @@ -prototype(Carbon.IncludeAssets:HashOfFile) < prototype(Neos.Fusion:Value) { - path = null - resource = null - - @context { - path = ${this.path} - resource = ${this.resource} - } - - fileContent = Carbon.IncludeAssets:FileContent { - path = ${path} - resource = ${resource} - } - - value = ${(this.path || this.resource) && this.fileContent ? String.md5(this.fileContent) : ''} -} diff --git a/Resources/Private/Fusion/Internal/VersionOfAsset.fusion b/Resources/Private/Fusion/Internal/VersionOfAsset.fusion index 51b32fb..7161a58 100644 --- a/Resources/Private/Fusion/Internal/VersionOfAsset.fusion +++ b/Resources/Private/Fusion/Internal/VersionOfAsset.fusion @@ -3,7 +3,7 @@ prototype(Carbon.IncludeAssets:VersionOfAsset) < prototype(Neos.Fusion:Value) { @context.path = ${this.path} - hash = Carbon.IncludeAssets:HashOfFile { + hash = Carbon.FileContent:HashOfFile { path = ${path} } diff --git a/composer.json b/composer.json index 85f40d1..3355403 100755 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "description": "Include your assets (css, js) in an easy way into Neos", "license": "MIT", "require": { - "neos/neos": "~3.0 || dev-master" + "neos/neos": "~3.0 || dev-master", + "carbon/filecontent": "^1.0" }, "autoload": { "psr-4": {