]> git.openstreetmap.org Git - rails.git/commitdiff
Convert diary views to use CSS based user specific components
authorTom Hughes <tom@compton.nu>
Wed, 21 Jul 2010 20:11:52 +0000 (21:11 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 21 Jul 2010 21:24:35 +0000 (22:24 +0100)
app/views/diary_entry/_diary_comment.html.erb
app/views/diary_entry/_diary_entry.html.erb
app/views/diary_entry/list.html.erb
app/views/diary_entry/view.html.erb
test/functional/diary_entry_controller_test.rb

index 77238b4d37690348afd5586010d8609bff3f2d18..a0e75ecce0501de578f8ec44769a1cebf67e6305 100644 (file)
@@ -1,7 +1,7 @@
 <%= 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, :format => :friendly)) %></h4>
 <%= htmlize(diary_comment.body) %>
 <%= 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, :format => :friendly)) %></h4>
 <%= htmlize(diary_comment.body) %>
-<% if @user && @user.administrator? %> 
-<%= link_to t('diary_entry.diary_comment.hide_link'), {:action => 'hidecomment', :display_name => @user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id}, {:confirm => t('diary_entry.diary_comment.confirm')} %>
+<% if_administrator(:span) do %> 
+  <%= link_to t('diary_entry.diary_comment.hide_link'), {:action => 'hidecomment', :display_name => diary_comment.diary_entry.user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id}, {:confirm => t('diary_entry.diary_comment.confirm')} %>
 <% end %>
 <hr />
 <% end %>
 <hr />
index 8991e1d54e05f04a7b1f3864fc19daf213232bcc..d6e21869fbb06c7d1b7dc0fd8c5caa69d09cedc0 100644 (file)
@@ -1,25 +1,30 @@
 <b><%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %></b><br />
 <b><%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %></b><br />
+
 <div xml:lang="<%= diary_entry.language_code %>" lang="<%= diary_entry.language_code %>">
 <div xml:lang="<%= diary_entry.language_code %>" lang="<%= diary_entry.language_code %>">
-<%= htmlize(diary_entry.body) %>
+  <%= htmlize(diary_entry.body) %>
 </div>
 </div>
+
 <% if diary_entry.latitude and diary_entry.longitude %>
 <% if diary_entry.latitude and diary_entry.longitude %>
-<%= render :partial => "location", :object => diary_entry %>
-<br />
+  <%= render :partial => "location", :object => diary_entry %>
+  <br />
 <% end %>
 <% end %>
+
 <%= t 'diary_entry.diary_entry.posted_by', :link_user => (link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name), :created => l(diary_entry.created_at, :format => :friendly), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entry', :action => 'list', :language => diary_entry.language_code)  %> 
 <%= t 'diary_entry.diary_entry.posted_by', :link_user => (link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name), :created => l(diary_entry.created_at, :format => :friendly), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entry', :action => 'list', :language => diary_entry.language_code)  %> 
+
 <% if params[:action] == 'list' %>
 <% if params[:action] == 'list' %>
