diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-06-25 12:49:17 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-06-25 12:49:17 +0100 |
commit | fe5880e555f98350b4c08a4885c560e35692687f (patch) | |
tree | 31ae4a508ec50a1c4801a56d85f1329848358380 /app/helpers/application_helper.rb | |
parent | c99c9ef86c9020939cf8d0930faca5bd206e111f (diff) | |
parent | f23b89f3474847cdd14ba892c5a7259964e18148 (diff) |
Merge branch 'issues/1434-email-highlighting' into rails-3-develop
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 45b042354..49ce94951 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -22,6 +22,9 @@ module ApplicationHelper # Useful for sending emails include MailerHelper + # Extra highlight helpers + include HighlightHelper + # Copied from error_messages_for in active_record_helper.rb def foi_error_messages_for(*params) options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {} @@ -54,25 +57,6 @@ module ApplicationHelper end end - # Highlight words, also escapes HTML (other than spans that we add) - def highlight_words(t, words, html = true) - if html - highlight(h(t), words, :highlighter => '<span class="highlight">\1</span>').html_safe - else - highlight(t, words, :highlighter => '*\1*') - end - end - - def highlight_and_excerpt(t, words, excount, html = true) - newt = excerpt(t, words[0], :radius => excount) - if not newt - newt = excerpt(t, '', :radius => excount) - end - t = newt - t = highlight_words(t, words, html) - return t - end - def locale_name(locale) return LanguageNames::get_language_name(locale) end |