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")
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
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"
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
<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>
<% 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'} %>
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'
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
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
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