-<br />
-<%= link_to t('diary_entry.diary_entry.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %>
-|
-<%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :title => "Re: #{diary_entry.title}" %>
-|
-<%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %>
+  <br />
+  <%= link_to t('diary_entry.diary_entry.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %>
+  |
+  <%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :title => "Re: #{diary_entry.title}" %>
+  |
+  <%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %>
 <% end %>
 <% end %>
-<% if @user == diary_entry.user %> 
-| <%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => @user.display_name, :id => diary_entry.id %>
+<% if_user(diary_entry.user, :span) do %>
+  | <%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
 <% end %>
 <% end %>
-<% if @user && @user.administrator? %> 
-| <%= link_to t('diary_entry.diary_entry.hide_link'), {:action => 'hide', :display_name => @user.display_name, :id => diary_entry.id}, {:confirm => t('diary_entry.diary_entry.confirm')} %>
+<% if_administrator(:span) do %>
+  | <%= link_to t('diary_entry.diary_entry.hide_link'), {:action => 'hide', :display_name => diary_entry.user.display_name, :id => diary_entry.id}, {:confirm => t('diary_entry.diary_entry.confirm')} %>
 <% end %>
 <% end %>
+
 <br />
 <hr />
 <br />
 <hr />
index 9fbb9ca32aba72d812955446cb3ef04ca548b1f4..1be32fd21169f34109efe493e7746b2e00a25b34 100644 (file)
@@ -5,11 +5,11 @@
 <h2><%= h(@title) %></h2>
 
 <% if @this_user %>
 <h2><%= h(@title) %></h2>
 
 <% if @this_user %>
-  <% if @user == @this_user %>
+  <% if_user(@this_user) do %>
     <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %>
   <% end %>
 <% else %>
     <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %>
   <% end %>
 <% else %>
-  <% if @user %>
+  <% if_logged_in do %>
     <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %>
   <% end %>
 <% end %>
     <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %>
   <% end %>
 <% end %>
index 312b7b81a75166a2f533f4e7184ba77a15ca8516..c3e49a22767852402a219a2ea2b63b101455ede7 100644 (file)
@@ -8,19 +8,19 @@
 
 <%= render :partial => 'diary_comment', :collection => @entry.visible_comments %>
 
 
 <%= render :partial => 'diary_comment', :collection => @entry.visible_comments %>
 
-<% if @user %>
-
-<h4 id="newcomment"><%= t 'diary_entry.view.leave_a_comment' %></h4>
-<%= error_messages_for 'diary_comment' %>
-<% form_for :diary_comment, @diary_comment, :url => { :action => 'comment' } do |f| %>
-<%= f.text_area :body, :cols => 80, :rows => 5 %>
-<br />
-<br />
-<%= submit_tag t('diary_entry.view.save_button') %>
-<% end %>
+<% if_logged_in(:div) do %>
+  <h4 id="newcomment"><%= t 'diary_entry.view.leave_a_comment' %></h4>
 
 
-<% else %>
+  <%= error_messages_for 'diary_comment' %>
 
 
-<h4 id="newcomment"><%= t("diary_entry.view.login_to_leave_a_comment", :login_link => link_to(t("diary_entry.view.login"), :controller => 'user', :action => 'login', :referer => request.request_uri)) %></h4>
+  <% form_for :diary_comment, @diary_comment, :url => { :action => 'comment' } do |f| %>
+    <%= f.text_area :body, :cols => 80, :rows => 5 %>
+    <br />
+    <br />
+    <%= submit_tag t('diary_entry.view.save_button') %>
+  <% end %>
+<% end %>
 
 
+<% if_not_logged_in(:div) do %>
+  <h4 id="newcomment"><%= t("diary_entry.view.login_to_leave_a_comment", :login_link => link_to(t("diary_entry.view.login"), :controller => 'user', :action => 'login', :referer => request.request_uri)) %></h4>
 <% end %>
 <% end %>
index bd65088e4ed4a1b1b11c10980abd136fca568f6c..38c7bddcd50b89571de01e6745d2b67a0306a500 100644 (file)
@@ -137,7 +137,9 @@ class DiaryEntryControllerTest < ActionController::TestCase
           assert_select "p", :text => /#{new_body}/, :count => 1
           assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
           # As we're not logged in, check that you cannot edit
           assert_select "p", :text => /#{new_body}/, :count => 1
           assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
           # As we're not logged in, check that you cannot edit
-          assert_select "a[href='/user/#{users(:normal_user).display_name}/diary/#{diary_entries(:normal_user_entry_1).id}/edit']", :text => "Edit this entry", :count => 0
+          assert_select "span[class=hidden show_if_user_#{users(:normal_user).id}]", :count => 1 do
+            assert_select "a[href='/user/#{users(:normal_user).display_name}/diary/#{diary_entries(:normal_user_entry_1).id}/edit']", :text => "Edit this entry", :count => 1
+          end
         end
       end
     end
         end
       end
     end