]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/application_helper.rb
Make rel=nofollow actually work - when in doubt trust the source as
[rails.git] / app / helpers / application_helper.rb
index 7dcbe369b4eca7868f3b93084be921e5307f617e..2eebec1708378663a5bc4f67ad828ec5dd847da9 100644 (file)
@@ -1,6 +1,14 @@
 module ApplicationHelper
   def htmlize(text)
-    return sanitize(auto_link(simple_format(text), :urls))
+    return sanitize(auto_link(simple_format(text), :link => :urls, :html => { :rel => "nofollow" }))
+  end
+
+  def html_escape_unicode(text)
+    chars = ActiveSupport::Multibyte::Chars.u_unpack(text).map do |c|
+      c < 127 ? c.chr : "&##{c.to_s};"
+    end
+
+    return chars.join("")
   end
 
   def rss_link_to(*args)
@@ -26,10 +34,10 @@ private
 
   def javascript_strings_for_key(key)
     js = ""
-    value = t(key)
+    value = t(key, :locale => "en")
 
     if value.is_a?(String)
-      js << "i18n_strings['#{key}'] = '" << escape_javascript(value) << "';\n"
+      js << "i18n_strings['#{key}'] = '" << escape_javascript(t(key)) << "';\n"
     else
       value.each_key do |k|
         js << javascript_strings_for_key("#{key}.#{k}")