Switch to using ATOM for changeset feeds.
This commit is contained in:
parent
493fd3fa11
commit
336d40f2c5
3 changed files with 59 additions and 53 deletions
53
app/views/changeset/list.atom.builder
Normal file
53
app/views/changeset/list.atom.builder
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
atom_feed(:language => I18n.locale, :schema_date => 2009,
|
||||||
|
:id => url_for(params.merge({ :only_path => false })),
|
||||||
|
:root_url => url_for(params.merge({ :only_path => false, :format => nil })),
|
||||||
|
"xmlns:georss" => "http://www.georss.org/georss") do |feed|
|
||||||
|
feed.title @title
|
||||||
|
feed.subtitle @description
|
||||||
|
feed.updated @edits.map {|e| [e.created_at, e.closed_at].max }.max
|
||||||
|
feed.icon "http://#{SERVER_URL}/favicon.ico"
|
||||||
|
feed.logo "http://#{SERVER_URL}/images/mag_map-rss2.0.png"
|
||||||
|
|
||||||
|
feed.rights :type => 'xhtml' do |xhtml|
|
||||||
|
xhtml.a :href => "http://creativecommons.org/licenses/by-sa/2.0/" do |a|
|
||||||
|
a.img :src => "http://#{SERVER_URL}/images/cc_button.png", :alt => "CC by-sa 2.0"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for changeset in @edits
|
||||||
|
feed.entry(changeset, :updated => changeset.closed_at, :id => changeset_url(changeset.id, :only_path => false)) do |entry|
|
||||||
|
entry.link :rel => "alternate",
|
||||||
|
:href => changeset_read_url(changeset, :only_path => false),
|
||||||
|
:type => "application/osm+xml"
|
||||||
|
entry.link :rel => "alternate",
|
||||||
|
:href => changeset_download_url(changeset, :only_path => false),
|
||||||
|
:type => "application/osmChange+xml"
|
||||||
|
|
||||||
|
entry.title t('browse.changeset.title') + " " + h(changeset.id)
|
||||||
|
|
||||||
|
if changeset.user.data_public?
|
||||||
|
entry.author do |author|
|
||||||
|
author.name changeset.user.display_name
|
||||||
|
author.uri url_for(:controller => 'user', :action => 'view', :display_name => changeset.user.display_name, :only_path => false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if changeset.tags['comment']
|
||||||
|
feed.content changeset.tags['comment']
|
||||||
|
end
|
||||||
|
|
||||||
|
unless changeset.min_lat.nil?
|
||||||
|
minlon = changeset.min_lon/GeoRecord::SCALE.to_f
|
||||||
|
minlat = changeset.min_lat/GeoRecord::SCALE.to_f
|
||||||
|
maxlon = changeset.max_lon/GeoRecord::SCALE.to_f
|
||||||
|
maxlat = changeset.max_lat/GeoRecord::SCALE.to_f
|
||||||
|
|
||||||
|
# See http://georss.org/Encodings#Geometry
|
||||||
|
lower_corner = "#{minlat} #{minlon}"
|
||||||
|
upper_corner = "#{maxlat} #{maxlon}"
|
||||||
|
|
||||||
|
feed.georss :box, lower_corner + " " + upper_corner
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,47 +0,0 @@
|
||||||
xml.rss("version" => "2.0",
|
|
||||||
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
|
|
||||||
"xmlns:georss" => "http://www.georss.org/georss") do
|
|
||||||
xml.channel do
|
|
||||||
xml.title @title
|
|
||||||
xml.description @description
|
|
||||||
xml.link url_for(params.merge({ :only_path => false }))
|
|
||||||
xml.image do
|
|
||||||
xml.url "http://www.openstreetmap.org/images/mag_map-rss2.0.png"
|
|
||||||
xml.title "OpenStreetMap"
|
|
||||||
xml.width "100"
|
|
||||||
xml.height "100"
|
|
||||||
xml.link url_for(params.merge({ :only_path => false }))
|
|
||||||
end
|
|
||||||
|
|
||||||
for changeset in @edits
|
|
||||||
xml.item do
|
|
||||||
xml.title t('browse.changeset.title') + " " + h(changeset.id)
|
|
||||||
xml.link url_for(:controller => 'browse', :action => "changeset", :id => changeset.id, :only_path => false)
|
|
||||||
xml.guid url_for(:controller => 'browse', :action => "changeset", :id => changeset.id, :only_path => false)
|
|
||||||
if changeset.user.data_public?
|
|
||||||
xml.author changeset.user.display_name
|
|
||||||
end
|
|
||||||
if changeset.tags['comment']
|
|
||||||
xml.description changeset.tags['comment']
|
|
||||||
end
|
|
||||||
xml.pubDate changeset.created_at.to_s(:rfc822)
|
|
||||||
if changeset.user.data_public?
|
|
||||||
xml.comments url_for(:controller => "message", :action => "new", :id => changeset.user.id, :only_path => false)
|
|
||||||
end
|
|
||||||
|
|
||||||
unless changeset.min_lat.nil?
|
|
||||||
minlon = changeset.min_lon/GeoRecord::SCALE.to_f
|
|
||||||
minlat = changeset.min_lat/GeoRecord::SCALE.to_f
|
|
||||||
maxlon = changeset.max_lon/GeoRecord::SCALE.to_f
|
|
||||||
maxlat = changeset.max_lat/GeoRecord::SCALE.to_f
|
|
||||||
|
|
||||||
# See http://georss.org/Encodings#Geometry
|
|
||||||
lower_corner = "#{minlat} #{minlon}"
|
|
||||||
upper_corner = "#{maxlat} #{maxlon}"
|
|
||||||
|
|
||||||
xml.georss :box, lower_corner + " " + upper_corner
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,9 +6,9 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
|
|
||||||
map.connect "api/#{API_VERSION}/changeset/create", :controller => 'changeset', :action => 'create'
|
map.connect "api/#{API_VERSION}/changeset/create", :controller => 'changeset', :action => 'create'
|
||||||
map.connect "api/#{API_VERSION}/changeset/:id/upload", :controller => 'changeset', :action => 'upload', :id => /\d+/
|
map.connect "api/#{API_VERSION}/changeset/:id/upload", :controller => 'changeset', :action => 'upload', :id => /\d+/
|
||||||
map.connect "api/#{API_VERSION}/changeset/:id/download", :controller => 'changeset', :action => 'download', :id => /\d+/
|
map.changeset_download "api/#{API_VERSION}/changeset/:id/download", :controller => 'changeset', :action => 'download', :id => /\d+/
|
||||||
map.connect "api/#{API_VERSION}/changeset/:id/expand_bbox", :controller => 'changeset', :action => 'expand_bbox', :id => /\d+/
|
map.connect "api/#{API_VERSION}/changeset/:id/expand_bbox", :controller => 'changeset', :action => 'expand_bbox', :id => /\d+/
|
||||||
map.connect "api/#{API_VERSION}/changeset/:id", :controller => 'changeset', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
|
map.changeset_read "api/#{API_VERSION}/changeset/:id", :controller => 'changeset', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
|
||||||
map.connect "api/#{API_VERSION}/changeset/:id", :controller => 'changeset', :action => 'update', :id => /\d+/, :conditions => { :method => :put }
|
map.connect "api/#{API_VERSION}/changeset/:id", :controller => 'changeset', :action => 'update', :id => /\d+/, :conditions => { :method => :put }
|
||||||
map.connect "api/#{API_VERSION}/changeset/:id/close", :controller => 'changeset', :action => 'close', :id =>/\d+/
|
map.connect "api/#{API_VERSION}/changeset/:id/close", :controller => 'changeset', :action => 'close', :id =>/\d+/
|
||||||
map.connect "api/#{API_VERSION}/changesets", :controller => 'changeset', :action => 'query'
|
map.connect "api/#{API_VERSION}/changesets", :controller => 'changeset', :action => 'query'
|
||||||
|
@ -81,16 +81,16 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.connect '/browse/node/:id/history', :controller => 'browse', :action => 'node_history', :id => /\d+/
|
map.connect '/browse/node/:id/history', :controller => 'browse', :action => 'node_history', :id => /\d+/
|
||||||
map.connect '/browse/relation/:id', :controller => 'browse', :action => 'relation', :id => /\d+/
|
map.connect '/browse/relation/:id', :controller => 'browse', :action => 'relation', :id => /\d+/
|
||||||
map.connect '/browse/relation/:id/history', :controller => 'browse', :action => 'relation_history', :id => /\d+/
|
map.connect '/browse/relation/:id/history', :controller => 'browse', :action => 'relation_history', :id => /\d+/
|
||||||
map.connect '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/
|
map.changeset '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/
|
||||||
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
|
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
|
||||||
map.connect '/browse/changesets/rss', :controller => 'changeset', :action => 'list', :format => :rss
|
map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
|
||||||
|
|
||||||
# web site
|
# web site
|
||||||
map.root :controller => 'site', :action => 'index'
|
map.root :controller => 'site', :action => 'index'
|
||||||
map.connect '/', :controller => 'site', :action => 'index'
|
map.connect '/', :controller => 'site', :action => 'index'
|
||||||
map.connect '/edit', :controller => 'site', :action => 'edit'
|
map.connect '/edit', :controller => 'site', :action => 'edit'
|
||||||
map.connect '/history', :controller => 'changeset', :action => 'list'
|
map.connect '/history', :controller => 'changeset', :action => 'list'
|
||||||
map.connect '/history/rss', :controller => 'changeset', :action => 'list', :format => :rss
|
map.connect '/history/feed', :controller => 'changeset', :action => 'list', :format => :atom
|
||||||
map.connect '/export', :controller => 'site', :action => 'export'
|
map.connect '/export', :controller => 'site', :action => 'export'
|
||||||
map.connect '/login', :controller => 'user', :action => 'login'
|
map.connect '/login', :controller => 'user', :action => 'login'
|
||||||
map.connect '/logout', :controller => 'user', :action => 'logout'
|
map.connect '/logout', :controller => 'user', :action => 'logout'
|
||||||
|
@ -149,7 +149,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
# user pages
|
# user pages
|
||||||
map.connect '/user/:display_name', :controller => 'user', :action => 'view'
|
map.connect '/user/:display_name', :controller => 'user', :action => 'view'
|
||||||
map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list'
|
map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list'
|
||||||
map.connect '/user/:display_name/edits/rss', :controller => 'changeset', :action => 'list', :format =>:rss
|
map.connect '/user/:display_name/edits/feed', :controller => 'changeset', :action => 'list', :format =>:atom
|
||||||
map.connect '/user/:display_name/make_friend', :controller => 'user', :action => 'make_friend'
|
map.connect '/user/:display_name/make_friend', :controller => 'user', :action => 'make_friend'
|
||||||
map.connect '/user/:display_name/remove_friend', :controller => 'user', :action => 'remove_friend'
|
map.connect '/user/:display_name/remove_friend', :controller => 'user', :action => 'remove_friend'
|
||||||
map.connect '/user/:display_name/diary', :controller => 'diary_entry', :action => 'list'
|
map.connect '/user/:display_name/diary', :controller => 'diary_entry', :action => 'list'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue