]> git.openstreetmap.org Git - rails.git/blob - app/helpers/changesets_helper.rb
Merge remote-tracking branch 'upstream/pull/4151'
[rails.git] / app / helpers / changesets_helper.rb
1 module ChangesetsHelper
2   def changeset_user_link(changeset)
3     if changeset.user.status == "deleted"
4       t("users.no_such_user.deleted")
5     elsif changeset.user.data_public?
6       link_to(changeset.user.display_name, user_path(changeset.user))
7     else
8       t("browse.anonymous")
9     end
10   end
11
12   def changeset_details(changeset)
13     if changeset.closed_at > Time.now.utc
14       action = :created
15       time = time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")
16       title = l(changeset.created_at)
17     else
18       action = :closed
19       time = time_ago_in_words(changeset.closed_at, :scope => :"datetime.distance_in_words_ago")
20       title = safe_join([t("browse.created"), ": ", l(changeset.created_at), "
".html_safe, t("browse.closed"), ": ", l(changeset.closed_at)])
21     end
22
23     if params.key?(:display_name)
24       t "browse.#{action}_ago_html", :time_ago => tag.abbr(time, :title => title)
25     else
26       t "browse.#{action}_ago_by_html", :time_ago => tag.abbr(time, :title => title),
27                                         :user => changeset_user_link(changeset)
28     end
29   end
30
31   def changeset_index_title(params, user)
32     if params[:friends] && user
33       t "changesets.index.title_friend"
34     elsif params[:nearby] && user
35       t "changesets.index.title_nearby"
36     elsif params[:display_name]
37       t "changesets.index.title_user", :user => params[:display_name]
38     else
39       t "changesets.index.title"
40     end
41   end
42 end