Browse code

added email obfusticator to the helpers, use with #{to_html_email("user@domain.com")}

B Mathis authored on 12/11/2009 at 18:03:34
Showing 1 changed files
... ...
@@ -156,6 +156,15 @@ module Helpers
156 156
   
157 157
   # My added helpers
158 158
   
159
+  def to_html_email(address)
160
+    email = string_to_html(address)
161
+    "<a href=\"#{string_to_html('mailto:')}#{email}\">#{email}</a>"
162
+  end
163
+
164
+  def string_to_html(s)
165
+    s.strip.unpack("C*").map{|ch| "&#" + ch.to_s + ";" }.to_s
166
+  end
167
+  
159 168
   def show_part (file)
160 169
     data = ''
161 170
     f = File.open(Dir.pwd+"/source/"+file)