]> git.openstreetmap.org Git - rails.git/commitdiff
Add user images to diary view.
authorTom Hughes <tom@compton.nu>
Sun, 28 Feb 2010 00:24:33 +0000 (00:24 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 28 Feb 2010 00:24:33 +0000 (00:24 +0000)
app/helpers/application_helper.rb
app/views/diary_entry/_diary_comment.html.erb
app/views/diary_entry/view.html.erb
app/views/user/_contact.html.erb
app/views/user/view.html.erb

index c5df676757d1ca761f13453a463aaf16f67eee5d..7a4953f0ffdf79c835efb6c428474101f1f75178 100644 (file)
@@ -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)
index b2a4449828d53a4974e0e731556aa75f4201430c..6bc7f73f9ffdfe1f0b78d90c58a65f8261fb1792 100644 (file)
@@ -1,3 +1,4 @@
+<%= user_thumbnail diary_comment.user, :style => "float: right" %>
 <h4 id="comment<%= diary_comment.id %>"><%= 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)) %></h4>
 <%= htmlize(diary_comment.body) %>
 <% if @user && @user.administrator? %> 
index 8e71cb24298a5b9d9fdfc759e7e03308348629d0..312b7b81a75166a2f533f4e7184ba77a15ca8516 100644 (file)
@@ -1,3 +1,5 @@
+<%= user_image @entry.user, :style => "float: right" %>
+
 <h2><%= t 'diary_entry.view.user_title', :user => h(@entry.user.display_name) %></h2>
 
 <%= render :partial => 'diary_entry', :object => @entry %>
index aa277f83ed3bc78112c2d9eb2029272529c39834..f019ccf159af08a7d913eb3e53fda9dd916dba5c 100644 (file)
@@ -1,10 +1,6 @@
 <tr>
   <td rowspan="2">
-    <% 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 %>
   </td>
   <td>
     <%= link_to h(contact.display_name), :controller => 'user', :action => 'view',  :display_name => contact.display_name %>
index 0a182861e4611c5575c59b42c8609bfb3b6dbb87..8aa4ead492486182895318e2f801335490a8964f 100644 (file)
@@ -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" %>
 
 <h2><%= h(@this_user.display_name) %>