<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,4 @@
+* [#83] Added mail_to HTML helper.
 * [#82] Added ACL support to mack-distributed
 * [#81] Fixed sessions working with redirects in testing
 * [#80] Distributed objects present both the DRb::DRbObject inspect and the original object's inspect when asked.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -124,6 +124,34 @@ module Mack
         # content_tag(:form, options, &amp;block)
       end
       
+      # Builds a mailto href. By default it will generate 
+      # JavaScript to help prevent phishing. To turn this off
+      # pass in the option :format =&gt; :plain
+      # 
+      #   mail_to(&quot;Saul Frami&quot;, &quot;frami.saul@klocko.ca&quot;) # =&gt; 
+      #   &lt;script&gt;document.write(String.fromCharCode(60,97,32,104,114,101,
+      #   102,61,34,109,97,105,108,116,111,58,102,114,97,109,105,46,115,97,117,
+      #   108,64,107,108,111,99,107,111,46,99,97,34,62,83,97,117,108,32,70,114,97,109,105,60,47,97,62));&lt;/script&gt;
+      def mail_to(text, email_address = nil, options = {})
+        email_address = text if email_address.blank?
+        options = {:format =&gt; :js}.merge(options)
+        format = options[:format]
+        options - [:format]
+        link = link_to(text, &quot;mailto:#{email_address}&quot;, options)
+        if format == :js
+          y = ''
+          link.size.times {y &lt;&lt; 'a'}
+          js_link = &quot;&lt;script&gt;&quot;
+          c_code = []
+          link.each_byte {|c| c_code &lt;&lt; c}
+          js_link &lt;&lt; &quot;document.write(String.fromCharCode(#{c_code.join(&quot;,&quot;)}));&quot;
+          js_link &lt;&lt; &quot;&lt;/script&gt;&quot;
+          return js_link
+        else
+          return link
+        end
+      end
+      
       private
       def build_options(options)
         opts = &quot;&quot;</diff>
      <filename>lib/mack/view_helpers/html_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,22 @@ end
 describe Mack::ViewHelpers::HtmlHelpers do
   include HTMLSpecHelpers
   
+  describe &quot;mail_to&quot; do
+    
+    it &quot;should use the 'text' parameter for the email parameter if one isn't given&quot; do
+      mail_to(&quot;iii.blick.randy@langworthtowne.co.uk&quot;).should == %{&lt;script&gt;document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,105,105,105,46,98,108,105,99,107,46,114,97,110,100,121,64,108,97,110,103,119,111,114,116,104,116,111,119,110,101,46,99,111,46,117,107,34,62,105,105,105,46,98,108,105,99,107,46,114,97,110,100,121,64,108,97,110,103,119,111,114,116,104,116,111,119,110,101,46,99,111,46,117,107,60,47,97,62));&lt;/script&gt;}.strip
+    end
+    
+    it &quot;should build a javascript link by default&quot; do
+      mail_to(&quot;Randy Blick III&quot;, &quot;iii.blick.randy@langworthtowne.co.uk&quot;).should == %{&lt;script&gt;document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,105,105,105,46,98,108,105,99,107,46,114,97,110,100,121,64,108,97,110,103,119,111,114,116,104,116,111,119,110,101,46,99,111,46,117,107,34,62,82,97,110,100,121,32,66,108,105,99,107,32,73,73,73,60,47,97,62));&lt;/script&gt;}.strip
+    end
+    
+    it &quot;should generate a 'plain' version of the link if specified&quot; do
+      mail_to(&quot;Randy Blick III&quot;, &quot;iii.blick.randy@langworthtowne.co.uk&quot;, :format =&gt; :plain).should == link_to(&quot;Randy Blick III&quot;, &quot;mailto:iii.blick.randy@langworthtowne.co.uk&quot;)
+    end
+    
+  end
+  
   describe &quot;submit_tag&quot; do
     
     it &quot;should build a simple submit tag&quot; do</diff>
      <filename>test/unit/view_helpers/html_helpers_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c9ff2bb597018796f83858b7fe6e0f166e285db9</id>
    </parent>
  </parents>
  <author>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </author>
  <url>http://github.com/markbates/mack/commit/5df6fe20c63f83b9ace55dcd6a92d58d8df31ec0</url>
  <id>5df6fe20c63f83b9ace55dcd6a92d58d8df31ec0</id>
  <committed-date>2008-08-08T11:16:02-07:00</committed-date>
  <authored-date>2008-08-08T11:16:02-07:00</authored-date>
  <message>Added mail_to HTML helper. [#83 state:resolved]</message>
  <tree>e9f9ed03dc977788582485be34abc7a76094a137</tree>
  <committer>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </committer>
</commit>
