From: Tom Hughes Date: Sun, 28 Feb 2010 00:24:33 +0000 (+0000) Subject: Add user images to diary view. X-Git-Tag: live~5052^2~241 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3e8d8092500a3713e8dfbb4fd61fd8a95d067d20?ds=sidebyside Add user images to diary view. --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c5df67675..7a4953f0f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,6 +49,26 @@ module ApplicationHelper end end + def user_image(user, options = {}) + options[:class] ||= "user_image" + + if user.image + image_tag url_for_file_column(user, "image"), options + else + image_tag "anon_large.png", options + end + end + + def user_thumbnail(user, options = {}) + options[:class] ||= "user_thumbnail" + + if user.image + image_tag url_for_file_column(user, "image"), options + else + image_tag "anon_small.png", options + end + end + private def javascript_strings_for_key(key) diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index b2a444982..6bc7f73f9 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -1,3 +1,4 @@ +<%= user_thumbnail diary_comment.user, :style => "float: right" %>

<%= t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => l(diary_comment.created_at)) %>

<%= htmlize(diary_comment.body) %> <% if @user && @user.administrator? %> diff --git a/app/views/diary_entry/view.html.erb b/app/views/diary_entry/view.html.erb index 8e71cb242..312b7b81a 100644 --- a/app/views/diary_entry/view.html.erb +++ b/app/views/diary_entry/view.html.erb @@ -1,3 +1,5 @@ +<%= user_image @entry.user, :style => "float: right" %> +

<%= t 'diary_entry.view.user_title', :user => h(@entry.user.display_name) %>

<%= render :partial => 'diary_entry', :object => @entry %> diff --git a/app/views/user/_contact.html.erb b/app/views/user/_contact.html.erb index aa277f83e..f019ccf15 100644 --- a/app/views/user/_contact.html.erb +++ b/app/views/user/_contact.html.erb @@ -1,10 +1,6 @@ - <% if contact.image %> - <%= image_tag url_for_file_column(contact, "image"), :class => "user_thumbnail" %> - <% else %> - <%= image_tag "anon_small.png", :class => "user_thumbnail" %> - <% end %> + <%= user_thumbnail contact %> <%= link_to h(contact.display_name), :controller => 'user', :action => 'view', :display_name => contact.display_name %> diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 0a182861e..8aa4ead49 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -1,8 +1,4 @@ -<% if @this_user.image %> - <%= image_tag url_for_file_column(@this_user, "image"), :style => "float: right; margin-top: 19px", :class => "user_image" %> -<% else %> - <%= image_tag "anon_large.png", :style => "float: right; margin-top: 19px", :class => "user_image" %> -<% end %> +<%= user_image @this_user, :style => "float: right" %>

<%= h(@this_user.display_name) %>