Merge branch 'master' into openid

Conflicts:
	app/controllers/user_controller.rb
	app/views/user/login.html.erb
	config/locales/en.yml
This commit is contained in:
Tom Hughes 2010-04-20 00:41:03 +01:00
commit d36fab2913
257 changed files with 8478 additions and 12548 deletions

View file

@ -86,11 +86,11 @@ private
end
rescue ActionView::TemplateError => ex
if ex.original_exception.is_a?(Timeout::Error)
render :action => "timeout", :status => :request_timeout
render :action => "timeout"
else
raise
end
rescue Timeout::Error
render :action => "timeout", :status => :request_timeout
render :action => "timeout"
end
end

View file

@ -357,8 +357,8 @@ class GeocoderController < ApplicationController
response = fetch_xml("http://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{request.user_preferred_languages.join(',')}")
# parse the response
response.elements.each("reversegeocode") do |result|
description = result.get_text("result").to_s
response.elements.each("reversegeocode/result") do |result|
description = result.get_text.to_s
@results.push({:prefix => "#{description}"})
end

View file

@ -47,25 +47,38 @@ class MessageController < ApplicationController
# Allow the user to reply to another message.
def reply
message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
@body = "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
@title = @subject = "Re: #{message.title.sub(/^Re:\s*/, '')}"
@to_user = User.find(message.from_user_id)
render :action => 'new'
message = Message.find(params[:message_id])
if message.to_user_id == @user.id then
@body = "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
@title = @subject = "Re: #{message.title.sub(/^Re:\s*/, '')}"
@to_user = User.find(message.from_user_id)
render :action => 'new'
else
flash[:notice] = t 'message.reply.wrong_user', :user => @user.display_name
redirect_to :controller => "user", :action => "login", :referer => request.request_uri
end
rescue ActiveRecord::RecordNotFound
@title = t'message.no_such_user.title'
render :action => 'no_such_user', :status => :not_found
@title = t'message.no_such_message.title'
render :action => 'no_such_message', :status => :not_found
end
# Show a message
def read
@title = t 'message.read.title'
@message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
@message.message_read = true if @message.to_user_id == @user.id
@message.save
@message = Message.find(params[:message_id])
if @message.to_user_id == @user.id or @message.from_user_id == @user.id then
@message.message_read = true if @message.to_user_id == @user.id
@message.save
else
flash[:notice] = t 'message.read.wrong_user', :user => @user.display_name
redirect_to :controller => "user", :action => "login", :referer => request.request_uri
end
rescue ActiveRecord::RecordNotFound
@title = t'message.no_such_user.title'
render :action => 'no_such_user', :status => :not_found
@title = t'message.no_such_message.title'
render :action => 'no_such_message', :status => :not_found
end
# Display the list of messages that have been sent to the user.
@ -90,7 +103,7 @@ class MessageController < ApplicationController
def mark
if params[:message_id]
id = params[:message_id]
message = Message.find_by_id(id)
message = Message.find_by_id(id, :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id])
if params[:mark] == 'unread'
message_read = false
notice = t 'message.mark.as_unread'
@ -102,6 +115,7 @@ class MessageController < ApplicationController
if message.save
if request.xhr?
render :update do |page|
page.replace "inboxanchor", :partial => "layouts/inbox"
page.replace "inbox-count", :partial => "message_count"
page.replace "inbox-#{message.id}", :partial => "message_summary", :object => message
end
@ -112,15 +126,15 @@ class MessageController < ApplicationController
end
end
rescue ActiveRecord::RecordNotFound
@title = t'message.no_such_user.title'
render :action => 'no_such_user', :status => :not_found
@title = t'message.no_such_message.title'
render :action => 'no_such_message', :status => :not_found
end
# Delete the message.
def delete
if params[:message_id]
id = params[:message_id]
message = Message.find_by_id(id)
message = Message.find_by_id(id, :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id])
message.from_user_visible = false if message.sender == @user
message.to_user_visible = false if message.recipient == @user
if message.save
@ -134,7 +148,7 @@ class MessageController < ApplicationController
end
end
rescue ActiveRecord::RecordNotFound
@title = t'message.no_such_user.title'
render :action => 'no_such_user', :status => :not_found
@title = t'message.no_such_message.title'
render :action => 'no_such_message', :status => :not_found
end
end

View file

