source: subversion/sites/rails_port/app/helpers/application_helper.rb @ 18588

Revision 18588, 1.2 KB checked in by tomhughes, 4 years ago (diff)

Make rel=nofollow actually work - when in doubt trust the source as
the rails documentation speaks with forked tongue.

Line 
1module ApplicationHelper
2  def htmlize(text)
3    return sanitize(auto_link(simple_format(text), :link => :urls, :html => { :rel => "nofollow" }))
4  end
5
6  def html_escape_unicode(text)
7    chars = ActiveSupport::Multibyte::Chars.u_unpack(text).map do |c|
8      c < 127 ? c.chr : "&##{c.to_s};"
9    end
10
11    return chars.join("")
12  end
13
14  def rss_link_to(*args)
15    return link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), Hash[*args], { :class => "rsssmall" });
16  end
17
18  def atom_link_to(*args)
19    return link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), Hash[*args], { :class => "rsssmall" });
20  end
21
22  def javascript_strings
23    js = ""
24
25    js << "<script type='text/javascript'>\n"
26    js << "i18n_strings = new Array();\n"
27    js << javascript_strings_for_key("javascripts")
28    js << "</script>\n"
29
30    return js
31  end
32
33private
34
35  def javascript_strings_for_key(key)
36    js = ""
37    value = t(key, :locale => "en")
38
39    if value.is_a?(String)
40      js << "i18n_strings['#{key}'] = '" << escape_javascript(t(key)) << "';\n"
41    else
42      value.each_key do |k|
43        js << javascript_strings_for_key("#{key}.#{k}")
44      end
45    end
46
47    return js
48  end
49end
Note: See TracBrowser for help on using the repository browser.