-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec8b020
commit 4ae3d3a
Showing
5 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace Flownative\Neos\Compressor; | ||
|
||
use TYPO3\Eel\ProtectedContextAwareInterface; | ||
use TYPO3\Flow\Annotations as Flow; | ||
use WyriHaximus\HtmlCompress\Factory; | ||
|
||
class CompressionHelper implements ProtectedContextAwareInterface | ||
{ | ||
|
||
/** | ||
* @var \WyriHaximus\HtmlCompress\Parser | ||
*/ | ||
protected $parser; | ||
|
||
/** | ||
* CompressionHelper constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->parser = Factory::construct(); | ||
} | ||
|
||
/** | ||
* Run the value through the compressor. | ||
* | ||
* @param $content string | ||
* @return string | ||
*/ | ||
public function compress($content) | ||
{ | ||
return $this->parser->compress($content); | ||
} | ||
|
||
/** | ||
* All methods are considered safe, i.e. can be executed from within Eel | ||
* | ||
* @param string $methodName | ||
* @return boolean | ||
*/ | ||
public function allowsCallOfMethod($methodName) | ||
{ | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
TYPO3: | ||
Neos: | ||
typoScript: | ||
autoInclude: | ||
'Flownative.Neos.Compressor': TRUE | ||
|
||
TypoScript: | ||
defaultContext: | ||
'Flownative.Compressor': 'Flownative\Neos\Compressor\CompressionHelper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# neos-compressor | ||
# Flownative Neos Compressor | ||
|
||
This package by default compresses the `head` and `body` of the `TYPO3.Neos:Page` prototype | ||
using the default compressor of `wyrihaximus/html-compress`. | ||
|
||
## Installation | ||
|
||
`composer require flownative/neos-compressor` | ||
|
||
## Usage | ||
|
||
As soon as the package is installed, the `TYPO3.Neos:Page` prototype is amended with `@process` | ||
instructions on the `head` and `body` elements. This will compress and "regular" output without | ||
any further steps to take. | ||
|
||
### Adjust compression | ||
|
||
To remove the default compression, simply override: | ||
|
||
``` | ||
prototype(TYPO3.Neos:Page) { | ||
[email protected] > | ||
[email protected] > | ||
} | ||
``` | ||
|
||
To compress specific parts, use the compression helper like this: | ||
|
||
``` | ||
[email protected] = ${Flownative.Compressor.compress(value)} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
prototype(TYPO3.Neos:Page) { | ||
[email protected] { | ||
expression = ${Flownative.Compressor.compress(value)} | ||
@position = 'end 999999999' | ||
} | ||
[email protected] { | ||
expression = ${Flownative.Compressor.compress(value)} | ||
@position = 'end 999999999' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "flownative/neos-compressor", | ||
"type": "typo3-flow-package", | ||
"description": "Output compression for Neos", | ||
"license": "MIT", | ||
"require": { | ||
"typo3/neos": "~2.0", | ||
"wyrihaximus/html-compress": "~1.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Flownative\\Neos\\Compressor\\": "Classes" | ||
} | ||
} | ||
} |