@ -253,6 +253,8 @@ if (!params[:user][:openid_url].nil? and params[:user][:openid_url].length > 0)
end
end
end
user
end
def go_public
@ -310,8 +312,8 @@ if (!params[:user][:openid_url].nil? and params[:user][:openid_url].length > 0)
def new
@title = t 'user.new.title'
# The user is logged in already, so don't show them the signup page, instead
# send them to the home page
# The user is logged in already, so don't show them the signup
# page, instead send them to the home page
redirect_to :controller => 'site', :action => 'index' if session[:user]
@nickname = params['nickname']
@ -320,66 +322,64 @@ if (!params[:user][:openid_url].nil? and params[:user][:openid_url].length > 0)
end
def login
@title = t 'user.login.title'
#The redirect from the OpenID provider reenters here again
#The redirect from the OpenID provider reenters here again
#and we need to pass the parameters through to the
# open_id_authentication function
if params[:open_id_complete]
open_id_authentication('')
end
if params[:user] and session[:user].nil?
if !params[:user][:openid_url].nil? and !params[:user][:openid_url].empty?
session[:remember] = params[:remember_me]
open_id_authentication(params[:user][:openid_url])
user = open_id_authentication('')
elsif params[:user]
if !params[:user][:openid_url].nil? and !params[:user][:openid_url].empty?
session[:remember] = params[:remember_me]
user = open_id_authentication(params[:user][:openid_url])
else
email_or_display_name = params[:user][:email]
pass = params[:user][:password]
user = User.authenticate(:username => email_or_display_name, :password => pass)
if user
session[:user] = user.id
session_expires_after 1.month if params[:remember_me]
elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
flash.now[:error] = t 'user.login.account not active'
else
flash.now[:error] = t 'user.login.auth failure'
end
end
email_or_display_name = params[:user][:email]
pass = params[:user][:password]
if user = User.authenticate(:username => email_or_display_name, :password => pass)
session[:user] = user.id
session_expires_after 1.month if params[:remember_me]
elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
flash.now[:error] = t 'user.login.account not active'
else
flash.now[:error] = t 'user.login.auth failure'
end
end
end
if session[:user]
# The user is logged in, if the referer param exists, redirect them to that
# unless they've also got a block on them, in which case redirect them to
# the block so they can clear it.
user = User.find(session[:user])
block = user.blocked_on_view
if block
redirect_to block, :referrer => params[:referrer]
if user
# The user is logged in, if the referer param exists, redirect
# them to that unless they've also got a block on them, in
# which case redirect them to the block so they can clear it.
if user.blocked_on_view
redirect_to user.blocked_on_view, :referrer => params[:referrer]
elsif params[:referer]
redirect_to params[:referer]
else
redirect_to :controller => 'site', :action => 'index'
end
return
end
@title = t 'user.login.title'
end
def logout
if session[:token]
token = UserToken.find_by_token(session[:token])
if token
token.destroy
@title = t 'user.logout.title'
if params[:session] == request.session_options[:id]
if session[:token]
token = UserToken.find_by_token(session[:token])
if token
token.destroy
end
session[:token] = nil
end
session[:user] = nil
session_expires_automatically
if params[:referer]
redirect_to params[:referer]
else
redirect_to :controller => 'site', :action => 'index'
end
session[:token] = nil
end
session[:user] = nil
session_expires_automatically
if params[:referer]
redirect_to params[:referer]
else
redirect_to :controller => 'site', :action => 'index'
end
end
@ -468,7 +468,11 @@ if (!params[:user][:openid_url].nil? and params[:user][:openid_url].length > 0)
flash[:warning] = t 'user.make_friend.already_a_friend', :name => name
end
redirect_to :controller => 'user', :action => 'view'
if params[:referer]
redirect_to params[:referer]
else
redirect_to :controller => 'user', :action => 'view'
end
end
end
@ -483,7 +487,11 @@ if (!params[:user][:openid_url].nil? and params[:user][:openid_url].length > 0)
flash[:error] = t 'user.remove_friend.not_a_friend', :name => friend.display_name
end
redirect_to :controller => 'user', :action => 'view'
if params[:referer]
redirect_to params[:referer]
else
redirect_to :controller => 'user', :action => 'view'
end
end
end

View file

@ -1,4 +1,10 @@
module ApplicationHelper
require 'rexml/document'
def sanitize(text)
Sanitize.clean(text, Sanitize::Config::OSM)
end
def htmlize(text)
return linkify(sanitize(simple_format(text)))
end
@ -34,6 +40,39 @@ module ApplicationHelper
return js
end
def describe_location(lat, lon, zoom = nil, language = nil)
zoom = zoom || 14
language = language || request.user_preferred_languages.join(',')
url = "http://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
response = REXML::Document.new(Net::HTTP.get(URI.parse(url)))
if result = response.get_text("reversegeocode/result")
result.to_s
else
"#{number_with_precision(lat, :precision => 3)}, #{number_with_precision(lon, :precision => 3)}"
end
end
def user_image(user, options = {})
options[:class] ||= "user_image"
if user.image
image_tag url_for_file_column(user, "image"), options
else
image_tag "anon_large.png", options
end
end
def user_thumbnail(user, options = {})
options[:class] ||= "user_thumbnail"
if user.image
image_tag url_for_file_column(user, "image"), options
else
image_tag "anon_small.png", options
end
end
private
def javascript_strings_for_key(key)

View file

@ -30,5 +30,9 @@ private
expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => nil)
expire_action(:controller => 'diary_entry', :action => 'rss', :language => entry.language_code, :display_name => nil)
expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => entry.user.display_name)
if record.is_a?(DiaryEntry)
expire_fragment(:controller => 'diary_entry', :action => 'view', :display_name => entry.user.display_name, :id => entry.id, :part => "location")
end
end
end

View file

@ -89,15 +89,9 @@ class Notifier < ActionMailer::Base
end
def friend_notification(friend)
befriender = User.find_by_id(friend.user_id)
befriendee = User.find_by_id(friend.friend_user_id)
common_headers befriendee
subject I18n.t('notifier.friend_notification.subject', :user => befriender.display_name, :locale => locale)
body :user => befriender.display_name,
:userurl => url_for(:host => SERVER_URL,
:controller => "user", :action => "view",
:display_name => befriender.display_name)
common_headers friend.befriendee
subject I18n.t('notifier.friend_notification.subject', :user => friend.befriender.display_name, :locale => locale)
body :friend => friend
end
private

View file

@ -86,7 +86,7 @@ class User < ActiveRecord::Base
end
def languages
attribute_present?(:languages) ? read_attribute(:languages).split(",") : []
attribute_present?(:languages) ? read_attribute(:languages).split(/ *, */) : []
end
def languages=(languages)

View file

@ -14,7 +14,7 @@
<% end %>
<% unless relation_details.containing_relation_members.empty? %>
<tr>
<tr valign="top">
<th><%= t'browse.relation_details.part_of' %></th>
<td>
<table cellpadding="0">

View file

@ -1,4 +1,5 @@
<h4 id="comment<%= diary_comment.id %>"><%= t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => l(diary_comment.created_at)) %></h4>
<%= user_thumbnail diary_comment.user, :style => "float: right" %>
<h4 id="comment<%= diary_comment.id %>"><%= t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => l(diary_comment.created_at, :format => :friendly)) %></h4>
<%= htmlize(diary_comment.body) %>
<% if @user && @user.administrator? %>
<%= link_to t('diary_entry.diary_comment.hide_link'), {:action => 'hidecomment', :display_name => @user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id}, {:confirm => t('diary_entry.diary_comment.confirm')} %>

View file

