Browse code

cleaned up helpers

B Mathis authored on 12/11/2009 at 20:13:51
Showing 1 changed files
... ...
@@ -85,49 +85,6 @@ module Helpers
85 85
       content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick))
86 86
     end
87 87
     
88
-    def mail_to(email_address, name = nil, html_options = {})
89
-      html_options = html_options.stringify_keys
90
-      encode = html_options.delete("encode").to_s
91
-      cc, bcc, subject, body = html_options.delete("cc"), html_options.delete("bcc"), html_options.delete("subject"), html_options.delete("body")
92
-      
93
-      string = ''
94
-      extras = ''
95
-      extras << "cc=#{CGI.escape(cc).gsub("+", "%20")}&" unless cc.nil?
96
-      extras << "bcc=#{CGI.escape(bcc).gsub("+", "%20")}&" unless bcc.nil?
97
-      extras << "body=#{CGI.escape(body).gsub("+", "%20")}&" unless body.nil?
98
-      extras << "subject=#{CGI.escape(subject).gsub("+", "%20")}&" unless subject.nil?
99
-      extras = "?" << extras.gsub!(/&?$/,"") unless extras.empty?
100
-      
101
-      email_address = email_address.to_s
102
-      
103
-      email_address_obfuscated = email_address.dup
104
-      email_address_obfuscated.gsub!(/@/, html_options.delete("replace_at")) if html_options.has_key?("replace_at")
105
-      email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")
106
-      
107
-      if encode == "javascript"
108
-        "document.write('#{content_tag("a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
109
-          string << sprintf("%%%x", c)
110
-        end
111
-        "<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>"
112
-      elsif encode == "hex"
113
-        email_address_encoded = ''
114
-        email_address_obfuscated.each_byte do |c|
115
-          email_address_encoded << sprintf("&#%d;", c)
116
-        end
117
-        
118
-        protocol = 'mailto:'
119
-        protocol.each_byte { |c| string << sprintf("&#%d;", c) }
120
-        
121
-        email_address.each_byte do |c|
122
-          char = c.chr
123
-          string << (char =~ /\w/ ? sprintf("%%%x", c) : char)
124
-        end
125
-        content_tag "a", name || email_address_encoded, html_options.merge({ "href" => "#{string}#{extras}" })
126
-      else
127
-        content_tag "a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:#{email_address}#{extras}" })
128
-      end
129
-    end
130
-    
131 88
     private
132 89
     
133 90
       def cdata_section(content)
... ...
@@ -156,15 +113,6 @@ 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
-  
168 159
   def show_part (file)
169 160
     data = ''
170 161
     f = File.open(Dir.pwd+"/source/"+file)