]> git.openstreetmap.org Git - rails.git/blob - app/helpers/note_helper.rb
Merge remote-tracking branch 'upstream/pull/3999'
[rails.git] / app / helpers / note_helper.rb
1 module NoteHelper
2   include ActionView::Helpers::TranslationHelper
3
4   def note_event(event, at, by)
5     if by.nil?
6       t("notes.show.event_#{event}_by_anonymous_html",
7         :time_ago => tag.abbr(friendly_date_ago(at),
8                               :title => l(at)))
9     else
10       t("notes.show.event_#{event}_by_html",
11         :time_ago => tag.abbr(friendly_date_ago(at),
12                               :title => l(at)),
13         :user => note_author(by))
14     end
15   end
16
17   def note_author(author, link_options = {})
18     if author.nil?
19       ""
20     elsif author.status == "deleted"
21       t("users.no_such_user.deleted")
22     else
23       link_to h(author.display_name), link_options.merge(:controller => "/users", :action => "show", :display_name => author.display_name)
24     end
25   end
26
27   def disappear_in(note)
28     date = note.freshly_closed_until
29     tag.span(distance_of_time_in_words(date, Time.now.utc), :title => l(date, :format => :friendly))
30   end
31 end