lots of rails gpx stuff

This commit is contained in:
Steve Coast 2006-12-01 20:38:29 +00:00
parent 92418b7954
commit 93dab8a127
7 changed files with 227 additions and 14 deletions

View file

@ -10,6 +10,11 @@ class TraceController < ApplicationController
@traces = Trace.find(:all, :conditions => ['user_id = ?', @user.id])
end
def view
@trace = Trace.find(params[:id])
render :nothing, :status => 401 if @trace.user.id != @user.id
end
def create
filename = "/tmp/#{rand}"
@ -28,4 +33,15 @@ class TraceController < ApplicationController
redirect_to :action => 'mine'
end
def picture
trace = Trace.find(params[:id])
send_data(trace.large_picture, :filename => "#{trace.id}.gif", :type => 'image/png', :disposition => 'inline') if trace.public
end
def icon
trace = Trace.find(params[:id])
send_data(trace.icon_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public
end
end

View file

@ -1,8 +1,8 @@
class Tracepoint < ActiveRecord::Base
set_table_name 'gps_points'
validates_numericality_of :latitude
validates_numericality_of :longitude
# validates_numericality_of :latitude
# validates_numericality_of :longitude
belongs_to :user
belongs_to :trace, :foreign_key => 'gpx_id'

View file

@ -1,6 +1,12 @@
<tr>
<% cl = cycle('table0', 'table1') %>
<td class="<%= cl %>">image here</td>
<td class="<%= cl %>">
<% if trace.inserted %>
<a href="<%= url_for :controller => 'trace', :action => 'view', :id => trace.id, :user_login => trace.user.display_name %>">
<img src="<%= url_for :controller => 'trace', :action => 'icon', :id => trace.id, :user_login => trace.user.display_name %>" border="0">
</a>
<% end %>
</td>
<td class="<%= cl %>"><%= link_to trace.name, {:controller => 'trace', :action => 'onetrace', :id => trace.id} %>
<span class="gpxsummary" title="<%= trace.timestamp %>"> ...
<% if trace.inserted %>

View file

@ -0,0 +1,15 @@
trace <%= @trace.name %>
<br>
icon <img src="<%= url_for :controller => 'trace', :action => 'icon', :id => @trace.id, :user_login => @trace.user.display_name %>" border="0">
<br>
picture <img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :user_login => @trace.user.display_name %>" border="0">
<br>
time <%= @trace.timestamp %>
<br>
dec <%= @trace.description %>