@ -1,9 +1,10 @@
<b><%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %></b><br />
<%= htmlize(diary_entry.body) %>
<% if diary_entry.latitude and diary_entry.longitude %>
<%= t 'map.coordinates' %> <div class="geo" style="display: inline"><span class="latitude"><%= diary_entry.latitude %></span>; <span class="longitude"><%= diary_entry.longitude %></span></div> (<%=link_to (t 'map.view'), :controller => 'site', :action => 'index', :lat => diary_entry.latitude, :lon => diary_entry.longitude, :zoom => 14 %> / <%=link_to (t 'map.edit'), :controller => 'site', :action => 'edit', :lat => diary_entry.latitude, :lon => diary_entry.longitude, :zoom => 14 %>)<br/>
<%= render :partial => "location", :object => diary_entry %>
<br />
<% end %>
<%= t 'diary_entry.diary_entry.posted_by', :link_user => (link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name), :created => l(diary_entry.created_at), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entry', :action => 'list', :language => diary_entry.language_code) %>
<%= t 'diary_entry.diary_entry.posted_by', :link_user => (link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name), :created => l(diary_entry.created_at, :format => :friendly), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entry', :action => 'list', :language => diary_entry.language_code) %>
<% if params[:action] == 'list' %>
<br />
<%= link_to t('diary_entry.diary_entry.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %>

View file

@ -0,0 +1,2 @@
<%= user_thumbnail diary_list_entry.user, :style => "float: right" %>
<%= render :partial => "diary_entry", :object => diary_list_entry %>

View file

@ -0,0 +1,11 @@
<%= t 'diary_entry.location.location' %>
<abbr class="geo" title="<%= number_with_precision(location.latitude, :precision => 4) %>; <%= number_with_precision(location.longitude, :precision => 4) %>">
<% cache(:controller => 'diary_entry', :action => 'view', :display_name => location.user.display_name, :id => location.id, :part => "location") do %>
<%= describe_location location.latitude, location.longitude, 14, location.language_code %>
<% end %>
</abbr>
(<%=link_to t('diary_entry.location.view'), :controller => 'site', :action => 'index', :lat => location.latitude, :lon => location.longitude, :zoom => 14 %>
/
<%=link_to t('diary_entry.location.edit'), :controller => 'site', :action => 'edit', :lat => location.latitude, :lon => location.longitude, :zoom => 14 %>)

View file

@ -1,9 +1,8 @@
<h2><%= h(@title) %></h2>
<% if @this_user && @this_user.image %>
<%= image_tag url_for_file_column(@this_user, "image") %>
<% if @this_user %>
<%= user_image @this_user, :style => "float: right" %>
<% end %>
<h2><%= h(@title) %></h2>
<% if @this_user %>
<% if @user == @this_user %>
@ -23,8 +22,12 @@
<hr />
<%= render :partial => 'diary_entry', :collection => @entries %>
<% if @this_user %>
<%= render :partial => 'diary_entry', :collection => @entries %>
<% else %>
<%= render :partial => 'diary_list_entry', :collection => @entries %>
<% end %>
<%= link_to t('diary_entry.list.older_entries'), { :page => @entry_pages.current.next, :language => params[:language] } if @entry_pages.current.next %>
<% if @entry_pages.current.next and @entry_pages.current.previous %>|<% end %>
<%= link_to t('diary_entry.list.newer_entries'), { :page => @entry_pages.current.previous, :language => params[:language] } if @entry_pages.current.previous %>

View file

@ -1,3 +1,5 @@
<%= user_image @entry.user, :style => "float: right" %>
<h2><%= t 'diary_entry.view.user_title', :user => h(@entry.user.display_name) %></h2>
<%= render :partial => 'diary_entry', :object => @entry %>

View file

@ -40,7 +40,7 @@
<div class="export_details">
<p><%= t'export.start.too_large.body' %></p>
</div
</div>
</div>
</div>

View file

@ -1 +1 @@
<p class="search_results_error"><%= @error %></p>
<p class="search_results_error"><%= h(@error) %></p>

View file

@ -0,0 +1,7 @@
<%
inbox_attributes = {}
inbox_attributes[:id] = "inboxanchor"
inbox_attributes[:class] = 'greeting-bar-unread' if @user.new_messages.size > 0
inbox_attributes[:title] = t 'layouts.inbox_tooltip', :count => @user.new_messages.size
%>
<%= link_to t('layouts.inbox', :count => @user.new_messages.size), {:controller => 'message', :action => 'inbox', :display_name => @user.display_name}, inbox_attributes %>

View file

@ -7,9 +7,9 @@
<%= javascript_include_tag 'site' %>
<!--[if lt IE 7]><%= javascript_include_tag 'pngfix' %><![endif]--> <!-- thanks, microsoft! -->
<%= stylesheet_link_tag 'common' %>
<!--[if IE]><%= stylesheet_link_tag 'site', :media => "screen" %><![endif]--> <!-- IE is totally broken with CSS media queries -->
<%= stylesheet_link_tag 'site-sml', :media => "only screen and (max-width: 481px)" %>
<%= stylesheet_link_tag 'site', :media => "screen and (min-width: 482px)" %>
<!--[if IE]><%= stylesheet_link_tag 'large', :media => "screen" %><![endif]--> <!-- IE is totally broken with CSS media queries -->
<%= stylesheet_link_tag 'small', :media => "only screen and (max-width: 481px)" %>
<%= stylesheet_link_tag 'large', :media => "screen and (min-width: 482px)" %>
<%= stylesheet_link_tag 'print', :media => "print" %>
<%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => "/opensearch/osm.xml" }) %>
<%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %>
@ -36,13 +36,8 @@
<span id="full-greeting"><%= t 'layouts.welcome_user', :user_link => (link_to h(@user.display_name), {:controller => 'user', :action => 'view', :display_name => @user.display_name}, :title => t('layouts.welcome_user_link_tooltip')) %></span>
<span id="small-greeting"><%= link_to t('layouts.welcome_user_link_tooltip'), {:controller => 'user', :action => 'view', :display_name => @user.display_name} %></span> |
<%= yield :greeting %>
<%
inbox_attributes = {}
inbox_attributes[:class] = 'greeting-bar-unread' if @user.new_messages.size > 0
inbox_attributes[:title] = t 'layouts.inbox_tooltip', :count => @user.new_messages.size
%>
<%= link_to t('layouts.inbox', :count => @user.new_messages.size), {:controller => 'message', :action => 'inbox', :display_name => @user.display_name}, inbox_attributes %> |
<%= link_to t('layouts.logout'), {:controller => 'user', :action => 'logout', :referer => request.request_uri}, {:id => 'logoutanchor', :title => t('layouts.logout_tooltip')}%>
<%= render :partial => "layouts/inbox" %> |
<%= link_to t('layouts.logout'), {:controller => 'user', :action => 'logout', :session => request.session_options[:id], :referer => request.request_uri}, {:id => 'logoutanchor', :title => t('layouts.logout_tooltip'), :method => :post, :href => url_for(:controller => 'user', :action => 'logout', :referer => request.request_uri)}%>
<% else %>
<%= link_to t('layouts.log_in'), {:controller => 'user', :action => 'login', :referer => request.request_uri}, {:id => 'loginanchor', :title => t('layouts.log_in_tooltip')} %> |
<%= link_to t('layouts.sign_up'), {:controller => 'user', :action => 'new'}, {:id => 'registeranchor', :title => t('layouts.sign_up_tooltip')} %>
@ -134,7 +129,7 @@
<a href="http://donate.openstreetmap.org/" title="<%= h(t('layouts.make_a_donation.title')) %>"><%= h(t('layouts.make_a_donation.text')) %></a>
</div>
<div id="cclogo" class="button" style="width: 88px">
<div id="cclogo" style="width: 88px">
<%= link_to(
image_tag("cc_button.png",
:alt => t('layouts.license.alt'),

View file

@ -3,7 +3,7 @@
<tr id="inbox-<%= message_summary.id %>" class="inbox-row<%= "-unread" if not message_summary.message_read? %>">
<td class="inbox-sender" bgcolor="<%= this_colour %>"><%= link_to h(message_summary.sender.display_name), :controller => 'user', :action => message_summary.sender.display_name %></td>
<td class="inbox-subject" bgcolor="<%= this_colour %>"><%= link_to h(message_summary.title), :controller => 'message', :action => 'read', :message_id => message_summary.id %></td>
<td class="inbox-sent nowrap" bgcolor="<%= this_colour %>"><%= l message_summary.sent_on %></td>
<td class="inbox-sent nowrap" bgcolor="<%= this_colour %>"><%= l message_summary.sent_on, :format => :friendly %></td>
<% if message_summary.message_read? %>
<td><%= button_to t('message.message_summary.unread_button'), {:controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'unread'}, { :onclick => remote_function(:url => {:controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'unread'}) + "; return false;" } %></td>
<% else %>

View file

@ -3,6 +3,6 @@
<tr class="inbox-row">
<td class="inbox-sender" bgcolor="<%= this_colour %>"><%= link_to h(sent_message_summary.recipient.display_name), :controller => 'user', :action => sent_message_summary.recipient.display_name %></td>
<td class="inbox-subject" bgcolor="<%= this_colour %>"><%= link_to h(sent_message_summary.title), :controller => 'message', :action => 'read', :message_id => sent_message_summary.id %></td>
<td class="inbox-sent nowrap" bgcolor="<%= this_colour %>"><%= l sent_message_summary.sent_on %></td>
<td class="inbox-sent nowrap" bgcolor="<%= this_colour %>"><%= l sent_message_summary.sent_on, :format => :friendly %></td>
<td><%= button_to t('message.sent_message_summary.delete_button'), :controller => 'message', :action => 'delete', :message_id => sent_message_summary.id, :referer => request.request_uri %></td>
</tr>

View file

@ -0,0 +1,2 @@
<h1><%= t'message.no_such_message.heading' %></h1>
<p><%= t'message.no_such_message.body' %></p>

View file

@ -5,24 +5,23 @@
<table>
<tr>
<th align="right"><%= t'message.read.from' %></th>
<td>
<% if @message.sender.image %>
<%= image_tag url_for_file_column(@message.sender, "image") %>
<% end %>
<%= link_to h(@message.sender.display_name), :controller => 'user', :action => 'view', :display_name => @message.sender.display_name %></td>
<td><%= link_to h(@message.sender.display_name), :controller => 'user', :action => 'view', :display_name => @message.sender.display_name %></td>
<td rowspan="4" valign="top"><%= user_thumbnail @message.sender %></td>
</tr>
<tr>
<th align="right"><%= t'message.read.subject' %></th>
<td><%= h(@message.title) %></td>
<td></td>
</tr>
<tr>
<th align="right"><%= t'message.read.date' %></th>
<td><%= l @message.sent_on %></td>
<td><%= l @message.sent_on, :format => :friendly %></td>
<td></td>
</tr>
<tr>
<th></th>
<td><%= htmlize(@message.body) %></td>
<td></td>
</tr>
</table>
@ -44,18 +43,22 @@
<tr>
<th align="right"><%= t'message.read.to' %></th>
<td><%= link_to h(@message.recipient.display_name), :controller => 'user', :action => 'view', :display_name => @message.recipient.display_name %></td>
<td rowspan="4" valign="top"><%= user_thumbnail @message.recipient %></td>
</tr>
<tr>
<th align="right"><%= t'message.read.subject' %></th>
<td><%= h(@message.title) %></td>
<td></td>
</tr>
<tr>
<th align="right"><%= t'message.read.date' %></th>
<td><%= l @message.sent_on %></td>
<td><%= l @message.sent_on, :format => :friendly %></td>
<td></td>
</tr>
<tr>
<th></th>
<td><%= htmlize(@message.body) %></td>
<td></td>
</tr>
</table>

View file

@ -1,4 +1,20 @@
<%= t'notifier.friend_notification.had_added_you', :user => @user %>
<%=
t 'notifier.friend_notification.had_added_you',
:user => @friend.befriender.display_name
%>
<%= t'notifier.friend_notification.see_their_profile', :userurl => @userurl %>
<%=
t 'notifier.friend_notification.see_their_profile',
:userurl => url_for(:host => SERVER_URL,
:controller => "user", :action => "view",
:display_name => @friend.befriender.display_name)
%>
<%=
unless @friend.befriendee.is_friends_with?(@friend.befriender)
t 'notifier.friend_notification.befriend_them',
:befriendurl => url_for(:host => SERVER_URL,
:controller => "user", :action => "make_friend",
:display_name => @friend.befriender.display_name)
end
%>

View file

@ -17,7 +17,7 @@
}
function updateMapKey() {
var layer = map.baseLayer.name.toLowerCase().replace(/\s+/g, "_");
var layer = map.baseLayer.keyid;
var zoom = map.getZoom();
<%= remote_function :update => "sidebar_content",

View file

@ -5,12 +5,11 @@
}
function describeLocation() {
var position = getPosition();
var zoom = getZoom();
var args = getArgs($("viewanchor").href);
<%= remote_function(:loading => "startSearch()",
:url => { :controller => :geocoder, :action => :description },
:with => "'lat=' + position.lat + '&lon=' + position.lon + '&zoom=' + zoom") %>
:with => "'lat=' + args['lat'] + '&lon=' + args['lon'] + '&zoom=' + args['zoom']") %>
}
function setSearchViewbox() {
@ -33,8 +32,8 @@
<% content_for "optionals" do %>
<div class="optionalbox">
<span class="oboxheader"><%= t 'site.search.search' %></span>
<span class="whereami"><a href="javascript:describeLocation()" title="<%= t 'site.search.where_am_i_title' %>"><%= t 'site.search.where_am_i' %></a></span>
<h1><%= t 'site.search.search' %></h1>
<div class="search_form">
<div id="search_field">
<% form_remote_tag(:before => "setSearchViewbox()",

View file

@ -10,7 +10,7 @@
<% end %>
</td>
<td class="<%= cl %>"><%= link_to trace.name, {:controller => 'trace', :action => 'view', :display_name => trace.user.display_name, :id => trace.id} %>
<span class="gpxsummary" title="<%= trace.timestamp %>"> ...
<span class="trace_summary" title="<%= trace.timestamp %>"> ...
<% if trace.inserted %>
(<%= t'trace.trace.count_points', :count => trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %>)
<% end %>

View file

@ -1,6 +1,6 @@
<%= render :partial => 'trace_paging_nav' %>
<table id="keyvalue" cellpadding="3">
<table id="trace_list" cellpadding="3">
<tr>
<th></th>
<th></th>

View file

@ -1,7 +1,6 @@
<% content_for "optionals" do %>
<div class="optionalbox">
<span class="oboxheader"><%= t'trace.trace_optionals.tags' %></span>
<br />
<h1><%= t'trace.trace_optionals.tags' %></h1>
<br />
<% if @all_tags %>
<% @all_tags.each do |tag| %>

View file

@ -11,7 +11,7 @@
</tr>
<tr>
<td><%= t'trace.edit.uploaded_at' %></td>
<td><%= l @trace.timestamp %></td>
<td><%= l @trace.timestamp, :format => :friendly %></td>
</tr>
<% if @trace.inserted? %>
<tr>

View file

@ -15,7 +15,7 @@
</tr>
<tr>
<td><%= t'trace.view.uploaded' %></td>
<td><%= l @trace.timestamp %></td>
<td><%= l @trace.timestamp, :format => :friendly %></td>
</tr>
<% if @trace.inserted? %>
<tr>

View file

@ -0,0 +1,27 @@
<tr>
<td rowspan="2">
<%= user_thumbnail contact %>
</td>
<td>
<%= link_to h(contact.display_name), :controller => 'user', :action => 'view', :display_name => contact.display_name %>
<% if @this_user.home_lon and @this_user.home_lat and contact.home_lon and contact.home_lat %>
<% distance = @this_user.distance(contact) %>
<% if distance < 1 %>
(<%= t 'user.view.m away', :count => (distance * 1000).round %>)
<% else %>
(<%= t 'user.view.km away', :count => distance.round %>)
<% end %>
<% end %>
</td>
</tr>
<tr>
<td>
<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => contact.display_name %>
|
<% if @user.is_friends_with?(contact) %>
<%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => contact.display_name, :referer => request.request_uri %>
<% else %>
<%= link_to t('user.view.add as friend'), :controller => 'user', :action => 'make_friend', :display_name => contact.display_name, :referer => request.request_uri %>
<% end %>
</td>
</tr>

View file

@ -1,15 +1,5 @@
<% nearest_str = "" %>
<% if !@user.home_lat.nil? and !@user.home_lon.nil? %>
<% if !@user.nearby.empty? %>
<% @user.nearby.each do |nearby| %>
<% nearest_str += "nearest.push( { 'display_name' : '#{escape_javascript(nearby.display_name)}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } );\n" %>
<% end %>
<% end %>
<% end %>
<script type="text/javascript">
var nearest = [], friends = [];
<%= nearest_str %>
</script>
<% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
<% nearest = @user.nearby - friends %>
<% if @user.home_lat.nil? or @user.home_lon.nil? %>
<% lon = h(params['lon'] || '-0.1') %>
@ -47,16 +37,29 @@
setMapCenter(centre, zoom);
<% if marker %>
marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null, "<%= t 'user.friend_map.your location' %>");
marker = addMarkerToMap(
new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null,
'<%= escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
);
<% end %>
var near_icon = OpenLayers.Marker.defaultIcon();
near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
var i = nearest.length;
while( i-- ) {
var description = i18n('<%= t 'user.friend_map.nearby mapper'%>', { nearby_user: '<a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a>' });
var nearmarker = addMarkerToMap(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat), near_icon.clone(), description);
}
near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";
<% nearest.each do |u| %>
addMarkerToMap(new OpenLayers.LonLat(
<%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
'<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
);
<% end %>
var friend_icon = OpenLayers.Marker.defaultIcon();
friend_icon.url = OpenLayers.Util.getImagesLocation() + "marker-blue.png";
<% friends.each do |u| %>
addMarkerToMap(new OpenLayers.LonLat(
<%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
'<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
);
<% end %>
if (document.getElementById('updatehome')) {
map.events.register("click", map, setHome);
@ -77,12 +80,13 @@
removeMarkerFromMap(marker);
}
marker = addMarkerToMap(lonlat, null, "<%= t 'user.friend_map.your location' %>");
marker = addMarkerToMap(
lonlat, null,
'<%= escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
);
}
}
window.onload = init;
// -->
</script>

