From: Steve Coast Date: Sat, 7 Apr 2007 17:07:03 +0000 (+0000) Subject: can now download a trace X-Git-Tag: live~8534 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/bc49dab4a82739afdc0554ef6b23c733460cccde can now download a trace --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index c3ddb5f2d..fd9e2af25 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -113,7 +113,15 @@ class TraceController < ApplicationController flash[:notice] = "Your GPX file has been uploaded and is awaiting insertion in to the database. This will usually happen within half an hour, and an email will be sent to you on completion." redirect_to :action => 'mine' else -# render :action => 'mine' + # fixme throw an error here + # render :action => 'mine' + end + end + + def data + trace = Trace.find(params[:id]) + if trace.public? or (@user and @user == trace.user) + send_data(File.open("/tmp/#{trace.id}.gpx",'r').read , :filename => "#{trace.id}.gpx", :type => 'text/plain', :disposition => 'inline') end end @@ -134,11 +142,11 @@ class TraceController < ApplicationController def picture trace = Trace.find(params[:id]) - send_data(trace.large_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public + send_data(trace.large_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public? end def icon trace = Trace.find(params[:id]) - send_data(trace.icon_picture, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline') if trace.public + send_data(trace.icon_picture, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline') if trace.public? end end diff --git a/app/views/trace/view.rhtml b/app/views/trace/view.rhtml index b5f3bf65d..63b1b7e00 100644 --- a/app/views/trace/view.rhtml +++ b/app/views/trace/view.rhtml @@ -3,7 +3,7 @@ - +
filename:<%= @trace.name %>
filename:<%= @trace.name %> (<%= link_to 'download', :controller => 'trace', :action => 'data', :id => @trace.id %>)
uploaded at:<%= @trace.timestamp %>
points:<%= @trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %>
start coordinate:<%= @trace.latitude %>, <%= @trace.longitude %> (<%=link_to 'map', :controller => 'site', :action => 'index', :lat => @trace.latitude, :lon => @trace.longitude, :zooom => 6 %>)