Skip to content

Commit

Permalink
Get returning of bugs as GPX files working
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed May 7, 2011
1 parent 560e41e commit cc311ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
5 changes: 3 additions & 2 deletions app/controllers/map_bugs_controller.rb
Expand Up @@ -47,7 +47,7 @@ def get_bugs
format.js
format.xml {render :template => 'map_bugs/get_bugs.xml'}
format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
# format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
end
end

Expand Down Expand Up @@ -166,6 +166,7 @@ def read
format.rss
format.xml
format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
format.gpx
end
end

Expand Down Expand Up @@ -200,7 +201,7 @@ def search
format.js
format.xml {render :template => 'map_bugs/get_bugs.xml'}
format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
# format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
end
end

Expand Down
15 changes: 15 additions & 0 deletions app/views/map_bugs/_bug.gpx.builder
@@ -0,0 +1,15 @@
xml.wpt("lon" => bug.lon, "lat" => bug.lat) do
xml.desc do
xml.cdata! bug.flatten_comment("<hr />")
end

xml.extension do
if bug.status = "open"
xml.closed "0"
else
xml.closed "1"
end

xml.id bug.id
end
end
20 changes: 2 additions & 18 deletions app/views/map_bugs/get_bugs.gpx.builder
@@ -1,23 +1,7 @@
xml.instruct!


xml.gpx("version" => "1.1",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do

for bug in @bugs
xml.wpt("lon" => bug.lon, "lat" => bug.lat) do
xml.desc do
xml.cdata! bug.flatten_comment("<hr />")
end
xml.extension do
if bug.status = "open"
xml.closed "0"
else
xml.closed "1"
end
xml.id bug.id
end
end
end
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
xml << render(:partial => "bug", :collection => @bugs)
end
7 changes: 7 additions & 0 deletions app/views/map_bugs/read.gpx.builder
@@ -0,0 +1,7 @@
xml.instruct!

xml.gpx("version" => "1.1",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
xml << render(:partial => "bug", :object => @bug)
end
6 changes: 2 additions & 4 deletions config/initializers/mime_types.rb
@@ -1,5 +1,3 @@
# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

Mime::Type.register "application/gpx+xml", :gpx

0 comments on commit cc311ff

Please sign in to comment.