]> git.openstreetmap.org Git - rails.git/blob - app/helpers/changesets_helper.rb
Simplify subscribe path helper calls
[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, 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       datetime = changeset.created_at.xmlschema
18     else
19       action = :closed
20       time = time_ago_in_words(changeset.closed_at, :scope => :"datetime.distance_in_words_ago")
21       title = safe_join([t("changesets.show.created", :when => l(changeset.created_at)), "
".html_safe, t("changesets.show.closed", :when => l(changeset.closed_at))])
22       datetime = changeset.closed_at.xmlschema
23     end
24
25     if params.key?(:display_name)
26       t "changesets.show.#{action}_ago_html", :time_ago => tag.time(time, :title => title, :datetime => datetime)
27     else
28       t "changesets.show.#{action}_ago_by_html", :time_ago => tag.time(time, :title => title, :datetime => datetime),
29                                                  :user => changeset_user_link(changeset)
30     end
31   end
32
33   def changeset_index_title(params, user)
34     if params[:friends] && user
35       t "changesets.index.title_friend"
36     elsif params[:nearby] && user
37       t "changesets.index.title_nearby"
38     elsif params[:display_name]
39       t "changesets.index.title_user", :user => params[:display_name]
40     else
41       t "changesets.index.title"
42     end
43   end
44 end