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