]> git.openstreetmap.org Git - rails.git/blob - app/views/changesets/index.atom.builder
Replace CC by-sa license link with ODbL in history feeds
[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 "Open Data Commons Open Database License", :href => "https://opendatacommons.org/licenses/odbl/"
14   end
15
16   @changesets.each do |changeset|
17     feed.entry(changeset, :updated => changeset.closed_at, :id => changeset_url(changeset.id, :only_path => false)) do |entry|
18       entry.link :rel => "alternate",
19                  :href => api_changeset_url(changeset, :only_path => false),
20                  :type => "application/osm+xml"
21       entry.link :rel => "alternate",
22                  :href => api_changeset_download_url(changeset, :only_path => false),
23                  :type => "application/osmChange+xml"
24
25       if !changeset.tags.empty? && changeset.tags.key?("comment")
26         entry.title t(".feed.title_comment", :id => changeset.id, :comment => changeset.tags["comment"])
27       else
28         entry.title t(".feed.title", :id => changeset.id)
29       end
30
31       if changeset.user.data_public?
32         entry.author do |author|
33           author.name changeset.user.display_name
34           author.uri user_url(changeset.user, :only_path => false)
35         end
36       end
37
38       feed.content :type => "xhtml" do |xhtml|
39         xhtml.style "th { text-align: left } tr { vertical-align: top }"
40         xhtml.table do |table|
41           table.tr do |tr|
42             tr.th t(".feed.created")
43             tr.td l(changeset.created_at)
44           end
45           table.tr do |tr|
46             tr.th t(".feed.closed")
47             tr.td l(changeset.closed_at)
48           end
49           if changeset.user.data_public?
50             table.tr do |tr|
51               tr.th t(".feed.belongs_to")
52               tr.td do |td|
53                 td.a changeset.user.display_name, :href => user_url(changeset.user, :only_path => false)
54               end
55             end
56           end
57           unless changeset.tags.empty?
58             table.tr do |tr|
59               tr.th t("browse.tag_details.tags")
60               tr.td do |td|
61                 td.table :cellpadding => "0" do |tag_table|
62                   changeset.tags.sort.each do |tag|
63                     tag_table.tr do |tag_tr|
64                       tag_tr.td "#{tag[0]} = #{linkify(tag[1])}"
65                     end
66                   end
67                 end
68               end
69             end
70           end
71         end
72       end
73
74       if changeset.bbox_valid?
75         bbox = changeset.bbox.to_unscaled
76
77         # See http://georss.org/Encodings#Geometry
78         lower_corner = "#{bbox.min_lat} #{bbox.min_lon}"
79         upper_corner = "#{bbox.max_lat} #{bbox.max_lon}"
80
81         feed.georss :box, "#{lower_corner} #{upper_corner}"
82       end
83     end
84   end
85 end