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
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
<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>