View file

@ -0,0 +1,5 @@
<div class="user_popup">
<%= user_thumbnail popup, :style => "float :left" %>
<p><%= t('user.popup.' + type) %></p>
<p><%= link_to popup.display_name, :controller => "user", :action => "view", :display_name => popup.display_name %></p>
</div>

View file

@ -18,12 +18,12 @@
<tr>
<td class="fieldName" style="padding-bottom:0px;"><%= t 'user.new.password' %></td>
<td style="padding-bottom:0px;"><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %></td>
<td style="padding-bottom:0px;"><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255, :autocomplete => :off} %></td>
</tr>
<tr>
<td class="fieldName"><%= t 'user.new.confirm password' %></td>
<td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %></td>
<td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255, :autocomplete => :off} %></td>
</tr>
<tr>
<td class="fieldName" ><%= t 'user.account.openid.openid' %></td>
@ -58,11 +58,11 @@
<td valign="top">
<% if @user.image.nil? %>
<%= hidden_field_tag "image_action", "new" %>
<%= t 'user.account.new image' %><br /><%= file_column_field "user", "image" %>
<%= t 'user.account.new image' %><br /><%= file_column_field "user", "image" %><br /><span class="minorNote"><%= t 'user.account.image size hint' %></span>
<% else %>
<table>
<table id="accountImage">
<tr>
<td rowspan="3" valign="top"><%= image_tag url_for_file_column(@user, "image") %></td>
<td rowspan="3" valign="top"><%= image_tag url_for_file_column(@user, "image"), :class => "user_image" %></td>
<td><%= radio_button_tag "image_action", "keep", true %></td>
<td><%= t 'user.account.keep image' %></td>
</tr>
@ -72,7 +72,7 @@
</tr>
<tr>
<td><%= radio_button_tag "image_action", "new" %></td>
<td><%= t 'user.account.replace image' %><br /><%= file_column_field "user", "image", :onchange => "$('image_action_new').checked = true" %></td>
<td><%= t 'user.account.replace image' %><br /><%= file_column_field "user", "image", :onchange => "$('image_action_new').checked = true" %><br /><span class="minorNote"><%= t 'user.account.image size hint' %></span></td>
</tr>
</table>
<% end %>
@ -88,7 +88,7 @@
<td></td>
<td>
<p><%= t 'user.account.update home location on click' %> <input type="checkbox" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" /> </p>
<div id="map" style="border:1px solid black; position:relative; width:500px; height:400px;"></div>
<div id="map" class="user_map" style="border:1px solid black; position:relative; width:500px; height:400px;"></div>
</td>
</tr>
@ -99,7 +99,7 @@
</table>
<% end %>
<%= render :partial => 'friend_map' %>
<%= render :partial => 'map' %>
<% unless @user.data_public? %>
<a name="public"></a>

