TomH's patches

This commit is contained in:
Richard Fairhurst 2007-05-28 14:54:50 +00:00
parent 124cd67ac8
commit 4769eec5aa
7 changed files with 25 additions and 13 deletions

View file

@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
end
def require_user
redirect_to :controller => 'user', :action => 'login' unless @user
redirect_to :controller => 'user', :action => 'login', :next_controller => controller_name, :next_action => action_name unless @user
end
def authorize(realm='Web Password', errormessage="Couldn't authenticate you")

View file

@ -1,12 +1,12 @@
class DiaryEntryController < ApplicationController
layout 'site'
before_filter :authorize_web, :only => [:new]
before_filter :authorize_web
before_filter :require_user, :only => [:new]
def new
if params[:diary_entry]
@entry = DiaryEntry.new(@params[:diary_entry])
@entry = DiaryEntry.new(params[:diary_entry])
@entry.user = @user
if @entry.save
redirect_to :controller => 'user', :action => 'diary', :display_name => @user.display_name

View file

@ -97,7 +97,11 @@ class UserController < ApplicationController
u.timeout = 1.day.from_now
u.save
session[:token] = u.token
redirect_to :controller => 'site', :action => 'index'
if params[:next_controller] and params[:next_action]
redirect_to :controller => params[:next_controller], :action => params[:next_action]
else
redirect_to :controller => 'site', :action => 'index'
end
return
else
flash[:notice] = "Couldn't log in with those details"
@ -115,7 +119,11 @@ class UserController < ApplicationController
end
end
session[:token] = nil
redirect_to :controller => 'site', :action => 'index'
if params[:next_controller] and params[:next_action]
redirect_to :controller => params[:next_controller], :action => params[:next_action]
else
redirect_to :controller => 'site', :action => 'index'
end
end
def confirm

View file

@ -26,9 +26,9 @@
<span id="greeting">
<% if @user %>
Welcome, <%= link_to @user.display_name, {:controller => 'user', :action => 'view', :display_name => @user.display_name}, {:id => 'loginanchor'}%> |
<%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%>
<%= link_to 'logout', {:controller => 'user', :action => 'logout', :next_controller => @controller.controller_name, :next_action => @controller.action_name}, {:id => 'loginanchor'}%>
<% else %>
<%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> |
<%= link_to 'log in', {:controller => 'user', :action => 'login', :next_controller => @controller.controller_name, :next_action => @controller.action_name}, {:id => 'loginanchor'}%> |
<%= link_to 'sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %>
<% end %>
</span>

View file

@ -8,7 +8,7 @@
<% if @user %>
<%= link_to 'See just your traces', {:controller => 'trace', :action => 'mine'} %>
<% else %>
<%= link_to 'login', {:controller => 'user', :action => 'login'} %> to see just your traces
<%= link_to 'login', {:controller => 'user', :action => 'login', :next_controller => 'traces', :next_action => 'mine'} %> to see just your traces
<% end %>
<% if @tag %>
| <%= link_to 'See all traces', {:controller => 'trace', :action => 'list'} %>

View file

@ -45,6 +45,8 @@ ActionController::Routing::Routes.draw do |map|
map.connect '/user/confirm', :controller => 'user', :action => 'confirm'
map.connect '/user/go_public', :controller => 'user', :action => 'go_public'
map.connect '/user/reset_password', :controller => 'user', :action => 'reset_password'
map.connect '/user/login/:next_controller/:next_action', :controller => 'user', :action => 'login'
map.connect '/user/logout/:next_controller/:next_action', :controller => 'user', :action => 'logout'
map.connect '/index.html', :controller => 'site', :action => 'index'
map.connect '/edit.html', :controller => 'site', :action => 'edit'
map.connect '/search.html', :controller => 'way_tag', :action => 'search'

View file

@ -68,14 +68,12 @@ module OSM
attr_reader :tracksegs
def initialize(filename)
@filename = filename
@possible_points = 0
@actual_points = 0
@tracksegs = 0
end
@points = []
def points
file = File.new(@filename)
file = File.new(filename)
parser = REXML::Parsers::SAX2Parser.new( file )
lat = -1
@ -114,7 +112,7 @@ module OSM
ele = '0' unless gotele
if lat < 90 && lat > -90 && lon > -180 && lon < 180
@actual_points += 1
yield Hash['latitude' => lat,'longitude' => lon,'timestamp' => date,'altitude' => ele,'segment' => @tracksegs]
@points.push(Hash['latitude' => lat,'longitude' => lon,'timestamp' => date,'altitude' => ele,'segment' => @tracksegs])
end
end
gotlatlon = false
@ -124,6 +122,10 @@ module OSM
parser.parse
end
def points
@points.each { |p| yield p }
end
def get_picture(min_lat, min_lon, max_lat, max_lon, num_points)
#puts "getting picfor bbox #{min_lat},#{min_lon} - #{max_lat},#{max_lon}"
frames = 10