can now download a trace
This commit is contained in:
parent
dd57a8d248
commit
bc49dab4a8
2 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :user_login => @trace.user.display_name %>">
|
||||
|
||||
<table border="0">
|
||||
<tr><td>filename:</td><td><%= @trace.name %></td></tr> <!-- TODO link to download -->
|
||||
<tr><td>filename:</td><td><%= @trace.name %> (<%= link_to 'download', :controller => 'trace', :action => 'data', :id => @trace.id %>)</td></tr> <!-- TODO link to download -->
|
||||
<tr><td>uploaded at:</td><td><%= @trace.timestamp %></td></tr>
|
||||
<tr><td>points:</td><td><%= @trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %></td></tr>
|
||||
<tr><td>start coordinate:</td><td><%= @trace.latitude %>, <%= @trace.longitude %> (<%=link_to 'map', :controller => 'site', :action => 'index', :lat => @trace.latitude, :lon => @trace.longitude, :zooom => 6 %>)</td></tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue