]> git.openstreetmap.org Git - rails.git/blob - app/views/changeset/list.atom.builder
More improvements to Atom feeds.
[rails.git] / app / views / changeset / list.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({ :only_path => false, :format => nil })),
4           "xmlns:georss" => "http://www.georss.org/georss") do |feed|
5   feed.title @title
6
7   feed.subtitle :type => 'xhtml' do |xhtml|
8     xhtml.p @description
9   end
10
11   feed.updated @edits.map {|e|  [e.created_at, e.closed_at].max }.max
12   feed.icon "http://#{SERVER_URL}/favicon.ico"
13   feed.logo "http://#{SERVER_URL}/images/mag_map-rss2.0.png"
14
15   feed.rights :type => 'xhtml' do |xhtml|
16     xhtml.a :href => "http://creativecommons.org/licenses/by-sa/2.0/" do |a|
17       a.img :src => "http://#{SERVER_URL}/images/cc_button.png", :alt => "CC by-sa 2.0"
18     end
19   end
20
21   for changeset in @edits
22     feed.entry(changeset, :updated => changeset.closed_at, :id => changeset_url(changeset.id, :only_path => false)) do |entry|
23       entry.link :rel => "alternate",
24                  :href => changeset_read_url(changeset, :only_path => false),
25                  :type => "application/osm+xml"
26       entry.link :rel => "alternate",
27                  :href => changeset_download_url(changeset, :only_path => false),
28                  :type => "application/osmChange+xml"
29
30       entry.title t('browse.changeset.title') + " " + h(changeset.id)
31
32       if changeset.user.data_public?
33         entry.author do |author|
34           author.name changeset.user.display_name
35           author.uri url_for(:controller => 'user', :action => 'view', :display_name => changeset.user.display_name, :only_path => false)
36         end
37       end
38
39       feed.content :type => 'xhtml' do |xhtml|
40         xhtml.table do |table|
41           table.tr do |tr|
42             tr.th t("browse.changeset_details.created_at")
43             tr.td l(changeset.created_at)
44           end
45           table.tr do |tr|
46             tr.th t("browse.changeset_details.closed_at")
47             tr.td l(changeset.closed_at)
48           end
49           if changeset.user.data_public?
50             table.tr do |tr|
51               tr.th t("browse.changeset_details.belongs_to")
52               tr.td do |td|
53                 td.a h(changeset.user.display_name), :href => url_for(:controller => "user", :action => "view", :display_name => changeset.user.display_name, :only_path => false)
54               end
55             end
56           end
57           unless changeset.tags.empty?
58             table.tr :valign => "top" do |tr|
59               tr.th t("browse.tag_details.tags")
60               tr.td do |td|
61                 td.table :cellpadding => "0" do |table|
62                   changeset.tags.sort.each do |tag|
63                     table.tr do |tr|
64                       tr.td "#{h(tag[0])} = #{sanitize(auto_link(tag[1]))}"
65                     end
66                   end
67                 end
68               end
69             end
70           end
71         end
72       end
73
74       unless changeset.min_lat.nil?
75         minlon = changeset.min_lon/GeoRecord::SCALE.to_f
76         minlat = changeset.min_lat/GeoRecord::SCALE.to_f
77         maxlon = changeset.max_lon/GeoRecord::SCALE.to_f
78         maxlat = changeset.max_lat/GeoRecord::SCALE.to_f
79
80         # See http://georss.org/Encodings#Geometry
81         lower_corner = "#{minlat} #{minlon}"
82         upper_corner = "#{maxlat} #{maxlon}"
83
84         feed.georss :box, lower_corner + " " + upper_corner
85       end
86     end
87   end
88 end