map view defaults to a home lat and lon
This commit is contained in:
parent
f4e4fefaa1
commit
8bd09c0828
6 changed files with 52 additions and 3 deletions
|
@ -3,6 +3,13 @@ class ApiController < ApplicationController
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
after_filter :compress_output
|
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
|
# The maximum area you're allowed to request, in square degrees
|
||||||
MAX_REQUEST_AREA = 0.25
|
MAX_REQUEST_AREA = 0.25
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,16 @@ class UserController < ApplicationController
|
||||||
def diary
|
def diary
|
||||||
@this_user = User.find_by_display_name(params[:display_name])
|
@this_user = User.find_by_display_name(params[:display_name])
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,10 @@ class User < ActiveRecord::Base
|
||||||
return el1
|
return el1
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,15 @@ eg:Essen
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% 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' %>
|
<% lon = params['lon'] || '-0.1' %>
|
||||||
<% lat = params['lat'] || '51.5' %>
|
<% lat = params['lat'] || '51.5' %>
|
||||||
<% zoom = params['zoom'] || '4' %>
|
<% zoom = params['zoom'] || '4' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var lon = <%= lon %>;
|
var lon = <%= lon %>;
|
||||||
|
|
|
@ -10,9 +10,30 @@
|
||||||
|
|
||||||
<h2>Users in your area</h2>
|
<h2>Users in your area</h2>
|
||||||
|
|
||||||
These users are mapping in your area:
|
<% if @user.nearby.empty? %>
|
||||||
|
There are no users mapping in your area. Better go out and spread the word about OSM!
|
||||||
|
<% else %>
|
||||||
|
|
||||||
|
<p>These users are mapping in your area:</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Contact</th>
|
||||||
|
</tr>
|
||||||
|
<% @user.nearby(1,1).each do |nearby| %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><%= nearby.email %></td>
|
||||||
|
<td><%= nearby.display_name %></td>
|
||||||
|
<td>FIXME: send user an email</td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%end%>
|
||||||
|
<br />
|
||||||
|
FIXME: OL Map showing the users on
|
||||||
|
|
||||||
<h2>Privacy</h2>
|
<h2>Privacy</h2>
|
||||||
<% if @user.data_public? %>
|
<% if @user.data_public? %>
|
||||||
|
|
|
@ -41,4 +41,7 @@ alter table diary_entries add updated_at datetime;
|
||||||
|
|
||||||
alter table users add column (home_lat double default NULL);
|
alter table users add column (home_lat double default NULL);
|
||||||
alter table users add column (home_lon double default NULL);
|
alter table users add column (home_lon double default NULL);
|
||||||
|
alter table users add column within_lon double default null;
|
||||||
|
alter table users add column within_lat double default null;
|
||||||
|
|
||||||
|
create table messages (id bigint not null auto_increment, user_id bigint(20) not null, title varchar(255), body text, sent_on datetime, message_read boolean default 0, primary key(id));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue