diff options
| author | Michel Etienne | 2015-01-09 17:40:47 +0100 | 
|---|---|---|
| committer | Michel Etienne | 2015-01-09 17:40:47 +0100 | 
| commit | 4574ad2fb9d1622396d86aa26074930f5cfa5c16 (patch) | |
| tree | 29fd5dd7a482dfe621a173f8e37a9699206c8842 /app/helpers | |
| parent | 83f9d8cf48fb832b43f0ea08d6ee53eef1be734a (diff) | |
| download | chouette-core-4574ad2fb9d1622396d86aa26074930f5cfa5c16.tar.bz2 | |
add tests for hub export
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/rule_parameter_sets_helper.rb | 5 | ||||
| -rw-r--r-- | app/helpers/users_helper.rb | 32 | 
2 files changed, 31 insertions, 6 deletions
| diff --git a/app/helpers/rule_parameter_sets_helper.rb b/app/helpers/rule_parameter_sets_helper.rb index 8485b63ca..538a5cddd 100644 --- a/app/helpers/rule_parameter_sets_helper.rb +++ b/app/helpers/rule_parameter_sets_helper.rb @@ -13,6 +13,11 @@ module RuleParameterSetsHelper      return t("rule_parameter_sets.labels.lower_char") if value == "4"    end +  def boolean_value(value) +    return t("true") if value == "1" +    t "false" +  end +    end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index ea5f41fb7..11fd7af34 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -4,13 +4,33 @@ module UsersHelper        image_tag user_image(user), :alt => "", :class => "preview", :width => size, :height => size    end -  def user_default_avatar -    return "#{authenticated_root_url}#{image_path('icons/user.png')}" if Rails.application.config.relative_url_root.blank? +#  def user_default_avatar +#    return "#{authenticated_root_url}#{image_path('icons/user.png')}" if Rails.application.config.relative_url_root.blank? +#   relative_url_root = Rails.application.config.relative_url_root.gsub( /\//, '') +#    "#{authenticated_root_url}#{image_path('icons/user.png')}". +#      sub( Regexp.new("/#{relative_url_root}/#{relative_url_root}/"), "/#{relative_url_root}/"). +#      sub( Regexp.new("/#{relative_url_root}//#{relative_url_root}/"), "/#{relative_url_root}/") +#  end -    relative_url_root = Rails.application.config.relative_url_root.gsub( /\//, '') -    "#{authenticated_root_url}#{image_path('icons/user.png')}". -      sub( Regexp.new("/#{relative_url_root}/#{relative_url_root}/"), "/#{relative_url_root}/"). -      sub( Regexp.new("/#{relative_url_root}//#{relative_url_root}/"), "/#{relative_url_root}/") +  def gravatar_hash(user) +    Digest::MD5.hexdigest( user.email) +  end +  def gravatar_url( user) +    "http://www.gravatar.com/avatar/#{gravatar_hash(user)}?d=404" +  end +  def user_image(user) +    begin +      gravatar_resource = RestClient.get( gravatar_url( user)){|response, request, result| response } +    rescue +      # Happens if network is not available +      return 'icons/user.png' +    end +    if gravatar_resource.code == 404 +      # Happens if user has not registered to gravatar +      'icons/user.png' +    else +      gravatar_url( user) +    end    end  end | 
