Git Product home page Git Product logo

radiant-mail-to-extension's Introduction

MailTo is a Radiant CMS extension that hides e-mails from robots. It is a wrapper for the Rails mail_to method and supports all of the same options provided by that method.

mail_to

The mail_to tag obfuscates an email address as a block of javascript. For example,

<r:mail_to email="[email protected]" encode="hex" />

is turned into

<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6a%6f%65@%65%78%61%6d%70%6c%65.%63%6f%6d">[email protected]</a>

and will be displayed as a human-readable link.

Usage

Install the extension at vendor/extensions. Make sure the extension's directory is named mail_to so that it will load properly.

Use the tag in pages or snippets like this:

<r:mail_to email="[email protected]" replace_at="_at_" replace_dot="_dot_" class="email" />

enkode_mailto

This tag will be used by the textile editor extension. It also generate a mailto: encoded link:

<r:enkode_mailto email="[email protected]" link_text="Joe User" />

is turned into

<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6a%6f%65@%65%78%61%6d%70%6c%65.%63%6f%6d">&#74;&#111;&#101;&#32;&#85;&#115;&#101;&#114;</a>

Both email and link text are automatically hex encoded. This tag takes no other options.

Additional Options

From the Rails documentation:

Creates a mailto link tag to the specified email_address, which is also used as the name of the link unless name is specified. Additional HTML attributes for the link can be passed in html_options.

mail_to has several methods for hindering email harvesters and customizing the email itself by passing special keys to html_options.

Options

  • :encode - This key will accept the strings "javascript" or "hex". Passing "javascript" will dynamically create and encode the mailto: link then eval it into the DOM of the page. This method will not show the link on the page if the user has JavaScript disabled. Passing "hex" will hex encode the email_address before outputting the mailto: link.
  • :replace_at - When the link name isn‘t provided, the email_address is used for the link label. You can use this option to obfuscate the email_address by substituting the @ sign with the string given as the value.
  • :replace_dot - When the link name isn‘t provided, the email_address is used for the link label. You can use this option to obfuscate the email_address by substituting the . in the email with the string given as the value.
  • :subject - Preset the subject line of the email.
  • :body - Preset the body of the email.
  • :cc - Carbon Copy addition recipients on the email.
  • :bcc - Blind Carbon Copy additional recipients on the email.

Examples

<r:mail_to email="[email protected]" /><br/>
# => <a href="mailto:[email protected]">[email protected]</a>

<r:mail_to email="[email protected]" name="My email" encode="javascript" /><br/>
# => <script type="text/javascript">eval(unescape('%64%6f%63...%6d%65%6e'))</script>

<r:mail_to email="[email protected]" encode="hex" encode_name="true" /><br/>
# => <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">&#109;&#101;...&#111;&#109;</a>

<r:mail_to email="[email protected]" replace_at="_at_" replace_dot="_dot_" class="email" /><br/>
# => <a href="mailto:[email protected]" class="email">me_at_domain_dot_com</a>

<r:mail_to email="[email protected]" name="My email" cc="[email protected]" subject="This is an example email" /><br/>
# => <a href="mailto:[email protected][email protected]&subject=This%20is%20an%20example%20email">My email</a>

radiant-mail-to-extension's People

Contributors

mrgossett avatar

Stargazers

Angus H. avatar Fabrice Luraine avatar

Watchers

Fabrice Luraine avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.