Move generation of gpx_file XML from model to builder
This commit is contained in:
parent
15841e8d2a
commit
17e6e69c39
6 changed files with 64 additions and 43 deletions
22
app/views/api/traces/_trace.builder
Normal file
22
app/views/api/traces/_trace.builder
Normal file
|
@ -0,0 +1,22 @@
|
|||
# basic attributes
|
||||
|
||||
attrs = {
|
||||
"id" => trace.id,
|
||||
"name" => trace.name,
|
||||
"user" => trace.user.display_name,
|
||||
"visibility" => trace.visibility,
|
||||
"pending" => trace.inserted ? "false" : "true",
|
||||
"timestamp" => trace.timestamp.xmlschema
|
||||
}
|
||||
|
||||
if trace.inserted
|
||||
attrs["lat"] = trace.latitude.to_s
|
||||
attrs["lon"] = trace.longitude.to_s
|
||||
end
|
||||
|
||||
xml.gpx_file(attrs) do |trace_xml_node|
|
||||
trace_xml_node.description(trace.description)
|
||||
trace.tags.each do |t|
|
||||
trace_xml_node.tag(t.tag)
|
||||
end
|
||||
end
|
9
app/views/api/traces/trace.builder
Normal file
9
app/views/api/traces/trace.builder
Normal file
|
@ -0,0 +1,9 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
|
||||
# basic attributes
|
||||
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
@traces.each do |trace|
|
||||
osm << render(:partial => "api/traces/trace.builder", :locals => { :trace => trace })
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue