From: Nick Black Date: Mon, 30 Apr 2007 09:57:54 +0000 (+0000) Subject: map view defaults to a home lat and lon X-Git-Tag: live~8526 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/8bd09c082897d808c4641f94836f5cfa4cbbf95c?ds=sidebyside map view defaults to a home lat and lon --- diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 8091aa67a..7451a91b9 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -3,6 +3,13 @@ class ApiController < ApplicationController before_filter :authorize after_filter :compress_output + helper :user + model :user + + def authorize_web + @current_user = User.find_by_token(session[:token]) + end + # The maximum area you're allowed to request, in square degrees MAX_REQUEST_AREA = 0.25 diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 5b370334c..354e8c66f 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -162,7 +162,16 @@ class UserController < ApplicationController def diary @this_user = User.find_by_display_name(params[:display_name]) end - + + def contact_others(user_id, message_body) + @to = User.find_by_id(user_id) + @to.messages.new = body + if @to.save + flash[:notice] = Message sent + end + + #Send a message to other users - maybe there's a rails messaging plugin + end end diff --git a/app/models/user.rb b/app/models/user.rb index cd0623bc1..1ecc3f710 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -58,7 +58,10 @@ class User < ActiveRecord::Base return el1 end - def get_nearby_users + def nearby(lat_range=1, lon_range=1) + + nearby = User.find(:all, :conditions => "#{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and #{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and data_public = 1") + return nearby end diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index 31b0a480e..7c1c083b7 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -20,9 +20,15 @@ eg:Essen +<% if @user and params['lon'].nil? and params['lat'].nil? %> +<% lon = @user.home_lon %> +<% lat = @user.home_lat %> +<% zoom = '10' %> +<%else%> <% lon = params['lon'] || '-0.1' %> <% lat = params['lat'] || '51.5' %> <% zoom = params['zoom'] || '4' %> +<% end %>