Skip to content

Commit

Permalink
FEATURE: Basic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kdambekalns committed Feb 8, 2016
1 parent ec8b020 commit 4ae3d3a
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
46 changes: 46 additions & 0 deletions Classes/CompressionHelper.php
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;
}

}
9 changes: 9 additions & 0 deletions Configuration/Settings.yaml
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'
32 changes: 31 additions & 1 deletion README.md
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)}
```
10 changes: 10 additions & 0 deletions Resources/Private/TypoScript/Root.ts2
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'
}
}
15 changes: 15 additions & 0 deletions composer.json
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"
}
}
}

0 comments on commit 4ae3d3a

Please sign in to comment.