<commit_before>Obfuscator
==========

A [Craft CMS][craft] plugin that adds a [Twig][twig] filter to obfuscate emails or any other content using [Hivelogic Enkoder][he].

[craft]:http://buildwithcraft.com/
[twig]:http://twig.sensiolabs.org/
[he]:http://hivelogic.com/enkoder/

This plugin uses [Standalone PHPEnkoder][sp].

[sp]: https://github.com/jnicol/standalone-phpenkoder


Requirements
------------
This plugin requires Craft CMS 3.0.0 or later. The Craft 2 version is availabe in [the `v0` branch](https://github.com/miranj/craft-obfuscator/tree/v0).



Installation
------------

You can install this plugin from the [Plugin Store][ps] or with Composer.

[ps]:https://plugins.craftcms.com/

#### From the Plugin Store
Go to the Plugin Store in your project’s Control Panel and search for “Obfuscator”.
Then click on the “Install” button in its modal window.

#### Using Composer
Open your terminal and run the following commands:

    # go to the project directory
    cd /path/to/project
    
    # tell composer to use the plugin
    composer require miranj/craft-obfuscator
    
    # tell Craft to install the plugin
    ./craft install/plugin obfuscator
    


Usage
-----
```
{{ 'Reach us on <EMAIL> or <a href="mailto:<EMAIL>">here</a>.' | enkode_emails }}
```

```
{{ '<a href="mailto:<EMAIL>">Contact Us</a>' | enkode_mailtos }}
```

```
{{ 'Contact us at <EMAIL>.' | enkode_plaintext_emails }}
```

```
{{ 'I don’t want spam bots to read this.' | enkode }}
```

```
{{ 'If you don’t have JavaScript, you’ll see a helpful message.' | enkode('JavaScript is required to view this message.') }}
```


---

Brought to you by [Miranj](https://miranj.in/)
<commit_msg>Improve Usage docs<commit_after>Obfuscator
==========

A [Craft CMS][craft] plugin that adds a [Twig][twig] filter to obfuscate emails or any other content using [Hivelogic Enkoder][he].

[craft]:http://buildwithcraft.com/
[twig]:http://twig.sensiolabs.org/
[he]:http://hivelogic.com/enkoder/

This plugin uses [Standalone PHPEnkoder][sp].

[sp]: https://github.com/jnicol/standalone-phpenkoder


Requirements
------------
This plugin requires Craft CMS 3.0.0 or later. The Craft 2 version is availabe in [the `v0` branch](https://github.com/miranj/craft-obfuscator/tree/v0).



Installation
------------

You can install this plugin from the [Plugin Store][ps] or with Composer.

[ps]:https://plugins.craftcms.com/

#### From the Plugin Store
Go to the Plugin Store in your project’s Control Panel and search for “Obfuscator”.
Then click on the “Install” button in its modal window.

#### Using Composer
Open your terminal and run the following commands:

    # go to the project directory
    cd /path/to/project
    
    # tell composer to use the plugin
    composer require miranj/craft-obfuscator
    
    # tell Craft to install the plugin
    ./craft install/plugin obfuscator
    


Usage
-----

The following Twig snippet —

```twig
{% filter enkode_emails %}
    Reach us on <EMAIL> or
    <a href="mailto:<EMAIL>">here</a>.
{% endfilter %}
```

will result in HTML where both the plain text email, and the `mailto:`
anchor tag are recognised as emails and obfuscated. It will result in something
like this (re-formatted for readability):

```html
Reach us on

<span id="enkoder_1_2033799978">email hidden; JavaScript is required</span>
<script id="script_enkoder_1_2033799978" type="text/javascript"> /* <!-- */
function hivelogic_enkoder_1_2033799978() { … } hivelogic_enkoder_1_2033799978();
/* --> */ </script>

or

<span id="enkoder_0_1540754146">email hidden; JavaScript is required</span>
<script id="script_enkoder_0_1540754146" type="text/javascript"> /* <!-- */
function hivelogic_enkoder_0_1540754146() { … } hivelogic_enkoder_0_1540754146();
/* --> */ </script>.
```

In addition to the `enkode_emails` filter, Obfuscator comes with a bunch of additional
filters for more fine grained targeting of what to obfuscate.

```twig
{{ 'Reach us on <EMAIL> or <a href="mailto:<EMAIL>">here</a>.'|enkode_emails }}

{{ '<a href="mailto:<EMAIL>">Contact Us</a>'|enkode_mailtos }}

{{ 'Contact us at <EMAIL>.'|enkode_plaintext_emails }}

{{ 'I don’t want spam bots to read this.'|enkode }}

{{ 'If you don’t have JavaScript, you’ll see a helpful message.'|enkode('JavaScript is required to view this message.') }}
```

---

Brought to you by [Miranj](https://miranj.in/)

{'fraction_non_alphanumeric': 0.1505844602337841, 'fraction_numerical': 0.022920009168003668, 'mean_word_length': 3.936651583710407, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4241589', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1468, 'n_words': 451}