From: Tom Hughes Date: Wed, 21 Jul 2010 20:11:52 +0000 (+0100) Subject: Convert diary views to use CSS based user specific components X-Git-Tag: live~6302^2~8 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/6f73468f188630be503cdb19b00be7d1ea888785?ds=sidebyside Convert diary views to use CSS based user specific components --- diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index 77238b4d3..a0e75ecce 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -1,7 +1,7 @@ <%= 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, :format => :friendly)) %>

<%= 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 %>
diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index 8991e1d54..d6e21869f 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -1,25 +1,30 @@ <%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
+
-<%= htmlize(diary_entry.body) %> + <%= htmlize(diary_entry.body) %>
+ <% if diary_entry.latitude and diary_entry.longitude %> -<%= render :partial => "location", :object => diary_entry %> -
+ <%= render :partial => "location", :object => diary_entry %> +
<% 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) %> + <% if params[:action] == 'list' %> -
-<%= 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' %> +
+ <%= 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 %> -<% 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 %> -<% 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 %> +

diff --git a/app/views/diary_entry/list.html.erb b/app/views/diary_entry/list.html.erb index 9fbb9ca32..1be32fd21 100644 --- a/app/views/diary_entry/list.html.erb +++ b/app/views/diary_entry/list.html.erb @@ -5,11 +5,11 @@

<%= h(@title) %>

<% 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 %> - <% 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 %> diff --git a/app/views/diary_entry/view.html.erb b/app/views/diary_entry/view.html.erb index 312b7b81a..c3e49a227 100644 --- a/app/views/diary_entry/view.html.erb +++ b/app/views/diary_entry/view.html.erb @@ -8,19 +8,19 @@ <%= render :partial => 'diary_comment', :collection => @entry.visible_comments %> -<% if @user %> - -

<%= t 'diary_entry.view.leave_a_comment' %>

-<%= error_messages_for 'diary_comment' %> -<% form_for :diary_comment, @diary_comment, :url => { :action => 'comment' } do |f| %> -<%= f.text_area :body, :cols => 80, :rows => 5 %> -
-
-<%= submit_tag t('diary_entry.view.save_button') %> -<% end %> +<% if_logged_in(:div) do %> +

<%= t 'diary_entry.view.leave_a_comment' %>

-<% else %> + <%= error_messages_for 'diary_comment' %> -

<%= 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)) %>

+ <% form_for :diary_comment, @diary_comment, :url => { :action => 'comment' } do |f| %> + <%= f.text_area :body, :cols => 80, :rows => 5 %> +
+
+ <%= submit_tag t('diary_entry.view.save_button') %> + <% end %> +<% end %> +<% if_not_logged_in(:div) do %> +

<%= 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)) %>

<% end %> diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index bd65088e4..38c7bddcd 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -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 "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