View file

@ -5,13 +5,12 @@
<% form_tag :action => 'login' do %>
<%= hidden_field_tag('referer', h(params[:referer])) %>
<table id="loginForm">
<tr><td class="fieldName"><%= t 'user.login.email or username' %></td><td><%= text_field('user', 'email',{:size => 28, :maxlength => 255, :tabindex => 1}) %></td></tr>
<tr><td class="fieldName"><%= t 'user.login.password' %></td><td><%= password_field('user', 'password',{:size => 28, :maxlength => 255, :tabindex => 2}) %></td><td> <span class="minorNote">(<%= link_to t('user.login.lost password link'), :controller => 'user', :action => 'lost_password' %>)</span></td></tr>
<tr><td colspan = "3"><h4><I><%= t 'user.login.alternatively' %></I></h4></td></tr>
<tr><td class="fieldName"><%= t 'user.login.openid' %></td><td><%= text_field('user', 'openid_url',{:size => 28, :maxlength => 255, :tabindex => 3}) %></td><td> <span class="minorNote">(<a href="<%= t 'user.account.openid.link' %>" target="_new"><%= t 'user.account.openid.link text' %></a>)</span></td></tr>
<tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
<tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
<tr><td class="fieldName"><label for="remember_me">Remember me:</label></td><td><%= check_box_tag "remember_me", "yes", false, :tabindex => 3 %></td><td align=right><%= submit_tag t('user.login.login_button'), :tabindex => 3 %></td></tr>
<tr><td class="fieldName"><%= t 'user.login.email or username' %></td><td><%= text_field('user', 'email',{:value => "", :size => 28, :maxlength => 255, :tabindex => 1}) %></td></tr>
<tr><td class="fieldName"><%= t 'user.login.password' %></td><td><%= password_field('user', 'password',{:value => "", :size => 28, :maxlength => 255, :tabindex => 2}) %></td><td> <span class="minorNote">(<%= link_to t('user.login.lost password link'), :controller => 'user', :action => 'lost_password' %>)</span></td></tr>
<tr><td colspan = "3"><h4><I><%= t 'user.login.alternatively' %></I></h4></td></tr>
<tr><td class="fieldName"><%= t 'user.login.openid' %></td><td><%= text_field('user', 'openid_url',{:size => 28, :maxlength => 255, :tabindex => 3}) %></td><td> <span class="minorNote">(<a href="<%= t 'user.account.openid.link' %>" target="_new"><%= t 'user.account.openid.link text' %></a>)</span></td></tr>
<tr><td colspan="3">&nbsp;<!--vertical spacer--></td></tr>
<tr><td colspan="3">&nbsp;<!--vertical spacer--></td></tr>
<tr><td class="fieldName"><label for="remember_me"><%= t 'user.login.remember' %></label></td><td><%= check_box_tag "remember_me", "yes", false, :tabindex => 3 %></td><td align=right><%= submit_tag t('user.login.login_button'), :tabindex => 3 %></td></tr>
</table>
<% end %>

