Skip to content

Commit

Permalink
Improve display of anonymous note comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Feb 2, 2013
1 parent 0b993e5 commit 2ef58f4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
8 changes: 0 additions & 8 deletions app/helpers/application_helper.rb
Expand Up @@ -99,12 +99,4 @@ def dir
def friendly_date(date) def friendly_date(date)
content_tag(:span, time_ago_in_words(date), :title => l(date, :format => :friendly)) content_tag(:span, time_ago_in_words(date), :title => l(date, :format => :friendly))
end end

def note_author(object, link_options = {})
if object.author.nil?
""
else
link_to h(object.author.display_name), link_options.merge({:controller => "user", :action => "view", :display_name => object.author.display_name})
end
end
end end
13 changes: 13 additions & 0 deletions app/helpers/note_helper.rb
@@ -0,0 +1,13 @@
module NoteHelper
def note_event(at, by)
if by.nil?
I18n.t("browse.note.at_html", :when => friendly_date(at)).html_safe
else
I18n.t("browse.note.at_by_html", :when => friendly_date(at), :user => note_author(by)).html_safe
end
end

def note_author(author, link_options = {})
link_to h(author.display_name), link_options.merge({:controller => "user", :action => "view", :display_name => author.display_name})
end
end
8 changes: 4 additions & 4 deletions app/views/browse/note.html.erb
Expand Up @@ -18,18 +18,18 @@
<div class='browse-section common'> <div class='browse-section common'>
<div> <div>
<h4><%= t "browse.note.opened" %></h4> <h4><%= t "browse.note.opened" %></h4>
<p><%= t "browse.note.at_by_html", :when => friendly_date(@note.created_at), :user => note_author(@note) %></p> <p><%= note_event(@note.created_at, @note.author) %></p>
</div> </div>


<% if @note.status == "closed" %> <% if @note.status == "closed" %>
<div> <div>
<h4><%= t "browse.note.closed" %></h4> <h4><%= t "browse.note.closed" %></h4>
<p><%= t "browse.note.at_by_html", :when => friendly_date(@note.closed_at), :user => note_author(@note.comments.last) %></p> <p><%= note_event(@note.closed_at, @note.comments.last.author) %></p>
</div> </div>
<% elsif @note.comments.length > 1 %> <% elsif @note.comments.length > 1 %>
<div> <div>
<h4><%= t "browse.note.last_modified" %></h4> <h4><%= t "browse.note.last_modified" %></h4>
<p><%= t "browse.note.at_by_html", :when => friendly_date(@note.updated_at), :user => note_author(@note.comments.last) %></p> <p><%= note_event(@note.updated_at, @note.comments.last.author) %></p>
</div> </div>
<% end %> <% end %>


Expand All @@ -51,7 +51,7 @@
<% @note.comments[1..-1].each do |comment| %> <% @note.comments[1..-1].each do |comment| %>
<li> <li>
<%= comment.body.to_html %> <%= comment.body.to_html %>
<small class="deemphasize"><%= t "browse.note.at_by_html", :when => friendly_date(comment.created_at), :user => note_author(comment) %></small> <small class="deemphasize"><%= note_event(comment.created_at, comment.author) %></small>
</li> </li>
<% end %> <% end %>
</ul> </ul>
Expand Down
6 changes: 5 additions & 1 deletion app/views/notes/_description.html.erb
@@ -1,7 +1,11 @@
<div> <div>
<% description.comments.each do |comment| -%> <% description.comments.each do |comment| -%>
<div class="note-comment" style="margin-top: 5px"> <div class="note-comment" style="margin-top: 5px">
<div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment, :only_path => false) %></div> <% if comment.author.nil> -%>
<div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %></div>
<% else -%>
<div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
<% end -%>
<div class="note-comment-text"><%= comment.body %></div> <div class="note-comment-text"><%= comment.body %></div>
</div> </div>
<% end -%> <% end -%>
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Expand Up @@ -288,6 +288,7 @@ en:
opened: "Opened:" opened: "Opened:"
last_modified: "Last modified:" last_modified: "Last modified:"
closed: "Closed:" closed: "Closed:"
at_html: "%{when} ago"
at_by_html: "%{when} ago by %{user}" at_by_html: "%{when} ago by %{user}"
description: "Description:" description: "Description:"
comments: "Comments:" comments: "Comments:"
Expand Down Expand Up @@ -1979,9 +1980,13 @@ en:
needs_view: "The user needs to log in before this block will be cleared." needs_view: "The user needs to log in before this block will be cleared."
note: note:
description: description:
opened_at: "Created %{when} ago"
opened_at_by: "Created %{when} ago by %{user}" opened_at_by: "Created %{when} ago by %{user}"
commented_at: "Updated %{when} ago"
commented_at_by: "Updated %{when} ago by %{user}" commented_at_by: "Updated %{when} ago by %{user}"
closed_at: "Resolved %{when} ago"
closed_at_by: "Resolved %{when} ago by %{user}" closed_at_by: "Resolved %{when} ago by %{user}"
reopened_at: "Reactivated %{when} ago"
reopened_at_by: "Reactivated %{when} ago by %{user}" reopened_at_by: "Reactivated %{when} ago by %{user}"
rss: rss:
title: "OpenStreetMap Notes" title: "OpenStreetMap Notes"
Expand Down

0 comments on commit 2ef58f4

Please sign in to comment.