Skip to content

Commit

Permalink
make obfuscation work when content is renderd with fusion afx
Browse files Browse the repository at this point in the history
  • Loading branch information
ger4003 committed Nov 28, 2019
1 parent cb51d5d commit 7c7900c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Neos:
Neos:
fusion:
autoInclude:
Networkteam.Neos.MailObfuscator: true
'Networkteam.Neos.MailObfuscator': true

Networkteam:
Neos:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Install the composer package in your site package or distribution:
$ composer require networkteam/neos-mailobfuscator
```

There is no need for configuration, as a Fusion processor is attached to all prototypes extending
`Neos.Neos:Content`.
There is no need for configuration, as a Fusion processor is attached to `body` of `Neos.Neos:Page`.
That means, that the complete content of body tag is obfuscated.

### Compatibility

Expand All @@ -52,16 +52,16 @@ See the following table for the correct plugin version to choose:
Obfuscation can be disabled for specific node types by unsetting the processor:

```
prototype(Vendor.MyPackage:MyNodeType) {
prototype(Neos.Neos:Page) {
@process.networkteamNeosMailObfuscator >
}
```

The JavaScript include can be disabled for custom minification:

```
page = prototype(Neos.Neos:Page) {
body.javascripts.networkteamNeosMailObfuscator >
prototype(Neos.Neos:Page) {
networkteamNeosMailObfuscator >
}
```

Expand Down
15 changes: 15 additions & 0 deletions Resources/Private/Fusion/Override/Neos.Neos/Page.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
##
# Extend the Page prototype to include the obfuscation JavaScript and obfuscate content within body tag
#
prototype(Neos.Neos:Page) {

networkteamNeosMailObfuscator = Neos.Fusion:Tag {
tagName = 'script'
attributes.src = Neos.Fusion:ResourceUri {
path = 'resource://Networkteam.Neos.MailObfuscator/Public/Scripts/nwt.mailobfuscation.min.js'
}
}
networkteamNeosMailObfuscator.@position = 'after body'

[email protected] = Networkteam.Neos:MailObfuscator
}
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Prototype/MailObfuscator.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Replaces all occurrences of "mailto:<emailAddress>" and email address labels using the configured implementation
#
prototype(Networkteam.Neos:MailObfuscator) {
@class = '\\Networkteam\\Neos\\MailObfuscator\\Fusion\\ConvertEmailLinksImplementation'
@class = 'Networkteam\\Neos\\MailObfuscator\\Fusion\\ConvertEmailLinksImplementation'

patternMailTo = '/(href=")mailto:([^"]*)/'
patternMailDisplay = '/(href="mailto:[^"]*">)([^<]*)/'
Expand Down
21 changes: 7 additions & 14 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@
# You should have received a copy of the GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

include: Prototype/MailObfuscator.fusion
##
# Include all .fusion files
#

include: ./**/*.fusion



# Extend the Page prototype to include the obfuscation JavaScript
prototype(Neos.Neos:Page) {
body.javascripts.networkteamNeosMailObfuscator = Neos.Fusion:Tag {
tagName = 'script'
attributes.src = Neos.Fusion:ResourceUri {
path = 'resource://Networkteam.Neos.MailObfuscator/Public/Scripts/nwt.mailobfuscation.min.js'
}
}
}

# Obfuscate all node types extending Neos:Content by default
prototype(Neos.Neos:Content) {
@process.networkteamNeosMailObfuscator = Networkteam.Neos:MailObfuscator
}

0 comments on commit 7c7900c

Please sign in to comment.