Commit 02130572aa4dfa420d259b8a15cd26c88b538c45

Authored by Nathan Broadbent
1 parent e7edcb8f
Exists in master and in 1 other branch production

Show gravatar on users index table, and in heading bar of users show page

app/assets/stylesheets/errbit.css
@@ -893,3 +893,12 @@ table.errs tr td.message .inline_comment em.commenter { @@ -893,3 +893,12 @@ table.errs tr td.message .inline_comment em.commenter {
893 893
894 .current.asc:after { content: ' ↑'; } 894 .current.asc:after { content: ' ↑'; }
895 .current.desc:after { content: ' ↓'; } 895 .current.desc:after { content: ' ↓'; }
  896 +
  897 +
  898 +table.users td {
  899 + vertical-align: middle;
  900 +}
  901 +table.users td img.gravatar {
  902 + vertical-align: middle;
  903 + margin-left: 3px;
  904 +}
app/helpers/errs_helper.rb
@@ -15,15 +15,17 @@ module ErrsHelper @@ -15,15 +15,17 @@ module ErrsHelper
15 end 15 end
16 16
17 def gravatar_tag(email, options = {}) 17 def gravatar_tag(email, options = {})
  18 + image_tag gravatar_url(email, options), :alt => email, :class => 'gravatar'
  19 + end
  20 +
  21 + def gravatar_url(email, options = {})
18 default_options = { 22 default_options = {
19 :d => Errbit::Config.gravatar_default, 23 :d => Errbit::Config.gravatar_default,
20 - :alt => email,  
21 - :class => 'gravatar'  
22 } 24 }
23 options.reverse_merge! default_options 25 options.reverse_merge! default_options
24 params = options.extract!(:s, :d).delete_if { |k, v| v.blank? } 26 params = options.extract!(:s, :d).delete_if { |k, v| v.blank? }
25 email_hash = Digest::MD5.hexdigest(email) 27 email_hash = Digest::MD5.hexdigest(email)
26 - image_tag "http://www.gravatar.com/avatar/#{email_hash}?#{params.to_query}", options 28 + "http://www.gravatar.com/avatar/#{email_hash}?#{params.to_query}"
27 end 29 end
28 end 30 end
29 31
app/views/layouts/application.html.haml
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 = render 'shared/navigation' if current_user 18 = render 'shared/navigation' if current_user
19 = render 'shared/session' 19 = render 'shared/session'
20 #content-wrapper 20 #content-wrapper
21 - #content-title{ :class => (yield :title_css_class).to_s } 21 + #content-title{ :class => (yield :title_css_class).to_s, :style => (yield :title_style) }
22 %h1= yield :title 22 %h1= yield :title
23 %span.meta= yield :meta 23 %span.meta= yield :meta
24 - if (action_bar = yield(:action_bar)).present? 24 - if (action_bar = yield(:action_bar)).present?
@@ -33,3 +33,4 @@ @@ -33,3 +33,4 @@
33 #footer= "Powered by #{link_to 'Errbit', 'http://github.com/errbit/errbit', :target => '_blank'}: the open source error catcher.".html_safe 33 #footer= "Powered by #{link_to 'Errbit', 'http://github.com/errbit/errbit', :target => '_blank'}: the open source error catcher.".html_safe
34 = yield :scripts 34 = yield :scripts
35 35
  36 += yield :before_title
36 \ No newline at end of file 37 \ No newline at end of file
app/views/users/index.html.haml
@@ -2,9 +2,11 @@ @@ -2,9 +2,11 @@
2 - content_for :action_bar do 2 - content_for :action_bar do
3 %span= link_to('Add a New User', new_user_path, :class => 'add') 3 %span= link_to('Add a New User', new_user_path, :class => 'add')
4 4
5 -%table 5 +%table.users
6 %thead 6 %thead
7 %tr 7 %tr
  8 + - if Errbit::Config.use_gravatar
  9 + %th
8 %th Name 10 %th Name
9 - if Errbit::Config.user_has_username 11 - if Errbit::Config.user_has_username
10 %th Username 12 %th Username
@@ -13,6 +15,8 @@ @@ -13,6 +15,8 @@
13 %tbody 15 %tbody
14 - @users.each do |user| 16 - @users.each do |user|
15 %tr 17 %tr
  18 + - if Errbit::Config.use_gravatar
  19 + %td= gravatar_tag user.email, :s => 24
16 %td.nowrap= link_to user.name, user_path(user) 20 %td.nowrap= link_to user.name, user_path(user)
17 - if Errbit::Config.user_has_username 21 - if Errbit::Config.user_has_username
18 %td= user.username 22 %td= user.username
app/views/users/show.html.haml
1 - content_for :title, @user.name 1 - content_for :title, @user.name
  2 +- if Errbit::Config.use_gravatar
  3 + - content_for :title_style do
  4 + background: url('#{gravatar_url @user.email, :s => 86}') no-repeat;
  5 + padding-left: 106px;
  6 +
2 - content_for :action_bar do 7 - content_for :action_bar do
3 = render 'shared/link_github_account', :user => @user 8 = render 'shared/link_github_account', :user => @user
4 %span= link_to('Add a New User', new_user_path, :class => 'add') 9 %span= link_to('Add a New User', new_user_path, :class => 'add')
5 = link_to 'edit', edit_user_path(@user), :class => 'button' 10 = link_to 'edit', edit_user_path(@user), :class => 'button'
6 = link_to 'destroy', user_path(@user), :method => :delete, :data => { :confirm => 'Seriously?' }, :class => 'button' 11 = link_to 'destroy', user_path(@user), :method => :delete, :data => { :confirm => 'Seriously?' }, :class => 'button'
7 12
8 -  
9 %table.single_user 13 %table.single_user
10 %tr 14 %tr
11 %th Email 15 %th Email