Get returning of bugs as GPX files working
This commit is contained in:
parent
560e41ebf9
commit
cc311ff301
5 changed files with 29 additions and 24 deletions
|
@ -47,7 +47,7 @@ class MapBugsController < ApplicationController
|
|||
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
|
||||
|
||||
|
@ -166,6 +166,7 @@ class MapBugsController < ApplicationController
|
|||
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
|
||||
|
||||
|
@ -200,7 +201,7 @@ class MapBugsController < ApplicationController
|
|||
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
|
||||
|
||||
|
|
15
app/views/map_bugs/_bug.gpx.builder
Normal file
15
app/views/map_bugs/_bug.gpx.builder
Normal file
|
@ -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
|
|
@ -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
app/views/map_bugs/read.gpx.builder
Normal file
7
app/views/map_bugs/read.gpx.builder
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue