]> git.openstreetmap.org Git - rails.git/blob - app/views/changesets/index.atom.builder
Merge remote-tracking branch 'upstream/pull/5349'
[rails.git] / app / views / changesets / index.atom.builder
1 atom_feed(:language => I18n.locale, :schema_date => 2009,
2           :id => url_for(@params.merge(:only_path => false)),
3           :root_url => url_for(@params.merge(:action => :index, :format => nil, :only_path => false)),
4           "xmlns:xhtml" => "http://www.w3.org/1999/xhtml",
5           "xmlns:georss" => "http://www.georss.org/georss") do |feed|
6   feed.title changeset_index_title(params, current_user)
7
8   feed.updated @changesets.map { |e| [e.created_at, e.closed_at].max }.max
9   feed.icon image_url("favicon.ico")
10   feed.logo image_url("mag_map-rss2.0.png")
11
12   feed.rights :type => "xhtml" do |xhtml|
13     xhtml.a :href => "https://creativecommons.org/licenses/by-sa/2.0/" do |a|
14       a.img :src => image_url("cc_button.png"), :alt => "CC by-sa 2.0"
15     end
16   end
17
18   @changesets.each do |changeset|
19     feed.entry(changeset, :updated => changeset.closed_at, :id => changeset_url(changeset.id, :only_path => false)) do |entry|
20       entry.link :rel => "alternate",
21                  :href => changeset_show_url(changeset, :only_path => false),
22                  :type => "application/osm+xml"
23       entry.link :rel => "alternate",
24                  :href => changeset_download_url(changeset, :only_path => false),
25                  :type => "application/osmChange+xml"
26
27       if !changeset.tags.empty? && changeset.tags.key?("comment")
28         entry.title t(".feed.title_comment", :id => changeset.id, :comment => changeset.tags["comment"])
29       else
30         entry.title t(".feed.title", :id => changeset.id)
31       end
32
33       if changeset.user.data_public?
34         entry.author do |author|
35           author.name changeset.user.display_name
36           author.uri user_url(changeset.user, :only_path => false)
37         end
38       end
39
40       feed.content :type => "xhtml" do |xhtml|
41         xhtml.style "th { text-align: left } tr { vertical-align: top }"
42         xhtml.table do |table|
43           table.tr do |tr|
44             tr.th t(".feed.created")
45             tr.td l(changeset.created_at)
46           end
47           table.tr do |tr|
48             tr.th t(".feed.closed")
49             tr.td l(changeset.closed_at)
50           end
51           if changeset.user.data_public?
52             table.tr do |tr|
53               tr.th t(".feed.belongs_to")
54               tr.td do |td|
55                 td.a changeset.user.display_name, :href => user_url(changeset.user, :only_path => false)
56               end
57             end
58           end
59           unless changeset.tags.empty?
60             table.tr do |tr|
61               tr.th t("browse.tag_details.tags")
62               tr.td do |td|
63                 td.table :cellpadding => "0" do |tag_table|
64                   changeset.tags.sort.each do |tag|
65                     tag_table.tr do |tag_tr|
66                       tag_tr.td "#{tag[0]} = #{linkify(tag[1])}"
67                     end
68                   end
69                 end
70               end
71             end
72           end
73         end
74       end
75
76       if changeset.bbox_valid?
77         bbox = changeset.bbox.to_unscaled
78
79         # See http://georss.org/Encodings#Geometry
80         lower_corner = "#{bbox.min_lat} #{bbox.min_lon}"
81         upper_corner = "#{bbox.max_lat} #{bbox.max_lon}"
82
83         feed.georss :box, "#{lower_corner} #{upper_corner}"
84       end
85     end
86   end
87 end