2013-06-03 16:12:24 -04:00
|
|
|
module UserNotificationsHelper
|
|
|
|
|
|
|
|
def indent(text, by=2)
|
|
|
|
spacer = " " * by
|
|
|
|
result = ""
|
|
|
|
text.each_line do |line|
|
|
|
|
result << spacer << line
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2013-07-24 03:13:15 -04:00
|
|
|
def correct_top_margin(html, desired)
|
|
|
|
fragment = Nokogiri::HTML.fragment(html)
|
|
|
|
if para = fragment.css("p:first").first
|
|
|
|
para["style"] = "margin-top: #{desired};"
|
|
|
|
end
|
|
|
|
fragment.to_html.html_safe
|
|
|
|
end
|
|
|
|
|
2013-11-28 17:20:56 -05:00
|
|
|
def logo_url
|
|
|
|
logo_url = SiteSetting.logo_url
|
|
|
|
if logo_url !~ /http(s)?\:\/\//
|
|
|
|
logo_url = "#{Discourse.base_url}#{logo_url}"
|
|
|
|
end
|
|
|
|
logo_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def html_site_link
|
|
|
|
"<a href='#{Discourse.base_url}'>#{@site_name}</a>"
|
|
|
|
end
|
|
|
|
|
|
|
|
def email_excerpt(html)
|
2013-11-29 12:21:21 -05:00
|
|
|
raw Sanitize.clean(HTML_Truncator.truncate(html, 300), Sanitize::Config::RELAXED)
|
2013-11-28 17:20:56 -05:00
|
|
|
end
|
2013-06-03 16:12:24 -04:00
|
|
|
end
|