View file

@ -0,0 +1,6 @@
<h1><%= t 'user.logout.heading' %></h1>
<% form_tag :action => "logout" do %>
<%= hidden_field_tag("referer", h(params[:referer])) %>
<%= hidden_field_tag("session", request.session_options[:id]) %>
<%= submit_tag t('user.logout.logout_button') %>
<% end %>

View file

@ -39,4 +39,6 @@
</table>
<% end %>
<%= javascript_include_tag 'https://ethnio.com/remotes/62786' %>
<% end %>

View file

@ -1,148 +1,122 @@
<% if @this_user.image %>
<%= image_tag url_for_file_column(@this_user, "image"), :align => "right", :float => "left" %>
<% end %>
<%= user_image @this_user, :style => "float: right" %>
<h2><%= h(@this_user.display_name) %>
<% UserRole::ALL_ROLES.each do |role| %>
<% if @user and @user.administrator? %>
<% if @this_user.has_role? role %>
<%= link_to(image_tag("roles/#{role}.png", :size => "20x20", :border => 0, :alt => t("user.view.role.revoke.#{role}"), :title => t("user.view.role.revoke.#{role}")), :controller => 'user_roles', :action => 'revoke', :display_name => @this_user.display_name, :role => role) %>
<% else %>
<%= link_to(image_tag("roles/blank_#{role}.png", :size => "20x20", :border => 0, :alt => t("user.view.role.grant.#{role}"), :title => t("user.view.role.grant.#{role}")), :controller => 'user_roles', :action => 'grant', :display_name => @this_user.display_name, :role => role) %>
<% end %>
<% elsif @this_user.has_role? role %>
<%= image_tag("roles/#{role}.png", :size => "20x20", :border => 0, :alt => t("user.view.role.#{role}"), :title => t("user.view.role.#{role}")) %>
<% end %>
<% if @user and @user.administrator? %>
<% if @this_user.has_role? role %>
<%= link_to(image_tag("roles/#{role}.png", :size => "20x20", :border => 0, :alt => t("user.view.role.revoke.#{role}"), :title => t("user.view.role.revoke.#{role}")), :controller => 'user_roles', :action => 'revoke', :display_name => @this_user.display_name, :role => role) %>
<% else %>
<%= link_to(image_tag("roles/blank_#{role}.png", :size => "20x20", :border => 0, :alt => t("user.view.role.grant.#{role}"), :title => t("user.view.role.grant.#{role}")), :controller => 'user_roles', :action => 'grant', :display_name => @this_user.display_name, :role => role) %>
<% end %>
<% elsif @this_user.has_role? role %>
<%= image_tag("roles/#{role}.png", :size => "20x20", :border => 0, :alt => t("user.view.role.#{role}"), :title => t("user.view.role.#{role}")) %>
<% end %>
<% end %></h2>
<div id="userinformation">
<% if @user and @this_user.id == @user.id %>
<!-- Displaying user's own profile page -->
<%= link_to t('user.view.my diary'), :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
| <%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
| <%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %>
| <%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %>
| <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %>
| <%= link_to t('user.view.blocks on me'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @user.display_name %>
<% if @user and @user.moderator? %>
| <%= link_to t('user.view.blocks by me'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @user.display_name %>
<% end %>
<% else %>
<!-- Displaying another user's profile page -->
<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => @this_user.display_name %>
| <%= link_to t('user.view.diary'), :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %>
| <%= link_to t('user.view.edits'), :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %>
| <%= link_to t('user.view.traces'), :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %>
| <% if @user and @user.is_friends_with?(@this_user) %>
<%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %>
<% else %>
<%= link_to t('user.view.add as friend'), :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %>
<% end %>
| <%= link_to t('user.view.block_history'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @this_user.display_name %>
<% if @this_user.moderator? %>
| <%= link_to t('user.view.moderator_history'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @this_user.display_name %>
<% end %>
<% if @user and @user.moderator? %>
| <%= link_to t('user.view.create_block'), :controller => 'user_blocks', :action => 'new', :display_name => @this_user.display_name %>
<% end %>
<% end %>
<% if @user and @user.administrator? %>
<br/>
<% if @this_user.active? %>
<%= link_to t('user.view.deactivate_user'), {:controller => 'user', :action => 'deactivate', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% else %>
<%= link_to t('user.view.activate_user'), {:controller => 'user', :action => 'activate', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% end %>
<% if @this_user.visible? %>
| <%= link_to t('user.view.hide_user'), {:controller => 'user', :action => 'hide', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
| <%= link_to t('user.view.delete_user'), {:controller => 'user', :action => 'delete', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% else %>
| <%= link_to t('user.view.unhide_user'), {:controller => 'user', :action => 'unhide', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% end %>
<% end %>
<% if @user and @this_user.id == @user.id %>
<!-- Displaying user's own profile page -->
<%= link_to t('user.view.my diary'), :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
|
<%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
<%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %>
|
<%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %>
|
<%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %>
|
<%= link_to t('user.view.oauth settings'), :controller => 'oauth_clients', :action => 'index' %>
|
<%= link_to t('user.view.blocks on me'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @user.display_name %>
<% if @user and @user.moderator? %>
| <%= link_to t('user.view.blocks by me'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @user.display_name %>
<% end %>
<% else %>
<!-- Displaying another user's profile page -->
<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => @this_user.display_name %>
|
<%= link_to t('user.view.diary'), :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %>
|
<%= link_to t('user.view.edits'), :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %>
|
<%= link_to t('user.view.traces'), :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %>
|
<% if @user and @user.is_friends_with?(@this_user) %>
<%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %>
<% else %>
<%= link_to t('user.view.add as friend'), :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %>
<% end %>
|
<%= link_to t('user.view.block_history'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @this_user.display_name %>
<% if @this_user.moderator? %>
| <%= link_to t('user.view.moderator_history'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @this_user.display_name %>
<% end %>
<% if @user and @user.moderator? %>
| <%= link_to t('user.view.create_block'), :controller => 'user_blocks', :action => 'new', :display_name => @this_user.display_name %>
<% end %>
<% end %>
<% if @user and @user.administrator? %>
<br/>
<% if @this_user.active? %>
<%= link_to t('user.view.deactivate_user'), {:controller => 'user', :action => 'deactivate', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% else %>
<%= link_to t('user.view.activate_user'), {:controller => 'user', :action => 'activate', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% end %>
|
<% if @this_user.visible? %>
<%= link_to t('user.view.hide_user'), {:controller => 'user', :action => 'hide', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
|
<%= link_to t('user.view.delete_user'), {:controller => 'user', :action => 'delete', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% else %>
<%= link_to t('user.view.unhide_user'), {:controller => 'user', :action => 'unhide', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %>
<% end %>
<% end %>
</div>
<p><b><%= t 'user.view.mapper since' %></b> <%= l @this_user.creation_time %> <%= t 'user.view.ago', :time_in_words_ago => time_ago_in_words(@this_user.creation_time) %></p>
<p><b><%= t 'user.view.mapper since' %></b> <%= l @this_user.creation_time, :format => :friendly %> <%= t 'user.view.ago', :time_in_words_ago => time_ago_in_words(@this_user.creation_time) %></p>
<% if @user and @user.administrator? %>
<p><b><%= t 'user.view.email address' %></b> <%= @this_user.email %></p>
<p><b><%= t 'user.view.created from' %></b> <%= @this_user.creation_ip %></p>
<p><b><%= t 'user.view.email address' %></b> <%= @this_user.email %></p>
<p><b><%= t 'user.view.created from' %></b> <%= @this_user.creation_ip %></p>
<% end %>
<h3><%= t 'user.view.description' %></h3>
<div id="description"><%= htmlize(@this_user.description) %></div>
<% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %>
<h3><%= t 'user.view.user location' %></h3>
<%= t 'user.view.no home location' %>
<% if @user and @this_user.id == @user.id %>
<%= t 'user.view.if set location', :settings_link => (link_to t('user.view.settings_link_text'), :controller => 'user', :action => 'account', :display_name => @user.display_name) %>
<% end %>
<% else %>
<% if @user and @this_user.id == @user.id %>
<h3><%= t 'user.view.your friends' %></h3>
<% if @this_user.friends.empty? %>
<%= t 'user.view.no friends' %>
<% else %>
<table id="friends">
<% @this_user.friends.each do |friend| %>
<% @friend = User.find_by_id(friend.friend_user_id) %>
<tr>
<td class="image">
<% if @friend.image %>
<%= image_tag url_for_file_column(@friend, "image") %>
<% end %>
</td>
<td class="username"><%= link_to h(@friend.display_name), :controller => 'user', :action => 'view', :display_name => @friend.display_name %></td>
<td>
<% if @friend.home_lon and @friend.home_lat %>
<% distance = @this_user.distance(@friend) %>
<% if distance < 1 %>
<%= t 'user.view.m away', :count => (distance * 1000).round %>
<% else %>
<%= t 'user.view.km away', :count => distance.round %>
<% end %>
<% end %>
</td>
<td class="message">(<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => @friend.display_name %>)</td>
</tr>
<%end%>
</table>
<%end%>
<br/>
<%end%>
<% if @user and @this_user.id == @user.id %>
<h3><%= t 'user.view.nearby users' %></h3>
<% if @this_user.nearby.empty? %>
<%= t 'user.view.no nearby users' %>
<% else %>
<div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 400px;"></div>
<%= render :partial => 'friend_map' %>
<table id="nearbyusers">
<% @this_user.nearby.each do |nearby| %>
<tr>
<td class="username"><%= link_to h(nearby.display_name), :controller => 'user', :action => 'view', :display_name => nearby.display_name %></td>
<td>
<% distance = @this_user.distance(nearby) %>
<% if distance < 1 %>
<%= t 'user.view.m away', :count => (distance * 1000).round %>
<% else %>
<%= t 'user.view.km away', :count => distance.round %>
<% end %>
</td>
<td class="message">(<%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => nearby.display_name %>)</td>
</tr>
<% end %>
</table>
<% end %>
<% end %>
<% end %>
<br/>
<br/>
<% if @user and @this_user.id == @user.id %>
<%= link_to t('user.view.my_oauth_details'), :controller => 'oauth_clients', :action => 'index' %>
<div id="map" class="user_map" style="border: 1px solid black; position: relative; width: 400px; height: 400px; float: right;">
<% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %>
<p style="position: absolute; top: 0; bottom: 0; width: 90%; height: 30%; margin: auto 5%">
<%= t 'user.view.if set location', :settings_link => (link_to t('user.view.settings_link_text'), :controller => 'user', :action => 'account', :display_name => @user.display_name) %>
</p>
<% else %>
<%= render :partial => 'map' %>
<% end %>
</div>
<% friends = @this_user.friends.collect { |f| f.befriendee } %>
<% nearby = @this_user.nearby - friends %>
<h3 style="margin-top: 0"><%= t 'user.view.your friends' %></h3>
<% if friends.empty? %>
<%= t 'user.view.no friends' %>
<% else %>
<table id="friends">
<%= render :partial => "contact", :collection => friends %>
</table>
<% end %>
<h3><%= t 'user.view.nearby users' %></h3>
<% if nearby.empty? %>
<%= t 'user.view.no nearby users' %>
<% else %>
<table id="nearbyusers">
<%= render :partial => "contact", :collection => nearby %>
</table>
<% end %>
<% end %>