simplify grabbing of a xml base doc
This commit is contained in:
parent
2f55a3f0a8
commit
668f8020cc
13 changed files with 45 additions and 46 deletions
|
@ -40,7 +40,7 @@ class ApiController < ApplicationController
|
|||
# get missing nodes if there are any
|
||||
nodes += Node.find(missing_nodes) if missing_nodes.length > 0
|
||||
|
||||
doc = get_xml_doc
|
||||
doc = OSM::API.get_xml_doc
|
||||
|
||||
# get ways
|
||||
# find which ways are needed
|
||||
|
|
|
@ -38,16 +38,6 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def get_xml_doc
|
||||
doc = XML::Document.new
|
||||
doc.encoding = 'UTF-8'
|
||||
root = XML::Node.new 'osm'
|
||||
root['version'] = API_VERSION
|
||||
root['generator'] = 'OpenStreetMap server'
|
||||
doc.root = root
|
||||
return doc
|
||||
end
|
||||
|
||||
# extract authorisation credentials from headers, returns user = nil if none
|
||||
private
|
||||
def get_auth_data
|
||||
|
|
|
@ -9,7 +9,7 @@ class OldNodeController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
doc = get_xml_doc
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
|
||||
node.old_nodes.each do |old_node|
|
||||
doc.root << old_node.to_xml_node
|
||||
|
|
|
@ -9,7 +9,7 @@ class OldSegmentController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
doc = get_xml_doc
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
|
||||
segment.old_segments.each do |old_segment|
|
||||
doc.root << old_segment.to_xml_node
|
||||
|
@ -17,9 +17,4 @@ class OldSegmentController < ApplicationController
|
|||
|
||||
render :text => doc.to_s
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ class SegmentController < ApplicationController
|
|||
ids = params['segments'].split(',').collect {|s| s.to_i }
|
||||
if ids.length > 0
|
||||
segmentlist = Segment.find(ids)
|
||||
doc = get_xml_doc
|
||||
doc = OSM::API.get_xml_doc
|
||||
segmentlist.each do |segment|
|
||||
doc.root << segment.to_xml_node
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class UserController < ApplicationController
|
||||
layout 'site'
|
||||
|
||||
before_filter :authorize, :only => :preferences
|
||||
before_filter :authorize, :only => [:preferences, :api_details]
|
||||
before_filter :authorize_web, :only => [:rename, :account, :go_public]
|
||||
before_filter :require_user, :only => [:rename, :account, :go_public]
|
||||
|
||||
|
@ -125,5 +125,9 @@ class UserController < ApplicationController
|
|||
render :status => 400, :nothing => true
|
||||
end
|
||||
end
|
||||
|
||||
def api_details
|
||||
render :text => @user.to_xml.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class WayController < ApplicationController
|
|||
ids = params['ways'].split(',').collect {|w| w.to_i }
|
||||
if ids.length > 0
|
||||
waylist = Way.find(ids)
|
||||
doc = get_xml_doc
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
waylist.each do |way|
|
||||
doc.root << way.to_xml_node
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue