Module: ProblemsHelper

Defined in:
app/helpers/problems_helper.rb

Instance Method Summary collapse

Instance Method Details

#gravatar_tag(email, options = {}) ⇒ Object


13
14
15
16
17
# File 'app/helpers/problems_helper.rb', line 13

def gravatar_tag(email, options = {})
  return nil unless email.present?

  image_tag gravatar_url(email, options), :alt => email, :class => 'gravatar'
end

#gravatar_url(email, options = {}) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/problems_helper.rb', line 19

def gravatar_url(email, options = {})
  return nil unless email.present?

  default_options = {
    :d => Errbit::Config.gravatar_default,
  }
  options.reverse_merge! default_options
  params = options.extract!(:s, :d).delete_if { |k, v| v.blank? }
  email_hash = Digest::MD5.hexdigest(email)
  url = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com"
  "#{url}/avatar/#{email_hash}?#{params.to_query}"
end

#problem_confirm(action) ⇒ Object


2
3
4
# File 'app/helpers/problems_helper.rb', line 2

def problem_confirm(action)
  t('problems.confirm.%s' % action) unless Errbit::Config.confirm_err_actions.eql? false
end

#truncated_problem_message(problem) ⇒ Object


6
7
8
9
10
11
# File 'app/helpers/problems_helper.rb', line 6

def truncated_problem_message(problem)
  unless (msg = problem.message).blank?
    # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule
    truncate(msg, :length => 300, :escape => false).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe
  end
end